@waveform-playlist/browser 5.0.0-alpha.1 → 5.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),W=require("styled-components");require("react-dom");var Jr=typeof document<"u"?document.currentScript:null;function Hu(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const le=Hu(S),Eo="15.1.22",za=(s,e,t)=>({endTime:e,insertTime:t,type:"exponentialRampToValue",value:s}),Za=(s,e,t)=>({endTime:e,insertTime:t,type:"linearRampToValue",value:s}),uo=(s,e)=>({startTime:e,type:"setValue",value:s}),il=(s,e,t)=>({duration:t,startTime:e,type:"setValueCurve",values:s}),rl=(s,e,{startTime:t,target:n,timeConstant:i})=>n+(e-n)*Math.exp((t-s)/i),Js=s=>s.type==="exponentialRampToValue",qi=s=>s.type==="linearRampToValue",bs=s=>Js(s)||qi(s),Mo=s=>s.type==="setValue",ls=s=>s.type==="setValueCurve",ji=(s,e,t,n)=>{const i=s[e];return i===void 0?n:bs(i)||Mo(i)?i.value:ls(i)?i.values[i.values.length-1]:rl(t,ji(s,e-1,i.startTime,n),i)},Ga=(s,e,t,n,i)=>t===void 0?[n.insertTime,i]:bs(t)?[t.endTime,t.value]:Mo(t)?[t.startTime,t.value]:ls(t)?[t.startTime+t.duration,t.values[t.values.length-1]]:[t.startTime,ji(s,e-1,t.startTime,i)],ho=s=>s.type==="cancelAndHold",po=s=>s.type==="cancelScheduledValues",ys=s=>ho(s)||po(s)?s.cancelTime:Js(s)||qi(s)?s.endTime:s.startTime,Xa=(s,e,t,{endTime:n,value:i})=>t===i?i:0<t&&0<i||t<0&&i<0?t*(i/t)**((s-e)/(n-e)):0,Ha=(s,e,t,{endTime:n,value:i})=>t+(s-e)/(n-e)*(i-t),Yu=(s,e)=>{const t=Math.floor(e),n=Math.ceil(e);return t===n?s[t]:(1-(e-t))*s[t]+(1-(n-e))*s[n]},Uu=(s,{duration:e,startTime:t,values:n})=>{const i=(s-t)/e*(n.length-1);return Yu(n,i)},Ei=s=>s.type==="setTarget";class Ku{constructor(e){this._automationEvents=[],this._currenTime=0,this._defaultValue=e}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(e){const t=ys(e);if(ho(e)||po(e)){const n=this._automationEvents.findIndex(r=>po(e)&&ls(r)?r.startTime+r.duration>=t:ys(r)>=t),i=this._automationEvents[n];if(n!==-1&&(this._automationEvents=this._automationEvents.slice(0,n)),ho(e)){const r=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&bs(i)){if(r!==void 0&&Ei(r))throw new Error("The internal list is malformed.");const o=r===void 0?i.insertTime:ls(r)?r.startTime+r.duration:ys(r),a=r===void 0?this._defaultValue:ls(r)?r.values[r.values.length-1]:r.value,c=Js(i)?Xa(t,o,a,i):Ha(t,o,a,i),l=Js(i)?za(c,t,this._currenTime):Za(c,t,this._currenTime);this._automationEvents.push(l)}if(r!==void 0&&Ei(r)&&this._automationEvents.push(uo(this.getValue(t),t)),r!==void 0&&ls(r)&&r.startTime+r.duration>t){const o=t-r.startTime,a=(r.values.length-1)/r.duration,c=Math.max(2,1+Math.ceil(o*a)),l=o/(c-1)*a,u=r.values.slice(0,c);if(l<1)for(let h=1;h<c;h+=1){const p=l*h%1;u[h]=r.values[h-1]*(1-p)+r.values[h]*p}this._automationEvents[this._automationEvents.length-1]=il(u,r.startTime,o)}}}else{const n=this._automationEvents.findIndex(o=>ys(o)>t),i=n===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[n-1];if(i!==void 0&&ls(i)&&ys(i)+i.duration>t)return!1;const r=Js(e)?za(e.value,e.endTime,this._currenTime):qi(e)?Za(e.value,t,this._currenTime):e;if(n===-1)this._automationEvents.push(r);else{if(ls(e)&&t+e.duration>ys(this._automationEvents[n]))return!1;this._automationEvents.splice(n,0,r)}}return!0}flush(e){const t=this._automationEvents.findIndex(n=>ys(n)>e);if(t>1){const n=this._automationEvents.slice(t-1),i=n[0];Ei(i)&&n.unshift(uo(ji(this._automationEvents,t-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=n}}getValue(e){if(this._automationEvents.length===0)return this._defaultValue;const t=this._automationEvents.findIndex(o=>ys(o)>e),n=this._automationEvents[t],i=(t===-1?this._automationEvents.length:t)-1,r=this._automationEvents[i];if(r!==void 0&&Ei(r)&&(n===void 0||!bs(n)||n.insertTime>e))return rl(e,ji(this._automationEvents,i-1,r.startTime,this._defaultValue),r);if(r!==void 0&&Mo(r)&&(n===void 0||!bs(n)))return r.value;if(r!==void 0&&ls(r)&&(n===void 0||!bs(n)||r.startTime+r.duration>e))return e<r.startTime+r.duration?Uu(e,r):r.values[r.values.length-1];if(r!==void 0&&bs(r)&&(n===void 0||!bs(n)))return r.value;if(n!==void 0&&Js(n)){const[o,a]=Ga(this._automationEvents,i,r,n,this._defaultValue);return Xa(e,o,a,n)}if(n!==void 0&&qi(n)){const[o,a]=Ga(this._automationEvents,i,r,n,this._defaultValue);return Ha(e,o,a,n)}return this._defaultValue}}const Qu=s=>({cancelTime:s,type:"cancelAndHold"}),Ju=s=>({cancelTime:s,type:"cancelScheduledValues"}),eh=(s,e)=>({endTime:e,type:"exponentialRampToValue",value:s}),th=(s,e)=>({endTime:e,type:"linearRampToValue",value:s}),sh=(s,e,t)=>({startTime:e,target:s,timeConstant:t,type:"setTarget"}),nh=()=>new DOMException("","AbortError"),ih=s=>(e,t,[n,i,r],o)=>{s(e[i],[t,n,r],a=>a[0]===t&&a[1]===n,o)},rh=s=>(e,t,n)=>{const i=[];for(let r=0;r<n.numberOfInputs;r+=1)i.push(new Set);s.set(e,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:t})},oh=s=>(e,t)=>{s.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:t})},rn=new WeakSet,ol=new WeakMap,Oo=new WeakMap,al=new WeakMap,No=new WeakMap,ir=new WeakMap,cl=new WeakMap,fo=new WeakMap,mo=new WeakMap,go=new WeakMap,ll={construct(){return ll}},ah=s=>{try{const e=new Proxy(s,ll);new e}catch{return!1}return!0},Ya=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Ua=(s,e)=>{const t=[];let n=s.replace(/^[\s]+/,""),i=n.match(Ya);for(;i!==null;){const r=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(r,new URL(r,e).toString());t.push(o),n=n.slice(i[0].length).replace(/^[\s]+/,""),i=n.match(Ya)}return[t.join(";"),n]},Ka=s=>{if(s!==void 0&&!Array.isArray(s))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Qa=s=>{if(!ah(s))throw new TypeError("The given value for processorCtor should be a constructor.");if(s.prototype===null||typeof s.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},ch=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>{let d=0;return(f,_,m={credentials:"omit"})=>{const g=u.get(f);if(g!==void 0&&g.has(_))return Promise.resolve();const y=l.get(f);if(y!==void 0){const v=y.get(_);if(v!==void 0)return v}const x=r(f),w=x.audioWorklet===void 0?i(_).then(([v,b])=>{const[k,T]=Ua(v,b),R=`${k};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${T}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),P=require("styled-components");require("react-dom");var Jr=typeof document<"u"?document.currentScript:null;function Hu(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const ue=Hu(S),Eo="15.1.22",za=(s,e,t)=>({endTime:e,insertTime:t,type:"exponentialRampToValue",value:s}),Za=(s,e,t)=>({endTime:e,insertTime:t,type:"linearRampToValue",value:s}),uo=(s,e)=>({startTime:e,type:"setValue",value:s}),il=(s,e,t)=>({duration:t,startTime:e,type:"setValueCurve",values:s}),rl=(s,e,{startTime:t,target:n,timeConstant:i})=>n+(e-n)*Math.exp((t-s)/i),en=s=>s.type==="exponentialRampToValue",qi=s=>s.type==="linearRampToValue",bs=s=>en(s)||qi(s),Mo=s=>s.type==="setValue",cs=s=>s.type==="setValueCurve",ji=(s,e,t,n)=>{const i=s[e];return i===void 0?n:bs(i)||Mo(i)?i.value:cs(i)?i.values[i.values.length-1]:rl(t,ji(s,e-1,i.startTime,n),i)},Ga=(s,e,t,n,i)=>t===void 0?[n.insertTime,i]:bs(t)?[t.endTime,t.value]:Mo(t)?[t.startTime,t.value]:cs(t)?[t.startTime+t.duration,t.values[t.values.length-1]]:[t.startTime,ji(s,e-1,t.startTime,i)],ho=s=>s.type==="cancelAndHold",po=s=>s.type==="cancelScheduledValues",ys=s=>ho(s)||po(s)?s.cancelTime:en(s)||qi(s)?s.endTime:s.startTime,Xa=(s,e,t,{endTime:n,value:i})=>t===i?i:0<t&&0<i||t<0&&i<0?t*(i/t)**((s-e)/(n-e)):0,Ha=(s,e,t,{endTime:n,value:i})=>t+(s-e)/(n-e)*(i-t),Yu=(s,e)=>{const t=Math.floor(e),n=Math.ceil(e);return t===n?s[t]:(1-(e-t))*s[t]+(1-(n-e))*s[n]},Uu=(s,{duration:e,startTime:t,values:n})=>{const i=(s-t)/e*(n.length-1);return Yu(n,i)},Ei=s=>s.type==="setTarget";class Ku{constructor(e){this._automationEvents=[],this._currenTime=0,this._defaultValue=e}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(e){const t=ys(e);if(ho(e)||po(e)){const n=this._automationEvents.findIndex(r=>po(e)&&cs(r)?r.startTime+r.duration>=t:ys(r)>=t),i=this._automationEvents[n];if(n!==-1&&(this._automationEvents=this._automationEvents.slice(0,n)),ho(e)){const r=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&bs(i)){if(r!==void 0&&Ei(r))throw new Error("The internal list is malformed.");const o=r===void 0?i.insertTime:cs(r)?r.startTime+r.duration:ys(r),a=r===void 0?this._defaultValue:cs(r)?r.values[r.values.length-1]:r.value,c=en(i)?Xa(t,o,a,i):Ha(t,o,a,i),l=en(i)?za(c,t,this._currenTime):Za(c,t,this._currenTime);this._automationEvents.push(l)}if(r!==void 0&&Ei(r)&&this._automationEvents.push(uo(this.getValue(t),t)),r!==void 0&&cs(r)&&r.startTime+r.duration>t){const o=t-r.startTime,a=(r.values.length-1)/r.duration,c=Math.max(2,1+Math.ceil(o*a)),l=o/(c-1)*a,u=r.values.slice(0,c);if(l<1)for(let h=1;h<c;h+=1){const p=l*h%1;u[h]=r.values[h-1]*(1-p)+r.values[h]*p}this._automationEvents[this._automationEvents.length-1]=il(u,r.startTime,o)}}}else{const n=this._automationEvents.findIndex(o=>ys(o)>t),i=n===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[n-1];if(i!==void 0&&cs(i)&&ys(i)+i.duration>t)return!1;const r=en(e)?za(e.value,e.endTime,this._currenTime):qi(e)?Za(e.value,t,this._currenTime):e;if(n===-1)this._automationEvents.push(r);else{if(cs(e)&&t+e.duration>ys(this._automationEvents[n]))return!1;this._automationEvents.splice(n,0,r)}}return!0}flush(e){const t=this._automationEvents.findIndex(n=>ys(n)>e);if(t>1){const n=this._automationEvents.slice(t-1),i=n[0];Ei(i)&&n.unshift(uo(ji(this._automationEvents,t-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=n}}getValue(e){if(this._automationEvents.length===0)return this._defaultValue;const t=this._automationEvents.findIndex(o=>ys(o)>e),n=this._automationEvents[t],i=(t===-1?this._automationEvents.length:t)-1,r=this._automationEvents[i];if(r!==void 0&&Ei(r)&&(n===void 0||!bs(n)||n.insertTime>e))return rl(e,ji(this._automationEvents,i-1,r.startTime,this._defaultValue),r);if(r!==void 0&&Mo(r)&&(n===void 0||!bs(n)))return r.value;if(r!==void 0&&cs(r)&&(n===void 0||!bs(n)||r.startTime+r.duration>e))return e<r.startTime+r.duration?Uu(e,r):r.values[r.values.length-1];if(r!==void 0&&bs(r)&&(n===void 0||!bs(n)))return r.value;if(n!==void 0&&en(n)){const[o,a]=Ga(this._automationEvents,i,r,n,this._defaultValue);return Xa(e,o,a,n)}if(n!==void 0&&qi(n)){const[o,a]=Ga(this._automationEvents,i,r,n,this._defaultValue);return Ha(e,o,a,n)}return this._defaultValue}}const Qu=s=>({cancelTime:s,type:"cancelAndHold"}),Ju=s=>({cancelTime:s,type:"cancelScheduledValues"}),eh=(s,e)=>({endTime:e,type:"exponentialRampToValue",value:s}),th=(s,e)=>({endTime:e,type:"linearRampToValue",value:s}),sh=(s,e,t)=>({startTime:e,target:s,timeConstant:t,type:"setTarget"}),nh=()=>new DOMException("","AbortError"),ih=s=>(e,t,[n,i,r],o)=>{s(e[i],[t,n,r],a=>a[0]===t&&a[1]===n,o)},rh=s=>(e,t,n)=>{const i=[];for(let r=0;r<n.numberOfInputs;r+=1)i.push(new Set);s.set(e,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:t})},oh=s=>(e,t)=>{s.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:t})},on=new WeakSet,ol=new WeakMap,Oo=new WeakMap,al=new WeakMap,No=new WeakMap,ir=new WeakMap,cl=new WeakMap,fo=new WeakMap,mo=new WeakMap,go=new WeakMap,ll={construct(){return ll}},ah=s=>{try{const e=new Proxy(s,ll);new e}catch{return!1}return!0},Ya=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Ua=(s,e)=>{const t=[];let n=s.replace(/^[\s]+/,""),i=n.match(Ya);for(;i!==null;){const r=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(r,new URL(r,e).toString());t.push(o),n=n.slice(i[0].length).replace(/^[\s]+/,""),i=n.match(Ya)}return[t.join(";"),n]},Ka=s=>{if(s!==void 0&&!Array.isArray(s))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},Qa=s=>{if(!ah(s))throw new TypeError("The given value for processorCtor should be a constructor.");if(s.prototype===null||typeof s.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},ch=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>{let d=0;return(f,_,m={credentials:"omit"})=>{const g=u.get(f);if(g!==void 0&&g.has(_))return Promise.resolve();const y=l.get(f);if(y!==void 0){const v=y.get(_);if(v!==void 0)return v}const x=r(f),w=x.audioWorklet===void 0?i(_).then(([v,b])=>{const[k,T]=Ua(v,b),R=`${k};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${T}
2
2
  })})(window,'_AWGS')`;return t(R)}).then(()=>{const v=p._AWGS.pop();if(v===void 0)throw new SyntaxError;n(x.currentTime,x.sampleRate,()=>v(class{},void 0,(b,k)=>{if(b.trim()==="")throw e();const T=mo.get(x);if(T!==void 0){if(T.has(b))throw e();Qa(k),Ka(k.parameterDescriptors),T.set(b,k)}else Qa(k),Ka(k.parameterDescriptors),mo.set(x,new Map([[b,k]]))},x.sampleRate,void 0,void 0))}):Promise.all([i(_),Promise.resolve(s(h,h))]).then(([[v,b],k])=>{const T=d+1;d=T;const[R,I]=Ua(v,b),N=`${R};((AudioWorkletProcessor,registerProcessor)=>{${I}
3
- })(${k?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${k?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${k?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${T}',class extends AudioWorkletProcessor{process(){return !1}})`,q=new Blob([N],{type:"application/javascript; charset=utf-8"}),V=URL.createObjectURL(q);return x.audioWorklet.addModule(V,m).then(()=>{if(a(x))return x;const j=o(x);return j.audioWorklet.addModule(V,m).then(()=>j)}).then(j=>{if(c===null)throw new SyntaxError;try{new c(j,`__sac${T}`)}catch{throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(V))});return y===void 0?l.set(f,new Map([[_,w]])):y.set(_,w),w.then(()=>{const v=u.get(f);v===void 0?u.set(f,new Set([_])):v.add(_)}).finally(()=>{const v=l.get(f);v!==void 0&&v.delete(_)}),w}},Zt=(s,e)=>{const t=s.get(e);if(t===void 0)throw new Error("A value with the given key could not be found.");return t},rr=(s,e)=>{const t=Array.from(s).filter(e);if(t.length>1)throw Error("More than one element was found.");if(t.length===0)throw Error("No element was found.");const[n]=t;return s.delete(n),n},ul=(s,e,t,n)=>{const i=Zt(s,e),r=rr(i,o=>o[0]===t&&o[1]===n);return i.size===0&&s.delete(e),r},ti=s=>Zt(cl,s),on=s=>{if(rn.has(s))throw new Error("The AudioNode is already stored.");rn.add(s),ti(s).forEach(e=>e(!0))},hl=s=>"port"in s,si=s=>{if(!rn.has(s))throw new Error("The AudioNode is not stored.");rn.delete(s),ti(s).forEach(e=>e(!1))},_o=(s,e)=>{!hl(s)&&e.every(t=>t.size===0)&&si(s)},lh=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>{const d=new WeakMap;return(f,_,m,g,y)=>{const{activeInputs:x,passiveInputs:w}=r(_),{outputs:v}=r(f),b=a(f),k=T=>{const R=c(_),I=c(f);if(T){const A=ul(w,f,m,g);s(x,f,A,!1),!y&&!h(f)&&t(I,R,m,g),p(_)&&on(_)}else{const A=n(x,f,m,g);e(w,g,A,!1),!y&&!h(f)&&i(I,R,m,g);const D=o(_);if(D===0)u(_)&&_o(_,x);else{const M=d.get(_);M!==void 0&&clearTimeout(M),d.set(_,setTimeout(()=>{u(_)&&_o(_,x)},D*1e3))}}};return l(v,[_,m,g],T=>T[0]===_&&T[1]===m&&T[2]===g,!0)?(b.add(k),u(f)?s(x,f,[m,g,k],!0):e(w,g,[f,m,k],!0),!0):!1}},uh=s=>(e,t,[n,i,r],o)=>{const a=e.get(n);a===void 0?e.set(n,new Set([[i,t,r]])):s(a,[i,t,r],c=>c[0]===i&&c[1]===t,o)},hh=s=>(e,t)=>{const n=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});t.connect(n).connect(e.destination);const i=()=>{t.removeEventListener("ended",i),t.disconnect(n),n.disconnect()};t.addEventListener("ended",i)},dh=s=>(e,t)=>{s(e).add(t)},ph={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},fh=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...ph,...c},h=n(l,u),p=r(l)?e():null;super(a,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){const c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,t()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){const c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,t()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}},ft=(s,e)=>s.context===e,mh=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!ft(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},Li=s=>{try{s.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},ss=()=>new DOMException("","IndexSizeError"),Fo=s=>{s.getChannelData=(e=>t=>{try{return e.call(s,t)}catch(n){throw n.code===12?ss():n}})(s.getChannelData)},gh={numberOfChannels:1},_h=(s,e,t,n,i,r,o,a)=>{let c=null;return class dl{constructor(u){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:h,numberOfChannels:p,sampleRate:d}={...gh,...u};c===null&&(c=new i(1,1,44100));const f=n!==null&&e(r,r)?new n({length:h,numberOfChannels:p,sampleRate:d}):c.createBuffer(p,h,d);if(f.numberOfChannels===0)throw t();return typeof f.copyFromChannel!="function"?(o(f),Fo(f)):e(Li,()=>Li(f))||a(f),s.add(f),f}static[Symbol.hasInstance](u){return u!==null&&typeof u=="object"&&Object.getPrototypeOf(u)===dl.prototype||s.has(u)}}},St=-34028234663852886e22,mt=-St,ds=s=>rn.has(s),vh={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},yh=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...vh,...u},d=i(h,p),f=o(h),_=f?e():null;super(l,!1,d,_),this._audioBufferSourceNodeRenderer=_,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=d,this._onended=null,this._playbackRate=t(this,f,d.playbackRate,mt,St)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(l){if(this._nativeAudioBufferSourceNode.buffer=l,l!==null){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(l){this._nativeAudioBufferSourceNode.loop=l}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(l){this._nativeAudioBufferSourceNode.loopEnd=l}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(l){this._nativeAudioBufferSourceNode.loopStart=l}get onended(){return this._onended}set onended(l){const u=typeof l=="function"?a(this,l):null;this._nativeAudioBufferSourceNode.onended=u;const h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===u?l:h}get playbackRate(){return this._playbackRate}start(l=0,u=0,h){if(this._nativeAudioBufferSourceNode.start(l,u,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[l,u]:[l,u,h]),this.context.state!=="closed"){on(this);const p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),ds(this)&&si(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(l=0){this._nativeAudioBufferSourceNode.stop(l),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=l)}},bh=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;const c=async(l,u)=>{let h=t(l);const p=ft(h,u);if(!p){const d={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=e(u,d),o!==null&&h.start(...o),a!==null&&h.stop(a)}return r.set(u,h),p?await s(u,l.playbackRate,h.playbackRate):await n(u,l.playbackRate,h.playbackRate),await i(l,u,h),h};return{set start(l){o=l},set stop(l){a=l},render(l,u){const h=r.get(u);return h!==void 0?Promise.resolve(h):c(l,u)}}},wh=s=>"playbackRate"in s,xh=s=>"frequency"in s&&"gain"in s,Ch=s=>"offset"in s,Sh=s=>!("frequency"in s)&&"gain"in s,Th=s=>"detune"in s&&"frequency"in s&&!("gain"in s),kh=s=>"pan"in s,_t=s=>Zt(ol,s),ni=s=>Zt(al,s),vo=(s,e)=>{const{activeInputs:t}=_t(s);t.forEach(i=>i.forEach(([r])=>{e.includes(s)||vo(r,[...e,s])}));const n=wh(s)?[s.playbackRate]:hl(s)?Array.from(s.parameters.values()):xh(s)?[s.Q,s.detune,s.frequency,s.gain]:Ch(s)?[s.offset]:Sh(s)?[s.gain]:Th(s)?[s.detune,s.frequency]:kh(s)?[s.pan]:[];for(const i of n){const r=ni(i);r!==void 0&&r.activeInputs.forEach(([o])=>vo(o,e))}ds(s)&&si(s)},pl=s=>{vo(s.destination,[])},Ah=s=>s===void 0||typeof s=="number"||typeof s=="string"&&(s==="balanced"||s==="interactive"||s==="playback"),Ih=(s,e,t,n,i,r,o,a,c)=>class extends s{constructor(u={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(u)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?t():f}if(h===null)throw n();if(!Ah(u.latencyHint))throw new TypeError(`The provided value '${u.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(u.sampleRate!==void 0&&h.sampleRate!==u.sampleRate)throw t();super(h,2);const{latencyHint:p}=u,{sampleRate:d}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/d:p==="interactive"||p===void 0?256/d:p==="playback"?1024/d:Math.max(2,Math.min(128,Math.round(p*d/128)))*128/d,this._nativeAudioContext=h,c.name==="webkitAudioContext"?(this._nativeGainNode=h.createGain(),this._nativeOscillatorNode=h.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(h.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,h.state==="running"){this._state="suspended";const f=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",f)};h.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw e()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),pl(this)}))}createMediaElementSource(u){return new i(this,{mediaElement:u})}createMediaStreamDestination(){return new r(this)}createMediaStreamSource(u){return new o(this,{mediaStream:u})}createMediaStreamTrackSource(u){return new a(this,{mediaStreamTrack:u})}resume(){return this._state==="suspended"?new Promise((u,h)=>{const p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?u():this.resume().then(u,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(u=>{throw u===void 0||u.code===15?e():u})}suspend(){return this._nativeAudioContext.suspend().catch(u=>{throw u===void 0?e():u})}},Dh=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p=o(h),d=i(h,u,p),f=p?e(a):null;super(l,!1,d,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=d}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(l){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(l>this._nativeAudioDestinationNode.maxChannelCount)throw t();this._nativeAudioDestinationNode.channelCount=l}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(l){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=l}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},Rh=s=>{const e=new WeakMap,t=async(n,i)=>{const r=i.destination;return e.set(i,r),await s(n,i,r),r};return{render(n,i){const r=e.get(i);return r!==void 0?Promise.resolve(r):t(n,i)}}},Eh=(s,e,t,n,i,r,o,a)=>(c,l)=>{const u=l.listener,h=()=>{const v=new Float32Array(1),b=e(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),k=o(l);let T=!1,R=[0,0,-1,0,1,0],I=[0,0,0];const A=()=>{if(T)return;T=!0;const q=n(l,256,9,0);q.onaudioprocess=({inputBuffer:V})=>{const j=[r(V,v,0),r(V,v,1),r(V,v,2),r(V,v,3),r(V,v,4),r(V,v,5)];j.some((B,Z)=>B!==R[Z])&&(u.setOrientation(...j),R=j);const G=[r(V,v,6),r(V,v,7),r(V,v,8)];G.some((B,Z)=>B!==I[Z])&&(u.setPosition(...G),I=G)},b.connect(q)},D=q=>V=>{V!==R[q]&&(R[q]=V,u.setOrientation(...R))},M=q=>V=>{V!==I[q]&&(I[q]=V,u.setPosition(...I))},N=(q,V,j)=>{const G=t(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:V});G.connect(b,0,q),G.start(),Object.defineProperty(G.offset,"defaultValue",{get(){return V}});const B=s({context:c},k,G.offset,mt,St);return a(B,"value",Z=>()=>Z.call(B),Z=>X=>{try{Z.call(B,X)}catch(ee){if(ee.code!==9)throw ee}A(),k&&j(X)}),B.cancelAndHoldAtTime=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.cancelAndHoldAtTime),B.cancelScheduledValues=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.cancelScheduledValues),B.exponentialRampToValueAtTime=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.exponentialRampToValueAtTime),B.linearRampToValueAtTime=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.linearRampToValueAtTime),B.setTargetAtTime=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.setTargetAtTime),B.setValueAtTime=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.setValueAtTime),B.setValueCurveAtTime=(Z=>k?()=>{throw i()}:(...X)=>{const ee=Z.apply(B,X);return A(),ee})(B.setValueCurveAtTime),B};return{forwardX:N(0,0,D(0)),forwardY:N(1,0,D(1)),forwardZ:N(2,-1,D(2)),positionX:N(6,0,M(0)),positionY:N(7,0,M(1)),positionZ:N(8,0,M(2)),upX:N(3,0,D(3)),upY:N(4,1,D(4)),upZ:N(5,0,D(5))}},{forwardX:p,forwardY:d,forwardZ:f,positionX:_,positionY:m,positionZ:g,upX:y,upY:x,upZ:w}=u.forwardX===void 0?h():u;return{get forwardX(){return p},get forwardY(){return d},get forwardZ(){return f},get positionX(){return _},get positionY(){return m},get positionZ(){return g},get upX(){return y},get upY(){return x},get upZ(){return w}}},zi=s=>"context"in s,ii=s=>zi(s[0]),Bs=(s,e,t,n)=>{for(const i of s)if(t(i)){if(n)return!1;throw Error("The set contains at least one similar element.")}return s.add(e),!0},Ja=(s,e,[t,n],i)=>{Bs(s,[e,t,n],r=>r[0]===e&&r[1]===t,i)},ec=(s,[e,t,n],i)=>{const r=s.get(e);r===void 0?s.set(e,new Set([[t,n]])):Bs(r,[t,n],o=>o[0]===t,i)},pn=s=>"inputs"in s,Zi=(s,e,t,n)=>{if(pn(e)){const i=e.inputs[n];return s.connect(i,t,0),[i,t,0]}return s.connect(e,t,n),[e,t,n]},fl=(s,e,t)=>{for(const n of s)if(n[0]===e&&n[1]===t)return s.delete(n),n;return null},Mh=(s,e,t)=>rr(s,n=>n[0]===e&&n[1]===t),ml=(s,e)=>{if(!ti(s).delete(e))throw new Error("Missing the expected event listener.")},gl=(s,e,t)=>{const n=Zt(s,e),i=rr(n,r=>r[0]===t);return n.size===0&&s.delete(e),i},Gi=(s,e,t,n)=>{pn(e)?s.disconnect(e.inputs[n],t,0):s.disconnect(e,t,n)},Re=s=>Zt(Oo,s),Gn=s=>Zt(No,s),Ps=s=>fo.has(s),Wi=s=>!rn.has(s),tc=(s,e)=>new Promise(t=>{if(e!==null)t(!0);else{const n=s.createScriptProcessor(256,1,1),i=s.createGain(),r=s.createBuffer(1,2,44100),o=r.getChannelData(0);o[0]=1,o[1]=1;const a=s.createBufferSource();a.buffer=r,a.loop=!0,a.connect(n).connect(s.destination),a.connect(i),a.disconnect(i),n.onaudioprocess=c=>{const l=c.inputBuffer.getChannelData(0);Array.prototype.some.call(l,u=>u===1)?t(!0):t(!1),a.stop(),n.onaudioprocess=null,a.disconnect(n),n.disconnect(s.destination)},a.start()}}),eo=(s,e)=>{const t=new Map;for(const n of s)for(const i of n){const r=t.get(i);t.set(i,r===void 0?1:r+1)}t.forEach((n,i)=>e(i,n))},Xi=s=>"context"in s,Oh=s=>{const e=new Map;s.connect=(t=>(n,i=0,r=0)=>{const o=Xi(n)?t(n,i,r):t(n,i),a=e.get(n);return a===void 0?e.set(n,[{input:r,output:i}]):a.every(c=>c.input!==r||c.output!==i)&&a.push({input:r,output:i}),o})(s.connect.bind(s)),s.disconnect=(t=>(n,i,r)=>{if(t.apply(s),n===void 0)e.clear();else if(typeof n=="number")for(const[o,a]of e){const c=a.filter(l=>l.output!==n);c.length===0?e.delete(o):e.set(o,c)}else if(e.has(n))if(i===void 0)e.delete(n);else{const o=e.get(n);if(o!==void 0){const a=o.filter(c=>c.output!==i&&(c.input!==r||r===void 0));a.length===0?e.delete(n):e.set(n,a)}}for(const[o,a]of e)a.forEach(c=>{Xi(o)?s.connect(o,c.output,c.input):s.connect(o,c.output)})})(s.disconnect)},Nh=(s,e,t,n)=>{const{activeInputs:i,passiveInputs:r}=ni(e),{outputs:o}=_t(s),a=ti(s),c=l=>{const u=Re(s),h=Gn(e);if(l){const p=gl(r,s,t);Ja(i,s,p,!1),!n&&!Ps(s)&&u.connect(h,t)}else{const p=Mh(i,s,t);ec(r,p,!1),!n&&!Ps(s)&&u.disconnect(h,t)}};return Bs(o,[e,t],l=>l[0]===e&&l[1]===t,!0)?(a.add(c),ds(s)?Ja(i,s,[t,c],!0):ec(r,[s,t,c],!0),!0):!1},Fh=(s,e,t,n)=>{const{activeInputs:i,passiveInputs:r}=_t(e),o=fl(i[n],s,t);return o===null?[ul(r,s,t,n)[2],!1]:[o[2],!0]},Vh=(s,e,t)=>{const{activeInputs:n,passiveInputs:i}=ni(e),r=fl(n,s,t);return r===null?[gl(i,s,t)[1],!1]:[r[2],!0]},Vo=(s,e,t,n,i)=>{const[r,o]=Fh(s,t,n,i);if(r!==null&&(ml(s,r),o&&!e&&!Ps(s)&&Gi(Re(s),Re(t),n,i)),ds(t)){const{activeInputs:a}=_t(t);_o(t,a)}},Po=(s,e,t,n)=>{const[i,r]=Vh(s,t,n);i!==null&&(ml(s,i),r&&!e&&!Ps(s)&&Re(s).disconnect(Gn(t),n))},Ph=(s,e)=>{const t=_t(s),n=[];for(const i of t.outputs)ii(i)?Vo(s,e,...i):Po(s,e,...i),n.push(i[0]);return t.outputs.clear(),n},Wh=(s,e,t)=>{const n=_t(s),i=[];for(const r of n.outputs)r[1]===t&&(ii(r)?Vo(s,e,...r):Po(s,e,...r),i.push(r[0]),n.outputs.delete(r));return i},Bh=(s,e,t,n,i)=>{const r=_t(s);return Array.from(r.outputs).filter(o=>o[0]===t&&(n===void 0||o[1]===n)&&(i===void 0||o[2]===i)).map(o=>(ii(o)?Vo(s,e,...o):Po(s,e,...o),r.outputs.delete(o),o[0]))},$h=(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_)=>class extends l{constructor(g,y,x,w){super(x),this._context=g,this._nativeAudioNode=x;const v=u(g);h(v)&&t(tc,()=>tc(v,_))!==!0&&Oh(x),Oo.set(this,x),cl.set(this,new Set),g.state!=="closed"&&y&&on(this),s(this,w,x)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(g){this._nativeAudioNode.channelCount=g}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(g){this._nativeAudioNode.channelCountMode=g}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(g){this._nativeAudioNode.channelInterpretation=g}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(g,y=0,x=0){if(y<0||y>=this._nativeAudioNode.numberOfOutputs)throw i();const w=u(this._context),v=f(w);if(p(g)||d(g))throw r();if(zi(g)){const T=Re(g);try{const I=Zi(this._nativeAudioNode,T,y,x),A=Wi(this);(v||A)&&this._nativeAudioNode.disconnect(...I),this.context.state!=="closed"&&!A&&Wi(g)&&on(g)}catch(I){throw I.code===12?r():I}if(e(this,g,y,x,v)){const I=c([this],g);eo(I,n(v))}return g}const b=Gn(g);if(b.name==="playbackRate"&&b.maxValue===1024)throw o();try{this._nativeAudioNode.connect(b,y),(v||Wi(this))&&this._nativeAudioNode.disconnect(b,y)}catch(T){throw T.code===12?r():T}if(Nh(this,g,y,v)){const T=c([this],g);eo(T,n(v))}}disconnect(g,y,x){let w;const v=u(this._context),b=f(v);if(g===void 0)w=Ph(this,b);else if(typeof g=="number"){if(g<0||g>=this.numberOfOutputs)throw i();w=Wh(this,b,g)}else{if(y!==void 0&&(y<0||y>=this.numberOfOutputs)||zi(g)&&x!==void 0&&(x<0||x>=g.numberOfInputs))throw i();if(w=Bh(this,b,g,y,x),w.length===0)throw r()}for(const k of w){const T=c([this],k);eo(T,a)}}},qh=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>(d,f,_,m=null,g=null)=>{const y=_.value,x=new Ku(y),w=f?n(x):null,v={get defaultValue(){return y},get maxValue(){return m===null?_.maxValue:m},get minValue(){return g===null?_.minValue:g},get value(){return _.value},set value(b){_.value=b,v.setValueAtTime(b,d.context.currentTime)},cancelAndHoldAtTime(b){if(typeof _.cancelAndHoldAtTime=="function")w===null&&x.flush(d.context.currentTime),x.add(i(b)),_.cancelAndHoldAtTime(b);else{const k=Array.from(x).pop();w===null&&x.flush(d.context.currentTime),x.add(i(b));const T=Array.from(x).pop();_.cancelScheduledValues(b),k!==T&&T!==void 0&&(T.type==="exponentialRampToValue"?_.exponentialRampToValueAtTime(T.value,T.endTime):T.type==="linearRampToValue"?_.linearRampToValueAtTime(T.value,T.endTime):T.type==="setValue"?_.setValueAtTime(T.value,T.startTime):T.type==="setValueCurve"&&_.setValueCurveAtTime(T.values,T.startTime,T.duration))}return v},cancelScheduledValues(b){return w===null&&x.flush(d.context.currentTime),x.add(r(b)),_.cancelScheduledValues(b),v},exponentialRampToValueAtTime(b,k){if(b===0)throw new RangeError;if(!Number.isFinite(k)||k<0)throw new RangeError;const T=d.context.currentTime;return w===null&&x.flush(T),Array.from(x).length===0&&(x.add(l(y,T)),_.setValueAtTime(y,T)),x.add(o(b,k)),_.exponentialRampToValueAtTime(b,k),v},linearRampToValueAtTime(b,k){const T=d.context.currentTime;return w===null&&x.flush(T),Array.from(x).length===0&&(x.add(l(y,T)),_.setValueAtTime(y,T)),x.add(a(b,k)),_.linearRampToValueAtTime(b,k),v},setTargetAtTime(b,k,T){return w===null&&x.flush(d.context.currentTime),x.add(c(b,k,T)),_.setTargetAtTime(b,k,T),v},setValueAtTime(b,k){return w===null&&x.flush(d.context.currentTime),x.add(l(b,k)),_.setValueAtTime(b,k),v},setValueCurveAtTime(b,k,T){const R=b instanceof Float32Array?b:new Float32Array(b);if(h!==null&&h.name==="webkitAudioContext"){const I=k+T,A=d.context.sampleRate,D=Math.ceil(k*A),M=Math.floor(I*A),N=M-D,q=new Float32Array(N);for(let j=0;j<N;j+=1){const G=(R.length-1)/T*((D+j)/A-k),B=Math.floor(G),Z=Math.ceil(G);q[j]=B===Z?R[B]:(1-(G-B))*R[B]+(1-(Z-G))*R[Z]}w===null&&x.flush(d.context.currentTime),x.add(u(q,k,T)),_.setValueCurveAtTime(q,k,T);const V=M/A;V<I&&p(v,q[q.length-1],V),p(v,R[R.length-1],I)}else w===null&&x.flush(d.context.currentTime),x.add(u(R,k,T)),_.setValueCurveAtTime(R,k,T);return v}};return t.set(v,_),e.set(v,d),s(v,w),v},jh=s=>({replay(e){for(const t of s)if(t.type==="exponentialRampToValue"){const{endTime:n,value:i}=t;e.exponentialRampToValueAtTime(i,n)}else if(t.type==="linearRampToValue"){const{endTime:n,value:i}=t;e.linearRampToValueAtTime(i,n)}else if(t.type==="setTarget"){const{startTime:n,target:i,timeConstant:r}=t;e.setTargetAtTime(i,n,r)}else if(t.type==="setValue"){const{startTime:n,value:i}=t;e.setValueAtTime(i,n)}else if(t.type==="setValueCurve"){const{duration:n,startTime:i,values:r}=t;e.setValueCurveAtTime(r,i,n)}else throw new Error("Can't apply an unknown automation.")}});class _l{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((n,i)=>e.call(t,n,i,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}}const Lh={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},zh=(s,e,t,n,i,r,o,a,c,l,u,h,p,d)=>class extends e{constructor(_,m,g){var y;const x=a(_),w=c(x),v=u({...Lh,...g});p(v);const b=mo.get(x),k=b?.get(m),T=w||x.state!=="closed"?x:(y=o(x))!==null&&y!==void 0?y:x,R=i(T,w?null:_.baseLatency,l,m,k,v),I=w?n(m,v,k):null;super(_,!0,R,I);const A=[];R.parameters.forEach((M,N)=>{const q=t(this,w,M);A.push([N,q])}),this._nativeAudioWorkletNode=R,this._onprocessorerror=null,this._parameters=new _l(A),w&&s(x,this);const{activeInputs:D}=r(this);h(R,D)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(_){const m=typeof _=="function"?d(this,_):null;this._nativeAudioWorkletNode.onprocessorerror=m;const g=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=g!==null&&g===m?_:g}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Hi(s,e,t,n,i){if(typeof s.copyFromChannel=="function")e[t].byteLength===0&&(e[t]=new Float32Array(128)),s.copyFromChannel(e[t],n,i);else{const r=s.getChannelData(n);if(e[t].byteLength===0)e[t]=r.slice(i,i+128);else{const o=new Float32Array(r.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[t].set(o)}}}const vl=(s,e,t,n,i)=>{typeof s.copyToChannel=="function"?e[t].byteLength!==0&&s.copyToChannel(e[t],n,i):e[t].byteLength!==0&&s.getChannelData(n).set(e[t],i)},Yi=(s,e)=>{const t=[];for(let n=0;n<s;n+=1){const i=[],r=typeof e=="number"?e:e[n];for(let o=0;o<r;o+=1)i.push(new Float32Array(128));t.push(i)}return t},Zh=(s,e)=>{const t=Zt(go,s),n=Re(e);return Zt(t,n)},Gh=async(s,e,t,n,i,r,o)=>{const a=e===null?Math.ceil(s.context.length/128)*128:e.length,c=n.channelCount*n.numberOfInputs,l=i.reduce((m,g)=>m+g,0),u=l===0?null:t.createBuffer(l,a,t.sampleRate);if(r===void 0)throw new Error("Missing the processor constructor.");const h=_t(s),p=await Zh(t,s),d=Yi(n.numberOfInputs,n.channelCount),f=Yi(n.numberOfOutputs,i),_=Array.from(s.parameters.keys()).reduce((m,g)=>({...m,[g]:new Float32Array(128)}),{});for(let m=0;m<a;m+=128){if(n.numberOfInputs>0&&e!==null)for(let g=0;g<n.numberOfInputs;g+=1)for(let y=0;y<n.channelCount;y+=1)Hi(e,d[g],y,y,m);r.parameterDescriptors!==void 0&&e!==null&&r.parameterDescriptors.forEach(({name:g},y)=>{Hi(e,_,g,c+y,m)});for(let g=0;g<n.numberOfInputs;g+=1)for(let y=0;y<i[g];y+=1)f[g][y].byteLength===0&&(f[g][y]=new Float32Array(128));try{const g=d.map((x,w)=>h.activeInputs[w].size===0?[]:x),y=o(m/t.sampleRate,t.sampleRate,()=>p.process(g,f,_));if(u!==null)for(let x=0,w=0;x<n.numberOfOutputs;x+=1){for(let v=0;v<i[x];v+=1)vl(u,f[x],v,w+v,m);w+=i[x]}if(!y)break}catch(g){s.dispatchEvent(new ErrorEvent("processorerror",{colno:g.colno,filename:g.filename,lineno:g.lineno,message:g.message}));break}}return u},Xh=(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_)=>(m,g,y)=>{const x=new WeakMap;let w=null;const v=async(b,k)=>{let T=u(b),R=null;const I=ft(T,k),A=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(h===null){const D=A.reduce((V,j)=>V+j,0),M=i(k,{channelCount:Math.max(1,D),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,D)}),N=[];for(let V=0;V<b.numberOfOutputs;V+=1)N.push(n(k,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:A[V]}));const q=o(k,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});q.connect=e.bind(null,N),q.disconnect=c.bind(null,N),R=[M,N,q]}else I||(T=new h(k,m));if(x.set(k,R===null?T:R[2]),R!==null){if(w===null){if(y===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");const j=b.channelCount*b.numberOfInputs,G=y.parameterDescriptors===void 0?0:y.parameterDescriptors.length,B=j+G;w=Gh(b,B===0?null:await(async()=>{const X=new p(B,Math.ceil(b.context.length/128)*128,k.sampleRate),ee=[],pe=[];for(let ye=0;ye<g.numberOfInputs;ye+=1)ee.push(o(X,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),pe.push(i(X,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const ie=await Promise.all(Array.from(b.parameters.values()).map(async ye=>{const Ee=r(X,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:ye.value});return await d(X,ye,Ee.offset),Ee})),Q=n(X,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,j+G)});for(let ye=0;ye<g.numberOfInputs;ye+=1){ee[ye].connect(pe[ye]);for(let Ee=0;Ee<g.channelCount;Ee+=1)pe[ye].connect(Q,Ee,ye*g.channelCount+Ee)}for(const[ye,Ee]of ie.entries())Ee.connect(Q,0,j+ye),Ee.start(0);return Q.connect(X.destination),await Promise.all(ee.map(ye=>f(b,X,ye))),_(X)})(),k,g,A,y,l)}const D=await w,M=t(k,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[N,q,V]=R;D!==null&&(M.buffer=D,M.start(0)),M.connect(N);for(let j=0,G=0;j<b.numberOfOutputs;j+=1){const B=q[j];for(let Z=0;Z<A[j];Z+=1)N.connect(B,G+Z,Z);G+=A[j]}return V}if(I)for(const[D,M]of b.parameters.entries())await s(k,M,T.parameters.get(D));else for(const[D,M]of b.parameters.entries())await d(k,M,T.parameters.get(D));return await f(b,k,T),T};return{render(b,k){a(k,b);const T=x.get(k);return T!==void 0?Promise.resolve(T):v(b,k)}}},Hh=(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_,m,g,y,x)=>class extends f{constructor(v,b){super(v,b),this._nativeContext=v,this._audioWorklet=s===void 0?void 0:{addModule:(k,T)=>s(this,k,T)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(v,b,k){return new t({length:b,numberOfChannels:v,sampleRate:k})}createBufferSource(){return new n(this)}createChannelMerger(v=6){return new r(this,{numberOfInputs:v})}createChannelSplitter(v=6){return new o(this,{numberOfOutputs:v})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(v=1){return new u(this,{maxDelayTime:v})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(v,b){return new d(this,{feedback:b,feedforward:v})}createOscillator(){return new _(this)}createPanner(){return new m(this)}createPeriodicWave(v,b,k={disableNormalization:!1}){return new g(this,{...k,imag:b,real:v})}createStereoPanner(){return new y(this)}createWaveShaper(){return new x(this)}decodeAudioData(v,b,k){return l(this._nativeContext,v).then(T=>(typeof b=="function"&&b(T),T),T=>{throw typeof k=="function"&&k(T),T})}},Yh={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Uh=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...Yh,...u},d=i(h,p),f=o(h),_=f?t():null;super(l,!1,d,_),this._Q=e(this,f,d.Q,mt,St),this._detune=e(this,f,d.detune,1200*Math.log2(mt),-1200*Math.log2(mt)),this._frequency=e(this,f,d.frequency,l.sampleRate/2,0),this._gain=e(this,f,d.gain,40*Math.log10(mt),St),this._nativeBiquadFilterNode=d,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(l){this._nativeBiquadFilterNode.type=l}getFrequencyResponse(l,u,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(l,u,h)}catch(p){throw p.code===11?n():p}if(l.length!==u.length||u.length!==h.length)throw n()}},Kh=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=ft(l,c);if(!u){const h={Q:l.Q.value,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,detune:l.detune.value,frequency:l.frequency.value,gain:l.gain.value,type:l.type};l=e(c,h)}return r.set(c,l),u?(await s(c,a.Q,l.Q),await s(c,a.detune,l.detune),await s(c,a.frequency,l.frequency),await s(c,a.gain,l.gain)):(await n(c,a.Q,l.Q),await n(c,a.detune,l.detune),await n(c,a.frequency,l.frequency),await n(c,a.gain,l.gain)),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Qh=(s,e)=>(t,n)=>{const i=e.get(t);if(i!==void 0)return i;const r=s.get(t);if(r!==void 0)return r;try{const o=n();return o instanceof Promise?(s.set(t,o),o.catch(()=>!1).then(a=>(s.delete(t),e.set(t,a),a))):(e.set(t,o),o)}catch{return e.set(t,!1),!1}},Jh={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},ed=(s,e,t,n,i)=>class extends s{constructor(o,a){const c=n(o),l={...Jh,...a},u=t(c,l),h=i(c)?e():null;super(o,!1,u,h)}},td=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!ft(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},sd={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},nd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u=r({...sd,...c}),h=t(l,u),p=i(l)?e():null;super(a,!1,h,p)}},id=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!ft(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},rd=s=>(e,t,n)=>s(t,e,n),od=s=>(e,t,n=0,i=0)=>{const r=e[n];if(r===void 0)throw s();return Xi(t)?r.connect(t,0,i):r.connect(t,0)},ad=s=>(e,t)=>{const n=s(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return n.buffer=i,n.loop=!0,n.connect(t),n.start(),()=>{n.stop(),n.disconnect(t)}},cd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},ld=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...cd,...l},p=n(u,h),d=r(u),f=d?t():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=e(this,d,p.offset,mt,St),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){const l=typeof c=="function"?o(this,c):null;this._nativeConstantSourceNode.onended=l;const u=this._nativeConstantSourceNode.onended;this._onended=u!==null&&u===l?c:u}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){on(this);const l=()=>{this._nativeConstantSourceNode.removeEventListener("ended",l),ds(this)&&si(this)};this._nativeConstantSourceNode.addEventListener("ended",l)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}},ud=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;const c=async(l,u)=>{let h=t(l);const p=ft(h,u);if(!p){const d={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(u,d),o!==null&&h.start(o),a!==null&&h.stop(a)}return r.set(u,h),p?await s(u,l.offset,h.offset):await n(u,l.offset,h.offset),await i(l,u,h),h};return{set start(l){o=l},set stop(l){a=l},render(l,u){const h=r.get(u);return h!==void 0?Promise.resolve(h):c(l,u)}}},hd=s=>e=>(s[0]=e,s[0]),dd={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},pd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u={...dd,...c},h=t(l,u),d=i(l)?e():null;super(a,!1,h,d),this._isBufferNullified=!1,this._nativeConvolverNode=h,u.buffer!==null&&r(this,u.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){const c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,r(this,0)}else this._isBufferNullified=!1,r(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}},fd=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!ft(a,o)){const l={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=s(o,l)}return n.set(o,a),pn(a)?await t(r,o,a.inputs[0]):await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},md=(s,e)=>(t,n,i)=>{if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(t,n,i)}catch(r){throw r.name==="SyntaxError"?s():r}},gd=()=>new DOMException("","DataCloneError"),sc=s=>{const{port1:e,port2:t}=new MessageChannel;return new Promise(n=>{const i=()=>{t.onmessage=null,e.close(),t.close(),n()};t.onmessage=()=>i();try{e.postMessage(s,[s])}catch{}finally{i()}})},_d=(s,e,t,n,i,r,o,a,c,l,u)=>(h,p)=>{const d=o(h)?h:r(h);if(i.has(p)){const f=t();return Promise.reject(f)}try{i.add(p)}catch{}return e(c,()=>c(d))?d.decodeAudioData(p).then(f=>(sc(p).catch(()=>{}),e(a,()=>a(f))||u(f),s.add(f),f)):new Promise((f,_)=>{const m=async()=>{try{await sc(p)}catch{}},g=y=>{_(y),m()};try{d.decodeAudioData(p,y=>{typeof y.copyFromChannel!="function"&&(l(y),Fo(y)),s.add(y),m().then(()=>f(y))},y=>{g(y===null?n():y)})}catch(y){g(y)}})},vd=(s,e,t,n,i,r,o,a)=>(c,l)=>{const u=e.get(c);if(u===void 0)throw new Error("Missing the expected cycle count.");const h=r(c.context),p=a(h);if(u===l){if(e.delete(c),!p&&o(c)){const d=n(c),{outputs:f}=t(c);for(const _ of f)if(ii(_)){const m=n(_[0]);s(d,m,_[1],_[2])}else{const m=i(_[0]);d.connect(m,_[1])}}}else e.set(c,u-l)},yd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},bd=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...yd,...l},p=n(u,h),d=r(u),f=d?t(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=e(this,d,p.delayTime),o(this,h.maxDelayTime)}get delayTime(){return this._delayTime}},wd=(s,e,t,n,i)=>r=>{const o=new WeakMap,a=async(c,l)=>{let u=t(c);const h=ft(u,l);if(!h){const p={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,delayTime:u.delayTime.value,maxDelayTime:r};u=e(l,p)}return o.set(l,u),h?await s(l,c.delayTime,u.delayTime):await n(l,c.delayTime,u.delayTime),await i(c,l,u),u};return{render(c,l){const u=o.get(l);return u!==void 0?Promise.resolve(u):a(c,l)}}},xd=s=>(e,t,n,i)=>s(e[i],r=>r[0]===t&&r[1]===n),Cd=s=>(e,t)=>{s(e).delete(t)},Sd=s=>"delayTime"in s,Td=(s,e,t)=>function n(i,r){const o=zi(r)?r:t(s,r);if(Sd(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map(c=>n([...i,o],c[0])).reduce((c,l)=>c.concat(l),[])},Mi=(s,e,t)=>{const n=e[t];if(n===void 0)throw s();return n},kd=s=>(e,t=void 0,n=void 0,i=0)=>t===void 0?e.forEach(r=>r.disconnect()):typeof t=="number"?Mi(s,e,t).disconnect():Xi(t)?n===void 0?e.forEach(r=>r.disconnect(t)):i===void 0?Mi(s,e,n).disconnect(t,0):Mi(s,e,n).disconnect(t,0,i):n===void 0?e.forEach(r=>r.disconnect(t)):Mi(s,e,n).disconnect(t,0),Ad={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Id=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...Ad,...u},d=n(h,p),f=o(h),_=f?t():null;super(l,!1,d,_),this._attack=e(this,f,d.attack),this._knee=e(this,f,d.knee),this._nativeDynamicsCompressorNode=d,this._ratio=e(this,f,d.ratio),this._release=e(this,f,d.release),this._threshold=e(this,f,d.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(l){const u=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=l,l>2)throw this._nativeDynamicsCompressorNode.channelCount=u,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(l){const u=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=l,l==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=u,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value=="number"?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}},Dd=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=ft(l,c);if(!u){const h={attack:l.attack.value,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,knee:l.knee.value,ratio:l.ratio.value,release:l.release.value,threshold:l.threshold.value};l=e(c,h)}return r.set(c,l),u?(await s(c,a.attack,l.attack),await s(c,a.knee,l.knee),await s(c,a.ratio,l.ratio),await s(c,a.release,l.release),await s(c,a.threshold,l.threshold)):(await n(c,a.attack,l.attack),await n(c,a.knee,l.knee),await n(c,a.ratio,l.ratio),await n(c,a.release,l.release),await n(c,a.threshold,l.threshold)),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Rd=()=>new DOMException("","EncodingError"),Ed=s=>e=>new Promise((t,n)=>{if(s===null){n(new SyntaxError);return}const i=s.document.head;if(i===null)n(new SyntaxError);else{const r=s.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),c=s.onerror,l=()=>{s.onerror=c,URL.revokeObjectURL(a)};s.onerror=(u,h,p,d,f)=>{if(h===a||h===s.location.href&&p===1&&d===1)return l(),n(f),!1;if(c!==null)return c(u,h,p,d,f)},r.onerror=()=>{l(),n(new SyntaxError)},r.onload=()=>{l(),t()},r.src=a,r.type="module",i.appendChild(r)}}),Md=s=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,n,i){if(n!==null){let r=this._listeners.get(n);r===void 0&&(r=s(this,n),typeof n=="function"&&this._listeners.set(n,r)),this._nativeEventTarget.addEventListener(t,r,i)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,n,i){const r=n===null?void 0:this._listeners.get(n);this._nativeEventTarget.removeEventListener(t,r===void 0?null:r,i)}},Od=s=>(e,t,n)=>{Object.defineProperties(s,{currentFrame:{configurable:!0,get(){return Math.round(e*t)}},currentTime:{configurable:!0,get(){return e}}});try{return n()}finally{s!==null&&(delete s.currentFrame,delete s.currentTime)}},Nd=s=>async e=>{try{const t=await fetch(e);if(t.ok)return[await t.text(),t.url]}catch{}throw s()},Fd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Vd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...Fd,...c},h=n(l,u),p=r(l),d=p?t():null;super(a,!1,h,d),this._gain=e(this,p,h.gain,mt,St)}get gain(){return this._gain}},Pd=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=ft(l,c);if(!u){const h={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,gain:l.gain.value};l=e(c,h)}return r.set(c,l),u?await s(c,a.gain,l.gain):await n(c,a.gain,l.gain),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Wd=(s,e)=>t=>e(s,t),Bd=s=>e=>{const t=s(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return t.renderer},$d=s=>e=>{var t;return(t=s.get(e))!==null&&t!==void 0?t:0},qd=s=>e=>{const t=s(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return t.renderer},jd=s=>e=>s.get(e),st=()=>new DOMException("","InvalidStateError"),Ld=s=>e=>{const t=s.get(e);if(t===void 0)throw st();return t},zd=(s,e)=>t=>{let n=s.get(t);if(n!==void 0)return n;if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new e(1,1,44100),s.set(t,n),n},Zd=s=>e=>{const t=s.get(e);if(t===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return t},or=()=>new DOMException("","InvalidAccessError"),Gd=s=>{s.getFrequencyResponse=(e=>(t,n,i)=>{if(t.length!==n.length||n.length!==i.length)throw or();return e.call(s,t,n,i)})(s.getFrequencyResponse)},Xd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Hd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u=i(l),h={...Xd,...c},p=e(l,u?null:a.baseLatency,h),d=u?t(h.feedback,h.feedforward):null;super(a,!1,p,d),Gd(p),this._nativeIIRFilterNode=p,r(this,1)}getFrequencyResponse(a,c,l){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,l)}},yl=(s,e,t,n,i,r,o,a,c,l,u)=>{const h=l.length;let p=a;for(let d=0;d<h;d+=1){let f=t[0]*l[d];for(let _=1;_<i;_+=1){const m=p-_&c-1;f+=t[_]*r[m],f-=s[_]*o[m]}for(let _=i;_<n;_+=1)f+=t[_]*r[p-_&c-1];for(let _=i;_<e;_+=1)f-=s[_]*o[p-_&c-1];r[p]=l[d],o[p]=f,p=p+1&c-1,u[d]=f}return p},Yd=(s,e,t,n)=>{const i=t instanceof Float64Array?t:new Float64Array(t),r=n instanceof Float64Array?n:new Float64Array(n),o=i.length,a=r.length,c=Math.min(o,a);if(i[0]!==1){for(let f=0;f<o;f+=1)r[f]/=i[0];for(let f=1;f<a;f+=1)i[f]/=i[0]}const l=32,u=new Float32Array(l),h=new Float32Array(l),p=e.createBuffer(s.numberOfChannels,s.length,s.sampleRate),d=s.numberOfChannels;for(let f=0;f<d;f+=1){const _=s.getChannelData(f),m=p.getChannelData(f);u.fill(0),h.fill(0),yl(i,o,r,a,c,u,h,0,l,_,m)}return p},Ud=(s,e,t,n,i)=>(r,o)=>{const a=new WeakMap;let c=null;const l=async(u,h)=>{let p=null,d=e(u);const f=ft(d,h);if(h.createIIRFilter===void 0?p=s(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(d=h.createIIRFilter(o,r)),a.set(h,p===null?d:p),p!==null){if(c===null){if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");const m=new t(u.context.destination.channelCount,u.context.length,h.sampleRate);c=(async()=>{await n(u,m,m.destination);const g=await i(m);return Yd(g,h,r,o)})()}const _=await c;return p.buffer=_,p.start(0),p}return await n(u,h,d),d};return{render(u,h){const p=a.get(h);return p!==void 0?Promise.resolve(p):l(u,h)}}},Kd=(s,e,t,n,i,r)=>o=>(a,c)=>{const l=s.get(a);if(l===void 0){if(!o&&r(a)){const u=n(a),{outputs:h}=t(a);for(const p of h)if(ii(p)){const d=n(p[0]);e(u,d,p[1],p[2])}else{const d=i(p[0]);u.disconnect(d,p[1])}}s.set(a,c)}else s.set(a,l+c)},Qd=(s,e)=>t=>{const n=s.get(t);return e(n)||e(t)},Jd=(s,e)=>t=>s.has(t)||e(t),ep=(s,e)=>t=>s.has(t)||e(t),tp=(s,e)=>t=>{const n=s.get(t);return e(n)||e(t)},sp=s=>e=>s!==null&&e instanceof s,np=s=>e=>s!==null&&typeof s.AudioNode=="function"&&e instanceof s.AudioNode,ip=s=>e=>s!==null&&typeof s.AudioParam=="function"&&e instanceof s.AudioParam,rp=(s,e)=>t=>s(t)||e(t),op=s=>e=>s!==null&&e instanceof s,ap=s=>s!==null&&s.isSecureContext,cp=async(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_)=>s(e,e)&&s(t,t)&&s(i,i)&&s(r,r)&&s(a,a)&&s(c,c)&&s(l,l)&&s(u,u)&&s(h,h)&&s(p,p)&&s(d,d)?(await Promise.all([s(n,n),s(o,o),s(f,f),s(_,_)])).every(g=>g):!1,lp=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r),c=e(a,o);if(n(a))throw TypeError();super(r,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}},up={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},hp=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r);if(n(a))throw new TypeError;const c={...up,...o},l=e(a,c);super(r,!1,l,null),this._nativeMediaStreamAudioDestinationNode=l}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},dp=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r),c=e(a,o);if(n(a))throw new TypeError;super(r,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},pp=(s,e,t)=>class extends s{constructor(i,r){const o=t(i),a=e(o,r);super(i,!0,a,null)}},fp=(s,e,t,n,i,r)=>class extends t{constructor(a,c){super(a),this._nativeContext=a,ir.set(this,a),n(a)&&i.set(a,new Set),this._destination=new s(this,c),this._listener=e(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){const c=typeof a=="function"?r(this,a):null;this._nativeContext.onstatechange=c;const l=this._nativeContext.onstatechange;this._onstatechange=l!==null&&l===c?a:l}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},Xn=s=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const t=s.decodeAudioData(e.buffer,()=>{});return t===void 0?!1:(t.catch(()=>{}),!0)}catch{}return!1},mp=(s,e)=>(t,n,i)=>{const r=new Set;return t.connect=(o=>(a,c=0,l=0)=>{const u=r.size===0;if(e(a))return o.call(t,a,c,l),s(r,[a,c,l],h=>h[0]===a&&h[1]===c&&h[2]===l,!0),u&&n(),a;o.call(t,a,c),s(r,[a,c],h=>h[0]===a&&h[1]===c,!0),u&&n()})(t.connect),t.disconnect=(o=>(a,c,l)=>{const u=r.size>0;if(a===void 0)o.apply(t),r.clear();else if(typeof a=="number"){o.call(t,a);for(const p of r)p[1]===a&&r.delete(p)}else{e(a)?o.call(t,a,c,l):o.call(t,a,c);for(const p of r)p[0]===a&&(c===void 0||p[1]===c)&&(l===void 0||p[2]===l)&&r.delete(p)}const h=r.size===0;u&&h&&i()})(t.disconnect),t},Me=(s,e,t)=>{const n=e[t];n!==void 0&&n!==s[t]&&(s[t]=n)},Ue=(s,e)=>{Me(s,e,"channelCount"),Me(s,e,"channelCountMode"),Me(s,e,"channelInterpretation")},nc=s=>typeof s.getFloatTimeDomainData=="function",gp=s=>{s.getFloatTimeDomainData=e=>{const t=new Uint8Array(e.length);s.getByteTimeDomainData(t);const n=Math.max(t.length,s.fftSize);for(let i=0;i<n;i+=1)e[i]=(t[i]-128)*.0078125;return e}},_p=(s,e)=>(t,n)=>{const i=t.createAnalyser();if(Ue(i,n),!(n.maxDecibels>n.minDecibels))throw e();return Me(i,n,"fftSize"),Me(i,n,"maxDecibels"),Me(i,n,"minDecibels"),Me(i,n,"smoothingTimeConstant"),s(nc,()=>nc(i))||gp(i),i},vp=s=>s===null?null:s.hasOwnProperty("AudioBuffer")?s.AudioBuffer:null,We=(s,e,t)=>{const n=e[t];n!==void 0&&n!==s[t].value&&(s[t].value=n)},yp=s=>{s.start=(e=>{let t=!1;return(n=0,i=0,r)=>{if(t)throw st();e.call(s,n,i,r),t=!0}})(s.start)},Wo=s=>{s.start=(e=>(t=0,n=0,i)=>{if(typeof i=="number"&&i<0||n<0||t<0)throw new RangeError("The parameters can't be negative.");e.call(s,t,n,i)})(s.start)},Bo=s=>{s.stop=(e=>(t=0)=>{if(t<0)throw new RangeError("The parameter can't be negative.");e.call(s,t)})(s.stop)},bp=(s,e,t,n,i,r,o,a,c,l,u)=>(h,p)=>{const d=h.createBufferSource();return Ue(d,p),We(d,p,"playbackRate"),Me(d,p,"buffer"),Me(d,p,"loop"),Me(d,p,"loopEnd"),Me(d,p,"loopStart"),e(t,()=>t(h))||yp(d),e(n,()=>n(h))||c(d),e(i,()=>i(h))||l(d,h),e(r,()=>r(h))||Wo(d),e(o,()=>o(h))||u(d,h),e(a,()=>a(h))||Bo(d),s(h,d),d},wp=s=>s===null?null:s.hasOwnProperty("AudioContext")?s.AudioContext:s.hasOwnProperty("webkitAudioContext")?s.webkitAudioContext:null,xp=(s,e)=>(t,n,i)=>{const r=t.destination;if(r.channelCount!==n)try{r.channelCount=n}catch{}i&&r.channelCountMode!=="explicit"&&(r.channelCountMode="explicit"),r.maxChannelCount===0&&Object.defineProperty(r,"maxChannelCount",{value:n});const o=s(t,{channelCount:n,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,gain:1});return e(o,"channelCount",a=>()=>a.call(o),a=>c=>{a.call(o,c);try{r.channelCount=c}catch(l){if(c>r.maxChannelCount)throw l}}),e(o,"channelCountMode",a=>()=>a.call(o),a=>c=>{a.call(o,c),r.channelCountMode=c}),e(o,"channelInterpretation",a=>()=>a.call(o),a=>c=>{a.call(o,c),r.channelInterpretation=c}),Object.defineProperty(o,"maxChannelCount",{get:()=>r.maxChannelCount}),o.connect(r),o},Cp=s=>s===null?null:s.hasOwnProperty("AudioWorkletNode")?s.AudioWorkletNode:null,Sp=s=>{const{port1:e}=new MessageChannel;try{e.postMessage(s)}finally{e.close()}},Tp=(s,e,t,n,i)=>(r,o,a,c,l,u)=>{if(a!==null)try{const h=new a(r,c,u),p=new Map;let d=null;if(Object.defineProperties(h,{channelCount:{get:()=>u.channelCount,set:()=>{throw s()}},channelCountMode:{get:()=>"explicit",set:()=>{throw s()}},onprocessorerror:{get:()=>d,set:f=>{typeof d=="function"&&h.removeEventListener("processorerror",d),d=typeof f=="function"?f:null,typeof d=="function"&&h.addEventListener("processorerror",d)}}}),h.addEventListener=(f=>(..._)=>{if(_[0]==="processorerror"){const m=typeof _[1]=="function"?_[1]:typeof _[1]=="object"&&_[1]!==null&&typeof _[1].handleEvent=="function"?_[1].handleEvent:null;if(m!==null){const g=p.get(_[1]);g!==void 0?_[1]=g:(_[1]=y=>{y.type==="error"?(Object.defineProperties(y,{type:{value:"processorerror"}}),m(y)):m(new ErrorEvent(_[0],{...y}))},p.set(m,_[1]))}}return f.call(h,"error",_[1],_[2]),f.call(h,..._)})(h.addEventListener),h.removeEventListener=(f=>(..._)=>{if(_[0]==="processorerror"){const m=p.get(_[1]);m!==void 0&&(p.delete(_[1]),_[1]=m)}return f.call(h,"error",_[1],_[2]),f.call(h,_[0],_[1],_[2])})(h.removeEventListener),u.numberOfOutputs!==0){const f=t(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(r.destination),i(h,()=>f.disconnect(),()=>f.connect(r.destination))}return h}catch(h){throw h.code===11?n():h}if(l===void 0)throw n();return Sp(u),e(r,o,l,u)},bl=(s,e)=>s===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(s*e))))),kp=s=>new Promise((e,t)=>{const{port1:n,port2:i}=new MessageChannel;n.onmessage=({data:r})=>{n.close(),i.close(),e(r)},n.onmessageerror=({data:r})=>{n.close(),i.close(),t(r)},i.postMessage(s)}),Ap=async(s,e)=>{const t=await kp(e);return new s(t)},Ip=(s,e,t,n)=>{let i=go.get(s);i===void 0&&(i=new WeakMap,go.set(s,i));const r=Ap(t,n);return i.set(e,r),r},Dp=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>(d,f,_,m)=>{if(m.numberOfInputs===0&&m.numberOfOutputs===0)throw c();const g=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(g.some(L=>L<1))throw c();if(g.length!==m.numberOfOutputs)throw e();if(m.channelCountMode!=="explicit")throw c();const y=m.channelCount*m.numberOfInputs,x=g.reduce((L,H)=>L+H,0),w=_.parameterDescriptors===void 0?0:_.parameterDescriptors.length;if(y+w>6||x>6)throw c();const v=new MessageChannel,b=[],k=[];for(let L=0;L<m.numberOfInputs;L+=1)b.push(o(d,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),k.push(i(d,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const T=[];if(_.parameterDescriptors!==void 0)for(const{defaultValue:L,maxValue:H,minValue:be,name:we}of _.parameterDescriptors){const ce=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:m.parameterData[we]!==void 0?m.parameterData[we]:L===void 0?0:L});Object.defineProperties(ce.offset,{defaultValue:{get:()=>L===void 0?0:L},maxValue:{get:()=>H===void 0?mt:H},minValue:{get:()=>be===void 0?St:be}}),T.push(ce)}const R=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,y+w)}),I=bl(f,d.sampleRate),A=a(d,I,y+w,Math.max(1,x)),D=i(d,{channelCount:Math.max(1,x),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,x)}),M=[];for(let L=0;L<m.numberOfOutputs;L+=1)M.push(n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[L]}));for(let L=0;L<m.numberOfInputs;L+=1){b[L].connect(k[L]);for(let H=0;H<m.channelCount;H+=1)k[L].connect(R,H,L*m.channelCount+H)}const N=new _l(_.parameterDescriptors===void 0?[]:_.parameterDescriptors.map(({name:L},H)=>{const be=T[H];return be.connect(R,0,y+H),be.start(0),[L,be.offset]}));R.connect(A);let q=m.channelInterpretation,V=null;const j=m.numberOfOutputs===0?[A]:M,G={get bufferSize(){return I},get channelCount(){return m.channelCount},set channelCount(L){throw t()},get channelCountMode(){return m.channelCountMode},set channelCountMode(L){throw t()},get channelInterpretation(){return q},set channelInterpretation(L){for(const H of b)H.channelInterpretation=L;q=L},get context(){return A.context},get inputs(){return b},get numberOfInputs(){return m.numberOfInputs},get numberOfOutputs(){return m.numberOfOutputs},get onprocessorerror(){return V},set onprocessorerror(L){typeof V=="function"&&G.removeEventListener("processorerror",V),V=typeof L=="function"?L:null,typeof V=="function"&&G.addEventListener("processorerror",V)},get parameters(){return N},get port(){return v.port2},addEventListener(...L){return A.addEventListener(L[0],L[1],L[2])},connect:s.bind(null,j),disconnect:l.bind(null,j),dispatchEvent(...L){return A.dispatchEvent(L[0])},removeEventListener(...L){return A.removeEventListener(L[0],L[1],L[2])}},B=new Map;v.port1.addEventListener=(L=>(...H)=>{if(H[0]==="message"){const be=typeof H[1]=="function"?H[1]:typeof H[1]=="object"&&H[1]!==null&&typeof H[1].handleEvent=="function"?H[1].handleEvent:null;if(be!==null){const we=B.get(H[1]);we!==void 0?H[1]=we:(H[1]=ce=>{u(d.currentTime,d.sampleRate,()=>be(ce))},B.set(be,H[1]))}}return L.call(v.port1,H[0],H[1],H[2])})(v.port1.addEventListener),v.port1.removeEventListener=(L=>(...H)=>{if(H[0]==="message"){const be=B.get(H[1]);be!==void 0&&(B.delete(H[1]),H[1]=be)}return L.call(v.port1,H[0],H[1],H[2])})(v.port1.removeEventListener);let Z=null;Object.defineProperty(v.port1,"onmessage",{get:()=>Z,set:L=>{typeof Z=="function"&&v.port1.removeEventListener("message",Z),Z=typeof L=="function"?L:null,typeof Z=="function"&&(v.port1.addEventListener("message",Z),v.port1.start())}}),_.prototype.port=v.port1;let X=null;Ip(d,G,_,m).then(L=>X=L);const pe=Yi(m.numberOfInputs,m.channelCount),ie=Yi(m.numberOfOutputs,g),Q=_.parameterDescriptors===void 0?[]:_.parameterDescriptors.reduce((L,{name:H})=>({...L,[H]:new Float32Array(128)}),{});let ye=!0;const Ee=()=>{m.numberOfOutputs>0&&A.disconnect(D);for(let L=0,H=0;L<m.numberOfOutputs;L+=1){const be=M[L];for(let we=0;we<g[L];we+=1)D.disconnect(be,H+we,we);H+=g[L]}},z=new Map;A.onaudioprocess=({inputBuffer:L,outputBuffer:H})=>{if(X!==null){const be=h(G);for(let we=0;we<I;we+=128){for(let ce=0;ce<m.numberOfInputs;ce+=1)for(let Ce=0;Ce<m.channelCount;Ce+=1)Hi(L,pe[ce],Ce,Ce,we);_.parameterDescriptors!==void 0&&_.parameterDescriptors.forEach(({name:ce},Ce)=>{Hi(L,Q,ce,y+Ce,we)});for(let ce=0;ce<m.numberOfInputs;ce+=1)for(let Ce=0;Ce<g[ce];Ce+=1)ie[ce][Ce].byteLength===0&&(ie[ce][Ce]=new Float32Array(128));try{const ce=pe.map((He,Ze)=>{if(be[Ze].size>0)return z.set(Ze,I/128),He;const oe=z.get(Ze);return oe===void 0?[]:(He.every(ge=>ge.every(Ae=>Ae===0))&&(oe===1?z.delete(Ze):z.set(Ze,oe-1)),He)});ye=u(d.currentTime+we/d.sampleRate,d.sampleRate,()=>X.process(ce,ie,Q));for(let He=0,Ze=0;He<m.numberOfOutputs;He+=1){for(let Pt=0;Pt<g[He];Pt+=1)vl(H,ie[He],Pt,Ze+Pt,we);Ze+=g[He]}}catch(ce){ye=!1,G.dispatchEvent(new ErrorEvent("processorerror",{colno:ce.colno,filename:ce.filename,lineno:ce.lineno,message:ce.message}))}if(!ye){for(let ce=0;ce<m.numberOfInputs;ce+=1){b[ce].disconnect(k[ce]);for(let Ce=0;Ce<m.channelCount;Ce+=1)k[we].disconnect(R,Ce,ce*m.channelCount+Ce)}if(_.parameterDescriptors!==void 0){const ce=_.parameterDescriptors.length;for(let Ce=0;Ce<ce;Ce+=1){const He=T[Ce];He.disconnect(R,0,y+Ce),He.stop()}}R.disconnect(A),A.onaudioprocess=null,Je?Ee():U();break}}}};let Je=!1;const lt=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Vt=()=>A.connect(lt).connect(d.destination),U=()=>{A.disconnect(lt),lt.disconnect()},ut=()=>{if(ye){U(),m.numberOfOutputs>0&&A.connect(D);for(let L=0,H=0;L<m.numberOfOutputs;L+=1){const be=M[L];for(let we=0;we<g[L];we+=1)D.connect(be,H+we,we);H+=g[L]}}Je=!0},$e=()=>{ye&&(Vt(),Ee()),Je=!1};return Vt(),p(G,ut,$e)},wl=(s,e)=>{const t=s.createBiquadFilter();return Ue(t,e),We(t,e,"Q"),We(t,e,"detune"),We(t,e,"frequency"),We(t,e,"gain"),Me(t,e,"type"),t},Rp=(s,e)=>(t,n)=>{const i=t.createChannelMerger(n.numberOfInputs);return s!==null&&s.name==="webkitAudioContext"&&e(t,i),Ue(i,n),i},Ep=s=>{const e=s.numberOfOutputs;Object.defineProperty(s,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw st()}}),Object.defineProperty(s,"channelCountMode",{get:()=>"explicit",set:t=>{if(t!=="explicit")throw st()}}),Object.defineProperty(s,"channelInterpretation",{get:()=>"discrete",set:t=>{if(t!=="discrete")throw st()}})},ri=(s,e)=>{const t=s.createChannelSplitter(e.numberOfOutputs);return Ue(t,e),Ep(t),t},Mp=(s,e,t,n,i)=>(r,o)=>{if(r.createConstantSource===void 0)return t(r,o);const a=r.createConstantSource();return Ue(a,o),We(a,o,"offset"),e(n,()=>n(r))||Wo(a),e(i,()=>i(r))||Bo(a),s(r,a),a},fn=(s,e)=>(s.connect=e.connect.bind(e),s.disconnect=e.disconnect.bind(e),s),Op=(s,e,t,n)=>(i,{offset:r,...o})=>{const a=i.createBuffer(1,2,44100),c=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=t(i,{...o,gain:r}),u=a.getChannelData(0);u[0]=1,u[1]=1,c.buffer=a,c.loop=!0;const h={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(f){l.channelCount=f},get channelCountMode(){return l.channelCountMode},set channelCountMode(f){l.channelCountMode=f},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(f){l.channelInterpretation=f},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return c.onended},set onended(f){c.onended=f},addEventListener(...f){return c.addEventListener(f[0],f[1],f[2])},dispatchEvent(...f){return c.dispatchEvent(f[0])},removeEventListener(...f){return c.removeEventListener(f[0],f[1],f[2])},start(f=0){c.start.call(c,f)},stop(f=0){c.stop.call(c,f)}},p=()=>c.connect(l),d=()=>c.disconnect(l);return s(i,c),n(fn(h,l),p,d)},Np=(s,e)=>(t,n)=>{const i=t.createConvolver();if(Ue(i,n),n.disableNormalization===i.normalize&&(i.normalize=!n.disableNormalization),Me(i,n,"buffer"),n.channelCount>2||(e(i,"channelCount",r=>()=>r.call(i),r=>o=>{if(o>2)throw s();return r.call(i,o)}),n.channelCountMode==="max"))throw s();return e(i,"channelCountMode",r=>()=>r.call(i),r=>o=>{if(o==="max")throw s();return r.call(i,o)}),i},xl=(s,e)=>{const t=s.createDelay(e.maxDelayTime);return Ue(t,e),We(t,e,"delayTime"),t},Fp=s=>(e,t)=>{const n=e.createDynamicsCompressor();if(Ue(n,t),t.channelCount>2||t.channelCountMode==="max")throw s();return We(n,t,"attack"),We(n,t,"knee"),We(n,t,"ratio"),We(n,t,"release"),We(n,t,"threshold"),n},kt=(s,e)=>{const t=s.createGain();return Ue(t,e),We(t,e,"gain"),t},Vp=s=>(e,t,n)=>{if(e.createIIRFilter===void 0)return s(e,t,n);const i=e.createIIRFilter(n.feedforward,n.feedback);return Ue(i,n),i};function Pp(s,e){const t=e[0]*e[0]+e[1]*e[1];return[(s[0]*e[0]+s[1]*e[1])/t,(s[1]*e[0]-s[0]*e[1])/t]}function Wp(s,e){return[s[0]*e[0]-s[1]*e[1],s[0]*e[1]+s[1]*e[0]]}function ic(s,e){let t=[0,0];for(let n=s.length-1;n>=0;n-=1)t=Wp(t,e),t[0]+=s[n];return t}const Bp=(s,e,t,n)=>(i,r,{channelCount:o,channelCountMode:a,channelInterpretation:c,feedback:l,feedforward:u})=>{const h=bl(r,i.sampleRate),p=l instanceof Float64Array?l:new Float64Array(l),d=u instanceof Float64Array?u:new Float64Array(u),f=p.length,_=d.length,m=Math.min(f,_);if(f===0||f>20)throw n();if(p[0]===0)throw e();if(_===0||_>20)throw n();if(d[0]===0)throw e();if(p[0]!==1){for(let T=0;T<_;T+=1)d[T]/=p[0];for(let T=1;T<f;T+=1)p[T]/=p[0]}const g=t(i,h,o,o);g.channelCount=o,g.channelCountMode=a,g.channelInterpretation=c;const y=32,x=[],w=[],v=[];for(let T=0;T<o;T+=1){x.push(0);const R=new Float32Array(y),I=new Float32Array(y);R.fill(0),I.fill(0),w.push(R),v.push(I)}g.onaudioprocess=T=>{const R=T.inputBuffer,I=T.outputBuffer,A=R.numberOfChannels;for(let D=0;D<A;D+=1){const M=R.getChannelData(D),N=I.getChannelData(D);x[D]=yl(p,f,d,_,m,w[D],v[D],x[D],y,M,N)}};const b=i.sampleRate/2;return fn({get bufferSize(){return h},get channelCount(){return g.channelCount},set channelCount(T){g.channelCount=T},get channelCountMode(){return g.channelCountMode},set channelCountMode(T){g.channelCountMode=T},get channelInterpretation(){return g.channelInterpretation},set channelInterpretation(T){g.channelInterpretation=T},get context(){return g.context},get inputs(){return[g]},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},addEventListener(...T){return g.addEventListener(T[0],T[1],T[2])},dispatchEvent(...T){return g.dispatchEvent(T[0])},getFrequencyResponse(T,R,I){if(T.length!==R.length||R.length!==I.length)throw s();const A=T.length;for(let D=0;D<A;D+=1){const M=-Math.PI*(T[D]/b),N=[Math.cos(M),Math.sin(M)],q=ic(d,N),V=ic(p,N),j=Pp(q,V);R[D]=Math.sqrt(j[0]*j[0]+j[1]*j[1]),I[D]=Math.atan2(j[1],j[0])}},removeEventListener(...T){return g.removeEventListener(T[0],T[1],T[2])}},g)},$p=(s,e)=>s.createMediaElementSource(e.mediaElement),qp=(s,e)=>{const t=s.createMediaStreamDestination();return Ue(t,e),t.numberOfOutputs===1&&Object.defineProperty(t,"numberOfOutputs",{get:()=>0}),t},jp=(s,{mediaStream:e})=>{const t=e.getAudioTracks();t.sort((r,o)=>r.id<o.id?-1:r.id>o.id?1:0);const n=t.slice(0,1),i=s.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(i,"mediaStream",{value:e}),i},Lp=(s,e)=>(t,{mediaStreamTrack:n})=>{if(typeof t.createMediaStreamTrackSource=="function")return t.createMediaStreamTrackSource(n);const i=new MediaStream([n]),r=t.createMediaStreamSource(i);if(n.kind!=="audio")throw s();if(e(t))throw new TypeError;return r},zp=s=>s===null?null:s.hasOwnProperty("OfflineAudioContext")?s.OfflineAudioContext:s.hasOwnProperty("webkitOfflineAudioContext")?s.webkitOfflineAudioContext:null,Zp=(s,e,t,n,i,r)=>(o,a)=>{const c=o.createOscillator();return Ue(c,a),We(c,a,"detune"),We(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):Me(c,a,"type"),e(t,()=>t(o))||Wo(c),e(n,()=>n(o))||r(c,o),e(i,()=>i(o))||Bo(c),s(o,c),c},Gp=s=>(e,t)=>{const n=e.createPanner();return n.orientationX===void 0?s(e,t):(Ue(n,t),We(n,t,"orientationX"),We(n,t,"orientationY"),We(n,t,"orientationZ"),We(n,t,"positionX"),We(n,t,"positionY"),We(n,t,"positionZ"),Me(n,t,"coneInnerAngle"),Me(n,t,"coneOuterAngle"),Me(n,t,"coneOuterGain"),Me(n,t,"distanceModel"),Me(n,t,"maxDistance"),Me(n,t,"panningModel"),Me(n,t,"refDistance"),Me(n,t,"rolloffFactor"),n)},Xp=(s,e,t,n,i,r,o,a,c,l)=>(u,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:_,orientationX:m,orientationY:g,orientationZ:y,panningModel:x,positionX:w,positionY:v,positionZ:b,refDistance:k,rolloffFactor:T,...R})=>{const I=u.createPanner();if(R.channelCount>2||R.channelCountMode==="max")throw o();Ue(I,R);const A={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},D=t(u,{...A,channelInterpretation:"speakers",numberOfInputs:6}),M=n(u,{...R,gain:1}),N=n(u,{...A,gain:1}),q=n(u,{...A,gain:0}),V=n(u,{...A,gain:0}),j=n(u,{...A,gain:0}),G=n(u,{...A,gain:0}),B=n(u,{...A,gain:0}),Z=i(u,256,6,1),X=r(u,{...A,curve:new Float32Array([1,1]),oversample:"none"});let ee=[m,g,y],pe=[w,v,b];const ie=new Float32Array(1);Z.onaudioprocess=({inputBuffer:z})=>{const Je=[c(z,ie,0),c(z,ie,1),c(z,ie,2)];Je.some((Vt,U)=>Vt!==ee[U])&&(I.setOrientation(...Je),ee=Je);const lt=[c(z,ie,3),c(z,ie,4),c(z,ie,5)];lt.some((Vt,U)=>Vt!==pe[U])&&(I.setPosition(...lt),pe=lt)},Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(j.gain,"defaultValue",{get:()=>0}),Object.defineProperty(G.gain,"defaultValue",{get:()=>0}),Object.defineProperty(B.gain,"defaultValue",{get:()=>0});const Q={get bufferSize(){},get channelCount(){return I.channelCount},set channelCount(z){if(z>2)throw o();M.channelCount=z,I.channelCount=z},get channelCountMode(){return I.channelCountMode},set channelCountMode(z){if(z==="max")throw o();M.channelCountMode=z,I.channelCountMode=z},get channelInterpretation(){return I.channelInterpretation},set channelInterpretation(z){M.channelInterpretation=z,I.channelInterpretation=z},get coneInnerAngle(){return I.coneInnerAngle},set coneInnerAngle(z){I.coneInnerAngle=z},get coneOuterAngle(){return I.coneOuterAngle},set coneOuterAngle(z){I.coneOuterAngle=z},get coneOuterGain(){return I.coneOuterGain},set coneOuterGain(z){if(z<0||z>1)throw e();I.coneOuterGain=z},get context(){return I.context},get distanceModel(){return I.distanceModel},set distanceModel(z){I.distanceModel=z},get inputs(){return[M]},get maxDistance(){return I.maxDistance},set maxDistance(z){if(z<0)throw new RangeError;I.maxDistance=z},get numberOfInputs(){return I.numberOfInputs},get numberOfOutputs(){return I.numberOfOutputs},get orientationX(){return N.gain},get orientationY(){return q.gain},get orientationZ(){return V.gain},get panningModel(){return I.panningModel},set panningModel(z){I.panningModel=z},get positionX(){return j.gain},get positionY(){return G.gain},get positionZ(){return B.gain},get refDistance(){return I.refDistance},set refDistance(z){if(z<0)throw new RangeError;I.refDistance=z},get rolloffFactor(){return I.rolloffFactor},set rolloffFactor(z){if(z<0)throw new RangeError;I.rolloffFactor=z},addEventListener(...z){return M.addEventListener(z[0],z[1],z[2])},dispatchEvent(...z){return M.dispatchEvent(z[0])},removeEventListener(...z){return M.removeEventListener(z[0],z[1],z[2])}};h!==Q.coneInnerAngle&&(Q.coneInnerAngle=h),p!==Q.coneOuterAngle&&(Q.coneOuterAngle=p),d!==Q.coneOuterGain&&(Q.coneOuterGain=d),f!==Q.distanceModel&&(Q.distanceModel=f),_!==Q.maxDistance&&(Q.maxDistance=_),m!==Q.orientationX.value&&(Q.orientationX.value=m),g!==Q.orientationY.value&&(Q.orientationY.value=g),y!==Q.orientationZ.value&&(Q.orientationZ.value=y),x!==Q.panningModel&&(Q.panningModel=x),w!==Q.positionX.value&&(Q.positionX.value=w),v!==Q.positionY.value&&(Q.positionY.value=v),b!==Q.positionZ.value&&(Q.positionZ.value=b),k!==Q.refDistance&&(Q.refDistance=k),T!==Q.rolloffFactor&&(Q.rolloffFactor=T),(ee[0]!==1||ee[1]!==0||ee[2]!==0)&&I.setOrientation(...ee),(pe[0]!==0||pe[1]!==0||pe[2]!==0)&&I.setPosition(...pe);const ye=()=>{M.connect(I),s(M,X,0,0),X.connect(N).connect(D,0,0),X.connect(q).connect(D,0,1),X.connect(V).connect(D,0,2),X.connect(j).connect(D,0,3),X.connect(G).connect(D,0,4),X.connect(B).connect(D,0,5),D.connect(Z).connect(u.destination)},Ee=()=>{M.disconnect(I),a(M,X,0,0),X.disconnect(N),N.disconnect(D),X.disconnect(q),q.disconnect(D),X.disconnect(V),V.disconnect(D),X.disconnect(j),j.disconnect(D),X.disconnect(G),G.disconnect(D),X.disconnect(B),B.disconnect(D),D.disconnect(Z),Z.disconnect(u.destination)};return l(fn(Q,I),ye,Ee)},Hp=s=>(e,{disableNormalization:t,imag:n,real:i})=>{const r=n instanceof Float32Array?n:new Float32Array(n),o=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(o,r,{disableNormalization:t});if(Array.from(n).length<2)throw s();return a},oi=(s,e,t,n)=>s.createScriptProcessor(e,t,n),Yp=(s,e)=>(t,n)=>{const i=n.channelCountMode;if(i==="clamped-max")throw e();if(t.createStereoPanner===void 0)return s(t,n);const r=t.createStereoPanner();return Ue(r,n),We(r,n,"pan"),Object.defineProperty(r,"channelCountMode",{get:()=>i,set:o=>{if(o!==i)throw e()}}),r},Up=(s,e,t,n,i,r)=>{const a=new Float32Array([1,1]),c=Math.PI/2,l={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},u={...l,oversample:"none"},h=(f,_,m,g)=>{const y=new Float32Array(16385),x=new Float32Array(16385);for(let R=0;R<16385;R+=1){const I=R/16384*c;y[R]=Math.cos(I),x[R]=Math.sin(I)}const w=t(f,{...l,gain:0}),v=n(f,{...u,curve:y}),b=n(f,{...u,curve:a}),k=t(f,{...l,gain:0}),T=n(f,{...u,curve:x});return{connectGraph(){_.connect(w),_.connect(b.inputs===void 0?b:b.inputs[0]),_.connect(k),b.connect(m),m.connect(v.inputs===void 0?v:v.inputs[0]),m.connect(T.inputs===void 0?T:T.inputs[0]),v.connect(w.gain),T.connect(k.gain),w.connect(g,0,0),k.connect(g,0,1)},disconnectGraph(){_.disconnect(w),_.disconnect(b.inputs===void 0?b:b.inputs[0]),_.disconnect(k),b.disconnect(m),m.disconnect(v.inputs===void 0?v:v.inputs[0]),m.disconnect(T.inputs===void 0?T:T.inputs[0]),v.disconnect(w.gain),T.disconnect(k.gain),w.disconnect(g,0,0),k.disconnect(g,0,1)}}},p=(f,_,m,g)=>{const y=new Float32Array(16385),x=new Float32Array(16385),w=new Float32Array(16385),v=new Float32Array(16385),b=Math.floor(16385/2);for(let j=0;j<16385;j+=1)if(j>b){const G=(j-b)/(16384-b)*c;y[j]=Math.cos(G),x[j]=Math.sin(G),w[j]=0,v[j]=1}else{const G=j/(16384-b)*c;y[j]=1,x[j]=0,w[j]=Math.cos(G),v[j]=Math.sin(G)}const k=e(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),T=t(f,{...l,gain:0}),R=n(f,{...u,curve:y}),I=t(f,{...l,gain:0}),A=n(f,{...u,curve:x}),D=n(f,{...u,curve:a}),M=t(f,{...l,gain:0}),N=n(f,{...u,curve:w}),q=t(f,{...l,gain:0}),V=n(f,{...u,curve:v});return{connectGraph(){_.connect(k),_.connect(D.inputs===void 0?D:D.inputs[0]),k.connect(T,0),k.connect(I,0),k.connect(M,1),k.connect(q,1),D.connect(m),m.connect(R.inputs===void 0?R:R.inputs[0]),m.connect(A.inputs===void 0?A:A.inputs[0]),m.connect(N.inputs===void 0?N:N.inputs[0]),m.connect(V.inputs===void 0?V:V.inputs[0]),R.connect(T.gain),A.connect(I.gain),N.connect(M.gain),V.connect(q.gain),T.connect(g,0,0),M.connect(g,0,0),I.connect(g,0,1),q.connect(g,0,1)},disconnectGraph(){_.disconnect(k),_.disconnect(D.inputs===void 0?D:D.inputs[0]),k.disconnect(T,0),k.disconnect(I,0),k.disconnect(M,1),k.disconnect(q,1),D.disconnect(m),m.disconnect(R.inputs===void 0?R:R.inputs[0]),m.disconnect(A.inputs===void 0?A:A.inputs[0]),m.disconnect(N.inputs===void 0?N:N.inputs[0]),m.disconnect(V.inputs===void 0?V:V.inputs[0]),R.disconnect(T.gain),A.disconnect(I.gain),N.disconnect(M.gain),V.disconnect(q.gain),T.disconnect(g,0,0),M.disconnect(g,0,0),I.disconnect(g,0,1),q.disconnect(g,0,1)}}},d=(f,_,m,g,y)=>{if(_===1)return h(f,m,g,y);if(_===2)return p(f,m,g,y);throw i()};return(f,{channelCount:_,channelCountMode:m,pan:g,...y})=>{if(m==="max")throw i();const x=s(f,{...y,channelCount:1,channelCountMode:m,numberOfInputs:2}),w=t(f,{...y,channelCount:_,channelCountMode:m,gain:1}),v=t(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:g});let{connectGraph:b,disconnectGraph:k}=d(f,_,w,v,x);Object.defineProperty(v.gain,"defaultValue",{get:()=>0}),Object.defineProperty(v.gain,"maxValue",{get:()=>1}),Object.defineProperty(v.gain,"minValue",{get:()=>-1});const T={get bufferSize(){},get channelCount(){return w.channelCount},set channelCount(D){w.channelCount!==D&&(R&&k(),{connectGraph:b,disconnectGraph:k}=d(f,D,w,v,x),R&&b()),w.channelCount=D},get channelCountMode(){return w.channelCountMode},set channelCountMode(D){if(D==="clamped-max"||D==="max")throw i();w.channelCountMode=D},get channelInterpretation(){return w.channelInterpretation},set channelInterpretation(D){w.channelInterpretation=D},get context(){return w.context},get inputs(){return[w]},get numberOfInputs(){return w.numberOfInputs},get numberOfOutputs(){return w.numberOfOutputs},get pan(){return v.gain},addEventListener(...D){return w.addEventListener(D[0],D[1],D[2])},dispatchEvent(...D){return w.dispatchEvent(D[0])},removeEventListener(...D){return w.removeEventListener(D[0],D[1],D[2])}};let R=!1;const I=()=>{b(),R=!0},A=()=>{k(),R=!1};return r(fn(T,x),I,A)}},Kp=(s,e,t,n,i,r,o)=>(a,c)=>{const l=a.createWaveShaper();if(r!==null&&r.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return t(a,c);Ue(l,c);const u=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(u!==null&&u.length<2)throw e();Me(l,{curve:u},"curve"),Me(l,c,"oversample");let h=null,p=!1;return o(l,"curve",_=>()=>_.call(l),_=>m=>(_.call(l,m),p&&(n(m)&&h===null?h=s(a,l):!n(m)&&h!==null&&(h(),h=null)),m)),i(l,()=>{p=!0,n(l.curve)&&(h=s(a,l))},()=>{p=!1,h!==null&&(h(),h=null)})},Qp=(s,e,t,n,i)=>(r,{curve:o,oversample:a,...c})=>{const l=r.createWaveShaper(),u=r.createWaveShaper();Ue(l,c),Ue(u,c);const h=t(r,{...c,gain:1}),p=t(r,{...c,gain:-1}),d=t(r,{...c,gain:1}),f=t(r,{...c,gain:-1});let _=null,m=!1,g=null;const y={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(v){h.channelCount=v,p.channelCount=v,l.channelCount=v,d.channelCount=v,u.channelCount=v,f.channelCount=v},get channelCountMode(){return l.channelCountMode},set channelCountMode(v){h.channelCountMode=v,p.channelCountMode=v,l.channelCountMode=v,d.channelCountMode=v,u.channelCountMode=v,f.channelCountMode=v},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(v){h.channelInterpretation=v,p.channelInterpretation=v,l.channelInterpretation=v,d.channelInterpretation=v,u.channelInterpretation=v,f.channelInterpretation=v},get context(){return l.context},get curve(){return g},set curve(v){if(v!==null&&v.length<2)throw e();if(v===null)l.curve=v,u.curve=v;else{const b=v.length,k=new Float32Array(b+2-b%2),T=new Float32Array(b+2-b%2);k[0]=v[0],T[0]=-v[b-1];const R=Math.ceil((b+1)/2),I=(b+1)/2-1;for(let A=1;A<R;A+=1){const D=A/R*I,M=Math.floor(D),N=Math.ceil(D);k[A]=M===N?v[M]:(1-(D-M))*v[M]+(1-(N-D))*v[N],T[A]=M===N?-v[b-1-M]:-((1-(D-M))*v[b-1-M])-(1-(N-D))*v[b-1-N]}k[R]=b%2===1?v[R-1]:(v[R-2]+v[R-1])/2,l.curve=k,u.curve=T}g=v,m&&(n(g)&&_===null?_=s(r,h):_!==null&&(_(),_=null))},get inputs(){return[h]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(v){l.oversample=v,u.oversample=v},addEventListener(...v){return h.addEventListener(v[0],v[1],v[2])},dispatchEvent(...v){return h.dispatchEvent(v[0])},removeEventListener(...v){return h.removeEventListener(v[0],v[1],v[2])}};o!==null&&(y.curve=o instanceof Float32Array?o:new Float32Array(o)),a!==y.oversample&&(y.oversample=a);const x=()=>{h.connect(l).connect(d),h.connect(p).connect(u).connect(f).connect(d),m=!0,n(g)&&(_=s(r,h))},w=()=>{h.disconnect(l),l.disconnect(d),h.disconnect(p),p.disconnect(u),u.disconnect(f),f.disconnect(d),m=!1,_!==null&&(_(),_=null)};return i(fn(y,d),x,w)},bt=()=>new DOMException("","NotSupportedError"),Jp={numberOfChannels:1},ef=(s,e,t,n,i)=>class extends s{constructor(o,a,c){let l;if(typeof o=="number"&&a!==void 0&&c!==void 0)l={length:a,numberOfChannels:o,sampleRate:c};else if(typeof o=="object")l=o;else throw new Error("The given parameters are not valid.");const{length:u,numberOfChannels:h,sampleRate:p}={...Jp,...l},d=n(h,u,p);e(Xn,()=>Xn(d))||d.addEventListener("statechange",(()=>{let f=0;const _=m=>{this._state==="running"&&(f>0?(d.removeEventListener("statechange",_),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):f+=1)};return _})()),super(d,h),this._length=u,this._nativeOfflineAudioContext=d,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,pl(this)}))}_waitForThePromiseToSettle(o){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(o):setTimeout(()=>this._waitForThePromiseToSettle(o))}},tf={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},sf=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...tf,...l},p=t(u,h),d=r(u),f=d?n():null,_=c.sampleRate/2;super(c,!1,p,f),this._detune=e(this,d,p.detune,153600,-153600),this._frequency=e(this,d,p.frequency,_,-_),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&h.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=h.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){const l=typeof c=="function"?o(this,c):null;this._nativeOscillatorNode.onended=l;const u=this._nativeOscillatorNode.onended;this._onended=u!==null&&u===l?c:u}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){on(this);const l=()=>{this._nativeOscillatorNode.removeEventListener("ended",l),ds(this)&&si(this)};this._nativeOscillatorNode.addEventListener("ended",l)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}},nf=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null,c=null;const l=async(u,h)=>{let p=t(u);const d=ft(p,h);if(!d){const f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:o===null?void 0:o,type:p.type};p=e(h,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return r.set(h,p),d?(await s(h,u.detune,p.detune),await s(h,u.frequency,p.frequency)):(await n(h,u.detune,p.detune),await n(h,u.frequency,p.frequency)),await i(u,h,p),p};return{set periodicWave(u){o=u},set start(u){a=u},set stop(u){c=u},render(u,h){const p=r.get(h);return p!==void 0?Promise.resolve(p):l(u,h)}}},rf={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},of=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...rf,...l},p=t(u,h),d=r(u),f=d?n():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=e(this,d,p.orientationX,mt,St),this._orientationY=e(this,d,p.orientationY,mt,St),this._orientationZ=e(this,d,p.orientationZ,mt,St),this._positionX=e(this,d,p.positionX,mt,St),this._positionY=e(this,d,p.positionY,mt,St),this._positionZ=e(this,d,p.positionZ,mt,St),o(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}},af=(s,e,t,n,i,r,o,a,c,l)=>()=>{const u=new WeakMap;let h=null;const p=async(d,f)=>{let _=null,m=r(d);const g={channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation},y={...g,coneInnerAngle:m.coneInnerAngle,coneOuterAngle:m.coneOuterAngle,coneOuterGain:m.coneOuterGain,distanceModel:m.distanceModel,maxDistance:m.maxDistance,panningModel:m.panningModel,refDistance:m.refDistance,rolloffFactor:m.rolloffFactor},x=ft(m,f);if("bufferSize"in m)_=n(f,{...g,gain:1});else if(!x){const w={...y,orientationX:m.orientationX.value,orientationY:m.orientationY.value,orientationZ:m.orientationZ.value,positionX:m.positionX.value,positionY:m.positionY.value,positionZ:m.positionZ.value};m=i(f,w)}if(u.set(f,_===null?m:_),_!==null){if(h===null){if(o===null)throw new Error("Missing the native OfflineAudioContext constructor.");const A=new o(6,d.context.length,f.sampleRate),D=e(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});D.connect(A.destination),h=(async()=>{const M=await Promise.all([d.orientationX,d.orientationY,d.orientationZ,d.positionX,d.positionY,d.positionZ].map(async(N,q)=>{const V=t(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:q===0?1:0});return await a(A,N,V.offset),V}));for(let N=0;N<6;N+=1)M[N].connect(D,0,N),M[N].start(0);return l(A)})()}const w=await h,v=n(f,{...g,gain:1});await c(d,f,v);const b=[];for(let A=0;A<w.numberOfChannels;A+=1)b.push(w.getChannelData(A));let k=[b[0][0],b[1][0],b[2][0]],T=[b[3][0],b[4][0],b[5][0]],R=n(f,{...g,gain:1}),I=i(f,{...y,orientationX:k[0],orientationY:k[1],orientationZ:k[2],positionX:T[0],positionY:T[1],positionZ:T[2]});v.connect(R).connect(I.inputs[0]),I.connect(_);for(let A=128;A<w.length;A+=128){const D=[b[0][A],b[1][A],b[2][A]],M=[b[3][A],b[4][A],b[5][A]];if(D.some((N,q)=>N!==k[q])||M.some((N,q)=>N!==T[q])){k=D,T=M;const N=A/f.sampleRate;R.gain.setValueAtTime(0,N),R=n(f,{...g,gain:0}),I=i(f,{...y,orientationX:k[0],orientationY:k[1],orientationZ:k[2],positionX:T[0],positionY:T[1],positionZ:T[2]}),R.gain.setValueAtTime(1,N),v.connect(R).connect(I.inputs[0]),I.connect(_)}}return _}return x?(await s(f,d.orientationX,m.orientationX),await s(f,d.orientationY,m.orientationY),await s(f,d.orientationZ,m.orientationZ),await s(f,d.positionX,m.positionX),await s(f,d.positionY,m.positionY),await s(f,d.positionZ,m.positionZ)):(await a(f,d.orientationX,m.orientationX),await a(f,d.orientationY,m.orientationY),await a(f,d.orientationZ,m.orientationZ),await a(f,d.positionX,m.positionX),await a(f,d.positionY,m.positionY),await a(f,d.positionZ,m.positionZ)),pn(m)?await c(d,f,m.inputs[0]):await c(d,f,m),m};return{render(d,f){const _=u.get(f);return _!==void 0?Promise.resolve(_):p(d,f)}}},cf={disableNormalization:!1},lf=(s,e,t,n)=>class Cl{constructor(r,o){const a=e(r),c=n({...cf,...o}),l=s(a,c);return t.add(l),l}static[Symbol.hasInstance](r){return r!==null&&typeof r=="object"&&Object.getPrototypeOf(r)===Cl.prototype||t.has(r)}},uf=(s,e)=>(t,n,i)=>(s(n).replay(i),e(n,t,i)),hf=(s,e,t)=>async(n,i,r)=>{const o=s(n);await Promise.all(o.activeInputs.map((a,c)=>Array.from(a).map(async([l,u])=>{const p=await e(l).render(l,i),d=n.context.destination;!t(l)&&(n!==d||!t(n))&&p.connect(r,u,c)})).reduce((a,c)=>[...a,...c],[]))},df=(s,e,t)=>async(n,i,r)=>{const o=e(n);await Promise.all(Array.from(o.activeInputs).map(async([a,c])=>{const u=await s(a).render(a,i);t(a)||u.connect(r,c)}))},pf=(s,e,t,n)=>i=>s(Xn,()=>Xn(i))?Promise.resolve(s(n,n)).then(r=>{if(!r){const o=t(i,512,0,1);i.oncomplete=()=>{o.onaudioprocess=null,o.disconnect()},o.onaudioprocess=()=>i.currentTime,o.connect(i.destination)}return i.startRendering()}):new Promise(r=>{const o=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{o.disconnect(),r(a.renderedBuffer)},o.connect(i.destination),i.startRendering()}),ff=s=>(e,t)=>{s.set(e,t)},mf=s=>(e,t)=>s.set(e,t),gf=(s,e,t,n,i,r,o,a)=>(c,l)=>t(c).render(c,l).then(()=>Promise.all(Array.from(n(l)).map(u=>t(u).render(u,l)))).then(()=>i(l)).then(u=>(typeof u.copyFromChannel!="function"?(o(u),Fo(u)):e(r,()=>r(u))||a(u),s.add(u),u)),_f={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},vf=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={..._f,...c},h=t(l,u),p=r(l),d=p?n():null;super(a,!1,h,d),this._pan=e(this,p,h.pan)}get pan(){return this._pan}},yf=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=ft(l,c);if(!u){const h={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,pan:l.pan.value};l=e(c,h)}return r.set(c,l),u?await s(c,a.pan,l.pan):await n(c,a.pan,l.pan),pn(l)?await i(a,c,l.inputs[0]):await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},bf=s=>()=>{if(s===null)return!1;try{new s({length:1,sampleRate:44100})}catch{return!1}return!0},wf=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createBuffer(1,1,44100);if(t.copyToChannel===void 0)return!0;const n=new Float32Array(2);try{t.copyFromChannel(n,0,0)}catch{return!1}return!0},xf=s=>()=>{if(s===null)return!1;if(s.prototype!==void 0&&s.prototype.close!==void 0)return!0;const e=new s,t=e.close!==void 0;try{e.close()}catch{}return t},Cf=s=>()=>{if(s===null)return Promise.resolve(!1);const e=new s(1,1,44100);return new Promise(t=>{let n=!0;const i=o=>{n&&(n=!1,e.startRendering(),t(o instanceof TypeError))};let r;try{r=e.decodeAudioData(null,()=>{},i)}catch(o){i(o)}r!==void 0&&r.catch(i)})},Sf=s=>()=>{if(s===null)return!1;let e;try{e=new s({latencyHint:"balanced"})}catch{return!1}return e.close(),!0},Tf=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createGain(),n=t.connect(t)===t;return t.disconnect(t),n},kf=(s,e)=>async()=>{if(s===null)return!0;if(e===null)return!1;const t=new Blob(['let c,p;class A extends AudioWorkletProcessor{constructor(){super();this.port.onmessage=(e)=>{p=e.data;p.onmessage=()=>{p.postMessage(c);p.close()};this.port.postMessage(0)}}process(){c=1}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new MessageChannel,i=new e(1,128,44100),r=URL.createObjectURL(t);let o=!1;try{await i.audioWorklet.addModule(r);const a=new s(i,"a",{numberOfOutputs:0}),c=i.createOscillator();await new Promise(l=>{a.port.onmessage=()=>l(),a.port.postMessage(n.port2,[n.port2])}),a.port.onmessage=()=>o=!0,c.connect(a),c.start(0),await i.startRendering(),o=await new Promise(l=>{n.port1.onmessage=({data:u})=>l(u===1),n.port1.postMessage(0)})}catch{}finally{n.port1.close(),URL.revokeObjectURL(r)}return o},Af=(s,e)=>async()=>{if(s===null)return!0;if(e===null)return!1;const t=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new e(1,128,44100),i=URL.createObjectURL(t);let r=!1,o=!1;try{await n.audioWorklet.addModule(i);const a=new s(n,"a",{numberOfOutputs:0}),c=n.createOscillator();a.port.onmessage=()=>r=!0,a.onprocessorerror=()=>o=!0,c.connect(a),c.start(0),await n.startRendering(),await new Promise(l=>setTimeout(l))}catch{}finally{URL.revokeObjectURL(i)}return r&&!o},If=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createChannelMerger();if(t.channelCountMode==="max")return!0;try{t.channelCount=2}catch{return!0}return!1},Df=s=>()=>{if(s===null)return!1;const e=new s(1,1,44100);return e.createConstantSource===void 0?!0:e.createConstantSource().offset.maxValue!==Number.POSITIVE_INFINITY},Rf=s=>()=>{if(s===null)return!1;const e=new s(1,1,44100),t=e.createConvolver();t.buffer=e.createBuffer(1,1,e.sampleRate);try{t.buffer=e.createBuffer(1,1,e.sampleRate)}catch{return!1}return!0},Ef=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createConvolver();try{t.channelCount=1}catch{return!1}return!0},Mf=s=>()=>s!==null&&s.hasOwnProperty("isSecureContext"),Of=s=>()=>{if(s===null)return!1;const e=new s;try{return e.createMediaStreamSource(new MediaStream),!1}catch{return!0}finally{e.close()}},Nf=(s,e)=>()=>{if(e===null)return Promise.resolve(!1);const t=new e(1,1,44100),n=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{t.oncomplete=()=>{n.disconnect(),i(t.currentTime!==0)},t.startRendering()})},Ff=s=>()=>{if(s===null)return Promise.resolve(!1);const e=new s(1,1,44100);if(e.createStereoPanner===void 0||e.createConstantSource===void 0)return Promise.resolve(!0);const t=e.createConstantSource(),n=e.createStereoPanner();return t.channelCount=1,t.offset.value=1,n.channelCount=1,t.start(),t.connect(n).connect(e.destination),e.startRendering().then(i=>i.getChannelData(0)[0]!==1)},Vf=()=>new DOMException("","UnknownError"),Pf={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Wf=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...Pf,...l},p=t(u,h),f=r(u)?n():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,o(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}},Bf=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!ft(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=s(o,l)}return n.set(o,a),pn(a)?await t(r,o,a.inputs[0]):await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},$f=()=>typeof window>"u"?null:window,qf=(s,e)=>t=>{t.copyFromChannel=(n,i,r=0)=>{const o=s(r),a=s(i);if(a>=t.numberOfChannels)throw e();const c=t.length,l=t.getChannelData(a),u=n.length;for(let h=o<0?-o:0;h+o<c&&h<u;h+=1)n[h]=l[h+o]},t.copyToChannel=(n,i,r=0)=>{const o=s(r),a=s(i);if(a>=t.numberOfChannels)throw e();const c=t.length,l=t.getChannelData(a),u=n.length;for(let h=o<0?-o:0;h+o<c&&h<u;h+=1)l[h+o]=n[h]}},jf=s=>e=>{e.copyFromChannel=(t=>(n,i,r=0)=>{const o=s(r),a=s(i);if(o<e.length)return t.call(e,n,a,o)})(e.copyFromChannel),e.copyToChannel=(t=>(n,i,r=0)=>{const o=s(r),a=s(i);if(o<e.length)return t.call(e,n,a,o)})(e.copyToChannel)},Lf=s=>(e,t)=>{const n=t.createBuffer(1,1,44100);e.buffer===null&&(e.buffer=n),s(e,"buffer",i=>()=>{const r=i.call(e);return r===n?null:r},i=>r=>i.call(e,r===null?n:r))},zf=(s,e)=>(t,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw s()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw s()}});const i=t.createBufferSource();e(n,()=>{const a=n.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(n,0,c)},()=>i.disconnect(n))},Sl=(s,e,t)=>s.copyFromChannel===void 0?s.getChannelData(t)[0]:(s.copyFromChannel(e,t),e[0]),Tl=s=>{if(s===null)return!1;const e=s.length;return e%2!==0?s[Math.floor(e/2)]!==0:s[e/2-1]+s[e/2]!==0},ai=(s,e,t,n)=>{let i=s;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:r,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(s,e,{get:t(r),set:n(o)})},Zf=s=>({...s,outputChannelCount:s.outputChannelCount!==void 0?s.outputChannelCount:s.numberOfInputs===1&&s.numberOfOutputs===1?[s.channelCount]:Array.from({length:s.numberOfOutputs},()=>1)}),Gf=s=>({...s,channelCount:s.numberOfOutputs}),Xf=s=>{const{imag:e,real:t}=s;return e===void 0?t===void 0?{...s,imag:[0,0],real:[0,0]}:{...s,imag:Array.from(t,()=>0),real:t}:t===void 0?{...s,imag:e,real:Array.from(e,()=>0)}:{...s,imag:e,real:t}},kl=(s,e,t)=>{try{s.setValueAtTime(e,t)}catch(n){if(n.code!==9)throw n;kl(s,e,t+1e-7)}},Hf=s=>{const e=s.createBufferSource();e.start();try{e.start()}catch{return!0}return!1},Yf=s=>{const e=s.createBufferSource(),t=s.createBuffer(1,1,44100);e.buffer=t;try{e.start(0,1)}catch{return!1}return!0},Uf=s=>{const e=s.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0},$o=s=>{const e=s.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},Al=s=>{const e=s.createBuffer(1,1,44100),t=s.createBufferSource();t.buffer=e,t.start(),t.stop();try{return t.stop(),!0}catch{return!1}},qo=s=>{const e=s.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},Kf=s=>{const{port1:e,port2:t}=new MessageChannel;try{e.postMessage(s)}finally{e.close(),t.close()}},Qf=()=>{try{new DOMException}catch{return!1}return!0},Jf=()=>new Promise(s=>{const e=new ArrayBuffer(0),{port1:t,port2:n}=new MessageChannel;t.onmessage=({data:i})=>s(i!==null),n.postMessage(e,[e])}),em=s=>{s.start=(e=>(t=0,n=0,i)=>{const r=s.buffer,o=r===null?n:Math.min(r.duration,n);r!==null&&o>r.duration-.5/s.context.sampleRate?e.call(s,t,0,0):e.call(s,t,o,i)})(s.start)},Il=(s,e)=>{const t=e.createGain();s.connect(t);const n=(i=>()=>{i.call(s,t),s.removeEventListener("ended",n)})(s.disconnect);s.addEventListener("ended",n),fn(s,t),s.stop=(i=>{let r=!1;return(o=0)=>{if(r)try{i.call(s,o)}catch{t.gain.setValueAtTime(0,o)}else i.call(s,o),r=!0}})(s.stop)},mn=(s,e)=>t=>{const n={value:s};return Object.defineProperties(t,{currentTarget:n,target:n}),typeof e=="function"?e.call(s,t):e.handleEvent.call(s,t)},tm=ih(Bs),sm=uh(Bs),nm=xd(rr),Dl=new WeakMap,im=$d(Dl),jt=Qh(new Map,new WeakMap),Gt=$f(),Rl=_p(jt,ss),jo=Bd(_t),ct=hf(_t,jo,Ps),rm=mh(Rl,Re,ct),De=Ld(ir),tt=zp(Gt),Te=op(tt),El=new WeakMap,Ml=Md(mn),Cs=wp(Gt),Lo=sp(Cs),zo=np(Gt),Ol=ip(Gt),an=Cp(Gt),ze=$h(rh(ol),lh(tm,sm,Zi,nm,Gi,_t,im,ti,Re,Bs,ds,Ps,Wi),jt,Kd(fo,Gi,_t,Re,Gn,ds),ss,or,bt,vd(Zi,fo,_t,Re,Gn,De,ds,Te),Td(El,_t,Zt),Ml,De,Lo,zo,Ol,Te,an),om=fh(ze,rm,ss,Rl,De,Te),Zo=new WeakSet,rc=vp(Gt),Nl=hd(new Uint32Array(1)),Go=qf(Nl,ss),Xo=jf(Nl),Fl=_h(Zo,jt,bt,rc,tt,bf(rc),Go,Xo),ar=hh(kt),Vl=df(jo,ni,Ps),ns=rd(Vl),gn=bp(ar,jt,Hf,Yf,Uf,$o,Al,qo,em,Lf(ai),Il),is=uf(qd(ni),Vl),am=bh(ns,gn,Re,is,ct),Ht=qh(oh(al),El,No,jh,Qu,Ju,eh,th,sh,uo,il,Cs,kl),cm=yh(ze,am,Ht,st,gn,De,Te,mn),lm=Dh(ze,Rh,ss,st,xp(kt,ai),De,Te,ct),um=Kh(ns,wl,Re,is,ct),$s=mf(Dl),hm=Uh(ze,Ht,um,or,wl,De,Te,$s),Ds=mp(Bs,zo),dm=zf(st,Ds),Rs=Rp(Cs,dm),pm=td(Rs,Re,ct),fm=ed(ze,pm,Rs,De,Te),mm=id(ri,Re,ct),gm=nd(ze,mm,ri,De,Te,Gf),_m=Op(ar,gn,kt,Ds),_n=Mp(ar,jt,_m,$o,qo),vm=ud(ns,_n,Re,is,ct),ym=ld(ze,Ht,vm,_n,De,Te,mn),Pl=Np(bt,ai),bm=fd(Pl,Re,ct),wm=pd(ze,bm,Pl,De,Te,$s),xm=wd(ns,xl,Re,is,ct),Cm=bd(ze,Ht,xm,xl,De,Te,$s),Wl=Fp(bt),Sm=Dd(ns,Wl,Re,is,ct),Tm=Id(ze,Ht,Sm,Wl,bt,De,Te,$s),km=Pd(ns,kt,Re,is,ct),Am=Vd(ze,Ht,km,kt,De,Te),Im=Bp(or,st,oi,bt),cr=pf(jt,kt,oi,Nf(kt,tt)),Dm=Ud(gn,Re,tt,ct,cr),Rm=Vp(Im),Em=Hd(ze,Rm,Dm,De,Te,$s),Mm=Eh(Ht,Rs,_n,oi,bt,Sl,Te,ai),Bl=new WeakMap,Om=fp(lm,Mm,Ml,Te,Bl,mn),$l=Zp(ar,jt,$o,Al,qo,Il),Nm=nf(ns,$l,Re,is,ct),Fm=sf(ze,Ht,$l,Nm,De,Te,mn),ql=ad(gn),Vm=Qp(ql,st,kt,Tl,Ds),lr=Kp(ql,st,Vm,Tl,Ds,Cs,ai),Pm=Xp(Zi,st,Rs,kt,oi,lr,bt,Gi,Sl,Ds),jl=Gp(Pm),Wm=af(ns,Rs,_n,kt,jl,Re,tt,is,ct,cr),Bm=of(ze,Ht,jl,Wm,De,Te,$s),$m=Hp(ss),qm=lf($m,De,new WeakSet,Xf),jm=Up(Rs,ri,kt,lr,bt,Ds),Ll=Yp(jm,bt),Lm=yf(ns,Ll,Re,is,ct),zm=vf(ze,Ht,Ll,Lm,De,Te),Zm=Bf(lr,Re,ct),Gm=Wf(ze,st,lr,Zm,De,Te,$s),zl=ap(Gt),Ho=Od(Gt),Zl=new WeakMap,Xm=zd(Zl,tt),Hm=zl?ch(jt,bt,Ed(Gt),Ho,Nd(nh),De,Xm,Te,an,new WeakMap,new WeakMap,Af(an,tt),Gt):void 0,Ym=rp(Lo,Te),Um=_d(Zo,jt,gd,Rd,new WeakSet,De,Ym,Li,Xn,Go,Xo),Gl=Hh(Hm,om,Fl,cm,hm,fm,gm,ym,wm,Um,Cm,Tm,Am,Em,Om,Fm,Bm,qm,zm,Gm),Km=lp(ze,$p,De,Te),Qm=hp(ze,qp,De,Te),Jm=dp(ze,jp,De,Te),eg=Lp(st,Te),tg=pp(ze,eg,De),sg=Ih(Gl,st,bt,Vf,Km,Qm,Jm,tg,Cs),Yo=Zd(Bl),ng=dh(Yo),Xl=od(ss),ig=Cd(Yo),Hl=kd(ss),Yl=new WeakMap,rg=Wd(Yl,Zt),og=Dp(Xl,ss,st,Rs,ri,_n,kt,oi,bt,Hl,Ho,rg,Ds),ag=Tp(st,og,kt,bt,Ds),cg=Xh(ns,Xl,gn,Rs,ri,_n,kt,ig,Hl,Ho,Re,an,tt,is,ct,cr),lg=jd(Zl),ug=ff(Yl),oc=zl?zh(ng,ze,Ht,cg,ag,_t,lg,De,Te,an,Zf,ug,Kf,mn):void 0,hg=md(bt,tt),dg=gf(Zo,jt,jo,Yo,cr,Li,Go,Xo),pg=ef(Gl,jt,st,hg,dg),fg=Qd(ir,Lo),mg=Jd(Oo,zo),gg=ep(No,Ol),_g=tp(ir,Te),vg=()=>cp(jt,wf(tt),xf(Cs),Cf(tt),Sf(Cs),Tf(tt),kf(an,tt),If(tt),Df(tt),Rf(tt),Ef(tt),Qf,Mf(Gt),Of(Cs),Ff(tt),Jf);function Tt(s){return s===void 0}function de(s){return s!==void 0}function Ul(s){return typeof s=="function"}function Ot(s){return typeof s=="number"}function ps(s){return Object.prototype.toString.call(s)==="[object Object]"&&s.constructor===Object}function Uo(s){return typeof s=="boolean"}function ot(s){return Array.isArray(s)}function Xt(s){return typeof s=="string"}function Ln(s){return Xt(s)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(s)}function K(s,e){if(!s)throw new Error(e)}function Ye(s,e,t=1/0){if(!(e<=s&&s<=t))throw new RangeError(`Value must be within [${e}, ${t}], got: ${s}`)}function Ko(s){!s.isOffline&&s.state!=="running"&&vn('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Kl=!1,ac=!1;function yo(s){Kl=s}function Ql(s){Tt(s)&&Kl&&!ac&&(ac=!0,vn("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}let Qo=console;function yg(s){Qo=s}function Jl(...s){Qo.log(...s)}function vn(...s){Qo.warn(...s)}const bg=Object.freeze(Object.defineProperty({__proto__:null,assert:K,assertContextRunning:Ko,assertRange:Ye,assertUsedScheduleTime:Ql,enterScheduledCallback:yo,log:Jl,setLogger:yg,warn:vn},Symbol.toStringTag,{value:"Module"}));function wg(s){return new sg(s)}function xg(s,e,t){return new pg(s,e,t)}const gt=typeof self=="object"?self:null,Cg=gt&&(gt.hasOwnProperty("AudioContext")||gt.hasOwnProperty("webkitAudioContext"));function Sg(s,e,t){return K(de(oc),"AudioWorkletNode only works in a secure context (https or localhost)"),new(s instanceof gt?.BaseAudioContext?gt?.AudioWorkletNode:oc)(s,e,t)}function Yt(s,e,t,n){var i=arguments.length,r=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(s,e,t,n);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(r=(i<3?o(r):i>3?o(e,t,r):o(e,t))||r);return i>3&&r&&Object.defineProperty(e,t,r),r}function ke(s,e,t,n){function i(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(u){try{l(n.next(u))}catch(h){o(h)}}function c(u){try{l(n.throw(u))}catch(h){o(h)}}function l(u){u.done?r(u.value):i(u.value).then(a,c)}l((n=n.apply(s,e||[])).next())})}class Tg{constructor(e,t,n,i){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=n,this._createClock()}_createWorker(){const e=new Blob([`
3
+ })(${k?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${k?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${k?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${T}',class extends AudioWorkletProcessor{process(){return !1}})`,q=new Blob([N],{type:"application/javascript; charset=utf-8"}),V=URL.createObjectURL(q);return x.audioWorklet.addModule(V,m).then(()=>{if(a(x))return x;const j=o(x);return j.audioWorklet.addModule(V,m).then(()=>j)}).then(j=>{if(c===null)throw new SyntaxError;try{new c(j,`__sac${T}`)}catch{throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(V))});return y===void 0?l.set(f,new Map([[_,w]])):y.set(_,w),w.then(()=>{const v=u.get(f);v===void 0?u.set(f,new Set([_])):v.add(_)}).finally(()=>{const v=l.get(f);v!==void 0&&v.delete(_)}),w}},Zt=(s,e)=>{const t=s.get(e);if(t===void 0)throw new Error("A value with the given key could not be found.");return t},rr=(s,e)=>{const t=Array.from(s).filter(e);if(t.length>1)throw Error("More than one element was found.");if(t.length===0)throw Error("No element was found.");const[n]=t;return s.delete(n),n},ul=(s,e,t,n)=>{const i=Zt(s,e),r=rr(i,o=>o[0]===t&&o[1]===n);return i.size===0&&s.delete(e),r},ti=s=>Zt(cl,s),an=s=>{if(on.has(s))throw new Error("The AudioNode is already stored.");on.add(s),ti(s).forEach(e=>e(!0))},hl=s=>"port"in s,si=s=>{if(!on.has(s))throw new Error("The AudioNode is not stored.");on.delete(s),ti(s).forEach(e=>e(!1))},_o=(s,e)=>{!hl(s)&&e.every(t=>t.size===0)&&si(s)},lh=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>{const d=new WeakMap;return(f,_,m,g,y)=>{const{activeInputs:x,passiveInputs:w}=r(_),{outputs:v}=r(f),b=a(f),k=T=>{const R=c(_),I=c(f);if(T){const A=ul(w,f,m,g);s(x,f,A,!1),!y&&!h(f)&&t(I,R,m,g),p(_)&&an(_)}else{const A=n(x,f,m,g);e(w,g,A,!1),!y&&!h(f)&&i(I,R,m,g);const D=o(_);if(D===0)u(_)&&_o(_,x);else{const O=d.get(_);O!==void 0&&clearTimeout(O),d.set(_,setTimeout(()=>{u(_)&&_o(_,x)},D*1e3))}}};return l(v,[_,m,g],T=>T[0]===_&&T[1]===m&&T[2]===g,!0)?(b.add(k),u(f)?s(x,f,[m,g,k],!0):e(w,g,[f,m,k],!0),!0):!1}},uh=s=>(e,t,[n,i,r],o)=>{const a=e.get(n);a===void 0?e.set(n,new Set([[i,t,r]])):s(a,[i,t,r],c=>c[0]===i&&c[1]===t,o)},hh=s=>(e,t)=>{const n=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});t.connect(n).connect(e.destination);const i=()=>{t.removeEventListener("ended",i),t.disconnect(n),n.disconnect()};t.addEventListener("ended",i)},dh=s=>(e,t)=>{s(e).add(t)},ph={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},fh=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...ph,...c},h=n(l,u),p=r(l)?e():null;super(a,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){const c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,t()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){const c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,t()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}},pt=(s,e)=>s.context===e,mh=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!pt(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},Li=s=>{try{s.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},ts=()=>new DOMException("","IndexSizeError"),Fo=s=>{s.getChannelData=(e=>t=>{try{return e.call(s,t)}catch(n){throw n.code===12?ts():n}})(s.getChannelData)},gh={numberOfChannels:1},_h=(s,e,t,n,i,r,o,a)=>{let c=null;return class dl{constructor(u){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:h,numberOfChannels:p,sampleRate:d}={...gh,...u};c===null&&(c=new i(1,1,44100));const f=n!==null&&e(r,r)?new n({length:h,numberOfChannels:p,sampleRate:d}):c.createBuffer(p,h,d);if(f.numberOfChannels===0)throw t();return typeof f.copyFromChannel!="function"?(o(f),Fo(f)):e(Li,()=>Li(f))||a(f),s.add(f),f}static[Symbol.hasInstance](u){return u!==null&&typeof u=="object"&&Object.getPrototypeOf(u)===dl.prototype||s.has(u)}}},St=-34028234663852886e22,mt=-St,hs=s=>on.has(s),vh={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},yh=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...vh,...u},d=i(h,p),f=o(h),_=f?e():null;super(l,!1,d,_),this._audioBufferSourceNodeRenderer=_,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=d,this._onended=null,this._playbackRate=t(this,f,d.playbackRate,mt,St)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(l){if(this._nativeAudioBufferSourceNode.buffer=l,l!==null){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(l){this._nativeAudioBufferSourceNode.loop=l}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(l){this._nativeAudioBufferSourceNode.loopEnd=l}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(l){this._nativeAudioBufferSourceNode.loopStart=l}get onended(){return this._onended}set onended(l){const u=typeof l=="function"?a(this,l):null;this._nativeAudioBufferSourceNode.onended=u;const h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===u?l:h}get playbackRate(){return this._playbackRate}start(l=0,u=0,h){if(this._nativeAudioBufferSourceNode.start(l,u,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[l,u]:[l,u,h]),this.context.state!=="closed"){an(this);const p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),hs(this)&&si(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(l=0){this._nativeAudioBufferSourceNode.stop(l),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=l)}},bh=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;const c=async(l,u)=>{let h=t(l);const p=pt(h,u);if(!p){const d={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=e(u,d),o!==null&&h.start(...o),a!==null&&h.stop(a)}return r.set(u,h),p?await s(u,l.playbackRate,h.playbackRate):await n(u,l.playbackRate,h.playbackRate),await i(l,u,h),h};return{set start(l){o=l},set stop(l){a=l},render(l,u){const h=r.get(u);return h!==void 0?Promise.resolve(h):c(l,u)}}},wh=s=>"playbackRate"in s,xh=s=>"frequency"in s&&"gain"in s,Ch=s=>"offset"in s,Sh=s=>!("frequency"in s)&&"gain"in s,Th=s=>"detune"in s&&"frequency"in s&&!("gain"in s),kh=s=>"pan"in s,_t=s=>Zt(ol,s),ni=s=>Zt(al,s),vo=(s,e)=>{const{activeInputs:t}=_t(s);t.forEach(i=>i.forEach(([r])=>{e.includes(s)||vo(r,[...e,s])}));const n=wh(s)?[s.playbackRate]:hl(s)?Array.from(s.parameters.values()):xh(s)?[s.Q,s.detune,s.frequency,s.gain]:Ch(s)?[s.offset]:Sh(s)?[s.gain]:Th(s)?[s.detune,s.frequency]:kh(s)?[s.pan]:[];for(const i of n){const r=ni(i);r!==void 0&&r.activeInputs.forEach(([o])=>vo(o,e))}hs(s)&&si(s)},pl=s=>{vo(s.destination,[])},Ah=s=>s===void 0||typeof s=="number"||typeof s=="string"&&(s==="balanced"||s==="interactive"||s==="playback"),Ih=(s,e,t,n,i,r,o,a,c)=>class extends s{constructor(u={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(u)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?t():f}if(h===null)throw n();if(!Ah(u.latencyHint))throw new TypeError(`The provided value '${u.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(u.sampleRate!==void 0&&h.sampleRate!==u.sampleRate)throw t();super(h,2);const{latencyHint:p}=u,{sampleRate:d}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/d:p==="interactive"||p===void 0?256/d:p==="playback"?1024/d:Math.max(2,Math.min(128,Math.round(p*d/128)))*128/d,this._nativeAudioContext=h,c.name==="webkitAudioContext"?(this._nativeGainNode=h.createGain(),this._nativeOscillatorNode=h.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(h.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,h.state==="running"){this._state="suspended";const f=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",f)};h.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw e()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),pl(this)}))}createMediaElementSource(u){return new i(this,{mediaElement:u})}createMediaStreamDestination(){return new r(this)}createMediaStreamSource(u){return new o(this,{mediaStream:u})}createMediaStreamTrackSource(u){return new a(this,{mediaStreamTrack:u})}resume(){return this._state==="suspended"?new Promise((u,h)=>{const p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?u():this.resume().then(u,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(u=>{throw u===void 0||u.code===15?e():u})}suspend(){return this._nativeAudioContext.suspend().catch(u=>{throw u===void 0?e():u})}},Dh=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p=o(h),d=i(h,u,p),f=p?e(a):null;super(l,!1,d,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=d}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(l){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(l>this._nativeAudioDestinationNode.maxChannelCount)throw t();this._nativeAudioDestinationNode.channelCount=l}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(l){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=l}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},Rh=s=>{const e=new WeakMap,t=async(n,i)=>{const r=i.destination;return e.set(i,r),await s(n,i,r),r};return{render(n,i){const r=e.get(i);return r!==void 0?Promise.resolve(r):t(n,i)}}},Eh=(s,e,t,n,i,r,o,a)=>(c,l)=>{const u=l.listener,h=()=>{const v=new Float32Array(1),b=e(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),k=o(l);let T=!1,R=[0,0,-1,0,1,0],I=[0,0,0];const A=()=>{if(T)return;T=!0;const q=n(l,256,9,0);q.onaudioprocess=({inputBuffer:V})=>{const j=[r(V,v,0),r(V,v,1),r(V,v,2),r(V,v,3),r(V,v,4),r(V,v,5)];j.some((B,G)=>B!==R[G])&&(u.setOrientation(...j),R=j);const X=[r(V,v,6),r(V,v,7),r(V,v,8)];X.some((B,G)=>B!==I[G])&&(u.setPosition(...X),I=X)},b.connect(q)},D=q=>V=>{V!==R[q]&&(R[q]=V,u.setOrientation(...R))},O=q=>V=>{V!==I[q]&&(I[q]=V,u.setPosition(...I))},N=(q,V,j)=>{const X=t(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:V});X.connect(b,0,q),X.start(),Object.defineProperty(X.offset,"defaultValue",{get(){return V}});const B=s({context:c},k,X.offset,mt,St);return a(B,"value",G=>()=>G.call(B),G=>H=>{try{G.call(B,H)}catch(te){if(te.code!==9)throw te}A(),k&&j(H)}),B.cancelAndHoldAtTime=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.cancelAndHoldAtTime),B.cancelScheduledValues=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.cancelScheduledValues),B.exponentialRampToValueAtTime=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.exponentialRampToValueAtTime),B.linearRampToValueAtTime=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.linearRampToValueAtTime),B.setTargetAtTime=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.setTargetAtTime),B.setValueAtTime=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.setValueAtTime),B.setValueCurveAtTime=(G=>k?()=>{throw i()}:(...H)=>{const te=G.apply(B,H);return A(),te})(B.setValueCurveAtTime),B};return{forwardX:N(0,0,D(0)),forwardY:N(1,0,D(1)),forwardZ:N(2,-1,D(2)),positionX:N(6,0,O(0)),positionY:N(7,0,O(1)),positionZ:N(8,0,O(2)),upX:N(3,0,D(3)),upY:N(4,1,D(4)),upZ:N(5,0,D(5))}},{forwardX:p,forwardY:d,forwardZ:f,positionX:_,positionY:m,positionZ:g,upX:y,upY:x,upZ:w}=u.forwardX===void 0?h():u;return{get forwardX(){return p},get forwardY(){return d},get forwardZ(){return f},get positionX(){return _},get positionY(){return m},get positionZ(){return g},get upX(){return y},get upY(){return x},get upZ(){return w}}},zi=s=>"context"in s,ii=s=>zi(s[0]),$s=(s,e,t,n)=>{for(const i of s)if(t(i)){if(n)return!1;throw Error("The set contains at least one similar element.")}return s.add(e),!0},Ja=(s,e,[t,n],i)=>{$s(s,[e,t,n],r=>r[0]===e&&r[1]===t,i)},ec=(s,[e,t,n],i)=>{const r=s.get(e);r===void 0?s.set(e,new Set([[t,n]])):$s(r,[t,n],o=>o[0]===t,i)},fn=s=>"inputs"in s,Zi=(s,e,t,n)=>{if(fn(e)){const i=e.inputs[n];return s.connect(i,t,0),[i,t,0]}return s.connect(e,t,n),[e,t,n]},fl=(s,e,t)=>{for(const n of s)if(n[0]===e&&n[1]===t)return s.delete(n),n;return null},Mh=(s,e,t)=>rr(s,n=>n[0]===e&&n[1]===t),ml=(s,e)=>{if(!ti(s).delete(e))throw new Error("Missing the expected event listener.")},gl=(s,e,t)=>{const n=Zt(s,e),i=rr(n,r=>r[0]===t);return n.size===0&&s.delete(e),i},Gi=(s,e,t,n)=>{fn(e)?s.disconnect(e.inputs[n],t,0):s.disconnect(e,t,n)},Ee=s=>Zt(Oo,s),Gn=s=>Zt(No,s),Ws=s=>fo.has(s),Wi=s=>!on.has(s),tc=(s,e)=>new Promise(t=>{if(e!==null)t(!0);else{const n=s.createScriptProcessor(256,1,1),i=s.createGain(),r=s.createBuffer(1,2,44100),o=r.getChannelData(0);o[0]=1,o[1]=1;const a=s.createBufferSource();a.buffer=r,a.loop=!0,a.connect(n).connect(s.destination),a.connect(i),a.disconnect(i),n.onaudioprocess=c=>{const l=c.inputBuffer.getChannelData(0);Array.prototype.some.call(l,u=>u===1)?t(!0):t(!1),a.stop(),n.onaudioprocess=null,a.disconnect(n),n.disconnect(s.destination)},a.start()}}),eo=(s,e)=>{const t=new Map;for(const n of s)for(const i of n){const r=t.get(i);t.set(i,r===void 0?1:r+1)}t.forEach((n,i)=>e(i,n))},Xi=s=>"context"in s,Oh=s=>{const e=new Map;s.connect=(t=>(n,i=0,r=0)=>{const o=Xi(n)?t(n,i,r):t(n,i),a=e.get(n);return a===void 0?e.set(n,[{input:r,output:i}]):a.every(c=>c.input!==r||c.output!==i)&&a.push({input:r,output:i}),o})(s.connect.bind(s)),s.disconnect=(t=>(n,i,r)=>{if(t.apply(s),n===void 0)e.clear();else if(typeof n=="number")for(const[o,a]of e){const c=a.filter(l=>l.output!==n);c.length===0?e.delete(o):e.set(o,c)}else if(e.has(n))if(i===void 0)e.delete(n);else{const o=e.get(n);if(o!==void 0){const a=o.filter(c=>c.output!==i&&(c.input!==r||r===void 0));a.length===0?e.delete(n):e.set(n,a)}}for(const[o,a]of e)a.forEach(c=>{Xi(o)?s.connect(o,c.output,c.input):s.connect(o,c.output)})})(s.disconnect)},Nh=(s,e,t,n)=>{const{activeInputs:i,passiveInputs:r}=ni(e),{outputs:o}=_t(s),a=ti(s),c=l=>{const u=Ee(s),h=Gn(e);if(l){const p=gl(r,s,t);Ja(i,s,p,!1),!n&&!Ws(s)&&u.connect(h,t)}else{const p=Mh(i,s,t);ec(r,p,!1),!n&&!Ws(s)&&u.disconnect(h,t)}};return $s(o,[e,t],l=>l[0]===e&&l[1]===t,!0)?(a.add(c),hs(s)?Ja(i,s,[t,c],!0):ec(r,[s,t,c],!0),!0):!1},Fh=(s,e,t,n)=>{const{activeInputs:i,passiveInputs:r}=_t(e),o=fl(i[n],s,t);return o===null?[ul(r,s,t,n)[2],!1]:[o[2],!0]},Vh=(s,e,t)=>{const{activeInputs:n,passiveInputs:i}=ni(e),r=fl(n,s,t);return r===null?[gl(i,s,t)[1],!1]:[r[2],!0]},Vo=(s,e,t,n,i)=>{const[r,o]=Fh(s,t,n,i);if(r!==null&&(ml(s,r),o&&!e&&!Ws(s)&&Gi(Ee(s),Ee(t),n,i)),hs(t)){const{activeInputs:a}=_t(t);_o(t,a)}},Po=(s,e,t,n)=>{const[i,r]=Vh(s,t,n);i!==null&&(ml(s,i),r&&!e&&!Ws(s)&&Ee(s).disconnect(Gn(t),n))},Ph=(s,e)=>{const t=_t(s),n=[];for(const i of t.outputs)ii(i)?Vo(s,e,...i):Po(s,e,...i),n.push(i[0]);return t.outputs.clear(),n},Wh=(s,e,t)=>{const n=_t(s),i=[];for(const r of n.outputs)r[1]===t&&(ii(r)?Vo(s,e,...r):Po(s,e,...r),i.push(r[0]),n.outputs.delete(r));return i},Bh=(s,e,t,n,i)=>{const r=_t(s);return Array.from(r.outputs).filter(o=>o[0]===t&&(n===void 0||o[1]===n)&&(i===void 0||o[2]===i)).map(o=>(ii(o)?Vo(s,e,...o):Po(s,e,...o),r.outputs.delete(o),o[0]))},$h=(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_)=>class extends l{constructor(g,y,x,w){super(x),this._context=g,this._nativeAudioNode=x;const v=u(g);h(v)&&t(tc,()=>tc(v,_))!==!0&&Oh(x),Oo.set(this,x),cl.set(this,new Set),g.state!=="closed"&&y&&an(this),s(this,w,x)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(g){this._nativeAudioNode.channelCount=g}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(g){this._nativeAudioNode.channelCountMode=g}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(g){this._nativeAudioNode.channelInterpretation=g}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(g,y=0,x=0){if(y<0||y>=this._nativeAudioNode.numberOfOutputs)throw i();const w=u(this._context),v=f(w);if(p(g)||d(g))throw r();if(zi(g)){const T=Ee(g);try{const I=Zi(this._nativeAudioNode,T,y,x),A=Wi(this);(v||A)&&this._nativeAudioNode.disconnect(...I),this.context.state!=="closed"&&!A&&Wi(g)&&an(g)}catch(I){throw I.code===12?r():I}if(e(this,g,y,x,v)){const I=c([this],g);eo(I,n(v))}return g}const b=Gn(g);if(b.name==="playbackRate"&&b.maxValue===1024)throw o();try{this._nativeAudioNode.connect(b,y),(v||Wi(this))&&this._nativeAudioNode.disconnect(b,y)}catch(T){throw T.code===12?r():T}if(Nh(this,g,y,v)){const T=c([this],g);eo(T,n(v))}}disconnect(g,y,x){let w;const v=u(this._context),b=f(v);if(g===void 0)w=Ph(this,b);else if(typeof g=="number"){if(g<0||g>=this.numberOfOutputs)throw i();w=Wh(this,b,g)}else{if(y!==void 0&&(y<0||y>=this.numberOfOutputs)||zi(g)&&x!==void 0&&(x<0||x>=g.numberOfInputs))throw i();if(w=Bh(this,b,g,y,x),w.length===0)throw r()}for(const k of w){const T=c([this],k);eo(T,a)}}},qh=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>(d,f,_,m=null,g=null)=>{const y=_.value,x=new Ku(y),w=f?n(x):null,v={get defaultValue(){return y},get maxValue(){return m===null?_.maxValue:m},get minValue(){return g===null?_.minValue:g},get value(){return _.value},set value(b){_.value=b,v.setValueAtTime(b,d.context.currentTime)},cancelAndHoldAtTime(b){if(typeof _.cancelAndHoldAtTime=="function")w===null&&x.flush(d.context.currentTime),x.add(i(b)),_.cancelAndHoldAtTime(b);else{const k=Array.from(x).pop();w===null&&x.flush(d.context.currentTime),x.add(i(b));const T=Array.from(x).pop();_.cancelScheduledValues(b),k!==T&&T!==void 0&&(T.type==="exponentialRampToValue"?_.exponentialRampToValueAtTime(T.value,T.endTime):T.type==="linearRampToValue"?_.linearRampToValueAtTime(T.value,T.endTime):T.type==="setValue"?_.setValueAtTime(T.value,T.startTime):T.type==="setValueCurve"&&_.setValueCurveAtTime(T.values,T.startTime,T.duration))}return v},cancelScheduledValues(b){return w===null&&x.flush(d.context.currentTime),x.add(r(b)),_.cancelScheduledValues(b),v},exponentialRampToValueAtTime(b,k){if(b===0)throw new RangeError;if(!Number.isFinite(k)||k<0)throw new RangeError;const T=d.context.currentTime;return w===null&&x.flush(T),Array.from(x).length===0&&(x.add(l(y,T)),_.setValueAtTime(y,T)),x.add(o(b,k)),_.exponentialRampToValueAtTime(b,k),v},linearRampToValueAtTime(b,k){const T=d.context.currentTime;return w===null&&x.flush(T),Array.from(x).length===0&&(x.add(l(y,T)),_.setValueAtTime(y,T)),x.add(a(b,k)),_.linearRampToValueAtTime(b,k),v},setTargetAtTime(b,k,T){return w===null&&x.flush(d.context.currentTime),x.add(c(b,k,T)),_.setTargetAtTime(b,k,T),v},setValueAtTime(b,k){return w===null&&x.flush(d.context.currentTime),x.add(l(b,k)),_.setValueAtTime(b,k),v},setValueCurveAtTime(b,k,T){const R=b instanceof Float32Array?b:new Float32Array(b);if(h!==null&&h.name==="webkitAudioContext"){const I=k+T,A=d.context.sampleRate,D=Math.ceil(k*A),O=Math.floor(I*A),N=O-D,q=new Float32Array(N);for(let j=0;j<N;j+=1){const X=(R.length-1)/T*((D+j)/A-k),B=Math.floor(X),G=Math.ceil(X);q[j]=B===G?R[B]:(1-(X-B))*R[B]+(1-(G-X))*R[G]}w===null&&x.flush(d.context.currentTime),x.add(u(q,k,T)),_.setValueCurveAtTime(q,k,T);const V=O/A;V<I&&p(v,q[q.length-1],V),p(v,R[R.length-1],I)}else w===null&&x.flush(d.context.currentTime),x.add(u(R,k,T)),_.setValueCurveAtTime(R,k,T);return v}};return t.set(v,_),e.set(v,d),s(v,w),v},jh=s=>({replay(e){for(const t of s)if(t.type==="exponentialRampToValue"){const{endTime:n,value:i}=t;e.exponentialRampToValueAtTime(i,n)}else if(t.type==="linearRampToValue"){const{endTime:n,value:i}=t;e.linearRampToValueAtTime(i,n)}else if(t.type==="setTarget"){const{startTime:n,target:i,timeConstant:r}=t;e.setTargetAtTime(i,n,r)}else if(t.type==="setValue"){const{startTime:n,value:i}=t;e.setValueAtTime(i,n)}else if(t.type==="setValueCurve"){const{duration:n,startTime:i,values:r}=t;e.setValueCurveAtTime(r,i,n)}else throw new Error("Can't apply an unknown automation.")}});class _l{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((n,i)=>e.call(t,n,i,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}}const Lh={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},zh=(s,e,t,n,i,r,o,a,c,l,u,h,p,d)=>class extends e{constructor(_,m,g){var y;const x=a(_),w=c(x),v=u({...Lh,...g});p(v);const b=mo.get(x),k=b?.get(m),T=w||x.state!=="closed"?x:(y=o(x))!==null&&y!==void 0?y:x,R=i(T,w?null:_.baseLatency,l,m,k,v),I=w?n(m,v,k):null;super(_,!0,R,I);const A=[];R.parameters.forEach((O,N)=>{const q=t(this,w,O);A.push([N,q])}),this._nativeAudioWorkletNode=R,this._onprocessorerror=null,this._parameters=new _l(A),w&&s(x,this);const{activeInputs:D}=r(this);h(R,D)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(_){const m=typeof _=="function"?d(this,_):null;this._nativeAudioWorkletNode.onprocessorerror=m;const g=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=g!==null&&g===m?_:g}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Hi(s,e,t,n,i){if(typeof s.copyFromChannel=="function")e[t].byteLength===0&&(e[t]=new Float32Array(128)),s.copyFromChannel(e[t],n,i);else{const r=s.getChannelData(n);if(e[t].byteLength===0)e[t]=r.slice(i,i+128);else{const o=new Float32Array(r.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[t].set(o)}}}const vl=(s,e,t,n,i)=>{typeof s.copyToChannel=="function"?e[t].byteLength!==0&&s.copyToChannel(e[t],n,i):e[t].byteLength!==0&&s.getChannelData(n).set(e[t],i)},Yi=(s,e)=>{const t=[];for(let n=0;n<s;n+=1){const i=[],r=typeof e=="number"?e:e[n];for(let o=0;o<r;o+=1)i.push(new Float32Array(128));t.push(i)}return t},Zh=(s,e)=>{const t=Zt(go,s),n=Ee(e);return Zt(t,n)},Gh=async(s,e,t,n,i,r,o)=>{const a=e===null?Math.ceil(s.context.length/128)*128:e.length,c=n.channelCount*n.numberOfInputs,l=i.reduce((m,g)=>m+g,0),u=l===0?null:t.createBuffer(l,a,t.sampleRate);if(r===void 0)throw new Error("Missing the processor constructor.");const h=_t(s),p=await Zh(t,s),d=Yi(n.numberOfInputs,n.channelCount),f=Yi(n.numberOfOutputs,i),_=Array.from(s.parameters.keys()).reduce((m,g)=>({...m,[g]:new Float32Array(128)}),{});for(let m=0;m<a;m+=128){if(n.numberOfInputs>0&&e!==null)for(let g=0;g<n.numberOfInputs;g+=1)for(let y=0;y<n.channelCount;y+=1)Hi(e,d[g],y,y,m);r.parameterDescriptors!==void 0&&e!==null&&r.parameterDescriptors.forEach(({name:g},y)=>{Hi(e,_,g,c+y,m)});for(let g=0;g<n.numberOfInputs;g+=1)for(let y=0;y<i[g];y+=1)f[g][y].byteLength===0&&(f[g][y]=new Float32Array(128));try{const g=d.map((x,w)=>h.activeInputs[w].size===0?[]:x),y=o(m/t.sampleRate,t.sampleRate,()=>p.process(g,f,_));if(u!==null)for(let x=0,w=0;x<n.numberOfOutputs;x+=1){for(let v=0;v<i[x];v+=1)vl(u,f[x],v,w+v,m);w+=i[x]}if(!y)break}catch(g){s.dispatchEvent(new ErrorEvent("processorerror",{colno:g.colno,filename:g.filename,lineno:g.lineno,message:g.message}));break}}return u},Xh=(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_)=>(m,g,y)=>{const x=new WeakMap;let w=null;const v=async(b,k)=>{let T=u(b),R=null;const I=pt(T,k),A=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(h===null){const D=A.reduce((V,j)=>V+j,0),O=i(k,{channelCount:Math.max(1,D),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,D)}),N=[];for(let V=0;V<b.numberOfOutputs;V+=1)N.push(n(k,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:A[V]}));const q=o(k,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});q.connect=e.bind(null,N),q.disconnect=c.bind(null,N),R=[O,N,q]}else I||(T=new h(k,m));if(x.set(k,R===null?T:R[2]),R!==null){if(w===null){if(y===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");const j=b.channelCount*b.numberOfInputs,X=y.parameterDescriptors===void 0?0:y.parameterDescriptors.length,B=j+X;w=Gh(b,B===0?null:await(async()=>{const H=new p(B,Math.ceil(b.context.length/128)*128,k.sampleRate),te=[],de=[];for(let _e=0;_e<g.numberOfInputs;_e+=1)te.push(o(H,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),de.push(i(H,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const ie=await Promise.all(Array.from(b.parameters.values()).map(async _e=>{const Me=r(H,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:_e.value});return await d(H,_e,Me.offset),Me})),Q=n(H,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,j+X)});for(let _e=0;_e<g.numberOfInputs;_e+=1){te[_e].connect(de[_e]);for(let Me=0;Me<g.channelCount;Me+=1)de[_e].connect(Q,Me,_e*g.channelCount+Me)}for(const[_e,Me]of ie.entries())Me.connect(Q,0,j+_e),Me.start(0);return Q.connect(H.destination),await Promise.all(te.map(_e=>f(b,H,_e))),_(H)})(),k,g,A,y,l)}const D=await w,O=t(k,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[N,q,V]=R;D!==null&&(O.buffer=D,O.start(0)),O.connect(N);for(let j=0,X=0;j<b.numberOfOutputs;j+=1){const B=q[j];for(let G=0;G<A[j];G+=1)N.connect(B,X+G,G);X+=A[j]}return V}if(I)for(const[D,O]of b.parameters.entries())await s(k,O,T.parameters.get(D));else for(const[D,O]of b.parameters.entries())await d(k,O,T.parameters.get(D));return await f(b,k,T),T};return{render(b,k){a(k,b);const T=x.get(k);return T!==void 0?Promise.resolve(T):v(b,k)}}},Hh=(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_,m,g,y,x)=>class extends f{constructor(v,b){super(v,b),this._nativeContext=v,this._audioWorklet=s===void 0?void 0:{addModule:(k,T)=>s(this,k,T)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(v,b,k){return new t({length:b,numberOfChannels:v,sampleRate:k})}createBufferSource(){return new n(this)}createChannelMerger(v=6){return new r(this,{numberOfInputs:v})}createChannelSplitter(v=6){return new o(this,{numberOfOutputs:v})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(v=1){return new u(this,{maxDelayTime:v})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(v,b){return new d(this,{feedback:b,feedforward:v})}createOscillator(){return new _(this)}createPanner(){return new m(this)}createPeriodicWave(v,b,k={disableNormalization:!1}){return new g(this,{...k,imag:b,real:v})}createStereoPanner(){return new y(this)}createWaveShaper(){return new x(this)}decodeAudioData(v,b,k){return l(this._nativeContext,v).then(T=>(typeof b=="function"&&b(T),T),T=>{throw typeof k=="function"&&k(T),T})}},Yh={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Uh=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...Yh,...u},d=i(h,p),f=o(h),_=f?t():null;super(l,!1,d,_),this._Q=e(this,f,d.Q,mt,St),this._detune=e(this,f,d.detune,1200*Math.log2(mt),-1200*Math.log2(mt)),this._frequency=e(this,f,d.frequency,l.sampleRate/2,0),this._gain=e(this,f,d.gain,40*Math.log10(mt),St),this._nativeBiquadFilterNode=d,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(l){this._nativeBiquadFilterNode.type=l}getFrequencyResponse(l,u,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(l,u,h)}catch(p){throw p.code===11?n():p}if(l.length!==u.length||u.length!==h.length)throw n()}},Kh=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=pt(l,c);if(!u){const h={Q:l.Q.value,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,detune:l.detune.value,frequency:l.frequency.value,gain:l.gain.value,type:l.type};l=e(c,h)}return r.set(c,l),u?(await s(c,a.Q,l.Q),await s(c,a.detune,l.detune),await s(c,a.frequency,l.frequency),await s(c,a.gain,l.gain)):(await n(c,a.Q,l.Q),await n(c,a.detune,l.detune),await n(c,a.frequency,l.frequency),await n(c,a.gain,l.gain)),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Qh=(s,e)=>(t,n)=>{const i=e.get(t);if(i!==void 0)return i;const r=s.get(t);if(r!==void 0)return r;try{const o=n();return o instanceof Promise?(s.set(t,o),o.catch(()=>!1).then(a=>(s.delete(t),e.set(t,a),a))):(e.set(t,o),o)}catch{return e.set(t,!1),!1}},Jh={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},ed=(s,e,t,n,i)=>class extends s{constructor(o,a){const c=n(o),l={...Jh,...a},u=t(c,l),h=i(c)?e():null;super(o,!1,u,h)}},td=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!pt(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},sd={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},nd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u=r({...sd,...c}),h=t(l,u),p=i(l)?e():null;super(a,!1,h,p)}},id=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!pt(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=s(o,l)}return n.set(o,a),await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},rd=s=>(e,t,n)=>s(t,e,n),od=s=>(e,t,n=0,i=0)=>{const r=e[n];if(r===void 0)throw s();return Xi(t)?r.connect(t,0,i):r.connect(t,0)},ad=s=>(e,t)=>{const n=s(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return n.buffer=i,n.loop=!0,n.connect(t),n.start(),()=>{n.stop(),n.disconnect(t)}},cd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},ld=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...cd,...l},p=n(u,h),d=r(u),f=d?t():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=e(this,d,p.offset,mt,St),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){const l=typeof c=="function"?o(this,c):null;this._nativeConstantSourceNode.onended=l;const u=this._nativeConstantSourceNode.onended;this._onended=u!==null&&u===l?c:u}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){an(this);const l=()=>{this._nativeConstantSourceNode.removeEventListener("ended",l),hs(this)&&si(this)};this._nativeConstantSourceNode.addEventListener("ended",l)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}},ud=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;const c=async(l,u)=>{let h=t(l);const p=pt(h,u);if(!p){const d={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(u,d),o!==null&&h.start(o),a!==null&&h.stop(a)}return r.set(u,h),p?await s(u,l.offset,h.offset):await n(u,l.offset,h.offset),await i(l,u,h),h};return{set start(l){o=l},set stop(l){a=l},render(l,u){const h=r.get(u);return h!==void 0?Promise.resolve(h):c(l,u)}}},hd=s=>e=>(s[0]=e,s[0]),dd={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},pd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u={...dd,...c},h=t(l,u),d=i(l)?e():null;super(a,!1,h,d),this._isBufferNullified=!1,this._nativeConvolverNode=h,u.buffer!==null&&r(this,u.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){const c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,r(this,0)}else this._isBufferNullified=!1,r(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}},fd=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!pt(a,o)){const l={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=s(o,l)}return n.set(o,a),fn(a)?await t(r,o,a.inputs[0]):await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},md=(s,e)=>(t,n,i)=>{if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(t,n,i)}catch(r){throw r.name==="SyntaxError"?s():r}},gd=()=>new DOMException("","DataCloneError"),sc=s=>{const{port1:e,port2:t}=new MessageChannel;return new Promise(n=>{const i=()=>{t.onmessage=null,e.close(),t.close(),n()};t.onmessage=()=>i();try{e.postMessage(s,[s])}catch{}finally{i()}})},_d=(s,e,t,n,i,r,o,a,c,l,u)=>(h,p)=>{const d=o(h)?h:r(h);if(i.has(p)){const f=t();return Promise.reject(f)}try{i.add(p)}catch{}return e(c,()=>c(d))?d.decodeAudioData(p).then(f=>(sc(p).catch(()=>{}),e(a,()=>a(f))||u(f),s.add(f),f)):new Promise((f,_)=>{const m=async()=>{try{await sc(p)}catch{}},g=y=>{_(y),m()};try{d.decodeAudioData(p,y=>{typeof y.copyFromChannel!="function"&&(l(y),Fo(y)),s.add(y),m().then(()=>f(y))},y=>{g(y===null?n():y)})}catch(y){g(y)}})},vd=(s,e,t,n,i,r,o,a)=>(c,l)=>{const u=e.get(c);if(u===void 0)throw new Error("Missing the expected cycle count.");const h=r(c.context),p=a(h);if(u===l){if(e.delete(c),!p&&o(c)){const d=n(c),{outputs:f}=t(c);for(const _ of f)if(ii(_)){const m=n(_[0]);s(d,m,_[1],_[2])}else{const m=i(_[0]);d.connect(m,_[1])}}}else e.set(c,u-l)},yd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},bd=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...yd,...l},p=n(u,h),d=r(u),f=d?t(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=e(this,d,p.delayTime),o(this,h.maxDelayTime)}get delayTime(){return this._delayTime}},wd=(s,e,t,n,i)=>r=>{const o=new WeakMap,a=async(c,l)=>{let u=t(c);const h=pt(u,l);if(!h){const p={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,delayTime:u.delayTime.value,maxDelayTime:r};u=e(l,p)}return o.set(l,u),h?await s(l,c.delayTime,u.delayTime):await n(l,c.delayTime,u.delayTime),await i(c,l,u),u};return{render(c,l){const u=o.get(l);return u!==void 0?Promise.resolve(u):a(c,l)}}},xd=s=>(e,t,n,i)=>s(e[i],r=>r[0]===t&&r[1]===n),Cd=s=>(e,t)=>{s(e).delete(t)},Sd=s=>"delayTime"in s,Td=(s,e,t)=>function n(i,r){const o=zi(r)?r:t(s,r);if(Sd(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map(c=>n([...i,o],c[0])).reduce((c,l)=>c.concat(l),[])},Mi=(s,e,t)=>{const n=e[t];if(n===void 0)throw s();return n},kd=s=>(e,t=void 0,n=void 0,i=0)=>t===void 0?e.forEach(r=>r.disconnect()):typeof t=="number"?Mi(s,e,t).disconnect():Xi(t)?n===void 0?e.forEach(r=>r.disconnect(t)):i===void 0?Mi(s,e,n).disconnect(t,0):Mi(s,e,n).disconnect(t,0,i):n===void 0?e.forEach(r=>r.disconnect(t)):Mi(s,e,n).disconnect(t,0),Ad={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Id=(s,e,t,n,i,r,o,a)=>class extends s{constructor(l,u){const h=r(l),p={...Ad,...u},d=n(h,p),f=o(h),_=f?t():null;super(l,!1,d,_),this._attack=e(this,f,d.attack),this._knee=e(this,f,d.knee),this._nativeDynamicsCompressorNode=d,this._ratio=e(this,f,d.ratio),this._release=e(this,f,d.release),this._threshold=e(this,f,d.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(l){const u=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=l,l>2)throw this._nativeDynamicsCompressorNode.channelCount=u,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(l){const u=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=l,l==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=u,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value=="number"?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}},Dd=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=pt(l,c);if(!u){const h={attack:l.attack.value,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,knee:l.knee.value,ratio:l.ratio.value,release:l.release.value,threshold:l.threshold.value};l=e(c,h)}return r.set(c,l),u?(await s(c,a.attack,l.attack),await s(c,a.knee,l.knee),await s(c,a.ratio,l.ratio),await s(c,a.release,l.release),await s(c,a.threshold,l.threshold)):(await n(c,a.attack,l.attack),await n(c,a.knee,l.knee),await n(c,a.ratio,l.ratio),await n(c,a.release,l.release),await n(c,a.threshold,l.threshold)),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Rd=()=>new DOMException("","EncodingError"),Ed=s=>e=>new Promise((t,n)=>{if(s===null){n(new SyntaxError);return}const i=s.document.head;if(i===null)n(new SyntaxError);else{const r=s.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),c=s.onerror,l=()=>{s.onerror=c,URL.revokeObjectURL(a)};s.onerror=(u,h,p,d,f)=>{if(h===a||h===s.location.href&&p===1&&d===1)return l(),n(f),!1;if(c!==null)return c(u,h,p,d,f)},r.onerror=()=>{l(),n(new SyntaxError)},r.onload=()=>{l(),t()},r.src=a,r.type="module",i.appendChild(r)}}),Md=s=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,n,i){if(n!==null){let r=this._listeners.get(n);r===void 0&&(r=s(this,n),typeof n=="function"&&this._listeners.set(n,r)),this._nativeEventTarget.addEventListener(t,r,i)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,n,i){const r=n===null?void 0:this._listeners.get(n);this._nativeEventTarget.removeEventListener(t,r===void 0?null:r,i)}},Od=s=>(e,t,n)=>{Object.defineProperties(s,{currentFrame:{configurable:!0,get(){return Math.round(e*t)}},currentTime:{configurable:!0,get(){return e}}});try{return n()}finally{s!==null&&(delete s.currentFrame,delete s.currentTime)}},Nd=s=>async e=>{try{const t=await fetch(e);if(t.ok)return[await t.text(),t.url]}catch{}throw s()},Fd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Vd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={...Fd,...c},h=n(l,u),p=r(l),d=p?t():null;super(a,!1,h,d),this._gain=e(this,p,h.gain,mt,St)}get gain(){return this._gain}},Pd=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=pt(l,c);if(!u){const h={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,gain:l.gain.value};l=e(c,h)}return r.set(c,l),u?await s(c,a.gain,l.gain):await n(c,a.gain,l.gain),await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},Wd=(s,e)=>t=>e(s,t),Bd=s=>e=>{const t=s(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return t.renderer},$d=s=>e=>{var t;return(t=s.get(e))!==null&&t!==void 0?t:0},qd=s=>e=>{const t=s(e);if(t.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return t.renderer},jd=s=>e=>s.get(e),Je=()=>new DOMException("","InvalidStateError"),Ld=s=>e=>{const t=s.get(e);if(t===void 0)throw Je();return t},zd=(s,e)=>t=>{let n=s.get(t);if(n!==void 0)return n;if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new e(1,1,44100),s.set(t,n),n},Zd=s=>e=>{const t=s.get(e);if(t===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return t},or=()=>new DOMException("","InvalidAccessError"),Gd=s=>{s.getFrequencyResponse=(e=>(t,n,i)=>{if(t.length!==n.length||n.length!==i.length)throw or();return e.call(s,t,n,i)})(s.getFrequencyResponse)},Xd={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Hd=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=n(a),u=i(l),h={...Xd,...c},p=e(l,u?null:a.baseLatency,h),d=u?t(h.feedback,h.feedforward):null;super(a,!1,p,d),Gd(p),this._nativeIIRFilterNode=p,r(this,1)}getFrequencyResponse(a,c,l){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,l)}},yl=(s,e,t,n,i,r,o,a,c,l,u)=>{const h=l.length;let p=a;for(let d=0;d<h;d+=1){let f=t[0]*l[d];for(let _=1;_<i;_+=1){const m=p-_&c-1;f+=t[_]*r[m],f-=s[_]*o[m]}for(let _=i;_<n;_+=1)f+=t[_]*r[p-_&c-1];for(let _=i;_<e;_+=1)f-=s[_]*o[p-_&c-1];r[p]=l[d],o[p]=f,p=p+1&c-1,u[d]=f}return p},Yd=(s,e,t,n)=>{const i=t instanceof Float64Array?t:new Float64Array(t),r=n instanceof Float64Array?n:new Float64Array(n),o=i.length,a=r.length,c=Math.min(o,a);if(i[0]!==1){for(let f=0;f<o;f+=1)r[f]/=i[0];for(let f=1;f<a;f+=1)i[f]/=i[0]}const l=32,u=new Float32Array(l),h=new Float32Array(l),p=e.createBuffer(s.numberOfChannels,s.length,s.sampleRate),d=s.numberOfChannels;for(let f=0;f<d;f+=1){const _=s.getChannelData(f),m=p.getChannelData(f);u.fill(0),h.fill(0),yl(i,o,r,a,c,u,h,0,l,_,m)}return p},Ud=(s,e,t,n,i)=>(r,o)=>{const a=new WeakMap;let c=null;const l=async(u,h)=>{let p=null,d=e(u);const f=pt(d,h);if(h.createIIRFilter===void 0?p=s(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(d=h.createIIRFilter(o,r)),a.set(h,p===null?d:p),p!==null){if(c===null){if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");const m=new t(u.context.destination.channelCount,u.context.length,h.sampleRate);c=(async()=>{await n(u,m,m.destination);const g=await i(m);return Yd(g,h,r,o)})()}const _=await c;return p.buffer=_,p.start(0),p}return await n(u,h,d),d};return{render(u,h){const p=a.get(h);return p!==void 0?Promise.resolve(p):l(u,h)}}},Kd=(s,e,t,n,i,r)=>o=>(a,c)=>{const l=s.get(a);if(l===void 0){if(!o&&r(a)){const u=n(a),{outputs:h}=t(a);for(const p of h)if(ii(p)){const d=n(p[0]);e(u,d,p[1],p[2])}else{const d=i(p[0]);u.disconnect(d,p[1])}}s.set(a,c)}else s.set(a,l+c)},Qd=(s,e)=>t=>{const n=s.get(t);return e(n)||e(t)},Jd=(s,e)=>t=>s.has(t)||e(t),ep=(s,e)=>t=>s.has(t)||e(t),tp=(s,e)=>t=>{const n=s.get(t);return e(n)||e(t)},sp=s=>e=>s!==null&&e instanceof s,np=s=>e=>s!==null&&typeof s.AudioNode=="function"&&e instanceof s.AudioNode,ip=s=>e=>s!==null&&typeof s.AudioParam=="function"&&e instanceof s.AudioParam,rp=(s,e)=>t=>s(t)||e(t),op=s=>e=>s!==null&&e instanceof s,ap=s=>s!==null&&s.isSecureContext,cp=async(s,e,t,n,i,r,o,a,c,l,u,h,p,d,f,_)=>s(e,e)&&s(t,t)&&s(i,i)&&s(r,r)&&s(a,a)&&s(c,c)&&s(l,l)&&s(u,u)&&s(h,h)&&s(p,p)&&s(d,d)?(await Promise.all([s(n,n),s(o,o),s(f,f),s(_,_)])).every(g=>g):!1,lp=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r),c=e(a,o);if(n(a))throw TypeError();super(r,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}},up={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},hp=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r);if(n(a))throw new TypeError;const c={...up,...o},l=e(a,c);super(r,!1,l,null),this._nativeMediaStreamAudioDestinationNode=l}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},dp=(s,e,t,n)=>class extends s{constructor(r,o){const a=t(r),c=e(a,o);if(n(a))throw new TypeError;super(r,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},pp=(s,e,t)=>class extends s{constructor(i,r){const o=t(i),a=e(o,r);super(i,!0,a,null)}},fp=(s,e,t,n,i,r)=>class extends t{constructor(a,c){super(a),this._nativeContext=a,ir.set(this,a),n(a)&&i.set(a,new Set),this._destination=new s(this,c),this._listener=e(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){const c=typeof a=="function"?r(this,a):null;this._nativeContext.onstatechange=c;const l=this._nativeContext.onstatechange;this._onstatechange=l!==null&&l===c?a:l}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},Xn=s=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const t=s.decodeAudioData(e.buffer,()=>{});return t===void 0?!1:(t.catch(()=>{}),!0)}catch{}return!1},mp=(s,e)=>(t,n,i)=>{const r=new Set;return t.connect=(o=>(a,c=0,l=0)=>{const u=r.size===0;if(e(a))return o.call(t,a,c,l),s(r,[a,c,l],h=>h[0]===a&&h[1]===c&&h[2]===l,!0),u&&n(),a;o.call(t,a,c),s(r,[a,c],h=>h[0]===a&&h[1]===c,!0),u&&n()})(t.connect),t.disconnect=(o=>(a,c,l)=>{const u=r.size>0;if(a===void 0)o.apply(t),r.clear();else if(typeof a=="number"){o.call(t,a);for(const p of r)p[1]===a&&r.delete(p)}else{e(a)?o.call(t,a,c,l):o.call(t,a,c);for(const p of r)p[0]===a&&(c===void 0||p[1]===c)&&(l===void 0||p[2]===l)&&r.delete(p)}const h=r.size===0;u&&h&&i()})(t.disconnect),t},Ne=(s,e,t)=>{const n=e[t];n!==void 0&&n!==s[t]&&(s[t]=n)},He=(s,e)=>{Ne(s,e,"channelCount"),Ne(s,e,"channelCountMode"),Ne(s,e,"channelInterpretation")},nc=s=>typeof s.getFloatTimeDomainData=="function",gp=s=>{s.getFloatTimeDomainData=e=>{const t=new Uint8Array(e.length);s.getByteTimeDomainData(t);const n=Math.max(t.length,s.fftSize);for(let i=0;i<n;i+=1)e[i]=(t[i]-128)*.0078125;return e}},_p=(s,e)=>(t,n)=>{const i=t.createAnalyser();if(He(i,n),!(n.maxDecibels>n.minDecibels))throw e();return Ne(i,n,"fftSize"),Ne(i,n,"maxDecibels"),Ne(i,n,"minDecibels"),Ne(i,n,"smoothingTimeConstant"),s(nc,()=>nc(i))||gp(i),i},vp=s=>s===null?null:s.hasOwnProperty("AudioBuffer")?s.AudioBuffer:null,We=(s,e,t)=>{const n=e[t];n!==void 0&&n!==s[t].value&&(s[t].value=n)},yp=s=>{s.start=(e=>{let t=!1;return(n=0,i=0,r)=>{if(t)throw Je();e.call(s,n,i,r),t=!0}})(s.start)},Wo=s=>{s.start=(e=>(t=0,n=0,i)=>{if(typeof i=="number"&&i<0||n<0||t<0)throw new RangeError("The parameters can't be negative.");e.call(s,t,n,i)})(s.start)},Bo=s=>{s.stop=(e=>(t=0)=>{if(t<0)throw new RangeError("The parameter can't be negative.");e.call(s,t)})(s.stop)},bp=(s,e,t,n,i,r,o,a,c,l,u)=>(h,p)=>{const d=h.createBufferSource();return He(d,p),We(d,p,"playbackRate"),Ne(d,p,"buffer"),Ne(d,p,"loop"),Ne(d,p,"loopEnd"),Ne(d,p,"loopStart"),e(t,()=>t(h))||yp(d),e(n,()=>n(h))||c(d),e(i,()=>i(h))||l(d,h),e(r,()=>r(h))||Wo(d),e(o,()=>o(h))||u(d,h),e(a,()=>a(h))||Bo(d),s(h,d),d},wp=s=>s===null?null:s.hasOwnProperty("AudioContext")?s.AudioContext:s.hasOwnProperty("webkitAudioContext")?s.webkitAudioContext:null,xp=(s,e)=>(t,n,i)=>{const r=t.destination;if(r.channelCount!==n)try{r.channelCount=n}catch{}i&&r.channelCountMode!=="explicit"&&(r.channelCountMode="explicit"),r.maxChannelCount===0&&Object.defineProperty(r,"maxChannelCount",{value:n});const o=s(t,{channelCount:n,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,gain:1});return e(o,"channelCount",a=>()=>a.call(o),a=>c=>{a.call(o,c);try{r.channelCount=c}catch(l){if(c>r.maxChannelCount)throw l}}),e(o,"channelCountMode",a=>()=>a.call(o),a=>c=>{a.call(o,c),r.channelCountMode=c}),e(o,"channelInterpretation",a=>()=>a.call(o),a=>c=>{a.call(o,c),r.channelInterpretation=c}),Object.defineProperty(o,"maxChannelCount",{get:()=>r.maxChannelCount}),o.connect(r),o},Cp=s=>s===null?null:s.hasOwnProperty("AudioWorkletNode")?s.AudioWorkletNode:null,Sp=s=>{const{port1:e}=new MessageChannel;try{e.postMessage(s)}finally{e.close()}},Tp=(s,e,t,n,i)=>(r,o,a,c,l,u)=>{if(a!==null)try{const h=new a(r,c,u),p=new Map;let d=null;if(Object.defineProperties(h,{channelCount:{get:()=>u.channelCount,set:()=>{throw s()}},channelCountMode:{get:()=>"explicit",set:()=>{throw s()}},onprocessorerror:{get:()=>d,set:f=>{typeof d=="function"&&h.removeEventListener("processorerror",d),d=typeof f=="function"?f:null,typeof d=="function"&&h.addEventListener("processorerror",d)}}}),h.addEventListener=(f=>(..._)=>{if(_[0]==="processorerror"){const m=typeof _[1]=="function"?_[1]:typeof _[1]=="object"&&_[1]!==null&&typeof _[1].handleEvent=="function"?_[1].handleEvent:null;if(m!==null){const g=p.get(_[1]);g!==void 0?_[1]=g:(_[1]=y=>{y.type==="error"?(Object.defineProperties(y,{type:{value:"processorerror"}}),m(y)):m(new ErrorEvent(_[0],{...y}))},p.set(m,_[1]))}}return f.call(h,"error",_[1],_[2]),f.call(h,..._)})(h.addEventListener),h.removeEventListener=(f=>(..._)=>{if(_[0]==="processorerror"){const m=p.get(_[1]);m!==void 0&&(p.delete(_[1]),_[1]=m)}return f.call(h,"error",_[1],_[2]),f.call(h,_[0],_[1],_[2])})(h.removeEventListener),u.numberOfOutputs!==0){const f=t(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(r.destination),i(h,()=>f.disconnect(),()=>f.connect(r.destination))}return h}catch(h){throw h.code===11?n():h}if(l===void 0)throw n();return Sp(u),e(r,o,l,u)},bl=(s,e)=>s===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(s*e))))),kp=s=>new Promise((e,t)=>{const{port1:n,port2:i}=new MessageChannel;n.onmessage=({data:r})=>{n.close(),i.close(),e(r)},n.onmessageerror=({data:r})=>{n.close(),i.close(),t(r)},i.postMessage(s)}),Ap=async(s,e)=>{const t=await kp(e);return new s(t)},Ip=(s,e,t,n)=>{let i=go.get(s);i===void 0&&(i=new WeakMap,go.set(s,i));const r=Ap(t,n);return i.set(e,r),r},Dp=(s,e,t,n,i,r,o,a,c,l,u,h,p)=>(d,f,_,m)=>{if(m.numberOfInputs===0&&m.numberOfOutputs===0)throw c();const g=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(g.some(L=>L<1))throw c();if(g.length!==m.numberOfOutputs)throw e();if(m.channelCountMode!=="explicit")throw c();const y=m.channelCount*m.numberOfInputs,x=g.reduce((L,J)=>L+J,0),w=_.parameterDescriptors===void 0?0:_.parameterDescriptors.length;if(y+w>6||x>6)throw c();const v=new MessageChannel,b=[],k=[];for(let L=0;L<m.numberOfInputs;L+=1)b.push(o(d,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),k.push(i(d,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const T=[];if(_.parameterDescriptors!==void 0)for(const{defaultValue:L,maxValue:J,minValue:ve,name:ye}of _.parameterDescriptors){const le=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:m.parameterData[ye]!==void 0?m.parameterData[ye]:L===void 0?0:L});Object.defineProperties(le.offset,{defaultValue:{get:()=>L===void 0?0:L},maxValue:{get:()=>J===void 0?mt:J},minValue:{get:()=>ve===void 0?St:ve}}),T.push(le)}const R=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,y+w)}),I=bl(f,d.sampleRate),A=a(d,I,y+w,Math.max(1,x)),D=i(d,{channelCount:Math.max(1,x),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,x)}),O=[];for(let L=0;L<m.numberOfOutputs;L+=1)O.push(n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[L]}));for(let L=0;L<m.numberOfInputs;L+=1){b[L].connect(k[L]);for(let J=0;J<m.channelCount;J+=1)k[L].connect(R,J,L*m.channelCount+J)}const N=new _l(_.parameterDescriptors===void 0?[]:_.parameterDescriptors.map(({name:L},J)=>{const ve=T[J];return ve.connect(R,0,y+J),ve.start(0),[L,ve.offset]}));R.connect(A);let q=m.channelInterpretation,V=null;const j=m.numberOfOutputs===0?[A]:O,X={get bufferSize(){return I},get channelCount(){return m.channelCount},set channelCount(L){throw t()},get channelCountMode(){return m.channelCountMode},set channelCountMode(L){throw t()},get channelInterpretation(){return q},set channelInterpretation(L){for(const J of b)J.channelInterpretation=L;q=L},get context(){return A.context},get inputs(){return b},get numberOfInputs(){return m.numberOfInputs},get numberOfOutputs(){return m.numberOfOutputs},get onprocessorerror(){return V},set onprocessorerror(L){typeof V=="function"&&X.removeEventListener("processorerror",V),V=typeof L=="function"?L:null,typeof V=="function"&&X.addEventListener("processorerror",V)},get parameters(){return N},get port(){return v.port2},addEventListener(...L){return A.addEventListener(L[0],L[1],L[2])},connect:s.bind(null,j),disconnect:l.bind(null,j),dispatchEvent(...L){return A.dispatchEvent(L[0])},removeEventListener(...L){return A.removeEventListener(L[0],L[1],L[2])}},B=new Map;v.port1.addEventListener=(L=>(...J)=>{if(J[0]==="message"){const ve=typeof J[1]=="function"?J[1]:typeof J[1]=="object"&&J[1]!==null&&typeof J[1].handleEvent=="function"?J[1].handleEvent:null;if(ve!==null){const ye=B.get(J[1]);ye!==void 0?J[1]=ye:(J[1]=le=>{u(d.currentTime,d.sampleRate,()=>ve(le))},B.set(ve,J[1]))}}return L.call(v.port1,J[0],J[1],J[2])})(v.port1.addEventListener),v.port1.removeEventListener=(L=>(...J)=>{if(J[0]==="message"){const ve=B.get(J[1]);ve!==void 0&&(B.delete(J[1]),J[1]=ve)}return L.call(v.port1,J[0],J[1],J[2])})(v.port1.removeEventListener);let G=null;Object.defineProperty(v.port1,"onmessage",{get:()=>G,set:L=>{typeof G=="function"&&v.port1.removeEventListener("message",G),G=typeof L=="function"?L:null,typeof G=="function"&&(v.port1.addEventListener("message",G),v.port1.start())}}),_.prototype.port=v.port1;let H=null;Ip(d,X,_,m).then(L=>H=L);const de=Yi(m.numberOfInputs,m.channelCount),ie=Yi(m.numberOfOutputs,g),Q=_.parameterDescriptors===void 0?[]:_.parameterDescriptors.reduce((L,{name:J})=>({...L,[J]:new Float32Array(128)}),{});let _e=!0;const Me=()=>{m.numberOfOutputs>0&&A.disconnect(D);for(let L=0,J=0;L<m.numberOfOutputs;L+=1){const ve=O[L];for(let ye=0;ye<g[L];ye+=1)D.disconnect(ve,J+ye,ye);J+=g[L]}},z=new Map;A.onaudioprocess=({inputBuffer:L,outputBuffer:J})=>{if(H!==null){const ve=h(X);for(let ye=0;ye<I;ye+=128){for(let le=0;le<m.numberOfInputs;le+=1)for(let we=0;we<m.channelCount;we+=1)Hi(L,de[le],we,we,ye);_.parameterDescriptors!==void 0&&_.parameterDescriptors.forEach(({name:le},we)=>{Hi(L,Q,le,y+we,ye)});for(let le=0;le<m.numberOfInputs;le+=1)for(let we=0;we<g[le];we+=1)ie[le][we].byteLength===0&&(ie[le][we]=new Float32Array(128));try{const le=de.map((ze,tt)=>{if(ve[tt].size>0)return z.set(tt,I/128),ze;const ae=z.get(tt);return ae===void 0?[]:(ze.every(me=>me.every(Ie=>Ie===0))&&(ae===1?z.delete(tt):z.set(tt,ae-1)),ze)});_e=u(d.currentTime+ye/d.sampleRate,d.sampleRate,()=>H.process(le,ie,Q));for(let ze=0,tt=0;ze<m.numberOfOutputs;ze+=1){for(let xt=0;xt<g[ze];xt+=1)vl(J,ie[ze],xt,tt+xt,ye);tt+=g[ze]}}catch(le){_e=!1,X.dispatchEvent(new ErrorEvent("processorerror",{colno:le.colno,filename:le.filename,lineno:le.lineno,message:le.message}))}if(!_e){for(let le=0;le<m.numberOfInputs;le+=1){b[le].disconnect(k[le]);for(let we=0;we<m.channelCount;we+=1)k[ye].disconnect(R,we,le*m.channelCount+we)}if(_.parameterDescriptors!==void 0){const le=_.parameterDescriptors.length;for(let we=0;we<le;we+=1){const ze=T[we];ze.disconnect(R,0,y+we),ze.stop()}}R.disconnect(A),A.onaudioprocess=null,Ke?Me():U();break}}}};let Ke=!1;const ut=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Vt=()=>A.connect(ut).connect(d.destination),U=()=>{A.disconnect(ut),ut.disconnect()},ht=()=>{if(_e){U(),m.numberOfOutputs>0&&A.connect(D);for(let L=0,J=0;L<m.numberOfOutputs;L+=1){const ve=O[L];for(let ye=0;ye<g[L];ye+=1)D.connect(ve,J+ye,ye);J+=g[L]}}Ke=!0},$e=()=>{_e&&(Vt(),Me()),Ke=!1};return Vt(),p(X,ht,$e)},wl=(s,e)=>{const t=s.createBiquadFilter();return He(t,e),We(t,e,"Q"),We(t,e,"detune"),We(t,e,"frequency"),We(t,e,"gain"),Ne(t,e,"type"),t},Rp=(s,e)=>(t,n)=>{const i=t.createChannelMerger(n.numberOfInputs);return s!==null&&s.name==="webkitAudioContext"&&e(t,i),He(i,n),i},Ep=s=>{const e=s.numberOfOutputs;Object.defineProperty(s,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Je()}}),Object.defineProperty(s,"channelCountMode",{get:()=>"explicit",set:t=>{if(t!=="explicit")throw Je()}}),Object.defineProperty(s,"channelInterpretation",{get:()=>"discrete",set:t=>{if(t!=="discrete")throw Je()}})},ri=(s,e)=>{const t=s.createChannelSplitter(e.numberOfOutputs);return He(t,e),Ep(t),t},Mp=(s,e,t,n,i)=>(r,o)=>{if(r.createConstantSource===void 0)return t(r,o);const a=r.createConstantSource();return He(a,o),We(a,o,"offset"),e(n,()=>n(r))||Wo(a),e(i,()=>i(r))||Bo(a),s(r,a),a},mn=(s,e)=>(s.connect=e.connect.bind(e),s.disconnect=e.disconnect.bind(e),s),Op=(s,e,t,n)=>(i,{offset:r,...o})=>{const a=i.createBuffer(1,2,44100),c=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=t(i,{...o,gain:r}),u=a.getChannelData(0);u[0]=1,u[1]=1,c.buffer=a,c.loop=!0;const h={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(f){l.channelCount=f},get channelCountMode(){return l.channelCountMode},set channelCountMode(f){l.channelCountMode=f},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(f){l.channelInterpretation=f},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return c.onended},set onended(f){c.onended=f},addEventListener(...f){return c.addEventListener(f[0],f[1],f[2])},dispatchEvent(...f){return c.dispatchEvent(f[0])},removeEventListener(...f){return c.removeEventListener(f[0],f[1],f[2])},start(f=0){c.start.call(c,f)},stop(f=0){c.stop.call(c,f)}},p=()=>c.connect(l),d=()=>c.disconnect(l);return s(i,c),n(mn(h,l),p,d)},Np=(s,e)=>(t,n)=>{const i=t.createConvolver();if(He(i,n),n.disableNormalization===i.normalize&&(i.normalize=!n.disableNormalization),Ne(i,n,"buffer"),n.channelCount>2||(e(i,"channelCount",r=>()=>r.call(i),r=>o=>{if(o>2)throw s();return r.call(i,o)}),n.channelCountMode==="max"))throw s();return e(i,"channelCountMode",r=>()=>r.call(i),r=>o=>{if(o==="max")throw s();return r.call(i,o)}),i},xl=(s,e)=>{const t=s.createDelay(e.maxDelayTime);return He(t,e),We(t,e,"delayTime"),t},Fp=s=>(e,t)=>{const n=e.createDynamicsCompressor();if(He(n,t),t.channelCount>2||t.channelCountMode==="max")throw s();return We(n,t,"attack"),We(n,t,"knee"),We(n,t,"ratio"),We(n,t,"release"),We(n,t,"threshold"),n},kt=(s,e)=>{const t=s.createGain();return He(t,e),We(t,e,"gain"),t},Vp=s=>(e,t,n)=>{if(e.createIIRFilter===void 0)return s(e,t,n);const i=e.createIIRFilter(n.feedforward,n.feedback);return He(i,n),i};function Pp(s,e){const t=e[0]*e[0]+e[1]*e[1];return[(s[0]*e[0]+s[1]*e[1])/t,(s[1]*e[0]-s[0]*e[1])/t]}function Wp(s,e){return[s[0]*e[0]-s[1]*e[1],s[0]*e[1]+s[1]*e[0]]}function ic(s,e){let t=[0,0];for(let n=s.length-1;n>=0;n-=1)t=Wp(t,e),t[0]+=s[n];return t}const Bp=(s,e,t,n)=>(i,r,{channelCount:o,channelCountMode:a,channelInterpretation:c,feedback:l,feedforward:u})=>{const h=bl(r,i.sampleRate),p=l instanceof Float64Array?l:new Float64Array(l),d=u instanceof Float64Array?u:new Float64Array(u),f=p.length,_=d.length,m=Math.min(f,_);if(f===0||f>20)throw n();if(p[0]===0)throw e();if(_===0||_>20)throw n();if(d[0]===0)throw e();if(p[0]!==1){for(let T=0;T<_;T+=1)d[T]/=p[0];for(let T=1;T<f;T+=1)p[T]/=p[0]}const g=t(i,h,o,o);g.channelCount=o,g.channelCountMode=a,g.channelInterpretation=c;const y=32,x=[],w=[],v=[];for(let T=0;T<o;T+=1){x.push(0);const R=new Float32Array(y),I=new Float32Array(y);R.fill(0),I.fill(0),w.push(R),v.push(I)}g.onaudioprocess=T=>{const R=T.inputBuffer,I=T.outputBuffer,A=R.numberOfChannels;for(let D=0;D<A;D+=1){const O=R.getChannelData(D),N=I.getChannelData(D);x[D]=yl(p,f,d,_,m,w[D],v[D],x[D],y,O,N)}};const b=i.sampleRate/2;return mn({get bufferSize(){return h},get channelCount(){return g.channelCount},set channelCount(T){g.channelCount=T},get channelCountMode(){return g.channelCountMode},set channelCountMode(T){g.channelCountMode=T},get channelInterpretation(){return g.channelInterpretation},set channelInterpretation(T){g.channelInterpretation=T},get context(){return g.context},get inputs(){return[g]},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},addEventListener(...T){return g.addEventListener(T[0],T[1],T[2])},dispatchEvent(...T){return g.dispatchEvent(T[0])},getFrequencyResponse(T,R,I){if(T.length!==R.length||R.length!==I.length)throw s();const A=T.length;for(let D=0;D<A;D+=1){const O=-Math.PI*(T[D]/b),N=[Math.cos(O),Math.sin(O)],q=ic(d,N),V=ic(p,N),j=Pp(q,V);R[D]=Math.sqrt(j[0]*j[0]+j[1]*j[1]),I[D]=Math.atan2(j[1],j[0])}},removeEventListener(...T){return g.removeEventListener(T[0],T[1],T[2])}},g)},$p=(s,e)=>s.createMediaElementSource(e.mediaElement),qp=(s,e)=>{const t=s.createMediaStreamDestination();return He(t,e),t.numberOfOutputs===1&&Object.defineProperty(t,"numberOfOutputs",{get:()=>0}),t},jp=(s,{mediaStream:e})=>{const t=e.getAudioTracks();t.sort((r,o)=>r.id<o.id?-1:r.id>o.id?1:0);const n=t.slice(0,1),i=s.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(i,"mediaStream",{value:e}),i},Lp=(s,e)=>(t,{mediaStreamTrack:n})=>{if(typeof t.createMediaStreamTrackSource=="function")return t.createMediaStreamTrackSource(n);const i=new MediaStream([n]),r=t.createMediaStreamSource(i);if(n.kind!=="audio")throw s();if(e(t))throw new TypeError;return r},zp=s=>s===null?null:s.hasOwnProperty("OfflineAudioContext")?s.OfflineAudioContext:s.hasOwnProperty("webkitOfflineAudioContext")?s.webkitOfflineAudioContext:null,Zp=(s,e,t,n,i,r)=>(o,a)=>{const c=o.createOscillator();return He(c,a),We(c,a,"detune"),We(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):Ne(c,a,"type"),e(t,()=>t(o))||Wo(c),e(n,()=>n(o))||r(c,o),e(i,()=>i(o))||Bo(c),s(o,c),c},Gp=s=>(e,t)=>{const n=e.createPanner();return n.orientationX===void 0?s(e,t):(He(n,t),We(n,t,"orientationX"),We(n,t,"orientationY"),We(n,t,"orientationZ"),We(n,t,"positionX"),We(n,t,"positionY"),We(n,t,"positionZ"),Ne(n,t,"coneInnerAngle"),Ne(n,t,"coneOuterAngle"),Ne(n,t,"coneOuterGain"),Ne(n,t,"distanceModel"),Ne(n,t,"maxDistance"),Ne(n,t,"panningModel"),Ne(n,t,"refDistance"),Ne(n,t,"rolloffFactor"),n)},Xp=(s,e,t,n,i,r,o,a,c,l)=>(u,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:_,orientationX:m,orientationY:g,orientationZ:y,panningModel:x,positionX:w,positionY:v,positionZ:b,refDistance:k,rolloffFactor:T,...R})=>{const I=u.createPanner();if(R.channelCount>2||R.channelCountMode==="max")throw o();He(I,R);const A={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},D=t(u,{...A,channelInterpretation:"speakers",numberOfInputs:6}),O=n(u,{...R,gain:1}),N=n(u,{...A,gain:1}),q=n(u,{...A,gain:0}),V=n(u,{...A,gain:0}),j=n(u,{...A,gain:0}),X=n(u,{...A,gain:0}),B=n(u,{...A,gain:0}),G=i(u,256,6,1),H=r(u,{...A,curve:new Float32Array([1,1]),oversample:"none"});let te=[m,g,y],de=[w,v,b];const ie=new Float32Array(1);G.onaudioprocess=({inputBuffer:z})=>{const Ke=[c(z,ie,0),c(z,ie,1),c(z,ie,2)];Ke.some((Vt,U)=>Vt!==te[U])&&(I.setOrientation(...Ke),te=Ke);const ut=[c(z,ie,3),c(z,ie,4),c(z,ie,5)];ut.some((Vt,U)=>Vt!==de[U])&&(I.setPosition(...ut),de=ut)},Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(j.gain,"defaultValue",{get:()=>0}),Object.defineProperty(X.gain,"defaultValue",{get:()=>0}),Object.defineProperty(B.gain,"defaultValue",{get:()=>0});const Q={get bufferSize(){},get channelCount(){return I.channelCount},set channelCount(z){if(z>2)throw o();O.channelCount=z,I.channelCount=z},get channelCountMode(){return I.channelCountMode},set channelCountMode(z){if(z==="max")throw o();O.channelCountMode=z,I.channelCountMode=z},get channelInterpretation(){return I.channelInterpretation},set channelInterpretation(z){O.channelInterpretation=z,I.channelInterpretation=z},get coneInnerAngle(){return I.coneInnerAngle},set coneInnerAngle(z){I.coneInnerAngle=z},get coneOuterAngle(){return I.coneOuterAngle},set coneOuterAngle(z){I.coneOuterAngle=z},get coneOuterGain(){return I.coneOuterGain},set coneOuterGain(z){if(z<0||z>1)throw e();I.coneOuterGain=z},get context(){return I.context},get distanceModel(){return I.distanceModel},set distanceModel(z){I.distanceModel=z},get inputs(){return[O]},get maxDistance(){return I.maxDistance},set maxDistance(z){if(z<0)throw new RangeError;I.maxDistance=z},get numberOfInputs(){return I.numberOfInputs},get numberOfOutputs(){return I.numberOfOutputs},get orientationX(){return N.gain},get orientationY(){return q.gain},get orientationZ(){return V.gain},get panningModel(){return I.panningModel},set panningModel(z){I.panningModel=z},get positionX(){return j.gain},get positionY(){return X.gain},get positionZ(){return B.gain},get refDistance(){return I.refDistance},set refDistance(z){if(z<0)throw new RangeError;I.refDistance=z},get rolloffFactor(){return I.rolloffFactor},set rolloffFactor(z){if(z<0)throw new RangeError;I.rolloffFactor=z},addEventListener(...z){return O.addEventListener(z[0],z[1],z[2])},dispatchEvent(...z){return O.dispatchEvent(z[0])},removeEventListener(...z){return O.removeEventListener(z[0],z[1],z[2])}};h!==Q.coneInnerAngle&&(Q.coneInnerAngle=h),p!==Q.coneOuterAngle&&(Q.coneOuterAngle=p),d!==Q.coneOuterGain&&(Q.coneOuterGain=d),f!==Q.distanceModel&&(Q.distanceModel=f),_!==Q.maxDistance&&(Q.maxDistance=_),m!==Q.orientationX.value&&(Q.orientationX.value=m),g!==Q.orientationY.value&&(Q.orientationY.value=g),y!==Q.orientationZ.value&&(Q.orientationZ.value=y),x!==Q.panningModel&&(Q.panningModel=x),w!==Q.positionX.value&&(Q.positionX.value=w),v!==Q.positionY.value&&(Q.positionY.value=v),b!==Q.positionZ.value&&(Q.positionZ.value=b),k!==Q.refDistance&&(Q.refDistance=k),T!==Q.rolloffFactor&&(Q.rolloffFactor=T),(te[0]!==1||te[1]!==0||te[2]!==0)&&I.setOrientation(...te),(de[0]!==0||de[1]!==0||de[2]!==0)&&I.setPosition(...de);const _e=()=>{O.connect(I),s(O,H,0,0),H.connect(N).connect(D,0,0),H.connect(q).connect(D,0,1),H.connect(V).connect(D,0,2),H.connect(j).connect(D,0,3),H.connect(X).connect(D,0,4),H.connect(B).connect(D,0,5),D.connect(G).connect(u.destination)},Me=()=>{O.disconnect(I),a(O,H,0,0),H.disconnect(N),N.disconnect(D),H.disconnect(q),q.disconnect(D),H.disconnect(V),V.disconnect(D),H.disconnect(j),j.disconnect(D),H.disconnect(X),X.disconnect(D),H.disconnect(B),B.disconnect(D),D.disconnect(G),G.disconnect(u.destination)};return l(mn(Q,I),_e,Me)},Hp=s=>(e,{disableNormalization:t,imag:n,real:i})=>{const r=n instanceof Float32Array?n:new Float32Array(n),o=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(o,r,{disableNormalization:t});if(Array.from(n).length<2)throw s();return a},oi=(s,e,t,n)=>s.createScriptProcessor(e,t,n),Yp=(s,e)=>(t,n)=>{const i=n.channelCountMode;if(i==="clamped-max")throw e();if(t.createStereoPanner===void 0)return s(t,n);const r=t.createStereoPanner();return He(r,n),We(r,n,"pan"),Object.defineProperty(r,"channelCountMode",{get:()=>i,set:o=>{if(o!==i)throw e()}}),r},Up=(s,e,t,n,i,r)=>{const a=new Float32Array([1,1]),c=Math.PI/2,l={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},u={...l,oversample:"none"},h=(f,_,m,g)=>{const y=new Float32Array(16385),x=new Float32Array(16385);for(let R=0;R<16385;R+=1){const I=R/16384*c;y[R]=Math.cos(I),x[R]=Math.sin(I)}const w=t(f,{...l,gain:0}),v=n(f,{...u,curve:y}),b=n(f,{...u,curve:a}),k=t(f,{...l,gain:0}),T=n(f,{...u,curve:x});return{connectGraph(){_.connect(w),_.connect(b.inputs===void 0?b:b.inputs[0]),_.connect(k),b.connect(m),m.connect(v.inputs===void 0?v:v.inputs[0]),m.connect(T.inputs===void 0?T:T.inputs[0]),v.connect(w.gain),T.connect(k.gain),w.connect(g,0,0),k.connect(g,0,1)},disconnectGraph(){_.disconnect(w),_.disconnect(b.inputs===void 0?b:b.inputs[0]),_.disconnect(k),b.disconnect(m),m.disconnect(v.inputs===void 0?v:v.inputs[0]),m.disconnect(T.inputs===void 0?T:T.inputs[0]),v.disconnect(w.gain),T.disconnect(k.gain),w.disconnect(g,0,0),k.disconnect(g,0,1)}}},p=(f,_,m,g)=>{const y=new Float32Array(16385),x=new Float32Array(16385),w=new Float32Array(16385),v=new Float32Array(16385),b=Math.floor(16385/2);for(let j=0;j<16385;j+=1)if(j>b){const X=(j-b)/(16384-b)*c;y[j]=Math.cos(X),x[j]=Math.sin(X),w[j]=0,v[j]=1}else{const X=j/(16384-b)*c;y[j]=1,x[j]=0,w[j]=Math.cos(X),v[j]=Math.sin(X)}const k=e(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),T=t(f,{...l,gain:0}),R=n(f,{...u,curve:y}),I=t(f,{...l,gain:0}),A=n(f,{...u,curve:x}),D=n(f,{...u,curve:a}),O=t(f,{...l,gain:0}),N=n(f,{...u,curve:w}),q=t(f,{...l,gain:0}),V=n(f,{...u,curve:v});return{connectGraph(){_.connect(k),_.connect(D.inputs===void 0?D:D.inputs[0]),k.connect(T,0),k.connect(I,0),k.connect(O,1),k.connect(q,1),D.connect(m),m.connect(R.inputs===void 0?R:R.inputs[0]),m.connect(A.inputs===void 0?A:A.inputs[0]),m.connect(N.inputs===void 0?N:N.inputs[0]),m.connect(V.inputs===void 0?V:V.inputs[0]),R.connect(T.gain),A.connect(I.gain),N.connect(O.gain),V.connect(q.gain),T.connect(g,0,0),O.connect(g,0,0),I.connect(g,0,1),q.connect(g,0,1)},disconnectGraph(){_.disconnect(k),_.disconnect(D.inputs===void 0?D:D.inputs[0]),k.disconnect(T,0),k.disconnect(I,0),k.disconnect(O,1),k.disconnect(q,1),D.disconnect(m),m.disconnect(R.inputs===void 0?R:R.inputs[0]),m.disconnect(A.inputs===void 0?A:A.inputs[0]),m.disconnect(N.inputs===void 0?N:N.inputs[0]),m.disconnect(V.inputs===void 0?V:V.inputs[0]),R.disconnect(T.gain),A.disconnect(I.gain),N.disconnect(O.gain),V.disconnect(q.gain),T.disconnect(g,0,0),O.disconnect(g,0,0),I.disconnect(g,0,1),q.disconnect(g,0,1)}}},d=(f,_,m,g,y)=>{if(_===1)return h(f,m,g,y);if(_===2)return p(f,m,g,y);throw i()};return(f,{channelCount:_,channelCountMode:m,pan:g,...y})=>{if(m==="max")throw i();const x=s(f,{...y,channelCount:1,channelCountMode:m,numberOfInputs:2}),w=t(f,{...y,channelCount:_,channelCountMode:m,gain:1}),v=t(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:g});let{connectGraph:b,disconnectGraph:k}=d(f,_,w,v,x);Object.defineProperty(v.gain,"defaultValue",{get:()=>0}),Object.defineProperty(v.gain,"maxValue",{get:()=>1}),Object.defineProperty(v.gain,"minValue",{get:()=>-1});const T={get bufferSize(){},get channelCount(){return w.channelCount},set channelCount(D){w.channelCount!==D&&(R&&k(),{connectGraph:b,disconnectGraph:k}=d(f,D,w,v,x),R&&b()),w.channelCount=D},get channelCountMode(){return w.channelCountMode},set channelCountMode(D){if(D==="clamped-max"||D==="max")throw i();w.channelCountMode=D},get channelInterpretation(){return w.channelInterpretation},set channelInterpretation(D){w.channelInterpretation=D},get context(){return w.context},get inputs(){return[w]},get numberOfInputs(){return w.numberOfInputs},get numberOfOutputs(){return w.numberOfOutputs},get pan(){return v.gain},addEventListener(...D){return w.addEventListener(D[0],D[1],D[2])},dispatchEvent(...D){return w.dispatchEvent(D[0])},removeEventListener(...D){return w.removeEventListener(D[0],D[1],D[2])}};let R=!1;const I=()=>{b(),R=!0},A=()=>{k(),R=!1};return r(mn(T,x),I,A)}},Kp=(s,e,t,n,i,r,o)=>(a,c)=>{const l=a.createWaveShaper();if(r!==null&&r.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return t(a,c);He(l,c);const u=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(u!==null&&u.length<2)throw e();Ne(l,{curve:u},"curve"),Ne(l,c,"oversample");let h=null,p=!1;return o(l,"curve",_=>()=>_.call(l),_=>m=>(_.call(l,m),p&&(n(m)&&h===null?h=s(a,l):!n(m)&&h!==null&&(h(),h=null)),m)),i(l,()=>{p=!0,n(l.curve)&&(h=s(a,l))},()=>{p=!1,h!==null&&(h(),h=null)})},Qp=(s,e,t,n,i)=>(r,{curve:o,oversample:a,...c})=>{const l=r.createWaveShaper(),u=r.createWaveShaper();He(l,c),He(u,c);const h=t(r,{...c,gain:1}),p=t(r,{...c,gain:-1}),d=t(r,{...c,gain:1}),f=t(r,{...c,gain:-1});let _=null,m=!1,g=null;const y={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(v){h.channelCount=v,p.channelCount=v,l.channelCount=v,d.channelCount=v,u.channelCount=v,f.channelCount=v},get channelCountMode(){return l.channelCountMode},set channelCountMode(v){h.channelCountMode=v,p.channelCountMode=v,l.channelCountMode=v,d.channelCountMode=v,u.channelCountMode=v,f.channelCountMode=v},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(v){h.channelInterpretation=v,p.channelInterpretation=v,l.channelInterpretation=v,d.channelInterpretation=v,u.channelInterpretation=v,f.channelInterpretation=v},get context(){return l.context},get curve(){return g},set curve(v){if(v!==null&&v.length<2)throw e();if(v===null)l.curve=v,u.curve=v;else{const b=v.length,k=new Float32Array(b+2-b%2),T=new Float32Array(b+2-b%2);k[0]=v[0],T[0]=-v[b-1];const R=Math.ceil((b+1)/2),I=(b+1)/2-1;for(let A=1;A<R;A+=1){const D=A/R*I,O=Math.floor(D),N=Math.ceil(D);k[A]=O===N?v[O]:(1-(D-O))*v[O]+(1-(N-D))*v[N],T[A]=O===N?-v[b-1-O]:-((1-(D-O))*v[b-1-O])-(1-(N-D))*v[b-1-N]}k[R]=b%2===1?v[R-1]:(v[R-2]+v[R-1])/2,l.curve=k,u.curve=T}g=v,m&&(n(g)&&_===null?_=s(r,h):_!==null&&(_(),_=null))},get inputs(){return[h]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(v){l.oversample=v,u.oversample=v},addEventListener(...v){return h.addEventListener(v[0],v[1],v[2])},dispatchEvent(...v){return h.dispatchEvent(v[0])},removeEventListener(...v){return h.removeEventListener(v[0],v[1],v[2])}};o!==null&&(y.curve=o instanceof Float32Array?o:new Float32Array(o)),a!==y.oversample&&(y.oversample=a);const x=()=>{h.connect(l).connect(d),h.connect(p).connect(u).connect(f).connect(d),m=!0,n(g)&&(_=s(r,h))},w=()=>{h.disconnect(l),l.disconnect(d),h.disconnect(p),p.disconnect(u),u.disconnect(f),f.disconnect(d),m=!1,_!==null&&(_(),_=null)};return i(mn(y,d),x,w)},bt=()=>new DOMException("","NotSupportedError"),Jp={numberOfChannels:1},ef=(s,e,t,n,i)=>class extends s{constructor(o,a,c){let l;if(typeof o=="number"&&a!==void 0&&c!==void 0)l={length:a,numberOfChannels:o,sampleRate:c};else if(typeof o=="object")l=o;else throw new Error("The given parameters are not valid.");const{length:u,numberOfChannels:h,sampleRate:p}={...Jp,...l},d=n(h,u,p);e(Xn,()=>Xn(d))||d.addEventListener("statechange",(()=>{let f=0;const _=m=>{this._state==="running"&&(f>0?(d.removeEventListener("statechange",_),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):f+=1)};return _})()),super(d,h),this._length=u,this._nativeOfflineAudioContext=d,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state==="running"?Promise.reject(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,pl(this)}))}_waitForThePromiseToSettle(o){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(o):setTimeout(()=>this._waitForThePromiseToSettle(o))}},tf={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},sf=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...tf,...l},p=t(u,h),d=r(u),f=d?n():null,_=c.sampleRate/2;super(c,!1,p,f),this._detune=e(this,d,p.detune,153600,-153600),this._frequency=e(this,d,p.frequency,_,-_),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&h.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=h.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){const l=typeof c=="function"?o(this,c):null;this._nativeOscillatorNode.onended=l;const u=this._nativeOscillatorNode.onended;this._onended=u!==null&&u===l?c:u}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){an(this);const l=()=>{this._nativeOscillatorNode.removeEventListener("ended",l),hs(this)&&si(this)};this._nativeOscillatorNode.addEventListener("ended",l)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}},nf=(s,e,t,n,i)=>()=>{const r=new WeakMap;let o=null,a=null,c=null;const l=async(u,h)=>{let p=t(u);const d=pt(p,h);if(!d){const f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:o===null?void 0:o,type:p.type};p=e(h,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return r.set(h,p),d?(await s(h,u.detune,p.detune),await s(h,u.frequency,p.frequency)):(await n(h,u.detune,p.detune),await n(h,u.frequency,p.frequency)),await i(u,h,p),p};return{set periodicWave(u){o=u},set start(u){a=u},set stop(u){c=u},render(u,h){const p=r.get(h);return p!==void 0?Promise.resolve(p):l(u,h)}}},rf={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},of=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...rf,...l},p=t(u,h),d=r(u),f=d?n():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=e(this,d,p.orientationX,mt,St),this._orientationY=e(this,d,p.orientationY,mt,St),this._orientationZ=e(this,d,p.orientationZ,mt,St),this._positionX=e(this,d,p.positionX,mt,St),this._positionY=e(this,d,p.positionY,mt,St),this._positionZ=e(this,d,p.positionZ,mt,St),o(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}},af=(s,e,t,n,i,r,o,a,c,l)=>()=>{const u=new WeakMap;let h=null;const p=async(d,f)=>{let _=null,m=r(d);const g={channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation},y={...g,coneInnerAngle:m.coneInnerAngle,coneOuterAngle:m.coneOuterAngle,coneOuterGain:m.coneOuterGain,distanceModel:m.distanceModel,maxDistance:m.maxDistance,panningModel:m.panningModel,refDistance:m.refDistance,rolloffFactor:m.rolloffFactor},x=pt(m,f);if("bufferSize"in m)_=n(f,{...g,gain:1});else if(!x){const w={...y,orientationX:m.orientationX.value,orientationY:m.orientationY.value,orientationZ:m.orientationZ.value,positionX:m.positionX.value,positionY:m.positionY.value,positionZ:m.positionZ.value};m=i(f,w)}if(u.set(f,_===null?m:_),_!==null){if(h===null){if(o===null)throw new Error("Missing the native OfflineAudioContext constructor.");const A=new o(6,d.context.length,f.sampleRate),D=e(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});D.connect(A.destination),h=(async()=>{const O=await Promise.all([d.orientationX,d.orientationY,d.orientationZ,d.positionX,d.positionY,d.positionZ].map(async(N,q)=>{const V=t(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:q===0?1:0});return await a(A,N,V.offset),V}));for(let N=0;N<6;N+=1)O[N].connect(D,0,N),O[N].start(0);return l(A)})()}const w=await h,v=n(f,{...g,gain:1});await c(d,f,v);const b=[];for(let A=0;A<w.numberOfChannels;A+=1)b.push(w.getChannelData(A));let k=[b[0][0],b[1][0],b[2][0]],T=[b[3][0],b[4][0],b[5][0]],R=n(f,{...g,gain:1}),I=i(f,{...y,orientationX:k[0],orientationY:k[1],orientationZ:k[2],positionX:T[0],positionY:T[1],positionZ:T[2]});v.connect(R).connect(I.inputs[0]),I.connect(_);for(let A=128;A<w.length;A+=128){const D=[b[0][A],b[1][A],b[2][A]],O=[b[3][A],b[4][A],b[5][A]];if(D.some((N,q)=>N!==k[q])||O.some((N,q)=>N!==T[q])){k=D,T=O;const N=A/f.sampleRate;R.gain.setValueAtTime(0,N),R=n(f,{...g,gain:0}),I=i(f,{...y,orientationX:k[0],orientationY:k[1],orientationZ:k[2],positionX:T[0],positionY:T[1],positionZ:T[2]}),R.gain.setValueAtTime(1,N),v.connect(R).connect(I.inputs[0]),I.connect(_)}}return _}return x?(await s(f,d.orientationX,m.orientationX),await s(f,d.orientationY,m.orientationY),await s(f,d.orientationZ,m.orientationZ),await s(f,d.positionX,m.positionX),await s(f,d.positionY,m.positionY),await s(f,d.positionZ,m.positionZ)):(await a(f,d.orientationX,m.orientationX),await a(f,d.orientationY,m.orientationY),await a(f,d.orientationZ,m.orientationZ),await a(f,d.positionX,m.positionX),await a(f,d.positionY,m.positionY),await a(f,d.positionZ,m.positionZ)),fn(m)?await c(d,f,m.inputs[0]):await c(d,f,m),m};return{render(d,f){const _=u.get(f);return _!==void 0?Promise.resolve(_):p(d,f)}}},cf={disableNormalization:!1},lf=(s,e,t,n)=>class Cl{constructor(r,o){const a=e(r),c=n({...cf,...o}),l=s(a,c);return t.add(l),l}static[Symbol.hasInstance](r){return r!==null&&typeof r=="object"&&Object.getPrototypeOf(r)===Cl.prototype||t.has(r)}},uf=(s,e)=>(t,n,i)=>(s(n).replay(i),e(n,t,i)),hf=(s,e,t)=>async(n,i,r)=>{const o=s(n);await Promise.all(o.activeInputs.map((a,c)=>Array.from(a).map(async([l,u])=>{const p=await e(l).render(l,i),d=n.context.destination;!t(l)&&(n!==d||!t(n))&&p.connect(r,u,c)})).reduce((a,c)=>[...a,...c],[]))},df=(s,e,t)=>async(n,i,r)=>{const o=e(n);await Promise.all(Array.from(o.activeInputs).map(async([a,c])=>{const u=await s(a).render(a,i);t(a)||u.connect(r,c)}))},pf=(s,e,t,n)=>i=>s(Xn,()=>Xn(i))?Promise.resolve(s(n,n)).then(r=>{if(!r){const o=t(i,512,0,1);i.oncomplete=()=>{o.onaudioprocess=null,o.disconnect()},o.onaudioprocess=()=>i.currentTime,o.connect(i.destination)}return i.startRendering()}):new Promise(r=>{const o=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{o.disconnect(),r(a.renderedBuffer)},o.connect(i.destination),i.startRendering()}),ff=s=>(e,t)=>{s.set(e,t)},mf=s=>(e,t)=>s.set(e,t),gf=(s,e,t,n,i,r,o,a)=>(c,l)=>t(c).render(c,l).then(()=>Promise.all(Array.from(n(l)).map(u=>t(u).render(u,l)))).then(()=>i(l)).then(u=>(typeof u.copyFromChannel!="function"?(o(u),Fo(u)):e(r,()=>r(u))||a(u),s.add(u),u)),_f={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},vf=(s,e,t,n,i,r)=>class extends s{constructor(a,c){const l=i(a),u={..._f,...c},h=t(l,u),p=r(l),d=p?n():null;super(a,!1,h,d),this._pan=e(this,p,h.pan)}get pan(){return this._pan}},yf=(s,e,t,n,i)=>()=>{const r=new WeakMap,o=async(a,c)=>{let l=t(a);const u=pt(l,c);if(!u){const h={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,pan:l.pan.value};l=e(c,h)}return r.set(c,l),u?await s(c,a.pan,l.pan):await n(c,a.pan,l.pan),fn(l)?await i(a,c,l.inputs[0]):await i(a,c,l),l};return{render(a,c){const l=r.get(c);return l!==void 0?Promise.resolve(l):o(a,c)}}},bf=s=>()=>{if(s===null)return!1;try{new s({length:1,sampleRate:44100})}catch{return!1}return!0},wf=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createBuffer(1,1,44100);if(t.copyToChannel===void 0)return!0;const n=new Float32Array(2);try{t.copyFromChannel(n,0,0)}catch{return!1}return!0},xf=s=>()=>{if(s===null)return!1;if(s.prototype!==void 0&&s.prototype.close!==void 0)return!0;const e=new s,t=e.close!==void 0;try{e.close()}catch{}return t},Cf=s=>()=>{if(s===null)return Promise.resolve(!1);const e=new s(1,1,44100);return new Promise(t=>{let n=!0;const i=o=>{n&&(n=!1,e.startRendering(),t(o instanceof TypeError))};let r;try{r=e.decodeAudioData(null,()=>{},i)}catch(o){i(o)}r!==void 0&&r.catch(i)})},Sf=s=>()=>{if(s===null)return!1;let e;try{e=new s({latencyHint:"balanced"})}catch{return!1}return e.close(),!0},Tf=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createGain(),n=t.connect(t)===t;return t.disconnect(t),n},kf=(s,e)=>async()=>{if(s===null)return!0;if(e===null)return!1;const t=new Blob(['let c,p;class A extends AudioWorkletProcessor{constructor(){super();this.port.onmessage=(e)=>{p=e.data;p.onmessage=()=>{p.postMessage(c);p.close()};this.port.postMessage(0)}}process(){c=1}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new MessageChannel,i=new e(1,128,44100),r=URL.createObjectURL(t);let o=!1;try{await i.audioWorklet.addModule(r);const a=new s(i,"a",{numberOfOutputs:0}),c=i.createOscillator();await new Promise(l=>{a.port.onmessage=()=>l(),a.port.postMessage(n.port2,[n.port2])}),a.port.onmessage=()=>o=!0,c.connect(a),c.start(0),await i.startRendering(),o=await new Promise(l=>{n.port1.onmessage=({data:u})=>l(u===1),n.port1.postMessage(0)})}catch{}finally{n.port1.close(),URL.revokeObjectURL(r)}return o},Af=(s,e)=>async()=>{if(s===null)return!0;if(e===null)return!1;const t=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new e(1,128,44100),i=URL.createObjectURL(t);let r=!1,o=!1;try{await n.audioWorklet.addModule(i);const a=new s(n,"a",{numberOfOutputs:0}),c=n.createOscillator();a.port.onmessage=()=>r=!0,a.onprocessorerror=()=>o=!0,c.connect(a),c.start(0),await n.startRendering(),await new Promise(l=>setTimeout(l))}catch{}finally{URL.revokeObjectURL(i)}return r&&!o},If=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createChannelMerger();if(t.channelCountMode==="max")return!0;try{t.channelCount=2}catch{return!0}return!1},Df=s=>()=>{if(s===null)return!1;const e=new s(1,1,44100);return e.createConstantSource===void 0?!0:e.createConstantSource().offset.maxValue!==Number.POSITIVE_INFINITY},Rf=s=>()=>{if(s===null)return!1;const e=new s(1,1,44100),t=e.createConvolver();t.buffer=e.createBuffer(1,1,e.sampleRate);try{t.buffer=e.createBuffer(1,1,e.sampleRate)}catch{return!1}return!0},Ef=s=>()=>{if(s===null)return!1;const t=new s(1,1,44100).createConvolver();try{t.channelCount=1}catch{return!1}return!0},Mf=s=>()=>s!==null&&s.hasOwnProperty("isSecureContext"),Of=s=>()=>{if(s===null)return!1;const e=new s;try{return e.createMediaStreamSource(new MediaStream),!1}catch{return!0}finally{e.close()}},Nf=(s,e)=>()=>{if(e===null)return Promise.resolve(!1);const t=new e(1,1,44100),n=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{t.oncomplete=()=>{n.disconnect(),i(t.currentTime!==0)},t.startRendering()})},Ff=s=>()=>{if(s===null)return Promise.resolve(!1);const e=new s(1,1,44100);if(e.createStereoPanner===void 0||e.createConstantSource===void 0)return Promise.resolve(!0);const t=e.createConstantSource(),n=e.createStereoPanner();return t.channelCount=1,t.offset.value=1,n.channelCount=1,t.start(),t.connect(n).connect(e.destination),e.startRendering().then(i=>i.getChannelData(0)[0]!==1)},Vf=()=>new DOMException("","UnknownError"),Pf={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Wf=(s,e,t,n,i,r,o)=>class extends s{constructor(c,l){const u=i(c),h={...Pf,...l},p=t(u,h),f=r(u)?n():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,o(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}},Bf=(s,e,t)=>()=>{const n=new WeakMap,i=async(r,o)=>{let a=e(r);if(!pt(a,o)){const l={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=s(o,l)}return n.set(o,a),fn(a)?await t(r,o,a.inputs[0]):await t(r,o,a),a};return{render(r,o){const a=n.get(o);return a!==void 0?Promise.resolve(a):i(r,o)}}},$f=()=>typeof window>"u"?null:window,qf=(s,e)=>t=>{t.copyFromChannel=(n,i,r=0)=>{const o=s(r),a=s(i);if(a>=t.numberOfChannels)throw e();const c=t.length,l=t.getChannelData(a),u=n.length;for(let h=o<0?-o:0;h+o<c&&h<u;h+=1)n[h]=l[h+o]},t.copyToChannel=(n,i,r=0)=>{const o=s(r),a=s(i);if(a>=t.numberOfChannels)throw e();const c=t.length,l=t.getChannelData(a),u=n.length;for(let h=o<0?-o:0;h+o<c&&h<u;h+=1)l[h+o]=n[h]}},jf=s=>e=>{e.copyFromChannel=(t=>(n,i,r=0)=>{const o=s(r),a=s(i);if(o<e.length)return t.call(e,n,a,o)})(e.copyFromChannel),e.copyToChannel=(t=>(n,i,r=0)=>{const o=s(r),a=s(i);if(o<e.length)return t.call(e,n,a,o)})(e.copyToChannel)},Lf=s=>(e,t)=>{const n=t.createBuffer(1,1,44100);e.buffer===null&&(e.buffer=n),s(e,"buffer",i=>()=>{const r=i.call(e);return r===n?null:r},i=>r=>i.call(e,r===null?n:r))},zf=(s,e)=>(t,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw s()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw s()}});const i=t.createBufferSource();e(n,()=>{const a=n.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(n,0,c)},()=>i.disconnect(n))},Sl=(s,e,t)=>s.copyFromChannel===void 0?s.getChannelData(t)[0]:(s.copyFromChannel(e,t),e[0]),Tl=s=>{if(s===null)return!1;const e=s.length;return e%2!==0?s[Math.floor(e/2)]!==0:s[e/2-1]+s[e/2]!==0},ai=(s,e,t,n)=>{let i=s;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:r,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(s,e,{get:t(r),set:n(o)})},Zf=s=>({...s,outputChannelCount:s.outputChannelCount!==void 0?s.outputChannelCount:s.numberOfInputs===1&&s.numberOfOutputs===1?[s.channelCount]:Array.from({length:s.numberOfOutputs},()=>1)}),Gf=s=>({...s,channelCount:s.numberOfOutputs}),Xf=s=>{const{imag:e,real:t}=s;return e===void 0?t===void 0?{...s,imag:[0,0],real:[0,0]}:{...s,imag:Array.from(t,()=>0),real:t}:t===void 0?{...s,imag:e,real:Array.from(e,()=>0)}:{...s,imag:e,real:t}},kl=(s,e,t)=>{try{s.setValueAtTime(e,t)}catch(n){if(n.code!==9)throw n;kl(s,e,t+1e-7)}},Hf=s=>{const e=s.createBufferSource();e.start();try{e.start()}catch{return!0}return!1},Yf=s=>{const e=s.createBufferSource(),t=s.createBuffer(1,1,44100);e.buffer=t;try{e.start(0,1)}catch{return!1}return!0},Uf=s=>{const e=s.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0},$o=s=>{const e=s.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},Al=s=>{const e=s.createBuffer(1,1,44100),t=s.createBufferSource();t.buffer=e,t.start(),t.stop();try{return t.stop(),!0}catch{return!1}},qo=s=>{const e=s.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},Kf=s=>{const{port1:e,port2:t}=new MessageChannel;try{e.postMessage(s)}finally{e.close(),t.close()}},Qf=()=>{try{new DOMException}catch{return!1}return!0},Jf=()=>new Promise(s=>{const e=new ArrayBuffer(0),{port1:t,port2:n}=new MessageChannel;t.onmessage=({data:i})=>s(i!==null),n.postMessage(e,[e])}),em=s=>{s.start=(e=>(t=0,n=0,i)=>{const r=s.buffer,o=r===null?n:Math.min(r.duration,n);r!==null&&o>r.duration-.5/s.context.sampleRate?e.call(s,t,0,0):e.call(s,t,o,i)})(s.start)},Il=(s,e)=>{const t=e.createGain();s.connect(t);const n=(i=>()=>{i.call(s,t),s.removeEventListener("ended",n)})(s.disconnect);s.addEventListener("ended",n),mn(s,t),s.stop=(i=>{let r=!1;return(o=0)=>{if(r)try{i.call(s,o)}catch{t.gain.setValueAtTime(0,o)}else i.call(s,o),r=!0}})(s.stop)},gn=(s,e)=>t=>{const n={value:s};return Object.defineProperties(t,{currentTarget:n,target:n}),typeof e=="function"?e.call(s,t):e.handleEvent.call(s,t)},tm=ih($s),sm=uh($s),nm=xd(rr),Dl=new WeakMap,im=$d(Dl),qt=Qh(new Map,new WeakMap),Gt=$f(),Rl=_p(qt,ts),jo=Bd(_t),lt=hf(_t,jo,Ws),rm=mh(Rl,Ee,lt),Re=Ld(ir),Qe=zp(Gt),Te=op(Qe),El=new WeakMap,Ml=Md(gn),Cs=wp(Gt),Lo=sp(Cs),zo=np(Gt),Ol=ip(Gt),cn=Cp(Gt),je=$h(rh(ol),lh(tm,sm,Zi,nm,Gi,_t,im,ti,Ee,$s,hs,Ws,Wi),qt,Kd(fo,Gi,_t,Ee,Gn,hs),ts,or,bt,vd(Zi,fo,_t,Ee,Gn,Re,hs,Te),Td(El,_t,Zt),Ml,Re,Lo,zo,Ol,Te,cn),om=fh(je,rm,ts,Rl,Re,Te),Zo=new WeakSet,rc=vp(Gt),Nl=hd(new Uint32Array(1)),Go=qf(Nl,ts),Xo=jf(Nl),Fl=_h(Zo,qt,bt,rc,Qe,bf(rc),Go,Xo),ar=hh(kt),Vl=df(jo,ni,Ws),ss=rd(Vl),_n=bp(ar,qt,Hf,Yf,Uf,$o,Al,qo,em,Lf(ai),Il),ns=uf(qd(ni),Vl),am=bh(ss,_n,Ee,ns,lt),Ht=qh(oh(al),El,No,jh,Qu,Ju,eh,th,sh,uo,il,Cs,kl),cm=yh(je,am,Ht,Je,_n,Re,Te,gn),lm=Dh(je,Rh,ts,Je,xp(kt,ai),Re,Te,lt),um=Kh(ss,wl,Ee,ns,lt),qs=mf(Dl),hm=Uh(je,Ht,um,or,wl,Re,Te,qs),Ds=mp($s,zo),dm=zf(Je,Ds),Rs=Rp(Cs,dm),pm=td(Rs,Ee,lt),fm=ed(je,pm,Rs,Re,Te),mm=id(ri,Ee,lt),gm=nd(je,mm,ri,Re,Te,Gf),_m=Op(ar,_n,kt,Ds),vn=Mp(ar,qt,_m,$o,qo),vm=ud(ss,vn,Ee,ns,lt),ym=ld(je,Ht,vm,vn,Re,Te,gn),Pl=Np(bt,ai),bm=fd(Pl,Ee,lt),wm=pd(je,bm,Pl,Re,Te,qs),xm=wd(ss,xl,Ee,ns,lt),Cm=bd(je,Ht,xm,xl,Re,Te,qs),Wl=Fp(bt),Sm=Dd(ss,Wl,Ee,ns,lt),Tm=Id(je,Ht,Sm,Wl,bt,Re,Te,qs),km=Pd(ss,kt,Ee,ns,lt),Am=Vd(je,Ht,km,kt,Re,Te),Im=Bp(or,Je,oi,bt),cr=pf(qt,kt,oi,Nf(kt,Qe)),Dm=Ud(_n,Ee,Qe,lt,cr),Rm=Vp(Im),Em=Hd(je,Rm,Dm,Re,Te,qs),Mm=Eh(Ht,Rs,vn,oi,bt,Sl,Te,ai),Bl=new WeakMap,Om=fp(lm,Mm,Ml,Te,Bl,gn),$l=Zp(ar,qt,$o,Al,qo,Il),Nm=nf(ss,$l,Ee,ns,lt),Fm=sf(je,Ht,$l,Nm,Re,Te,gn),ql=ad(_n),Vm=Qp(ql,Je,kt,Tl,Ds),lr=Kp(ql,Je,Vm,Tl,Ds,Cs,ai),Pm=Xp(Zi,Je,Rs,kt,oi,lr,bt,Gi,Sl,Ds),jl=Gp(Pm),Wm=af(ss,Rs,vn,kt,jl,Ee,Qe,ns,lt,cr),Bm=of(je,Ht,jl,Wm,Re,Te,qs),$m=Hp(ts),qm=lf($m,Re,new WeakSet,Xf),jm=Up(Rs,ri,kt,lr,bt,Ds),Ll=Yp(jm,bt),Lm=yf(ss,Ll,Ee,ns,lt),zm=vf(je,Ht,Ll,Lm,Re,Te),Zm=Bf(lr,Ee,lt),Gm=Wf(je,Je,lr,Zm,Re,Te,qs),zl=ap(Gt),Ho=Od(Gt),Zl=new WeakMap,Xm=zd(Zl,Qe),Hm=zl?ch(qt,bt,Ed(Gt),Ho,Nd(nh),Re,Xm,Te,cn,new WeakMap,new WeakMap,Af(cn,Qe),Gt):void 0,Ym=rp(Lo,Te),Um=_d(Zo,qt,gd,Rd,new WeakSet,Re,Ym,Li,Xn,Go,Xo),Gl=Hh(Hm,om,Fl,cm,hm,fm,gm,ym,wm,Um,Cm,Tm,Am,Em,Om,Fm,Bm,qm,zm,Gm),Km=lp(je,$p,Re,Te),Qm=hp(je,qp,Re,Te),Jm=dp(je,jp,Re,Te),eg=Lp(Je,Te),tg=pp(je,eg,Re),sg=Ih(Gl,Je,bt,Vf,Km,Qm,Jm,tg,Cs),Yo=Zd(Bl),ng=dh(Yo),Xl=od(ts),ig=Cd(Yo),Hl=kd(ts),Yl=new WeakMap,rg=Wd(Yl,Zt),og=Dp(Xl,ts,Je,Rs,ri,vn,kt,oi,bt,Hl,Ho,rg,Ds),ag=Tp(Je,og,kt,bt,Ds),cg=Xh(ss,Xl,_n,Rs,ri,vn,kt,ig,Hl,Ho,Ee,cn,Qe,ns,lt,cr),lg=jd(Zl),ug=ff(Yl),oc=zl?zh(ng,je,Ht,cg,ag,_t,lg,Re,Te,cn,Zf,ug,Kf,gn):void 0,hg=md(bt,Qe),dg=gf(Zo,qt,jo,Yo,cr,Li,Go,Xo),pg=ef(Gl,qt,Je,hg,dg),fg=Qd(ir,Lo),mg=Jd(Oo,zo),gg=ep(No,Ol),_g=tp(ir,Te),vg=()=>cp(qt,wf(Qe),xf(Cs),Cf(Qe),Sf(Cs),Tf(Qe),kf(cn,Qe),If(Qe),Df(Qe),Rf(Qe),Ef(Qe),Qf,Mf(Gt),Of(Cs),Ff(Qe),Jf);function Tt(s){return s===void 0}function he(s){return s!==void 0}function Ul(s){return typeof s=="function"}function Ot(s){return typeof s=="number"}function ds(s){return Object.prototype.toString.call(s)==="[object Object]"&&s.constructor===Object}function Uo(s){return typeof s=="boolean"}function at(s){return Array.isArray(s)}function Xt(s){return typeof s=="string"}function Ln(s){return Xt(s)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(s)}function K(s,e){if(!s)throw new Error(e)}function Xe(s,e,t=1/0){if(!(e<=s&&s<=t))throw new RangeError(`Value must be within [${e}, ${t}], got: ${s}`)}function Ko(s){!s.isOffline&&s.state!=="running"&&yn('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Kl=!1,ac=!1;function yo(s){Kl=s}function Ql(s){Tt(s)&&Kl&&!ac&&(ac=!0,yn("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}let Qo=console;function yg(s){Qo=s}function Jl(...s){Qo.log(...s)}function yn(...s){Qo.warn(...s)}const bg=Object.freeze(Object.defineProperty({__proto__:null,assert:K,assertContextRunning:Ko,assertRange:Xe,assertUsedScheduleTime:Ql,enterScheduledCallback:yo,log:Jl,setLogger:yg,warn:yn},Symbol.toStringTag,{value:"Module"}));function wg(s){return new sg(s)}function xg(s,e,t){return new pg(s,e,t)}const gt=typeof self=="object"?self:null,Cg=gt&&(gt.hasOwnProperty("AudioContext")||gt.hasOwnProperty("webkitAudioContext"));function Sg(s,e,t){return K(he(oc),"AudioWorkletNode only works in a secure context (https or localhost)"),new(s instanceof gt?.BaseAudioContext?gt?.AudioWorkletNode:oc)(s,e,t)}function Yt(s,e,t,n){var i=arguments.length,r=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(s,e,t,n);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(r=(i<3?o(r):i>3?o(e,t,r):o(e,t))||r);return i>3&&r&&Object.defineProperty(e,t,r),r}function Ae(s,e,t,n){function i(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function a(u){try{l(n.next(u))}catch(h){o(h)}}function c(u){try{l(n.throw(u))}catch(h){o(h)}}function l(u){u.done?r(u.value):i(u.value).then(a,c)}l((n=n.apply(s,e||[])).next())})}class Tg{constructor(e,t,n,i){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=n,this._createClock()}_createWorker(){const e=new Blob([`
4
4
  // the initial timeout time
5
5
  let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
6
6
  // onmessage callback
@@ -15,8 +15,8 @@
15
15
  }
16
16
  // call tick initially
17
17
  tick();
18
- `],{type:"text/javascript"}),t=URL.createObjectURL(e),n=new Worker(t);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch{this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type==="worker"&&((t=this._worker)===null||t===void 0||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}}function Ws(s){return gg(s)}function Ss(s){return mg(s)}function Bi(s){return _g(s)}function Qs(s){return fg(s)}function kg(s){return s instanceof Fl}function Ag(s,e){return s==="value"||Ws(e)||Ss(e)||kg(e)}function Bt(s,...e){if(!e.length)return s;const t=e.shift();if(ps(s)&&ps(t))for(const n in t)Ag(n,t[n])?s[n]=t[n]:ps(t[n])?(s[n]||Object.assign(s,{[n]:{}}),Bt(s[n],t[n])):Object.assign(s,{[n]:t[n]});return Bt(s,...e)}function Ig(s,e){return s.length===e.length&&s.every((t,n)=>e[n]===t)}function F(s,e,t=[],n){const i={},r=Array.from(e);if(ps(r[0])&&n&&!Reflect.has(r[0],n)&&(Object.keys(r[0]).some(a=>Reflect.has(s,a))||(Bt(i,{[n]:r[0]}),t.splice(t.indexOf(n),1),r.shift())),r.length===1&&ps(r[0]))Bt(i,r[0]);else for(let o=0;o<t.length;o++)de(r[o])&&(i[t[o]]=r[o]);return Bt(s,i)}function Dg(s){return s.constructor.getDefaults()}function $t(s,e){return Tt(s)?e:s}function it(s,e){return e.forEach(t=>{Reflect.has(s,t)&&delete s[t]}),s}class gs{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||gt&&this.toString()===gt.TONE_DEBUG_CLASS)&&Jl(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}gs.version=Eo;const Jo=1e-6;function cn(s,e){return s>e+Jo}function bo(s,e){return cn(s,e)||zt(s,e)}function Ui(s,e){return s+Jo<e}function zt(s,e){return Math.abs(s-e)<Jo}function qs(s,e,t){return Math.max(Math.min(s,t),e)}class Et extends gs{constructor(){super(),this.name="Timeline",this._timeline=[];const e=F(Et.getDefaults(),arguments,["memory"]);this.memory=e.memory,this.increasing=e.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(e){if(K(Reflect.has(e,"time"),"Timeline: events must have a time attribute"),e.time=e.time.valueOf(),this.increasing&&this.length){const t=this._timeline[this.length-1];K(bo(e.time,t.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(e)}else{const t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(e){const t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t="time"){const n=this._search(e,t);return n!==-1?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t="time"){const n=this._search(e,t);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(e){const t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];const n=this._search(e);return n-1>=0?this._timeline[n-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0)if(zt(this._timeline[t].time,e)){for(let n=t;n>=0&&zt(this._timeline[n].time,e);n--)t=n;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1);else this._timeline=[]}else this._timeline.length===1&&bo(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){const t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){const t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t="time"){if(this._timeline.length===0)return-1;let n=0;const i=this._timeline.length;let r=i;if(i>0&&this._timeline[i-1][t]<=e)return i-1;for(;n<r;){let o=Math.floor(n+(r-n)/2);const a=this._timeline[o],c=this._timeline[o+1];if(zt(a[t],e)){for(let l=o;l<this._timeline.length;l++){const u=this._timeline[l];if(zt(u[t],e))o=l;else break}return o}else{if(Ui(a[t],e)&&cn(c[t],e))return o;cn(a[t],e)?r=o:n=o+1}}return-1}_iterate(e,t=0,n=this._timeline.length-1){this._timeline.slice(t,n+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){const n=this._search(e);return n!==-1&&this._iterate(t,0,n),this}forEachAfter(e,t){const n=this._search(e);return this._iterate(t,n+1),this}forEachBetween(e,t,n){let i=this._search(e),r=this._search(t);return i!==-1&&r!==-1?(this._timeline[i].time!==e&&(i+=1),this._timeline[r].time===t&&(r-=1),this._iterate(n,i,r)):i===-1&&this._iterate(n,0,r),this}forEachFrom(e,t){let n=this._search(e);for(;n>=0&&this._timeline[n].time>=e;)n--;return this._iterate(t,n+1),this}forEachAtTime(e,t){const n=this._search(e);if(n!==-1&&zt(this._timeline[n].time,e)){let i=n;for(let r=n;r>=0&&zt(this._timeline[r].time,e);r--)i=r;this._iterate(r=>{t(r)},i,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const eu=[];function ur(s){eu.push(s)}function Rg(s){eu.forEach(e=>e(s))}const tu=[];function hr(s){tu.push(s)}function Eg(s){tu.forEach(e=>e(s))}class yn extends gs{constructor(){super(...arguments),this.name="Emitter"}on(e,t){return e.split(/\W+/).forEach(i=>{Tt(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(t)}),this}once(e,t){const n=(...i)=>{t(...i),this.off(e,n)};return this.on(e,n),this}off(e,t){return e.split(/\W+/).forEach(i=>{if(Tt(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Tt(t))this._events[i]=[];else{const r=this._events[i];for(let o=r.length-1;o>=0;o--)r[o]===t&&r.splice(o,1)}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){const n=this._events[e].slice(0);for(let i=0,r=n.length;i<r;i++)n[i].apply(this,t)}return this}static mixin(e){["on","once","off","emit"].forEach(t=>{const n=Object.getOwnPropertyDescriptor(yn.prototype,t);Object.defineProperty(e.prototype,t,n)})}dispose(){return super.dispose(),this._events=void 0,this}}class ea extends yn{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}class js extends ea{constructor(){var e,t;super(),this.name="Context",this._constants=new Map,this._timeouts=new Et,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;const n=F(js.getDefaults(),arguments,["context"]);n.context?(this._context=n.context,this._latencyHint=((e=arguments[0])===null||e===void 0?void 0:e.latencyHint)||""):(this._context=wg({latencyHint:n.latencyHint}),this._latencyHint=n.latencyHint),this._ticker=new Tg(this.emit.bind(this,"tick"),n.clockSource,n.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((t=arguments[0])===null||t===void 0)&&t.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=n.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Rg(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(e,t,n){return this._context.createBuffer(e,t,n)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,n){return this._context.createPeriodicWave(e,t,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(e){return K(Qs(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return K(Qs(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return K(Qs(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(e){K(!this._initialized,"The listener cannot be set after initialization."),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){K(!this._initialized,"The transport cannot be set after initialization."),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){K(!this._initialized,"Draw cannot be set after initialization."),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){K(!this._initialized,"The destination cannot be set after initialization."),this._destination=e}createAudioWorkletNode(e,t){return Sg(this.rawContext,e,t)}addAudioWorkletModule(e){return ke(this,void 0,void 0,function*(){K(de(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(e)),yield this._workletPromise})}workletsAreReady(){return ke(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return Qs(this._context)?this._context.resume():Promise.resolve()}close(){return ke(this,void 0,void 0,function*(){Qs(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Eg(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{const t=this._context.createBuffer(1,128,this._context.sampleRate),n=t.getChannelData(0);for(let r=0;r<n.length;r++)n[r]=e;const i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=t,i.loop=!0,i.start(0),this._constants.set(e,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){const e=this.now();this._timeouts.forEachBefore(e,t=>{t.callback(),this._timeouts.remove(t)})}setTimeout(e,t){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:n+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){const n=++this._timeoutIds,i=()=>{const r=this.now();this._timeouts.add({callback:()=>{e(),i()},id:n,time:r+t})};return i(),n}}class Mg extends ea{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,n){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return ke(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}}function ne(s,e){ot(e)?e.forEach(t=>ne(s,t)):Object.defineProperty(s,e,{enumerable:!0,writable:!1})}function ci(s,e){ot(e)?e.forEach(t=>ci(s,t)):Object.defineProperty(s,e,{writable:!0})}const _e=()=>{};class xe extends gs{constructor(){super(),this.name="ToneAudioBuffer",this.onload=_e;const e=F(xe.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=e.reverse,this.onload=e.onload,Xt(e.url)?this.load(e.url).catch(e.onerror):e.url&&this.set(e.url)}static getDefaults(){return{onerror:_e,onload:_e,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:me().sampleRate}set(e){return e instanceof xe?e.loaded?this._buffer=e.get():e.onload=()=>{this.set(e),this.onload(this)}:this._buffer=e,this._reversed&&this._reverse(),this}get(){return this._buffer}load(e){return ke(this,void 0,void 0,function*(){const t=xe.load(e).then(n=>{this.set(n),this.onload(this)});xe.downloads.push(t);try{yield t}finally{const n=xe.downloads.indexOf(t);xe.downloads.splice(n,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){const t=ot(e)&&e[0].length>0,n=t?e.length:1,i=t?e[0].length:e.length,r=me(),o=r.createBuffer(n,i,r.sampleRate),a=!t&&n===1?[e]:e;for(let c=0;c<n;c++)o.copyToChannel(a[c],c);return this._buffer=o,this}toMono(e){if(Ot(e))this.fromArray(this.toArray(e));else{let t=new Float32Array(this.length);const n=this.numberOfChannels;for(let i=0;i<n;i++){const r=this.toArray(i);for(let o=0;o<r.length;o++)t[o]+=r[o]}t=t.map(i=>i/n),this.fromArray(t)}return this}toArray(e){if(Ot(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{const t=[];for(let n=0;n<this.numberOfChannels;n++)t[n]=this.getChannelData(n);return t}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array(0)}slice(e,t=this.duration){K(this.loaded,"Buffer is not loaded");const n=Math.floor(e*this.sampleRate),i=Math.floor(t*this.sampleRate);K(n<i,"The start time must be less than the end time");const r=i-n,o=me().createBuffer(this.numberOfChannels,r,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)o.copyToChannel(this.getChannelData(a).subarray(n,i),a);return new xe(o)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(e){return new xe().fromArray(e)}static fromUrl(e){return ke(this,void 0,void 0,function*(){return yield new xe().load(e)})}static load(e){return ke(this,void 0,void 0,function*(){const t=xe.baseUrl===""||xe.baseUrl.endsWith("/")?xe.baseUrl:xe.baseUrl+"/",n=yield fetch(t+e);if(!n.ok)throw new Error(`could not load url: ${e}`);const i=yield n.arrayBuffer();return yield me().decodeAudioData(i)})}static supportsType(e){const t=e.split("."),n=t[t.length-1];return document.createElement("audio").canPlayType("audio/"+n)!==""}static loaded(){return ke(this,void 0,void 0,function*(){for(yield Promise.resolve();xe.downloads.length;)yield xe.downloads[0]})}}xe.baseUrl="";xe.downloads=[];class bn extends js{constructor(){super({clockSource:"offline",context:Bi(arguments[0])?arguments[0]:xg(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Bi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Bi(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return ke(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,t++;const n=Math.floor(this.sampleRate/128);e&&t%n===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return ke(this,arguments,void 0,function*(e=!0){yield this.workletsAreReady(),yield this._renderClock(e);const t=yield this._context.startRendering();return new xe(t)})}close(){return Promise.resolve()}}const su=new Mg;let Fs=su;function me(){return Fs===su&&Cg&&Hn(new js),Fs}function Hn(s,e=!1){e&&Fs.dispose(),Qs(s)?Fs=new js(s):Bi(s)?Fs=new bn(s):Fs=s}function ta(){return Fs.resume()}if(gt&&!gt.TONE_SILENCE_LOGGING){const e=` * Tone.js v${Eo} * `;console.log(`%c${e}`,"background: #000; color: #fff")}function ln(s){return Math.pow(10,s/20)}function li(s){return 20*(Math.log(s)/Math.LN10)}function un(s){return Math.pow(2,s/12)}let dr=440;function Og(){return dr}function Ng(s){dr=s}function xs(s){return Math.round(nu(s))}function nu(s){return 69+12*Math.log2(s/dr)}function sa(s){return dr*Math.pow(2,(s-69)/12)}class na extends gs{constructor(e,t,n){super(),this.defaultUnits="s",this._val=t,this._units=n,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{const n=parseInt(e,10),i=t==="."?1.5:1;return n===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/n)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{const t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,n)=>{let i=0;return e&&e!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i+=this._beatsToUnits(parseFloat(t))),n&&n!=="0"&&(i+=this._beatsToUnits(parseFloat(n)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof na&&this.fromType(this._val),Tt(this._val))return this._noArg();if(Xt(this._val)&&Tt(this._units)){for(const e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(ps(this._val)){let e=0;for(const t in this._val)if(de(this._val[t])){const n=this._val[t],i=new this.constructor(this.context,t).valueOf()*n;e+=i}return e}if(de(this._units)){const e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}else return Xt(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(e){switch(this._units=void 0,this.defaultUnits){case"s":this._val=e.toSeconds();break;case"i":this._val=e.toTicks();break;case"hz":this._val=e.toFrequency();break;case"midi":this._val=e.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}}class Dt extends na{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:e=>{const t=new Dt(this.context,e).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(t))},regexp:/^@(.+)/}})}quantize(e,t=1){const n=new this.constructor(this.context,e).valueOf(),i=this.valueOf(),a=Math.round(i/n)*n-i;return i+a*t}toNotation(){const e=this.toSeconds(),t=["1m"];for(let r=1;r<9;r++){const o=Math.pow(2,r);t.push(o+"n."),t.push(o+"n"),t.push(o+"t")}t.push("0");let n=t[0],i=new Dt(this.context,t[0]).toSeconds();return t.forEach(r=>{const o=new Dt(this.context,r).toSeconds();Math.abs(o-e)<Math.abs(i-e)&&(n=r,i=o)}),n}toBarsBeatsSixteenths(){const e=this._beatsToUnits(1);let t=this.valueOf()/e;t=parseFloat(t.toFixed(4));const n=Math.floor(t/this._getTimeSignature());let i=t%1*4;t=Math.floor(t)%this._getTimeSignature();const r=i.toString();return r.length>3&&(i=parseFloat(parseFloat(r).toFixed(3))),[n,t,i].join(":")}toTicks(){const e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return xs(this.toFrequency())}_now(){return this.context.now()}}function Fg(s,e){return new Dt(me(),s,e)}class vt extends Dt{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Og()}static set A4(e){Ng(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(e){return this.defaultUnits==="midi"?e:vt.mtof(e)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(e,t){const i=Vg[e.toLowerCase()]+(parseInt(t,10)+1)*12;return this.defaultUnits==="midi"?i:vt.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,n){let i=1;return e&&e!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i*=this._beatsToUnits(parseFloat(t))),n&&n!=="0"&&(i*=this._beatsToUnits(parseFloat(n)/4)),i}}})}transpose(e){return new vt(this.context,this.valueOf()*un(e))}harmonize(e){return e.map(t=>this.transpose(t))}toMidi(){return xs(this.valueOf())}toNote(){const e=this.toFrequency(),t=Math.log2(e/vt.A4);let n=Math.round(12*t)+57;const i=Math.floor(n/12);return i<0&&(n+=-12*i),Pg[n%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return sa(e)}static ftom(e){return xs(e)}}const Vg={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},Pg=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function Wg(s,e){return new vt(me(),s,e)}class Xe extends Dt{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}function Bg(s,e){return new Xe(me(),s,e)}class nt extends gs{constructor(){super();const e=F(nt.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=e.context}static getDefaults(){return{context:me()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(e){return Ql(e),new Dt(this.context,e).toSeconds()}toFrequency(e){return new vt(this.context,e).toFrequency()}toTicks(e){return new Xe(this.context,e).toTicks()}_getPartialProperties(e){const t=this.get();return Object.keys(t).forEach(n=>{Tt(e[n])&&delete t[n]}),t}get(){const e=Dg(this);return Object.keys(e).forEach(t=>{if(Reflect.has(this,t)){const n=this[t];de(n)&&de(n.value)&&de(n.setValueAtTime)?e[t]=n.value:n instanceof nt?e[t]=n._getPartialProperties(e[t]):ot(n)||Ot(n)||Xt(n)||Uo(n)?e[t]=n:delete e[t]}}),e}set(e){return Object.keys(e).forEach(t=>{Reflect.has(this,t)&&de(this[t])&&(this[t]&&de(this[t].value)&&de(this[t].setValueAtTime)?this[t].value!==e[t]&&(this[t].value=e[t]):this[t]instanceof nt?this[t].set(e[t]):this[t]=e[t])}),this}}class wn extends Et{constructor(e="stopped"){super(),this.name="StateTimeline",this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){const t=this.get(e);return t!==null?t.state:this._initial}setStateAtTime(e,t,n){return Ye(t,0),this.add(Object.assign({},n,{state:e,time:t})),this}getLastState(e,t){const n=this._search(t);for(let i=n;i>=0;i--){const r=this._timeline[i];if(r.state===e)return r}}getNextState(e,t){const n=this._search(t);if(n!==-1)for(let i=n;i<this._timeline.length;i++){const r=this._timeline[i];if(r.state===e)return r}}}class ae extends nt{constructor(){const e=F(ae.getDefaults(),arguments,["param","units","convert"]);for(super(e),this.name="Param",this.overridden=!1,this._minOutput=1e-7,K(de(e.param)&&(Ws(e.param)||e.param instanceof ae),"param must be an AudioParam");!Ws(e.param);)e.param=e.param._param;this._swappable=de(e.swappable)?e.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=e.param,this.input.connect(this._param)):this._param=this.input=e.param,this._events=new Et(1e3),this._initialValue=this._param.defaultValue,this.units=e.units,this.convert=e.convert,this._minValue=e.minValue,this._maxValue=e.maxValue,de(e.value)&&e.value!==this._toType(this._initialValue)&&this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(nt.getDefaults(),{convert:!0,units:"number"})}get value(){const e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return de(this._minValue)?this._minValue:this.units==="time"||this.units==="frequency"||this.units==="normalRange"||this.units==="positive"||this.units==="transportTime"||this.units==="ticks"||this.units==="bpm"||this.units==="hertz"||this.units==="samples"?0:this.units==="audioRange"?-1:this.units==="decibels"?-1/0:this._param.minValue}get maxValue(){return de(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return de(this.maxValue)&&de(this.minValue)&&Ye(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,"time")?this.toSeconds(e):this._is(e,"decibels")?ln(e):this._is(e,"frequency")?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units==="decibels"?li(e):e}setValueAtTime(e,t){const n=this.toSeconds(t),i=this._fromType(e);return K(isFinite(i)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",e,n),this._events.add({time:n,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,n),this}getValueAtTime(e){const t=Math.max(this.toSeconds(e),0),n=this._events.getAfter(t),i=this._events.get(t);let r=this._initialValue;if(i===null)r=this._initialValue;else if(i.type==="setTargetAtTime"&&(n===null||n.type==="setValueAtTime")){const o=this._events.getBefore(i.time);let a;o===null?a=this._initialValue:a=o.value,i.type==="setTargetAtTime"&&(r=this._exponentialApproach(i.time,a,i.value,i.constant,t))}else if(n===null)r=i.value;else if(n.type==="linearRampToValueAtTime"||n.type==="exponentialRampToValueAtTime"){let o=i.value;if(i.type==="setTargetAtTime"){const a=this._events.getBefore(i.time);a===null?o=this._initialValue:o=a.value}n.type==="linearRampToValueAtTime"?r=this._linearInterpolate(i.time,o,n.time,n.value,t):r=this._exponentialInterpolate(i.time,o,n.time,n.value,t)}else r=i.value;return this._toType(r)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){const n=this._fromType(e),i=this.toSeconds(t);return K(isFinite(n)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(n),this._events.add({time:i,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",e,i),this._param.linearRampToValueAtTime(n,i),this}exponentialRampToValueAtTime(e,t){let n=this._fromType(e);n=zt(n,0)?this._minOutput:n,this._assertRange(n);const i=this.toSeconds(t);return K(isFinite(n)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",e,i),this._param.exponentialRampToValueAtTime(n,i),this}exponentialRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(e,n+this.toSeconds(t)),this}linearRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(e,n+this.toSeconds(t)),this}targetRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(e,n,t),this}exponentialApproachValueAtTime(e,t,n){t=this.toSeconds(t),n=this.toSeconds(n);const i=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(e,t,i),this.cancelAndHoldAtTime(t+n*.9),this.linearRampToValueAtTime(e,t+n),this}setTargetAtTime(e,t,n){const i=this._fromType(e);K(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const r=this.toSeconds(t);return this._assertRange(i),K(isFinite(i)&&isFinite(r),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:n,time:r,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",e,r,n),this._param.setTargetAtTime(i,r,n),this}setValueCurveAtTime(e,t,n,i=1){n=this.toSeconds(n),t=this.toSeconds(t);const r=this._fromType(e[0])*i;this.setValueAtTime(this._toType(r),t);const o=n/(e.length-1);for(let a=1;a<e.length;a++){const c=this._fromType(e[a])*i;this.linearRampToValueAtTime(this._toType(c),t+a*o)}return this}cancelScheduledValues(e){const t=this.toSeconds(e);return K(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,"cancelScheduledValues",t),this}cancelAndHoldAtTime(e){const t=this.toSeconds(e),n=this._fromType(this.getValueAtTime(t));K(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,"cancelAndHoldAtTime",t,"value="+n);const i=this._events.get(t),r=this._events.getAfter(t);return i&&zt(i.time,t)?r?(this._param.cancelScheduledValues(r.time),this._events.cancel(r.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):r&&(this._param.cancelScheduledValues(r.time),this._events.cancel(r.time),r.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(n),t):r.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(n),t)),this._events.add({time:t,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,t),this}rampTo(e,t=.1,n){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(e,t,n):this.linearRampTo(e,t,n),this}apply(e){const t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);const n=this._events.get(t);if(n&&n.type==="setTargetAtTime"){const i=this._events.getAfter(n.time),r=i?i.time:t+2,o=(r-t)/10;for(let a=t;a<r;a+=o)e.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?e.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?e.setTargetAtTime(i.value,i.time,i.constant):e[i.type](i.value,i.time)}),this}setParam(e){K(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,n,i,r){return n+(t-n)*Math.exp(-(r-e)/i)}_linearInterpolate(e,t,n,i,r){return t+(i-t)*((r-e)/(n-e))}_exponentialInterpolate(e,t,n,i,r){return t*Math.pow(i/t,(r-e)/(n-e))}}class $ extends nt{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return de(this.input)?Ws(this.input)||this.input instanceof ae?1:this.input.numberOfInputs:0}get numberOfOutputs(){return de(this.output)?this.output.numberOfOutputs:0}_isAudioNode(e){return de(e)&&(e instanceof $||Ss(e))}_getInternalNodes(){const e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(n=>{n.channelCount=e.channelCount,n.channelCountMode=e.channelCountMode,n.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){const e=this._getInternalNodes();K(e.length>0,"ToneAudioNode does not have any internal nodes");const t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,n=0){return pt(this,e,t,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return vn("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(e,t=0,n=0){return ia(this,e,t,n),this}chain(...e){return Nt(this,...e),this}fan(...e){return e.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),de(this.input)&&(this.input instanceof $?this.input.dispose():Ss(this.input)&&this.input.disconnect()),de(this.output)&&(this.output instanceof $?this.output.dispose():Ss(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function Nt(...s){const e=s.shift();s.reduce((t,n)=>(t instanceof $?t.connect(n):Ss(t)&&pt(t,n),n),e)}function pt(s,e,t=0,n=0){for(K(de(s),"Cannot connect from undefined node"),K(de(e),"Cannot connect to undefined node"),(e instanceof $||Ss(e))&&K(e.numberOfInputs>0,"Cannot connect to node with no inputs"),K(s.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof $||e instanceof ae;)de(e.input)&&(e=e.input);for(;s instanceof $;)de(s.output)&&(s=s.output);Ws(e)?s.connect(e,t):s.connect(e,t,n)}function ia(s,e,t=0,n=0){if(de(e))for(;e instanceof $;)e=e.input;for(;!Ss(s);)de(s.output)&&(s=s.output);Ws(e)?s.disconnect(e,t):Ss(e)?s.disconnect(e,t,n):s.disconnect()}function $g(...s){const e=s.pop();de(e)&&s.forEach(t=>pt(t,e))}class Y extends ${constructor(){const e=F(Y.getDefaults(),arguments,["gain","units"]);super(e),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new ae({context:this.context,convert:e.convert,param:this._gainNode.gain,units:e.units,value:e.gain,minValue:e.minValue,maxValue:e.maxValue}),ne(this,"gain")}static getDefaults(){return Object.assign($.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class hn extends ${constructor(e){super(e),this.onended=_e,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Y({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const n=this.toSeconds(t);return this._startTime!==-1&&n>=this._startTime&&(this._stopTime===-1||n<=this._stopTime)?"started":"stopped"},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign($.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:_e})}_startGain(e,t=1){K(this._startTime===-1,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=e+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(t,e+n):this._gainNode.gain.exponentialApproachValueAtTime(t,e,n)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log("stop",e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){K(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();const t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{const n=this._curve==="exponential"?t*2:0;this._stopSource(this.now()+n),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==_e&&(this.onended(this),this.onended=_e,!this.context.isOffline)){const e=()=>this.dispose();typeof requestIdleCallback<"u"?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),K(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=_e,this}}class pr extends hn{constructor(){const e=F(pr.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),pt(this._source,this._gainNode),this.offset=new ae({context:this.context,convert:e.convert,param:this._source.offset,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(hn.getDefaults(),{convert:!0,offset:1,units:"number"})}start(e){const t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}}class re extends ${constructor(){const e=F(re.getDefaults(),arguments,["value","units"]);super(e),this.name="Signal",this.override=!0,this.output=this._constantSource=new pr({context:this.context,convert:e.convert,offset:e.value,units:e.units,minValue:e.minValue,maxValue:e.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign($.getDefaults(),{convert:!0,units:"number",value:0})}connect(e,t=0,n=0){return ui(this,e,t,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,n){return this._param.exponentialRampTo(e,t,n),this}linearRampTo(e,t,n){return this._param.linearRampTo(e,t,n),this}targetRampTo(e,t,n){return this._param.targetRampTo(e,t,n),this}exponentialApproachValueAtTime(e,t,n){return this._param.exponentialApproachValueAtTime(e,t,n),this}setTargetAtTime(e,t,n){return this._param.setTargetAtTime(e,t,n),this}setValueCurveAtTime(e,t,n,i){return this._param.setValueCurveAtTime(e,t,n,i),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,n){return this._param.rampTo(e,t,n),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}}function ui(s,e,t,n){(e instanceof ae||Ws(e)||e instanceof re&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof re&&(e.overridden=!0)),pt(s,e,t,n)}class ra extends ae{constructor(){const e=F(ra.getDefaults(),arguments,["value"]);super(e),this.name="TickParam",this._events=new Et(1/0),this._multiplier=1,this._multiplier=e.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(e.value)}),this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(ae.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(e,t,n){t=this.toSeconds(t),this.setRampPoint(t);const i=this._fromType(e),r=this._events.get(t),o=Math.round(Math.max(1/n,1));for(let a=0;a<=o;a++){const c=n*a+t,l=this._exponentialApproach(r.time,r.value,i,n,c);this.linearRampToValueAtTime(this._toType(l),c)}return this}setValueAtTime(e,t){const n=this.toSeconds(t);super.setValueAtTime(e,t);const i=this._events.get(n),r=this._events.previousEvent(i),o=this._getTicksUntilEvent(r,n);return i.ticks=Math.max(o,0),this}linearRampToValueAtTime(e,t){const n=this.toSeconds(t);super.linearRampToValueAtTime(e,t);const i=this._events.get(n),r=this._events.previousEvent(i),o=this._getTicksUntilEvent(r,n);return i.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);const n=this._fromType(e),i=this._events.get(t),r=Math.round(Math.max((t-i.time)*10,1)),o=(t-i.time)/r;for(let a=0;a<=r;a++){const c=o*a+i.time,l=this._exponentialInterpolate(i.time,i.value,t,n,c);this.linearRampToValueAtTime(this._toType(l),c)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Tt(e.ticks)){const o=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(o,e.time)}const n=this._fromType(this.getValueAtTime(e.time));let i=this._fromType(this.getValueAtTime(t));const r=this._events.get(t);return r&&r.time===t&&r.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(n+i)+e.ticks}getTicksAtTime(e){const t=this.toSeconds(e),n=this._events.get(t);return Math.max(this._getTicksUntilEvent(n,t),0)}getDurationOfTicks(e,t){const n=this.toSeconds(t),i=this.getTicksAtTime(t);return this.getTimeOfTick(i+e)-n}getTimeOfTick(e){const t=this._events.get(e,"ticks"),n=this._events.getAfter(e,"ticks");if(t&&t.ticks===e)return t.time;if(t&&n&&n.type==="linearRampToValueAtTime"&&t.value!==n.value){const i=this._fromType(this.getValueAtTime(t.time)),o=(this._fromType(this.getValueAtTime(n.time))-i)/(n.time-t.time),a=Math.sqrt(Math.pow(i,2)-2*o*(t.ticks-e)),c=(-i+a)/o,l=(-i-a)/o;return(c>0?c:l)+t.time}else return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){const n=this.toSeconds(t),i=this.toSeconds(e),r=this.getTicksAtTime(n);return this.getTicksAtTime(n+i)-r}_fromType(e){return this.units==="bpm"&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units==="bpm"&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){const t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}}class oa extends re{constructor(){const e=F(oa.getDefaults(),arguments,["value"]);super(e),this.name="TickSignal",this.input=this._param=new ra({context:this.context,convert:e.convert,multiplier:e.multiplier,param:this._constantSource.offset,units:e.units,value:e.value})}static getDefaults(){return Object.assign(re.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}}class aa extends nt{constructor(){const e=F(aa.getDefaults(),arguments,["frequency"]);super(e),this.name="TickSource",this._state=new wn,this._tickOffset=new Et,this._ticksAtTime=new Et,this._secondsAtTime=new Et,this.frequency=new oa({context:this.context,units:e.units,value:e.frequency}),ne(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},nt.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){const n=this.toSeconds(e);return this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),de(t)&&this.setTicksAtTime(t,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),this}stop(e){const t=this.toSeconds(e);if(this._state.getValueAtTime(t)==="stopped"){const n=this._state.get(t);n&&n.time>0&&(this._tickOffset.cancel(n.time),this._state.cancel(n.time))}return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){const t=this.toSeconds(e),n=this._state.getLastState("stopped",t),i=this._ticksAtTime.get(t),r={state:"paused",time:t};this._state.add(r);let o=i||n,a=i?i.ticks:0,c=null;return this._state.forEachBetween(o.time,t+this.sampleTime,l=>{let u=o.time;const h=this._tickOffset.get(l.time);h&&h.time>=o.time&&(a=h.ticks,u=h.time),o.state==="started"&&l.state!=="started"&&(a+=this.frequency.getTicksAtTime(l.time)-this.frequency.getTicksAtTime(u),l.time!==r.time&&(c={state:l.state,time:l.time,ticks:a})),o=l}),this._state.remove(r),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){const t=this.now(),n=this.frequency.timeToTicks(e,t);this.setTicksAtTime(n,t)}getSecondsAtTime(e){e=this.toSeconds(e);const t=this._state.getLastState("stopped",e),n={state:"paused",time:e};this._state.add(n);const i=this._secondsAtTime.get(e);let r=i||t,o=i?i.seconds:0,a=null;return this._state.forEachBetween(r.time,e+this.sampleTime,c=>{let l=r.time;const u=this._tickOffset.get(c.time);u&&u.time>=r.time&&(o=u.seconds,l=u.time),r.state==="started"&&c.state!=="started"&&(o+=c.time-l,c.time!==n.time&&(a={state:c.state,time:c.time,seconds:o})),r=c}),this._state.remove(n),a&&this._secondsAtTime.add(a),o}setTicksAtTime(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){const n=this._tickOffset.get(t),i=this._state.get(t),r=Math.max(n.time,i.time),o=this.frequency.getTicksAtTime(r)+e-n.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(e,t,n){let i=this._state.get(e);this._state.forEachBetween(e,t,o=>{i&&i.state==="started"&&o.state!=="started"&&this.forEachTickBetween(Math.max(i.time,e),o.time-this.sampleTime,n),i=o});let r=null;if(i&&i.state==="started"){const o=Math.max(i.time,e),a=this.frequency.getTicksAtTime(o),c=this.frequency.getTicksAtTime(i.time),l=a-c;let u=Math.ceil(l)-l;u=zt(u,1)?0:u;let h=this.frequency.getTimeOfTick(a+u);for(;h<t;){try{n(h,Math.round(this.getTicksAtTime(h)))}catch(p){r=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(r)throw r;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}}class xn extends nt{constructor(){const e=F(xn.getDefaults(),arguments,["callback","frequency"]);super(e),this.name="Clock",this.callback=_e,this._lastUpdate=0,this._state=new wn("stopped"),this._boundLoop=this._loop.bind(this),this.callback=e.callback,this._tickSource=new aa({context:this.context,frequency:e.frequency,units:e.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,ne(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(nt.getDefaults(),{callback:_e,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){Ko(this.context);const n=this.toSeconds(e);return this.log("start",n),this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,t),n<this._lastUpdate&&this.emit("start",n,t)),this}stop(e){const t=this.toSeconds(e);return this.log("stop",t),this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit("stop",t),this}pause(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit("pause",t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){const n=this.toSeconds(t),i=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(i+e,n)}_loop(){const e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log("loop",e,t),e!==t&&(this._state.forEachBetween(e,t,n=>{switch(n.state){case"started":const i=this._tickSource.getTicksAtTime(n.time);this.emit("start",n.time,i);break;case"stopped":n.time!==0&&this.emit("stop",n.time);break;case"paused":this.emit("pause",n.time);break}}),this._tickSource.forEachTickBetween(e,t,(n,i)=>{this.callback(n,i)}))}getStateAtTime(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}yn.mixin(xn);class Mt extends ${constructor(){const e=F(Mt.getDefaults(),arguments,["delayTime","maxDelay"]);super(e),this.name="Delay";const t=this.toSeconds(e.maxDelay);this._maxDelay=Math.max(t,this.toSeconds(e.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(t),this.delayTime=new ae({context:this.context,param:this._delayNode.delayTime,units:"time",value:e.delayTime,minValue:0,maxValue:this.maxDelay}),ne(this,"delayTime")}static getDefaults(){return Object.assign($.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}}class Ut extends ${constructor(){const e=F(Ut.getDefaults(),arguments,["volume"]);super(e),this.name="Volume",this.input=this.output=new Y({context:this.context,gain:e.volume,units:"decibels"}),this.volume=this.output.gain,ne(this,"volume"),this._unmutedVolume=e.volume,this.mute=e.mute}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class ca extends ${constructor(){const e=F(ca.getDefaults(),arguments);super(e),this.name="Destination",this.input=new Ut({context:this.context}),this.output=new Y({context:this.context}),this.volume=this.input.volume,Nt(this.input,this.output,this.context.rawContext.destination),this.mute=e.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),Nt(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}ur(s=>{s.destination=new ca({context:s})});hr(s=>{s.destination.dispose()});class qg extends ${constructor(){super(...arguments),this.name="Listener",this.positionX=new ae({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ae({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ae({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ae({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ae({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ae({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ae({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ae({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ae({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign($.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}}ur(s=>{s.listener=new qg({context:s})});hr(s=>{s.listener.dispose()});function jg(s,e){return ke(this,arguments,void 0,function*(t,n,i=2,r=me().sampleRate){const o=me(),a=new bn(i,n,r);Hn(a),yield t(a);const c=a.render();Hn(o);const l=yield c;return new xe(l)})}class Cn extends gs{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const e=F(Cn.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=e.baseUrl,Object.keys(e.urls).forEach(t=>{this._loadingCount++;const n=e.urls[t];this.add(t,n,this._bufferLoaded.bind(this,e.onload),e.onerror)})}static getDefaults(){return{baseUrl:"",onerror:_e,onload:_e,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return K(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,n=_e,i=_e){return Xt(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(e.toString(),new xe(this.baseUrl+t,n,i))):this._buffers.set(e.toString(),new xe(t,n,i)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}}class dn extends vt{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(e){return xs(super._frequencyToUnits(e))}_ticksToUnits(e){return xs(super._ticksToUnits(e))}_beatsToUnits(e){return xs(super._beatsToUnits(e))}_secondsToUnits(e){return xs(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return sa(this.toMidi())}transpose(e){return new dn(this.context,this.toMidi()+e)}}function Lg(s,e){return new dn(me(),s,e)}class Oe extends Xe{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}function zg(s,e){return new Oe(me(),s,e)}class Zg extends nt{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Et,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){const e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}ur(s=>{s.draw=new Zg({context:s})});hr(s=>{s.draw.dispose()});class iu extends gs{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(e){K(de(e.time),"Events must have a time property"),K(de(e.duration),"Events must have a duration parameter"),e.time=e.time.valueOf();let t=new Gg(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){const t=[];this._root.search(e.time,t);for(const n of t)if(n.event===e){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,t=>this.remove(t)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent!==null?(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent)):this._setRoot(t)}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{const t=e.getBalance();let n,i=null;if(t>0)if(e.left.right===null)n=e.left,n.right=e.right,i=n;else{for(n=e.left.right;n.right!==null;)n=n.right;n.parent&&(n.parent.right=n.left,i=n.parent,n.left=e.left,n.right=e.right)}else if(e.right.left===null)n=e.right,n.left=e.left,i=n;else{for(n=e.right.left;n.left!==null;)n=n.left;n.parent&&(n.parent.left=n.right,i=n.parent,n.left=e.left,n.right=e.right)}e.parent!==null?e.isLeftChild()?e.parent.left=n:e.parent.right=n:this._setRoot(n),i&&this._rebalance(i)}e.dispose()}_rotateLeft(e){const t=e.parent,n=e.isLeftChild(),i=e.right;i&&(e.right=i.left,i.left=e),t!==null?n?t.left=i:t.right=i:this._setRoot(i)}_rotateRight(e){const t=e.parent,n=e.isLeftChild(),i=e.left;i&&(e.left=i.right,i.right=e),t!==null?n?t.left=i:t.right=i:this._setRoot(i)}_rebalance(e){const t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){const t=[];if(this._root.search(e,t),t.length>0){let n=t[0];for(let i=1;i<t.length;i++)t[i].low>n.low&&(n=t[i]);return n.event}}return null}forEach(e){if(this._root!==null){const t=[];this._root.traverse(n=>t.push(n)),t.forEach(n=>{n.event&&e(n.event)})}return this}forEachAtTime(e,t){if(this._root!==null){const n=[];this._root.search(e,n),n.forEach(i=>{i.event&&t(i.event)})}return this}forEachFrom(e,t){if(this._root!==null){const n=[];this._root.searchAfter(e,n),n.forEach(i=>{i.event&&t(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}}class Gg{constructor(e,t,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),!(this.low>e)&&this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left!==null?e=this.left.height+1:this.right!==null&&(e=-(this.right.height+1)),e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}const Xg=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));class Hg extends gs{constructor(e){super(),this.name="TimelineValue",this._timeline=new Et({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){const t=this._timeline.get(e);return t?t.value:this._initialValue}}class Ft extends ${constructor(){super(F(Ft.getDefaults(),arguments,["context"]))}connect(e,t=0,n=0){return ui(this,e,t,n),this}}class Kt extends Ft{constructor(){const e=F(Kt.getDefaults(),arguments,["mapping","length"]);super(e),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,ot(e.mapping)||e.mapping instanceof Float32Array?this.curve=Float32Array.from(e.mapping):Ul(e.mapping)&&this.setMap(e.mapping,e.length)}static getDefaults(){return Object.assign(re.getDefaults(),{length:1024})}setMap(e,t=1024){const n=new Float32Array(t);for(let i=0,r=t;i<r;i++){const o=i/(r-1)*2-1;n[i]=e(o,i)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){const t=["none","2x","4x"].some(n=>n.includes(e));K(t,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class Sn extends Ft{constructor(){const e=F(Sn.getDefaults(),arguments,["value"]);super(e),this.name="Pow",this._exponentScaler=this.input=this.output=new Kt({context:this.context,mapping:this._expFunc(e.value),length:8192}),this._exponent=e.value}static getDefaults(){return Object.assign(Ft.getDefaults(),{value:1})}_expFunc(e){return t=>Math.pow(Math.abs(t),e)}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class Ts{constructor(e,t){this.id=Ts._eventId++,this._remainderTime=0;const n=Object.assign(Ts.getDefaults(),t);this.transport=e,this.callback=n.callback,this._once=n.once,this.time=Math.floor(n.time),this._remainderTime=n.time-this.time}static getDefaults(){return{callback:_e,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){const t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}}Ts._eventId=0;class la extends Ts{constructor(e,t){super(e,t),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(la.getDefaults(),t);this.duration=n.duration,this._interval=n.interval,this._nextTick=n.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Ts.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return Ui(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Oe(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){Ui(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Oe(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;const t=this.transport.getTicksAtTime(e);cn(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}}class fr extends nt{constructor(){const e=F(fr.getDefaults(),arguments);super(e),this.name="Transport",this._loop=new Hg(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Et,this._repeatedEvents=new iu,this._syncedSignals=[],this._swingAmount=0,this._ppq=e.ppq,this._clock=new xn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=e.ppq,this.bpm.setValueAtTime(e.bpm,0),ne(this,"bpm"),this._timeSignature=e.timeSignature,this._swingTicks=e.ppq/2}static getDefaults(){return Object.assign(nt.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit("loopEnd",e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit("loopStart",e,this._clock.getSecondsAtTime(e)),this.emit("loop",e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!==0){const n=t%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(n*Math.PI)*this._swingAmount;e+=new Oe(this.context,this._swingTicks*2/3).toSeconds()*i}yo(!0),this._timeline.forEachAtTime(t,n=>n.invoke(e)),yo(!1)}schedule(e,t){const n=new Ts(this,{callback:e,time:new Xe(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(e,t,n,i=1/0){const r=new la(this,{callback:e,duration:new Dt(this.context,i).toTicks(),interval:new Dt(this.context,t).toTicks(),time:new Xe(this.context,n).toTicks()});return this._addEvent(r,this._repeatedEvents)}scheduleOnce(e,t){const n=new Ts(this,{callback:e,once:!0,time:new Xe(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){const t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){const t=this.toTicks(e);return this._timeline.forEachFrom(t,n=>this.clear(n.id)),this._repeatedEvents.forEachFrom(t,n=>this.clear(n.id)),this}_bindClockEvents(){this._clock.on("start",(e,t)=>{t=new Oe(this.context,t).toSeconds(),this.emit("start",e,t)}),this._clock.on("stop",e=>{this.emit("stop",e)}),this._clock.on("pause",e=>{this.emit("pause",e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let n;return de(t)&&(n=this.toTicks(t)),this._clock.start(e,n),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)!=="started"?this.start(e):this.stop(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){ot(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new Dt(this.context,this._loopStart,"i").toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new Dt(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new Oe(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){const e=this.now(),t=this._clock.getTicksAtTime(e);return new Oe(this.context,t).toBarsBeatsSixteenths()}set position(e){const t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){const t=this.now(),n=this._clock.frequency.timeToTicks(e,t);this.ticks=n}get progress(){if(this.loop){const e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){const t=this.now();if(this.state==="started"){const n=this._clock.getTicksAtTime(t),i=this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,t),r=t+i;this.emit("stop",r),this._clock.setTicksAtTime(e,r),this.emit("start",r,this._clock.getSecondsAtTime(r))}else this.emit("ticks",t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!=="started")return 0;{const t=this.now(),n=this.getTicksAtTime(t),i=e-n%e;return this._clock.nextTickTime(i,t)}}syncSignal(e,t){const n=this.now();let i=this.bpm,r=1/(60/i.getValueAtTime(n)/this.PPQ),o=[];if(e.units==="time"){const c=.015625/r,l=new Y(c),u=new Sn(-1),h=new Y(c);i.chain(l,u,h),i=h,r=1/r,o=[l,u,h]}t||(e.getValueAtTime(n)!==0?t=e.getValueAtTime(n)/r:t=0);const a=new Y(t);return i.connect(a),a.connect(e._param),o.push(a),this._syncedSignals.push({initial:e.value,nodes:o,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){const n=this._syncedSignals[t];n.signal===e&&(n.nodes.forEach(i=>i.dispose()),n.signal.value=n.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),ci(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}yn.mixin(fr);ur(s=>{s.transport=new fr({context:s})});hr(s=>{s.transport.dispose()});class Be extends ${constructor(e){super(e),this.input=void 0,this._state=new wn("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=_e,this._syncedStop=_e,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Ut({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume"),this.onstop=e.onstop}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,onstop:_e,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,n){let i=Tt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")K(cn(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,t,n);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){const r=this._state.get(i);r&&(r.offset=this.toSeconds($t(t,0)),r.duration=n?this.toSeconds(n):void 0);const o=this.context.transport.schedule(a=>{this._start(a,t,n)},i);this._scheduled.push(o),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else Ko(this.context),this._start(i,t,n);return this}stop(e){let t=Tt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)==="started"||de(this._state.getNextState("started",t))){if(this.log("stop",t),!this._synced)this._stop(t);else{const n=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(n)}this._state.cancel(t),this._state.setStateAtTime("stopped",t)}return this}restart(e,t,n){return e=this.toSeconds(e),this._state.getValueAtTime(e)==="started"&&(this._state.cancel(e),this._restart(e,t,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>{if(cn(t,0)){const n=this._state.get(t);if(n&&n.state==="started"&&n.time!==t){const i=t-this.toSeconds(n.time);let r;n.duration&&(r=this.toSeconds(n.duration)-i),this._start(e,this.toSeconds(n.offset)+i,r)}}},this._syncedStop=e=>{const t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)==="started"&&this._stop(e)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=_e,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Es extends hn{constructor(){const e=F(Es.getDefaults(),arguments,["url","onload"]);super(e),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,pt(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ae({context:this.context,param:this._source.playbackRate,units:"positive",value:e.playbackRate}),this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this._buffer=new xe(e.url,e.onload,e.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(hn.getDefaults(),{url:new xe,loop:!1,loopEnd:0,loopStart:0,onload:_e,onerror:_e,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,n,i=1){K(this.buffer.loaded,"buffer is either not set or not loaded");const r=this.toSeconds(e);this._startGain(r,i),this.loop?t=$t(t,this.loopStart):t=$t(t,0);let o=Math.max(this.toSeconds(t),0);if(this.loop){const a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),l=a-c;bo(o,a)&&(o=(o-c)%l+c),zt(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Ui(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(r,o)),de(n)){let a=this.toSeconds(n);a=Math.max(a,0),this.stop(r+a)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class ks extends Be{constructor(){const e=F(ks.getDefaults(),arguments,["type"]);super(e),this.name="Noise",this._source=null,this._playbackRate=e.playbackRate,this.type=e.type,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Be.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(e){if(K(e in cc,"Noise: invalid type: "+e),this._type!==e&&(this._type=e,this.state==="started")){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){const t=cc[this._type];this._source=new Es({url:t,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&(this._source.stop(this.toSeconds(e)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Us=44100*5,to=2,cs={brown:null,pink:null,white:null},cc={get brown(){if(!cs.brown){const s=[];for(let e=0;e<to;e++){const t=new Float32Array(Us);s[e]=t;let n=0;for(let i=0;i<Us;i++){const r=Math.random()*2-1;t[i]=(n+.02*r)/1.02,n=t[i],t[i]*=3.5}}cs.brown=new xe().fromArray(s)}return cs.brown},get pink(){if(!cs.pink){const s=[];for(let e=0;e<to;e++){const t=new Float32Array(Us);s[e]=t;let n,i,r,o,a,c,l;n=i=r=o=a=c=l=0;for(let u=0;u<Us;u++){const h=Math.random()*2-1;n=.99886*n+h*.0555179,i=.99332*i+h*.0750759,r=.969*r+h*.153852,o=.8665*o+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,t[u]=n+i+r+o+a+c+l+h*.5362,t[u]*=.11,l=h*.115926}}cs.pink=new xe().fromArray(s)}return cs.pink},get white(){if(!cs.white){const s=[];for(let e=0;e<to;e++){const t=new Float32Array(Us);s[e]=t;for(let n=0;n<Us;n++)t[n]=Math.random()*2-1}cs.white=new xe().fromArray(s)}return cs.white}};class Zn extends ${constructor(){const e=F(Zn.getDefaults(),arguments,["volume"]);super(e),this.name="UserMedia",this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume"),this.mute=e.mute}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,volume:0})}open(e){return ke(this,void 0,void 0,function*(){K(Zn.supported,"UserMedia is not supported"),this.state==="started"&&this.close();const t=yield Zn.enumerateDevices();Ot(e)?this._device=t[e]:(this._device=t.find(r=>r.label===e||r.deviceId===e),!this._device&&t.length>0&&(this._device=t[0]),K(de(this._device),`No matching device ${e}`));const n={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(n.audio.deviceId=this._device.deviceId);const i=yield navigator.mediaDevices.getUserMedia(n);if(!this._stream){this._stream=i;const r=this.context.createMediaStreamSource(i);pt(r,this.output),this._mediaStream=r}return this})}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach(e=>{e.stop()}),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return ke(this,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput")})}get state(){return this._stream&&this._stream.active?"started":"stopped"}get deviceId(){if(this._device)return this._device.deviceId}get groupId(){if(this._device)return this._device.groupId}get label(){if(this._device)return this._device.label}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return de(navigator.mediaDevices)&&de(navigator.mediaDevices.getUserMedia)}}function Ls(s,e){return ke(this,void 0,void 0,function*(){const t=e/s.context.sampleRate,n=new bn(1,t,s.context.sampleRate);return new s.constructor(Object.assign(s.get(),{frequency:2/t,detune:0,context:n})).toDestination().start(0),(yield n.render()).getChannelData(0)})}class hi extends hn{constructor(){const e=F(hi.getDefaults(),arguments,["frequency","type"]);super(e),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],pt(this._oscillator,this._gainNode),this.type=e.type,this.frequency=new ae({context:this.context,param:this._oscillator.frequency,units:"frequency",value:e.frequency}),this.detune=new ae({context:this.context,param:this._oscillator.detune,units:"cents",value:e.detune}),ne(this,["frequency","detune"])}static getDefaults(){return Object.assign(hn.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(e){const t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class Ne extends Be{constructor(){const e=F(Ne.getDefaults(),arguments,["frequency","type"]);super(e),this.name="Oscillator",this._oscillator=null,this.frequency=new re({context:this.context,units:"frequency",value:e.frequency}),ne(this,"frequency"),this.detune=new re({context:this.context,units:"cents",value:e.detune}),ne(this,"detune"),this._partials=e.partials,this._partialCount=e.partialCount,this._type=e.type,e.partialCount&&e.type!=="custom"&&(this._type=this.baseType+e.partialCount.toString()),this.phase=e.phase}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(e){const t=this.toSeconds(e),n=new hi({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(t)}_stop(e){const t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){const t=this.toSeconds(e);return this.log("restart",t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return Ne._periodicWaveCache.find(t=>t.phase===this._phase&&Ig(t.partials,this._partials));{const e=Ne._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=e?e.partialCount:this._partialCount,e}}get type(){return this._type}set type(e){this._type=e;const t=["sine","square","sawtooth","triangle"].indexOf(e)!==-1;if(this._phase===0&&t)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=e);else{const n=this._getCachedPeriodicWave();if(de(n)){const{partials:i,wave:r}=n;this._wave=r,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{const[i,r]=this._getRealImaginary(e,this._phase),o=this.context.createPeriodicWave(i,r);this._wave=o,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),Ne._periodicWaveCache.push({imag:r,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),Ne._periodicWaveCache.length>100&&Ne._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(e){this.partialCount&&this._type!=="custom"&&e!=="custom"?this.type=e+this.partialCount:this.type=e}get partialCount(){return this._partialCount}set partialCount(e){Ye(e,0);let t=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(t=n[1]),this._type!=="custom")e===0?this.type=t:this.type=t+e.toString();else{const i=new Float32Array(e);this._partials.forEach((r,o)=>i[o]=r),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(e,t){let i=2048;const r=new Float32Array(i),o=new Float32Array(i);let a=1;if(e==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[r,o]}else{const c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),e=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){const l=2/(c*Math.PI);let u;switch(e){case"sine":u=c<=a?1:0,this._partials[c-1]=u;break;case"square":u=c&1?2*l:0,this._partials[c-1]=u;break;case"sawtooth":u=l*(c&1?1:-1),this._partials[c-1]=u;break;case"triangle":c&1?u=2*(l*l)*(c-1>>1&1?-1:1):u=0,this._partials[c-1]=u;break;case"custom":u=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+e)}u!==0?(r[c]=-u*Math.sin(t*c),o[c]=u*Math.cos(t*c)):(r[c]=0,o[c]=0)}return[r,o]}_inverseFFT(e,t,n){let i=0;const r=e.length;for(let o=0;o<r;o++)i+=e[o]*Math.cos(o*n)+t[o]*Math.sin(o*n);return i}getInitialValue(){const[e,t]=this._getRealImaginary(this._type,0);let n=0;const i=Math.PI*2,r=32;for(let o=0;o<r;o++)n=Math.max(this._inverseFFT(e,t,o/r*i),n);return qs(-this._inverseFFT(e,t,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}Ne._periodicWaveCache=[];class mr extends Ft{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Kt({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Fe extends re{constructor(){const e=F(Fe.getDefaults(),arguments,["value"]);super(e),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Y({context:this.context,minValue:e.minValue,maxValue:e.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(re.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class di extends Be{constructor(){const e=F(di.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="AMOscillator",this._modulationScale=new mr({context:this.context}),this._modulationNode=new Y({context:this.context}),this._carrier=new Ne({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Ne({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new Fe({context:this.context,units:"positive",value:e.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),ne(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ne.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}}class Tn extends Be{constructor(){const e=F(Tn.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="FMOscillator",this._modulationNode=new Y({context:this.context,gain:0}),this._carrier=new Ne({context:this.context,detune:e.detune,frequency:0,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.detune=this._carrier.detune,this.frequency=new re({context:this.context,units:"frequency",value:e.frequency}),this._modulator=new Ne({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new Fe({context:this.context,units:"positive",value:e.harmonicity}),this.modulationIndex=new Fe({context:this.context,units:"positive",value:e.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),ne(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ne.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class kn extends Be{constructor(){const e=F(kn.getDefaults(),arguments,["frequency","width"]);super(e),this.name="PulseOscillator",this._widthGate=new Y({context:this.context,gain:0}),this._thresh=new Kt({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new re({context:this.context,units:"audioRange",value:e.width}),this._triangle=new Ne({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),ne(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class pi extends Be{constructor(){const e=F(pi.getDefaults(),arguments,["frequency","type","spread"]);super(e),this.name="FatOscillator",this._oscillators=[],this.frequency=new re({context:this.context,units:"frequency",value:e.frequency}),this.detune=new re({context:this.context,units:"cents",value:e.detune}),this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=e.partials,this._partialCount=e.partialCount,this.count=e.count,ne(this,["frequency","detune"])}static getDefaults(){return Object.assign(Ne.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){const t=-e/2,n=e/(this._oscillators.length-1);this._forEach((i,r)=>i.detune.value=t+n*r)}}get count(){return this._oscillators.length}set count(e){if(Ye(e,1),this._oscillators.length!==e){this._forEach(t=>t.dispose()),this._oscillators=[];for(let t=0;t<e;t++){const n=new Ne({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):_e});this.type==="custom"&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[t]=n}this.spread=this._spread,this.state==="started"&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((t,n)=>t.phase=this._phase+n/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type="custom",this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}}class fi extends Be{constructor(){const e=F(fi.getDefaults(),arguments,["frequency","modulationFrequency"]);super(e),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Fe({context:this.context,value:2}),this._pulse=new kn({context:this.context,frequency:e.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Ne({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),ne(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const lc={am:di,fat:pi,fm:Tn,oscillator:Ne,pulse:kn,pwm:fi};class fs extends Be{constructor(){const e=F(fs.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OmniOscillator",this.frequency=new re({context:this.context,units:"frequency",value:e.frequency}),this.detune=new re({context:this.context,units:"cents",value:e.detune}),ne(this,["frequency","detune"]),this.set(e)}static getDefaults(){return Object.assign(Ne.getDefaults(),Tn.getDefaults(),di.getDefaults(),pi.getDefaults(),kn.getDefaults(),fi.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):e==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,"type")&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;const t=lc[e],n=this.now();if(this._oscillator){const i=this._oscillator;i.stop(n),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new t({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(t=this._oscillator.type),e==="fm"?this.type="fm"+t:e==="am"?this.type="am"+t:e==="fat"?this.type="fat"+t:e==="oscillator"?this.type=t:e==="pulse"?this.type="pulse":e==="pwm"&&(this.type="pwm")}_getOscType(e,t){return e instanceof lc[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&e!=="pulse"&&e!=="pwm"&&(this._oscillator.baseType=e)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(e){this._getOscType(this._oscillator,"fat")&&Ot(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,"fat")&&Ot(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&Xt(e)&&(this._oscillator.modulationType=e)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return ke(this,arguments,void 0,function*(e=1024){return Ls(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class zs extends re{constructor(){super(F(zs.getDefaults(),arguments,["value"])),this.override=!1,this.name="Add",this._sum=new Y({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,Nt(this._constantSource,this._sum)}static getDefaults(){return Object.assign(re.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class ms extends Ft{constructor(){const e=F(ms.getDefaults(),arguments,["min","max"]);super(e),this.name="Scale",this._mult=this.input=new Fe({context:this.context,value:e.max-e.min}),this._add=this.output=new zs({context:this.context,value:e.min}),this._min=e.min,this._max=e.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(Ft.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(e){this._min=e,this._setRange()}get max(){return this._max}set max(e){this._max=e,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}}class gr extends Ft{constructor(){super(F(gr.getDefaults(),arguments)),this.name="Zero",this._gain=new Y({context:this.context}),this.output=this._gain,this.input=void 0,pt(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),ia(this.context.getConstant(0),this._gain),this}}class yt extends ${constructor(){const e=F(yt.getDefaults(),arguments,["frequency","min","max"]);super(e),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=ae.prototype._fromType,this._toType=ae.prototype._toType,this._is=ae.prototype._is,this._clampValue=ae.prototype._clampValue,this._oscillator=new Ne(e),this.frequency=this._oscillator.frequency,this._amplitudeGain=new Y({context:this.context,gain:e.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new re({context:this.context,units:"audioRange",value:0}),this._zeros=new gr({context:this.context}),this._a2g=new mr({context:this.context}),this._scaler=this.output=new ms({context:this.context,max:e.max,min:e.min}),this.units=e.units,this.min=e.min,this.max=e.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),ne(this,["amplitude","frequency"]),this.phase=e.phase}static getDefaults(){return Object.assign(Ne.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,type:"sine",units:"number"})}start(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(0,e),this._oscillator.start(e),this}stop(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(this._stoppedValue,e),this._oscillator.stop(e),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}_setStoppedValue(){this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get min(){return this._toType(this._scaler.min)}set min(e){e=this._fromType(e),this._scaler.min=e}get max(){return this._toType(this._scaler.max)}set max(e){e=this._fromType(e),this._scaler.max=e}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(e){this._oscillator.partials=e,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e,this._setStoppedValue()}get units(){return this._units}set units(e){const t=this.min,n=this.max;this._units=e,this.min=t,this.max=n}get state(){return this._oscillator.state}connect(e,t,n){return(e instanceof ae||e instanceof re)&&(this.convert=e.convert,this.units=e.units),ui(this,e,t,n),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}}function ru(s,e=1/0){const t=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(r){Ye(r,s,e),t.set(this,r)}})}}function _s(s,e=1/0){const t=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(r){Ye(this.toSeconds(r),s,e),t.set(this,r)}})}}class Zs extends Be{constructor(){const e=F(Zs.getDefaults(),arguments,["url","onload"]);super(e),this.name="Player",this._activeSources=new Set,this._buffer=new xe({onload:this._onload.bind(this,e.onload),onerror:e.onerror,reverse:e.reverse,url:e.url}),this.autostart=e.autostart,this._loop=e.loop,this._loopStart=e.loopStart,this._loopEnd=e.loopEnd,this._playbackRate=e.playbackRate,this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Be.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:_e,onerror:_e,playbackRate:1,reverse:!1})}load(e){return ke(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=_e){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(e,t,n){return super.start(e,t,n),this}_start(e,t,n){this._loop?t=$t(t,this._loopStart):t=$t(t,0);const i=this.toSeconds(t),r=n;n=$t(n,Math.max(this._buffer.duration-i,0));let o=this.toSeconds(n);o=o/this._playbackRate,e=this.toSeconds(e);const a=new Es({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(e+o),this._state.setStateAtTime("stopped",e+o,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Tt(r)?a.start(e,i):a.start(e,i,o-this.toSeconds(this.fadeOut))}_stop(e){const t=this.toSeconds(e);this._activeSources.forEach(n=>n.stop(t))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(e),this._start(e,t,n)}seek(e,t){const n=this.toSeconds(t);if(this._state.getValueAtTime(n)==="started"){const i=this.toSeconds(e);this._stop(n),this._start(n,i)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&Ye(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&Ye(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;const t=this.now(),n=this._state.getNextState("stopped",t);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}}Yt([_s(0)],Zs.prototype,"fadeIn",void 0);Yt([_s(0)],Zs.prototype,"fadeOut",void 0);class ua extends ${constructor(){const e=F(ua.getDefaults(),arguments,["urls","onload"],"urls");super(e),this.name="Players",this.input=void 0,this._players=new Map,this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume"),this._buffers=new Cn({urls:e.urls,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.mute=e.mute,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Be.getDefaults(),{baseUrl:"",fadeIn:0,fadeOut:0,mute:!1,onload:_e,onerror:_e,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._players.forEach(t=>{t.fadeIn=e})}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._players.forEach(t=>{t.fadeOut=e})}get state(){return Array.from(this._players).some(([t,n])=>n.state==="started")?"started":"stopped"}has(e){return this._buffers.has(e)}player(e){if(K(this.has(e),`No Player with the name ${e} exists on this object`),!this._players.has(e)){const t=new Zs({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(e)}).connect(this.output);this._players.set(e,t)}return this._players.get(e)}get loaded(){return this._buffers.loaded}add(e,t,n){return K(!this._buffers.has(e),"A buffer with that name already exists on this object"),this._buffers.add(e,t,n),this}stopAll(e){return this._players.forEach(t=>t.stop(e)),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach(e=>e.dispose()),this._buffers.dispose(),this}}class ha extends Be{constructor(){const e=F(ha.getDefaults(),arguments,["url","onload"]);super(e),this.name="GrainPlayer",this._loopStart=0,this._loopEnd=0,this._activeSources=[],this.buffer=new xe({onload:e.onload,onerror:e.onerror,reverse:e.reverse,url:e.url}),this._clock=new xn({context:this.context,callback:this._tick.bind(this),frequency:1/e.grainSize}),this._playbackRate=e.playbackRate,this._grainSize=e.grainSize,this._overlap=e.overlap,this.detune=e.detune,this.overlap=e.overlap,this.loop=e.loop,this.playbackRate=e.playbackRate,this.grainSize=e.grainSize,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.reverse=e.reverse,this._clock.on("stop",this._onstop.bind(this))}static getDefaults(){return Object.assign(Be.getDefaults(),{onload:_e,onerror:_e,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(e,t,n){t=$t(t,0),t=this.toSeconds(t),e=this.toSeconds(e);const i=1/this._clock.frequency.getValueAtTime(e);this._clock.start(e,t/i),n&&this.stop(e+this.toSeconds(n))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){this._stop(e),this._start(e,t,n)}_stop(e){this._clock.stop(e)}_onstop(e){this._activeSources.forEach(t=>{t.fadeOut=0,t.stop(e)}),this.onstop(this)}_tick(e){const t=this._clock.getTicksAtTime(e),n=t*this._grainSize;if(this.log("offset",n),!this.loop&&n>this.buffer.duration){this.stop(e);return}const i=n<this._overlap?0:this._overlap,r=new Es({context:this.context,url:this.buffer,fadeIn:i,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:un(this.detune/100)}).connect(this.output);r.start(e,this._grainSize*t),r.stop(e+this._grainSize/this.playbackRate),this._activeSources.push(r),r.onended=()=>{const o=this._activeSources.indexOf(r);o!==-1&&this._activeSources.splice(o,1)}}get playbackRate(){return this._playbackRate}set playbackRate(e){Ye(e,.001),this._playbackRate=e,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(e){this.buffer.loaded&&Ye(this.toSeconds(e),0,this.buffer.duration),this._loopStart=this.toSeconds(e)}get loopEnd(){return this._loopEnd}set loopEnd(e){this.buffer.loaded&&Ye(this.toSeconds(e),0,this.buffer.duration),this._loopEnd=this.toSeconds(e)}get reverse(){return this.buffer.reverse}set reverse(e){this.buffer.reverse=e}get grainSize(){return this._grainSize}set grainSize(e){this._grainSize=this.toSeconds(e),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(e){const t=this.toSeconds(e);Ye(t,0),this._overlap=t}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach(e=>e.dispose()),this}}class ou extends Ft{constructor(){super(...arguments),this.name="Abs",this._abs=new Kt({context:this.context,mapping:e=>Math.abs(e)<.001?0:Math.abs(e)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}}class au extends Ft{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Kt({context:this.context,mapping:e=>Math.abs(e)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class da extends Ft{constructor(){super(...arguments),this.name="Negate",this._multiply=new Fe({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}}class Gs extends re{constructor(){super(F(Gs.getDefaults(),arguments,["value"])),this.override=!1,this.name="Subtract",this._sum=new Y({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new da({context:this.context}),this.subtrahend=this._param,Nt(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(re.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}}class _r extends Ft{constructor(){super(F(_r.getDefaults(),arguments)),this.name="GreaterThanZero",this._thresh=this.output=new Kt({context:this.context,length:127,mapping:e=>e<=0?0:1}),this._scale=this.input=new Fe({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}}class vr extends re{constructor(){const e=F(vr.getDefaults(),arguments,["value"]);super(e),this.name="GreaterThan",this.override=!1,this._subtract=this.input=new Gs({context:this.context,value:e.value}),this._gtz=this.output=new _r({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,ne(this,"comparator"),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(re.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}}class yr extends ms{constructor(){const e=F(yr.getDefaults(),arguments,["min","max","exponent"]);super(e),this.name="ScaleExp",this.input=this._exp=new Sn({context:this.context,value:e.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(ms.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(e){this._exp.value=e}dispose(){return super.dispose(),this._exp.dispose(),this}}class Yg extends re{constructor(){const e=F(re.getDefaults(),arguments,["value","units"]);super(e),this.name="SyncedSignal",this.override=!1,this._lastVal=e.value,this._synced=this.context.transport.scheduleRepeat(this._onTick.bind(this),"1i"),this._syncedCallback=this._anchorValue.bind(this),this.context.transport.on("start",this._syncedCallback),this.context.transport.on("pause",this._syncedCallback),this.context.transport.on("stop",this._syncedCallback),this._constantSource.disconnect(),this._constantSource.stop(0),this._constantSource=this.output=new pr({context:this.context,offset:e.value,units:e.units}).start(0),this.setValueAtTime(e.value,0)}_onTick(e){const t=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==t&&(this._lastVal=t,this._constantSource.offset.setValueAtTime(t,e))}_anchorValue(e){const t=super.getValueAtTime(this.context.transport.seconds);this._lastVal=t,this._constantSource.offset.cancelAndHoldAtTime(e),this._constantSource.offset.setValueAtTime(t,e)}getValueAtTime(e){const t=new Xe(this.context,e).toSeconds();return super.getValueAtTime(t)}setValueAtTime(e,t){const n=new Xe(this.context,t).toSeconds();return super.setValueAtTime(e,n),this}linearRampToValueAtTime(e,t){const n=new Xe(this.context,t).toSeconds();return super.linearRampToValueAtTime(e,n),this}exponentialRampToValueAtTime(e,t){const n=new Xe(this.context,t).toSeconds();return super.exponentialRampToValueAtTime(e,n),this}setTargetAtTime(e,t,n){const i=new Xe(this.context,t).toSeconds();return super.setTargetAtTime(e,i,n),this}cancelScheduledValues(e){const t=new Xe(this.context,e).toSeconds();return super.cancelScheduledValues(t),this}setValueCurveAtTime(e,t,n,i){const r=new Xe(this.context,t).toSeconds();return n=this.toSeconds(n),super.setValueCurveAtTime(e,r,n,i),this}cancelAndHoldAtTime(e){const t=new Xe(this.context,e).toSeconds();return super.cancelAndHoldAtTime(t),this}setRampPoint(e){const t=new Xe(this.context,e).toSeconds();return super.setRampPoint(t),this}exponentialRampTo(e,t,n){const i=new Xe(this.context,n).toSeconds();return super.exponentialRampTo(e,t,i),this}linearRampTo(e,t,n){const i=new Xe(this.context,n).toSeconds();return super.linearRampTo(e,t,i),this}targetRampTo(e,t,n){const i=new Xe(this.context,n).toSeconds();return super.targetRampTo(e,t,i),this}dispose(){return super.dispose(),this.context.transport.clear(this._synced),this.context.transport.off("start",this._syncedCallback),this.context.transport.off("pause",this._syncedCallback),this.context.transport.off("stop",this._syncedCallback),this._constantSource.dispose(),this}}class at extends ${constructor(){const e=F(at.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="Envelope",this._sig=new re({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve,this.decayCurve=e.decayCurve}static getDefaults(){return Object.assign($.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(Xt(e))return e;{let n;for(n in Oi)if(Oi[n][t]===e)return n;return e}}_setCurve(e,t,n){if(Xt(n)&&Reflect.has(Oi,n)){const i=Oi[n];ps(i)?e!=="_decayCurve"&&(this[e]=i[t]):this[e]=i}else if(ot(n)&&e!=="_decayCurve")this[e]=n;else throw new Error("Envelope: invalid curve: "+n)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(e){this._setCurve("_attackCurve","In",e)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(e){this._setCurve("_releaseCurve","Out",e)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(e){this._setCurve("_decayCurve","Out",e)}triggerAttack(e,t=1){this.log("triggerAttack",e,t),e=this.toSeconds(e);let i=this.toSeconds(this.attack);const r=this.toSeconds(this.decay),o=this.getValueAtTime(e);if(o>0){const a=1/i;i=(1-o)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve==="linear")this._sig.linearRampTo(t,i,e);else if(this._attackCurve==="exponential")this._sig.targetRampTo(t,i,e);else{this._sig.cancelAndHoldAtTime(e);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=o&&o<=a[c]){a=this._attackCurve.slice(c),a[0]=o;break}this._sig.setValueCurveAtTime(a,e,i,t)}if(r&&this.sustain<1){const a=t*this.sustain,c=e+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,r+c):this._sig.exponentialApproachValueAtTime(a,c,r)}return this}triggerRelease(e){this.log("triggerRelease",e),e=this.toSeconds(e);const t=this.getValueAtTime(e);if(t>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve==="linear"?this._sig.linearRampTo(0,n,e):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,n,e):(K(ot(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,n,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),this.triggerAttack(t,n),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}connect(e,t=0,n=0){return ui(this,e,t,n),this}asArray(){return ke(this,arguments,void 0,function*(e=1024){const t=e/this.context.sampleRate,n=new bn(1,t,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),r=i+this.toSeconds(this.release),o=r*.1,a=r+o,c=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/a,decay:t*this.toSeconds(this.decay)/a,release:t*this.toSeconds(this.release)/a,context:n}));return c._sig.toDestination(),c.triggerAttackRelease(t*(i+o)/a,0),(yield n.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}}Yt([_s(0)],at.prototype,"attack",void 0);Yt([_s(0)],at.prototype,"decay",void 0);Yt([ru(0,1)],at.prototype,"sustain",void 0);Yt([_s(0)],at.prototype,"release",void 0);const Oi=(()=>{let e,t;const n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));const i=[],r=6.4;for(e=0;e<127;e++){t=e/127;const p=Math.sin(t*(Math.PI*2)*r-Math.PI/2)+1;i[e]=p/10+t*.83}i[127]=1;const o=[],a=5;for(e=0;e<128;e++)o[e]=Math.ceil(e/127*a)/a;const c=[];for(e=0;e<128;e++)t=e/127,c[e]=.5*(1-Math.cos(Math.PI*t));const l=[];for(e=0;e<128;e++){t=e/127;const p=Math.pow(t,3)*4+.2,d=Math.cos(p*Math.PI*2*t);l[e]=Math.abs(d*(1-t))}function u(p){const d=new Array(p.length);for(let f=0;f<p.length;f++)d[f]=1-p[f];return d}function h(p){return p.slice(0).reverse()}return{bounce:{In:u(l),Out:l},cosine:{In:n,Out:h(n)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:u(i)},sine:{In:c,Out:u(c)},step:{In:o,Out:u(o)}}})();class qt extends ${constructor(){const e=F(qt.getDefaults(),arguments);super(e),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=t=>this._original_triggerRelease(t),this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume")}static getDefaults(){return Object.assign($.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){const n=this["_original_"+e]=this[e];this[e]=(...i)=>{const r=i[t],o=this.context.transport.schedule(a=>{i[t]=a,n.apply(this,i)},r);this._scheduledEvents.push(o)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(e,t,n,i){const r=this.toSeconds(n),o=this.toSeconds(t);return this.triggerAttack(e,r,i),this.triggerRelease(r+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class rt extends qt{constructor(){const e=F(rt.getDefaults(),arguments);super(e),this.portamento=e.portamento,this.onsilence=e.onsilence}static getDefaults(){return Object.assign(qt.getDefaults(),{detune:0,onsilence:_e,portamento:0})}triggerAttack(e,t,n=1){this.log("triggerAttack",e,t,n);const i=this.toSeconds(t);return this._triggerEnvelopeAttack(i,n),this.setNote(e,i),this}triggerRelease(e){this.log("triggerRelease",e);const t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){const n=this.toSeconds(t),i=e instanceof vt?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const r=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,r,n)}else this.frequency.setValueAtTime(i,n);return this}}Yt([_s(0)],rt.prototype,"portamento",void 0);class An extends at{constructor(){super(F(An.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Y({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}}class As extends rt{constructor(){const e=F(As.getDefaults(),arguments);super(e),this.name="Synth",this.oscillator=new fs(Object.assign({context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)},e.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new An(Object.assign({context:this.context},e.envelope)),this.oscillator.chain(this.envelope,this.output),ne(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(rt.getDefaults(),{envelope:Object.assign(it(at.getDefaults(),Object.keys($.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(it(fs.getDefaults(),[...Object.keys(Be.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){const n=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+n+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class Yn extends rt{constructor(){const e=F(Yn.getDefaults(),arguments);super(e),this.name="ModulationSynth",this._carrier=new As({context:this.context,oscillator:e.oscillator,envelope:e.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new As({context:this.context,oscillator:e.modulation,envelope:e.modulationEnvelope,volume:-10}),this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope,this.modulation=this._modulator.oscillator,this.modulationEnvelope=this._modulator.envelope,this.frequency=new re({context:this.context,units:"frequency"}),this.detune=new re({context:this.context,value:e.detune,units:"cents"}),this.harmonicity=new Fe({context:this.context,value:e.harmonicity,minValue:0}),this._modulationNode=new Y({context:this.context,gain:0}),ne(this,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])}static getDefaults(){return Object.assign(rt.getDefaults(),{harmonicity:3,oscillator:Object.assign(it(fs.getDefaults(),[...Object.keys(Be.getDefaults()),"frequency","detune"]),{type:"sine"}),envelope:Object.assign(it(at.getDefaults(),Object.keys($.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(it(fs.getDefaults(),[...Object.keys(Be.getDefaults()),"frequency","detune"]),{type:"square"}),modulationEnvelope:Object.assign(it(at.getDefaults(),Object.keys($.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(e,t){this._carrier._triggerEnvelopeAttack(e,t),this._modulator._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this._carrier._triggerEnvelopeRelease(e),this._modulator._triggerEnvelopeRelease(e),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}}class pa extends Yn{constructor(){super(F(pa.getDefaults(),arguments)),this.name="AMSynth",this._modulationScale=new mr({context:this.context}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output)}dispose(){return super.dispose(),this._modulationScale.dispose(),this}}class Un extends ${constructor(){const e=F(Un.getDefaults(),arguments,["frequency","type"]);super(e),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ae({context:this.context,units:"number",value:e.Q,param:this._filter.Q}),this.frequency=new ae({context:this.context,units:"frequency",value:e.frequency,param:this._filter.frequency}),this.detune=new ae({context:this.context,units:"cents",value:e.detune,param:this._filter.detune}),this.gain=new ae({context:this.context,units:"decibels",convert:!1,value:e.gain,param:this._filter.gain}),this.type=e.type}static getDefaults(){return Object.assign($.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){K(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){const t=new Float32Array(e);for(let o=0;o<e;o++){const c=Math.pow(o/e,2)*19980+20;t[o]=c}const n=new Float32Array(e),i=new Float32Array(e),r=this.context.createBiquadFilter();return r.type=this.type,r.Q.value=this.Q.value,r.frequency.value=this.frequency.value,r.gain.value=this.gain.value,r.getFrequencyResponse(t,n,i),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}class Rt extends ${constructor(){const e=F(Rt.getDefaults(),arguments,["frequency","type","rolloff"]);super(e),this.name="Filter",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._filters=[],this._filters=[],this.Q=new re({context:this.context,units:"positive",value:e.Q}),this.frequency=new re({context:this.context,units:"frequency",value:e.frequency}),this.detune=new re({context:this.context,units:"cents",value:e.detune}),this.gain=new re({context:this.context,units:"decibels",convert:!1,value:e.gain}),this._type=e.type,this.rolloff=e.rolloff,ne(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign($.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(e){K(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(n=>n.type=e)}get rolloff(){return this._rolloff}set rolloff(e){const t=Ot(e)?e:parseInt(e,10),n=[-12,-24,-48,-96];let i=n.indexOf(t);K(i!==-1,`rolloff can only be ${n.join(", ")}`),i+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(r=>r.disconnect()),this._filters=new Array(i);for(let r=0;r<i;r++){const o=new Un({context:this.context});o.type=this._type,this.frequency.connect(o.frequency),this.detune.connect(o.detune),this.Q.connect(o.Q),this.gain.connect(o.gain),this._filters[r]=o}this._internalChannels=this._filters,Nt(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){const t=new Un({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(e).map(()=>1);return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((r,o)=>n[o]*=r)}),t.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),ci(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class Kn extends at{constructor(){const e=F(Kn.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="FrequencyEnvelope",this._octaves=e.octaves,this._baseFrequency=this.toFrequency(e.baseFrequency),this._exponent=this.input=new Sn({context:this.context,value:e.exponent}),this._scale=this.output=new ms({context:this.context,min:this._baseFrequency,max:this._baseFrequency*Math.pow(2,this._octaves)}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(at.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){const t=this.toFrequency(e);Ye(t,0),this._baseFrequency=t,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._scale.max=this._baseFrequency*Math.pow(2,e)}get exponent(){return this._exponent.value}set exponent(e){this._exponent.value=e}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class Vs extends rt{constructor(){const e=F(Vs.getDefaults(),arguments);super(e),this.name="MonoSynth",this.oscillator=new fs(Object.assign(e.oscillator,{context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new Rt(Object.assign(e.filter,{context:this.context})),this.filterEnvelope=new Kn(Object.assign(e.filterEnvelope,{context:this.context})),this.envelope=new An(Object.assign(e.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),ne(this,["oscillator","frequency","detune","filter","filterEnvelope","envelope"])}static getDefaults(){return Object.assign(rt.getDefaults(),{envelope:Object.assign(it(at.getDefaults(),Object.keys($.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(it(Rt.getDefaults(),Object.keys($.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(it(Kn.getDefaults(),Object.keys($.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(it(fs.getDefaults(),Object.keys(Be.getDefaults())),{type:"sawtooth"})})}_triggerEnvelopeAttack(e,t=1){if(this.envelope.triggerAttack(e,t),this.filterEnvelope.triggerAttack(e),this.oscillator.start(e),this.envelope.sustain===0){const n=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+n+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.filterEnvelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}}class fa extends rt{constructor(){const e=F(fa.getDefaults(),arguments);super(e),this.name="DuoSynth",this.voice0=new Vs(Object.assign(e.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new Vs(Object.assign(e.voice1,{context:this.context})),this.harmonicity=new Fe({context:this.context,units:"positive",value:e.harmonicity}),this._vibrato=new yt({frequency:e.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new Y({context:this.context,units:"normalRange",gain:e.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new re({context:this.context,units:"frequency",value:440}),this.detune=new re({context:this.context,units:"cents",value:e.detune}),this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.detune.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),ne(this,["voice0","voice1","frequency","vibratoAmount","vibratoRate"])}getLevelAtTime(e){return e=this.toSeconds(e),this.voice0.envelope.getValueAtTime(e)+this.voice1.envelope.getValueAtTime(e)}static getDefaults(){return Bt(rt.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:Bt(it(Vs.getDefaults(),Object.keys(rt.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:Bt(it(Vs.getDefaults(),Object.keys(rt.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(e,t){this.voice0._triggerEnvelopeAttack(e,t),this.voice1._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this.voice0._triggerEnvelopeRelease(e),this.voice1._triggerEnvelopeRelease(e),this}dispose(){return super.dispose(),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this.detune.dispose(),this._vibrato.dispose(),this.vibratoRate.dispose(),this._vibratoGain.dispose(),this.harmonicity.dispose(),this}}class ma extends Yn{constructor(){const e=F(ma.getDefaults(),arguments);super(e),this.name="FMSynth",this.modulationIndex=new Fe({context:this.context,value:e.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output)}static getDefaults(){return Object.assign(Yn.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}}const uc=[1,1.483,1.932,2.546,2.63,3.897];class ga extends rt{constructor(){const e=F(ga.getDefaults(),arguments);super(e),this.name="MetalSynth",this._oscillators=[],this._freqMultipliers=[],this.detune=new re({context:this.context,units:"cents",value:e.detune}),this.frequency=new re({context:this.context,units:"frequency"}),this._amplitude=new Y({context:this.context,gain:0}).connect(this.output),this._highpass=new Rt({Q:0,context:this.context,type:"highpass"}).connect(this._amplitude);for(let t=0;t<uc.length;t++){const n=new Tn({context:this.context,harmonicity:e.harmonicity,modulationIndex:e.modulationIndex,modulationType:"square",onstop:t===0?()=>this.onsilence(this):_e,type:"square"});n.connect(this._highpass),this._oscillators[t]=n;const i=new Fe({context:this.context,value:uc[t]});this._freqMultipliers[t]=i,this.frequency.chain(i,n.frequency),this.detune.connect(n.detune)}this._filterFreqScaler=new ms({context:this.context,max:7e3,min:this.toFrequency(e.resonance)}),this.envelope=new at({attack:e.envelope.attack,attackCurve:"linear",context:this.context,decay:e.envelope.decay,release:e.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=e.octaves,this.octaves=e.octaves}static getDefaults(){return Bt(rt.getDefaults(),{envelope:Object.assign(it(at.getDefaults(),Object.keys($.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(e,t=1){return this.envelope.triggerAttack(e,t),this._oscillators.forEach(n=>n.start(e)),this.envelope.sustain===0&&this._oscillators.forEach(n=>{n.stop(e+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))}),this}_triggerEnvelopeRelease(e){return this.envelope.triggerRelease(e),this._oscillators.forEach(t=>t.stop(e+this.toSeconds(this.envelope.release))),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(e){this._oscillators.forEach(t=>t.modulationIndex.value=e)}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(e){this._oscillators.forEach(t=>t.harmonicity.value=e)}get resonance(){return this._filterFreqScaler.min}set resonance(e){this._filterFreqScaler.min=this.toFrequency(e),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,e)}dispose(){return super.dispose(),this._oscillators.forEach(e=>e.dispose()),this._freqMultipliers.forEach(e=>e.dispose()),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}}class mi extends As{constructor(){const e=F(mi.getDefaults(),arguments);super(e),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=e.pitchDecay,this.octaves=e.octaves,ne(this,["oscillator","envelope"])}static getDefaults(){return Bt(rt.getDefaults(),As.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(e,t){const n=this.toSeconds(t),i=this.toFrequency(e instanceof vt?e.toFrequency():e),r=i*this.octaves;return this.oscillator.frequency.setValueAtTime(r,n),this.oscillator.frequency.exponentialRampToValueAtTime(i,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}Yt([ru(0)],mi.prototype,"octaves",void 0);Yt([_s(0)],mi.prototype,"pitchDecay",void 0);class _a extends qt{constructor(){const e=F(_a.getDefaults(),arguments);super(e),this.name="NoiseSynth",this.noise=new ks(Object.assign({context:this.context},e.noise)),this.envelope=new An(Object.assign({context:this.context},e.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(qt.getDefaults(),{envelope:Object.assign(it(at.getDefaults(),Object.keys($.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(it(ks.getDefaults(),Object.keys(Be.getDefaults())),{type:"white"})})}triggerAttack(e,t=1){return e=this.toSeconds(e),this.envelope.triggerAttack(e,t),this.noise.start(e),this.envelope.sustain===0&&this.noise.stop(e+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(e){return e=this.toSeconds(e),this.envelope.triggerRelease(e),this.noise.stop(e+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0)),this}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),e=this.toSeconds(e),this.triggerAttack(t,n),this.triggerRelease(t+e),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}const va=new Set;function ya(s){va.add(s)}function cu(s,e){const t=`registerProcessor("${s}", ${e})`;va.add(t)}function Ug(){return Array.from(va).join(`
19
- `)}class wo extends ${constructor(e){super(e),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=_e;const t=URL.createObjectURL(new Blob([Ug()],{type:"text/javascript"})),n=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(t).then(()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(n,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))})}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage("dispose"),this._worklet.disconnect()),this}}const Kg=`
18
+ `],{type:"text/javascript"}),t=URL.createObjectURL(e),n=new Worker(t);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch{this._type="timeout",this._createClock()}else this._type==="timeout"&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type==="worker"&&((t=this._worker)===null||t===void 0||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}}function Bs(s){return gg(s)}function Ss(s){return mg(s)}function Bi(s){return _g(s)}function Js(s){return fg(s)}function kg(s){return s instanceof Fl}function Ag(s,e){return s==="value"||Bs(e)||Ss(e)||kg(e)}function Wt(s,...e){if(!e.length)return s;const t=e.shift();if(ds(s)&&ds(t))for(const n in t)Ag(n,t[n])?s[n]=t[n]:ds(t[n])?(s[n]||Object.assign(s,{[n]:{}}),Wt(s[n],t[n])):Object.assign(s,{[n]:t[n]});return Wt(s,...e)}function Ig(s,e){return s.length===e.length&&s.every((t,n)=>e[n]===t)}function F(s,e,t=[],n){const i={},r=Array.from(e);if(ds(r[0])&&n&&!Reflect.has(r[0],n)&&(Object.keys(r[0]).some(a=>Reflect.has(s,a))||(Wt(i,{[n]:r[0]}),t.splice(t.indexOf(n),1),r.shift())),r.length===1&&ds(r[0]))Wt(i,r[0]);else for(let o=0;o<t.length;o++)he(r[o])&&(i[t[o]]=r[o]);return Wt(s,i)}function Dg(s){return s.constructor.getDefaults()}function Bt(s,e){return Tt(s)?e:s}function rt(s,e){return e.forEach(t=>{Reflect.has(s,t)&&delete s[t]}),s}class ms{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||gt&&this.toString()===gt.TONE_DEBUG_CLASS)&&Jl(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}ms.version=Eo;const Jo=1e-6;function ln(s,e){return s>e+Jo}function bo(s,e){return ln(s,e)||zt(s,e)}function Ui(s,e){return s+Jo<e}function zt(s,e){return Math.abs(s-e)<Jo}function js(s,e,t){return Math.max(Math.min(s,t),e)}class Et extends ms{constructor(){super(),this.name="Timeline",this._timeline=[];const e=F(Et.getDefaults(),arguments,["memory"]);this.memory=e.memory,this.increasing=e.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(e){if(K(Reflect.has(e,"time"),"Timeline: events must have a time attribute"),e.time=e.time.valueOf(),this.increasing&&this.length){const t=this._timeline[this.length-1];K(bo(e.time,t.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(e)}else{const t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(e){const t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t="time"){const n=this._search(e,t);return n!==-1?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t="time"){const n=this._search(e,t);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(e){const t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];const n=this._search(e);return n-1>=0?this._timeline[n-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0)if(zt(this._timeline[t].time,e)){for(let n=t;n>=0&&zt(this._timeline[n].time,e);n--)t=n;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1);else this._timeline=[]}else this._timeline.length===1&&bo(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){const t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){const t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t="time"){if(this._timeline.length===0)return-1;let n=0;const i=this._timeline.length;let r=i;if(i>0&&this._timeline[i-1][t]<=e)return i-1;for(;n<r;){let o=Math.floor(n+(r-n)/2);const a=this._timeline[o],c=this._timeline[o+1];if(zt(a[t],e)){for(let l=o;l<this._timeline.length;l++){const u=this._timeline[l];if(zt(u[t],e))o=l;else break}return o}else{if(Ui(a[t],e)&&ln(c[t],e))return o;ln(a[t],e)?r=o:n=o+1}}return-1}_iterate(e,t=0,n=this._timeline.length-1){this._timeline.slice(t,n+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){const n=this._search(e);return n!==-1&&this._iterate(t,0,n),this}forEachAfter(e,t){const n=this._search(e);return this._iterate(t,n+1),this}forEachBetween(e,t,n){let i=this._search(e),r=this._search(t);return i!==-1&&r!==-1?(this._timeline[i].time!==e&&(i+=1),this._timeline[r].time===t&&(r-=1),this._iterate(n,i,r)):i===-1&&this._iterate(n,0,r),this}forEachFrom(e,t){let n=this._search(e);for(;n>=0&&this._timeline[n].time>=e;)n--;return this._iterate(t,n+1),this}forEachAtTime(e,t){const n=this._search(e);if(n!==-1&&zt(this._timeline[n].time,e)){let i=n;for(let r=n;r>=0&&zt(this._timeline[r].time,e);r--)i=r;this._iterate(r=>{t(r)},i,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const eu=[];function ur(s){eu.push(s)}function Rg(s){eu.forEach(e=>e(s))}const tu=[];function hr(s){tu.push(s)}function Eg(s){tu.forEach(e=>e(s))}class bn extends ms{constructor(){super(...arguments),this.name="Emitter"}on(e,t){return e.split(/\W+/).forEach(i=>{Tt(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(t)}),this}once(e,t){const n=(...i)=>{t(...i),this.off(e,n)};return this.on(e,n),this}off(e,t){return e.split(/\W+/).forEach(i=>{if(Tt(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Tt(t))this._events[i]=[];else{const r=this._events[i];for(let o=r.length-1;o>=0;o--)r[o]===t&&r.splice(o,1)}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){const n=this._events[e].slice(0);for(let i=0,r=n.length;i<r;i++)n[i].apply(this,t)}return this}static mixin(e){["on","once","off","emit"].forEach(t=>{const n=Object.getOwnPropertyDescriptor(bn.prototype,t);Object.defineProperty(e.prototype,t,n)})}dispose(){return super.dispose(),this._events=void 0,this}}class ea extends bn{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}class Ls extends ea{constructor(){var e,t;super(),this.name="Context",this._constants=new Map,this._timeouts=new Et,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;const n=F(Ls.getDefaults(),arguments,["context"]);n.context?(this._context=n.context,this._latencyHint=((e=arguments[0])===null||e===void 0?void 0:e.latencyHint)||""):(this._context=wg({latencyHint:n.latencyHint}),this._latencyHint=n.latencyHint),this._ticker=new Tg(this.emit.bind(this,"tick"),n.clockSource,n.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((t=arguments[0])===null||t===void 0)&&t.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=n.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(Rg(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(e,t,n){return this._context.createBuffer(e,t,n)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,n){return this._context.createPeriodicWave(e,t,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(e){return K(Js(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return K(Js(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return K(Js(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(e){K(!this._initialized,"The listener cannot be set after initialization."),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){K(!this._initialized,"The transport cannot be set after initialization."),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){K(!this._initialized,"Draw cannot be set after initialization."),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){K(!this._initialized,"The destination cannot be set after initialization."),this._destination=e}createAudioWorkletNode(e,t){return Sg(this.rawContext,e,t)}addAudioWorkletModule(e){return Ae(this,void 0,void 0,function*(){K(he(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(e)),yield this._workletPromise})}workletsAreReady(){return Ae(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return Js(this._context)?this._context.resume():Promise.resolve()}close(){return Ae(this,void 0,void 0,function*(){Js(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Eg(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{const t=this._context.createBuffer(1,128,this._context.sampleRate),n=t.getChannelData(0);for(let r=0;r<n.length;r++)n[r]=e;const i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=t,i.loop=!0,i.start(0),this._constants.set(e,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){const e=this.now();this._timeouts.forEachBefore(e,t=>{t.callback(),this._timeouts.remove(t)})}setTimeout(e,t){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:n+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){const n=++this._timeoutIds,i=()=>{const r=this.now();this._timeouts.add({callback:()=>{e(),i()},id:n,time:r+t})};return i(),n}}class Mg extends ea{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,n){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return Ae(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}}function ne(s,e){at(e)?e.forEach(t=>ne(s,t)):Object.defineProperty(s,e,{enumerable:!0,writable:!1})}function ci(s,e){at(e)?e.forEach(t=>ci(s,t)):Object.defineProperty(s,e,{writable:!0})}const ge=()=>{};class xe extends ms{constructor(){super(),this.name="ToneAudioBuffer",this.onload=ge;const e=F(xe.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=e.reverse,this.onload=e.onload,Xt(e.url)?this.load(e.url).catch(e.onerror):e.url&&this.set(e.url)}static getDefaults(){return{onerror:ge,onload:ge,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:fe().sampleRate}set(e){return e instanceof xe?e.loaded?this._buffer=e.get():e.onload=()=>{this.set(e),this.onload(this)}:this._buffer=e,this._reversed&&this._reverse(),this}get(){return this._buffer}load(e){return Ae(this,void 0,void 0,function*(){const t=xe.load(e).then(n=>{this.set(n),this.onload(this)});xe.downloads.push(t);try{yield t}finally{const n=xe.downloads.indexOf(t);xe.downloads.splice(n,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){const t=at(e)&&e[0].length>0,n=t?e.length:1,i=t?e[0].length:e.length,r=fe(),o=r.createBuffer(n,i,r.sampleRate),a=!t&&n===1?[e]:e;for(let c=0;c<n;c++)o.copyToChannel(a[c],c);return this._buffer=o,this}toMono(e){if(Ot(e))this.fromArray(this.toArray(e));else{let t=new Float32Array(this.length);const n=this.numberOfChannels;for(let i=0;i<n;i++){const r=this.toArray(i);for(let o=0;o<r.length;o++)t[o]+=r[o]}t=t.map(i=>i/n),this.fromArray(t)}return this}toArray(e){if(Ot(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{const t=[];for(let n=0;n<this.numberOfChannels;n++)t[n]=this.getChannelData(n);return t}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array(0)}slice(e,t=this.duration){K(this.loaded,"Buffer is not loaded");const n=Math.floor(e*this.sampleRate),i=Math.floor(t*this.sampleRate);K(n<i,"The start time must be less than the end time");const r=i-n,o=fe().createBuffer(this.numberOfChannels,r,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)o.copyToChannel(this.getChannelData(a).subarray(n,i),a);return new xe(o)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(e){return new xe().fromArray(e)}static fromUrl(e){return Ae(this,void 0,void 0,function*(){return yield new xe().load(e)})}static load(e){return Ae(this,void 0,void 0,function*(){const t=xe.baseUrl===""||xe.baseUrl.endsWith("/")?xe.baseUrl:xe.baseUrl+"/",n=yield fetch(t+e);if(!n.ok)throw new Error(`could not load url: ${e}`);const i=yield n.arrayBuffer();return yield fe().decodeAudioData(i)})}static supportsType(e){const t=e.split("."),n=t[t.length-1];return document.createElement("audio").canPlayType("audio/"+n)!==""}static loaded(){return Ae(this,void 0,void 0,function*(){for(yield Promise.resolve();xe.downloads.length;)yield xe.downloads[0]})}}xe.baseUrl="";xe.downloads=[];class wn extends Ls{constructor(){super({clockSource:"offline",context:Bi(arguments[0])?arguments[0]:xg(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Bi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Bi(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return Ae(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,t++;const n=Math.floor(this.sampleRate/128);e&&t%n===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return Ae(this,arguments,void 0,function*(e=!0){yield this.workletsAreReady(),yield this._renderClock(e);const t=yield this._context.startRendering();return new xe(t)})}close(){return Promise.resolve()}}const su=new Mg;let Vs=su;function fe(){return Vs===su&&Cg&&Hn(new Ls),Vs}function Hn(s,e=!1){e&&Vs.dispose(),Js(s)?Vs=new Ls(s):Bi(s)?Vs=new wn(s):Vs=s}function ta(){return Vs.resume()}if(gt&&!gt.TONE_SILENCE_LOGGING){const e=` * Tone.js v${Eo} * `;console.log(`%c${e}`,"background: #000; color: #fff")}function un(s){return Math.pow(10,s/20)}function li(s){return 20*(Math.log(s)/Math.LN10)}function hn(s){return Math.pow(2,s/12)}let dr=440;function Og(){return dr}function Ng(s){dr=s}function xs(s){return Math.round(nu(s))}function nu(s){return 69+12*Math.log2(s/dr)}function sa(s){return dr*Math.pow(2,(s-69)/12)}class na extends ms{constructor(e,t,n){super(),this.defaultUnits="s",this._val=t,this._units=n,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{const n=parseInt(e,10),i=t==="."?1.5:1;return n===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/n)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{const t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,n)=>{let i=0;return e&&e!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i+=this._beatsToUnits(parseFloat(t))),n&&n!=="0"&&(i+=this._beatsToUnits(parseFloat(n)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof na&&this.fromType(this._val),Tt(this._val))return this._noArg();if(Xt(this._val)&&Tt(this._units)){for(const e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(ds(this._val)){let e=0;for(const t in this._val)if(he(this._val[t])){const n=this._val[t],i=new this.constructor(this.context,t).valueOf()*n;e+=i}return e}if(he(this._units)){const e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}else return Xt(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(e){switch(this._units=void 0,this.defaultUnits){case"s":this._val=e.toSeconds();break;case"i":this._val=e.toTicks();break;case"hz":this._val=e.toFrequency();break;case"midi":this._val=e.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}}class Dt extends na{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:e=>{const t=new Dt(this.context,e).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(t))},regexp:/^@(.+)/}})}quantize(e,t=1){const n=new this.constructor(this.context,e).valueOf(),i=this.valueOf(),a=Math.round(i/n)*n-i;return i+a*t}toNotation(){const e=this.toSeconds(),t=["1m"];for(let r=1;r<9;r++){const o=Math.pow(2,r);t.push(o+"n."),t.push(o+"n"),t.push(o+"t")}t.push("0");let n=t[0],i=new Dt(this.context,t[0]).toSeconds();return t.forEach(r=>{const o=new Dt(this.context,r).toSeconds();Math.abs(o-e)<Math.abs(i-e)&&(n=r,i=o)}),n}toBarsBeatsSixteenths(){const e=this._beatsToUnits(1);let t=this.valueOf()/e;t=parseFloat(t.toFixed(4));const n=Math.floor(t/this._getTimeSignature());let i=t%1*4;t=Math.floor(t)%this._getTimeSignature();const r=i.toString();return r.length>3&&(i=parseFloat(parseFloat(r).toFixed(3))),[n,t,i].join(":")}toTicks(){const e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return xs(this.toFrequency())}_now(){return this.context.now()}}function Fg(s,e){return new Dt(fe(),s,e)}class vt extends Dt{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Og()}static set A4(e){Ng(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(e){return this.defaultUnits==="midi"?e:vt.mtof(e)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(e,t){const i=Vg[e.toLowerCase()]+(parseInt(t,10)+1)*12;return this.defaultUnits==="midi"?i:vt.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,n){let i=1;return e&&e!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!=="0"&&(i*=this._beatsToUnits(parseFloat(t))),n&&n!=="0"&&(i*=this._beatsToUnits(parseFloat(n)/4)),i}}})}transpose(e){return new vt(this.context,this.valueOf()*hn(e))}harmonize(e){return e.map(t=>this.transpose(t))}toMidi(){return xs(this.valueOf())}toNote(){const e=this.toFrequency(),t=Math.log2(e/vt.A4);let n=Math.round(12*t)+57;const i=Math.floor(n/12);return i<0&&(n+=-12*i),Pg[n%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return sa(e)}static ftom(e){return xs(e)}}const Vg={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},Pg=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function Wg(s,e){return new vt(fe(),s,e)}class Le extends Dt{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}function Bg(s,e){return new Le(fe(),s,e)}class et extends ms{constructor(){super();const e=F(et.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=e.context}static getDefaults(){return{context:fe()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(e){return Ql(e),new Dt(this.context,e).toSeconds()}toFrequency(e){return new vt(this.context,e).toFrequency()}toTicks(e){return new Le(this.context,e).toTicks()}_getPartialProperties(e){const t=this.get();return Object.keys(t).forEach(n=>{Tt(e[n])&&delete t[n]}),t}get(){const e=Dg(this);return Object.keys(e).forEach(t=>{if(Reflect.has(this,t)){const n=this[t];he(n)&&he(n.value)&&he(n.setValueAtTime)?e[t]=n.value:n instanceof et?e[t]=n._getPartialProperties(e[t]):at(n)||Ot(n)||Xt(n)||Uo(n)?e[t]=n:delete e[t]}}),e}set(e){return Object.keys(e).forEach(t=>{Reflect.has(this,t)&&he(this[t])&&(this[t]&&he(this[t].value)&&he(this[t].setValueAtTime)?this[t].value!==e[t]&&(this[t].value=e[t]):this[t]instanceof et?this[t].set(e[t]):this[t]=e[t])}),this}}class xn extends Et{constructor(e="stopped"){super(),this.name="StateTimeline",this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){const t=this.get(e);return t!==null?t.state:this._initial}setStateAtTime(e,t,n){return Xe(t,0),this.add(Object.assign({},n,{state:e,time:t})),this}getLastState(e,t){const n=this._search(t);for(let i=n;i>=0;i--){const r=this._timeline[i];if(r.state===e)return r}}getNextState(e,t){const n=this._search(t);if(n!==-1)for(let i=n;i<this._timeline.length;i++){const r=this._timeline[i];if(r.state===e)return r}}}class ce extends et{constructor(){const e=F(ce.getDefaults(),arguments,["param","units","convert"]);for(super(e),this.name="Param",this.overridden=!1,this._minOutput=1e-7,K(he(e.param)&&(Bs(e.param)||e.param instanceof ce),"param must be an AudioParam");!Bs(e.param);)e.param=e.param._param;this._swappable=he(e.swappable)?e.swappable:!1,this._swappable?(this.input=this.context.createGain(),this._param=e.param,this.input.connect(this._param)):this._param=this.input=e.param,this._events=new Et(1e3),this._initialValue=this._param.defaultValue,this.units=e.units,this.convert=e.convert,this._minValue=e.minValue,this._maxValue=e.maxValue,he(e.value)&&e.value!==this._toType(this._initialValue)&&this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(et.getDefaults(),{convert:!0,units:"number"})}get value(){const e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return he(this._minValue)?this._minValue:this.units==="time"||this.units==="frequency"||this.units==="normalRange"||this.units==="positive"||this.units==="transportTime"||this.units==="ticks"||this.units==="bpm"||this.units==="hertz"||this.units==="samples"?0:this.units==="audioRange"?-1:this.units==="decibels"?-1/0:this._param.minValue}get maxValue(){return he(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return he(this.maxValue)&&he(this.minValue)&&Xe(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,"time")?this.toSeconds(e):this._is(e,"decibels")?un(e):this._is(e,"frequency")?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units==="decibels"?li(e):e}setValueAtTime(e,t){const n=this.toSeconds(t),i=this._fromType(e);return K(isFinite(i)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",e,n),this._events.add({time:n,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,n),this}getValueAtTime(e){const t=Math.max(this.toSeconds(e),0),n=this._events.getAfter(t),i=this._events.get(t);let r=this._initialValue;if(i===null)r=this._initialValue;else if(i.type==="setTargetAtTime"&&(n===null||n.type==="setValueAtTime")){const o=this._events.getBefore(i.time);let a;o===null?a=this._initialValue:a=o.value,i.type==="setTargetAtTime"&&(r=this._exponentialApproach(i.time,a,i.value,i.constant,t))}else if(n===null)r=i.value;else if(n.type==="linearRampToValueAtTime"||n.type==="exponentialRampToValueAtTime"){let o=i.value;if(i.type==="setTargetAtTime"){const a=this._events.getBefore(i.time);a===null?o=this._initialValue:o=a.value}n.type==="linearRampToValueAtTime"?r=this._linearInterpolate(i.time,o,n.time,n.value,t):r=this._exponentialInterpolate(i.time,o,n.time,n.value,t)}else r=i.value;return this._toType(r)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){const n=this._fromType(e),i=this.toSeconds(t);return K(isFinite(n)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(n),this._events.add({time:i,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",e,i),this._param.linearRampToValueAtTime(n,i),this}exponentialRampToValueAtTime(e,t){let n=this._fromType(e);n=zt(n,0)?this._minOutput:n,this._assertRange(n);const i=this.toSeconds(t);return K(isFinite(n)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",e,i),this._param.exponentialRampToValueAtTime(n,i),this}exponentialRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(e,n+this.toSeconds(t)),this}linearRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(e,n+this.toSeconds(t)),this}targetRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(e,n,t),this}exponentialApproachValueAtTime(e,t,n){t=this.toSeconds(t),n=this.toSeconds(n);const i=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(e,t,i),this.cancelAndHoldAtTime(t+n*.9),this.linearRampToValueAtTime(e,t+n),this}setTargetAtTime(e,t,n){const i=this._fromType(e);K(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const r=this.toSeconds(t);return this._assertRange(i),K(isFinite(i)&&isFinite(r),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:n,time:r,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",e,r,n),this._param.setTargetAtTime(i,r,n),this}setValueCurveAtTime(e,t,n,i=1){n=this.toSeconds(n),t=this.toSeconds(t);const r=this._fromType(e[0])*i;this.setValueAtTime(this._toType(r),t);const o=n/(e.length-1);for(let a=1;a<e.length;a++){const c=this._fromType(e[a])*i;this.linearRampToValueAtTime(this._toType(c),t+a*o)}return this}cancelScheduledValues(e){const t=this.toSeconds(e);return K(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,"cancelScheduledValues",t),this}cancelAndHoldAtTime(e){const t=this.toSeconds(e),n=this._fromType(this.getValueAtTime(t));K(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,"cancelAndHoldAtTime",t,"value="+n);const i=this._events.get(t),r=this._events.getAfter(t);return i&&zt(i.time,t)?r?(this._param.cancelScheduledValues(r.time),this._events.cancel(r.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):r&&(this._param.cancelScheduledValues(r.time),this._events.cancel(r.time),r.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(n),t):r.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(n),t)),this._events.add({time:t,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,t),this}rampTo(e,t=.1,n){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(e,t,n):this.linearRampTo(e,t,n),this}apply(e){const t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);const n=this._events.get(t);if(n&&n.type==="setTargetAtTime"){const i=this._events.getAfter(n.time),r=i?i.time:t+2,o=(r-t)/10;for(let a=t;a<r;a+=o)e.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?e.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?e.setTargetAtTime(i.value,i.time,i.constant):e[i.type](i.value,i.time)}),this}setParam(e){K(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,n,i,r){return n+(t-n)*Math.exp(-(r-e)/i)}_linearInterpolate(e,t,n,i,r){return t+(i-t)*((r-e)/(n-e))}_exponentialInterpolate(e,t,n,i,r){return t*Math.pow(i/t,(r-e)/(n-e))}}class $ extends et{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return he(this.input)?Bs(this.input)||this.input instanceof ce?1:this.input.numberOfInputs:0}get numberOfOutputs(){return he(this.output)?this.output.numberOfOutputs:0}_isAudioNode(e){return he(e)&&(e instanceof $||Ss(e))}_getInternalNodes(){const e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(n=>{n.channelCount=e.channelCount,n.channelCountMode=e.channelCountMode,n.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){const e=this._getInternalNodes();K(e.length>0,"ToneAudioNode does not have any internal nodes");const t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){const t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,n=0){return dt(this,e,t,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return yn("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(e,t=0,n=0){return ia(this,e,t,n),this}chain(...e){return Nt(this,...e),this}fan(...e){return e.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),he(this.input)&&(this.input instanceof $?this.input.dispose():Ss(this.input)&&this.input.disconnect()),he(this.output)&&(this.output instanceof $?this.output.dispose():Ss(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function Nt(...s){const e=s.shift();s.reduce((t,n)=>(t instanceof $?t.connect(n):Ss(t)&&dt(t,n),n),e)}function dt(s,e,t=0,n=0){for(K(he(s),"Cannot connect from undefined node"),K(he(e),"Cannot connect to undefined node"),(e instanceof $||Ss(e))&&K(e.numberOfInputs>0,"Cannot connect to node with no inputs"),K(s.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof $||e instanceof ce;)he(e.input)&&(e=e.input);for(;s instanceof $;)he(s.output)&&(s=s.output);Bs(e)?s.connect(e,t):s.connect(e,t,n)}function ia(s,e,t=0,n=0){if(he(e))for(;e instanceof $;)e=e.input;for(;!Ss(s);)he(s.output)&&(s=s.output);Bs(e)?s.disconnect(e,t):Ss(e)?s.disconnect(e,t,n):s.disconnect()}function $g(...s){const e=s.pop();he(e)&&s.forEach(t=>dt(t,e))}class Y extends ${constructor(){const e=F(Y.getDefaults(),arguments,["gain","units"]);super(e),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new ce({context:this.context,convert:e.convert,param:this._gainNode.gain,units:e.units,value:e.gain,minValue:e.minValue,maxValue:e.maxValue}),ne(this,"gain")}static getDefaults(){return Object.assign($.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class dn extends ${constructor(e){super(e),this.onended=ge,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Y({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const n=this.toSeconds(t);return this._startTime!==-1&&n>=this._startTime&&(this._stopTime===-1||n<=this._stopTime)?"started":"stopped"},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign($.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:ge})}_startGain(e,t=1){K(this._startTime===-1,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=e+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(t,e+n):this._gainNode.gain.exponentialApproachValueAtTime(t,e,n)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log("stop",e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){K(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();const t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{const n=this._curve==="exponential"?t*2:0;this._stopSource(this.now()+n),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==ge&&(this.onended(this),this.onended=ge,!this.context.isOffline)){const e=()=>this.dispose();typeof requestIdleCallback<"u"?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),K(this._startTime!==-1,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=ge,this}}class pr extends dn{constructor(){const e=F(pr.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),dt(this._source,this._gainNode),this.offset=new ce({context:this.context,convert:e.convert,param:this._source.offset,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(dn.getDefaults(),{convert:!0,offset:1,units:"number"})}start(e){const t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}}class oe extends ${constructor(){const e=F(oe.getDefaults(),arguments,["value","units"]);super(e),this.name="Signal",this.override=!0,this.output=this._constantSource=new pr({context:this.context,convert:e.convert,offset:e.value,units:e.units,minValue:e.minValue,maxValue:e.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign($.getDefaults(),{convert:!0,units:"number",value:0})}connect(e,t=0,n=0){return ui(this,e,t,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,n){return this._param.exponentialRampTo(e,t,n),this}linearRampTo(e,t,n){return this._param.linearRampTo(e,t,n),this}targetRampTo(e,t,n){return this._param.targetRampTo(e,t,n),this}exponentialApproachValueAtTime(e,t,n){return this._param.exponentialApproachValueAtTime(e,t,n),this}setTargetAtTime(e,t,n){return this._param.setTargetAtTime(e,t,n),this}setValueCurveAtTime(e,t,n,i){return this._param.setValueCurveAtTime(e,t,n,i),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,n){return this._param.rampTo(e,t,n),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}}function ui(s,e,t,n){(e instanceof ce||Bs(e)||e instanceof oe&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof oe&&(e.overridden=!0)),dt(s,e,t,n)}class ra extends ce{constructor(){const e=F(ra.getDefaults(),arguments,["value"]);super(e),this.name="TickParam",this._events=new Et(1/0),this._multiplier=1,this._multiplier=e.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(e.value)}),this.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(ce.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(e,t,n){t=this.toSeconds(t),this.setRampPoint(t);const i=this._fromType(e),r=this._events.get(t),o=Math.round(Math.max(1/n,1));for(let a=0;a<=o;a++){const c=n*a+t,l=this._exponentialApproach(r.time,r.value,i,n,c);this.linearRampToValueAtTime(this._toType(l),c)}return this}setValueAtTime(e,t){const n=this.toSeconds(t);super.setValueAtTime(e,t);const i=this._events.get(n),r=this._events.previousEvent(i),o=this._getTicksUntilEvent(r,n);return i.ticks=Math.max(o,0),this}linearRampToValueAtTime(e,t){const n=this.toSeconds(t);super.linearRampToValueAtTime(e,t);const i=this._events.get(n),r=this._events.previousEvent(i),o=this._getTicksUntilEvent(r,n);return i.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);const n=this._fromType(e),i=this._events.get(t),r=Math.round(Math.max((t-i.time)*10,1)),o=(t-i.time)/r;for(let a=0;a<=r;a++){const c=o*a+i.time,l=this._exponentialInterpolate(i.time,i.value,t,n,c);this.linearRampToValueAtTime(this._toType(l),c)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Tt(e.ticks)){const o=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(o,e.time)}const n=this._fromType(this.getValueAtTime(e.time));let i=this._fromType(this.getValueAtTime(t));const r=this._events.get(t);return r&&r.time===t&&r.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(n+i)+e.ticks}getTicksAtTime(e){const t=this.toSeconds(e),n=this._events.get(t);return Math.max(this._getTicksUntilEvent(n,t),0)}getDurationOfTicks(e,t){const n=this.toSeconds(t),i=this.getTicksAtTime(t);return this.getTimeOfTick(i+e)-n}getTimeOfTick(e){const t=this._events.get(e,"ticks"),n=this._events.getAfter(e,"ticks");if(t&&t.ticks===e)return t.time;if(t&&n&&n.type==="linearRampToValueAtTime"&&t.value!==n.value){const i=this._fromType(this.getValueAtTime(t.time)),o=(this._fromType(this.getValueAtTime(n.time))-i)/(n.time-t.time),a=Math.sqrt(Math.pow(i,2)-2*o*(t.ticks-e)),c=(-i+a)/o,l=(-i-a)/o;return(c>0?c:l)+t.time}else return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){const n=this.toSeconds(t),i=this.toSeconds(e),r=this.getTicksAtTime(n);return this.getTicksAtTime(n+i)-r}_fromType(e){return this.units==="bpm"&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units==="bpm"&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){const t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}}class oa extends oe{constructor(){const e=F(oa.getDefaults(),arguments,["value"]);super(e),this.name="TickSignal",this.input=this._param=new ra({context:this.context,convert:e.convert,multiplier:e.multiplier,param:this._constantSource.offset,units:e.units,value:e.value})}static getDefaults(){return Object.assign(oe.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}}class aa extends et{constructor(){const e=F(aa.getDefaults(),arguments,["frequency"]);super(e),this.name="TickSource",this._state=new xn,this._tickOffset=new Et,this._ticksAtTime=new Et,this._secondsAtTime=new Et,this.frequency=new oa({context:this.context,units:e.units,value:e.frequency}),ne(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},et.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){const n=this.toSeconds(e);return this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),he(t)&&this.setTicksAtTime(t,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),this}stop(e){const t=this.toSeconds(e);if(this._state.getValueAtTime(t)==="stopped"){const n=this._state.get(t);n&&n.time>0&&(this._tickOffset.cancel(n.time),this._state.cancel(n.time))}return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){const t=this.toSeconds(e),n=this._state.getLastState("stopped",t),i=this._ticksAtTime.get(t),r={state:"paused",time:t};this._state.add(r);let o=i||n,a=i?i.ticks:0,c=null;return this._state.forEachBetween(o.time,t+this.sampleTime,l=>{let u=o.time;const h=this._tickOffset.get(l.time);h&&h.time>=o.time&&(a=h.ticks,u=h.time),o.state==="started"&&l.state!=="started"&&(a+=this.frequency.getTicksAtTime(l.time)-this.frequency.getTicksAtTime(u),l.time!==r.time&&(c={state:l.state,time:l.time,ticks:a})),o=l}),this._state.remove(r),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){const t=this.now(),n=this.frequency.timeToTicks(e,t);this.setTicksAtTime(n,t)}getSecondsAtTime(e){e=this.toSeconds(e);const t=this._state.getLastState("stopped",e),n={state:"paused",time:e};this._state.add(n);const i=this._secondsAtTime.get(e);let r=i||t,o=i?i.seconds:0,a=null;return this._state.forEachBetween(r.time,e+this.sampleTime,c=>{let l=r.time;const u=this._tickOffset.get(c.time);u&&u.time>=r.time&&(o=u.seconds,l=u.time),r.state==="started"&&c.state!=="started"&&(o+=c.time-l,c.time!==n.time&&(a={state:c.state,time:c.time,seconds:o})),r=c}),this._state.remove(n),a&&this._secondsAtTime.add(a),o}setTicksAtTime(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){const n=this._tickOffset.get(t),i=this._state.get(t),r=Math.max(n.time,i.time),o=this.frequency.getTicksAtTime(r)+e-n.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(e,t,n){let i=this._state.get(e);this._state.forEachBetween(e,t,o=>{i&&i.state==="started"&&o.state!=="started"&&this.forEachTickBetween(Math.max(i.time,e),o.time-this.sampleTime,n),i=o});let r=null;if(i&&i.state==="started"){const o=Math.max(i.time,e),a=this.frequency.getTicksAtTime(o),c=this.frequency.getTicksAtTime(i.time),l=a-c;let u=Math.ceil(l)-l;u=zt(u,1)?0:u;let h=this.frequency.getTimeOfTick(a+u);for(;h<t;){try{n(h,Math.round(this.getTicksAtTime(h)))}catch(p){r=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(r)throw r;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}}class Cn extends et{constructor(){const e=F(Cn.getDefaults(),arguments,["callback","frequency"]);super(e),this.name="Clock",this.callback=ge,this._lastUpdate=0,this._state=new xn("stopped"),this._boundLoop=this._loop.bind(this),this.callback=e.callback,this._tickSource=new aa({context:this.context,frequency:e.frequency,units:e.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,ne(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(et.getDefaults(),{callback:ge,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){Ko(this.context);const n=this.toSeconds(e);return this.log("start",n),this._state.getValueAtTime(n)!=="started"&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,t),n<this._lastUpdate&&this.emit("start",n,t)),this}stop(e){const t=this.toSeconds(e);return this.log("stop",t),this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit("stop",t),this}pause(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)==="started"&&(this._state.setStateAtTime("paused",t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit("pause",t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){const n=this.toSeconds(t),i=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(i+e,n)}_loop(){const e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log("loop",e,t),e!==t&&(this._state.forEachBetween(e,t,n=>{switch(n.state){case"started":const i=this._tickSource.getTicksAtTime(n.time);this.emit("start",n.time,i);break;case"stopped":n.time!==0&&this.emit("stop",n.time);break;case"paused":this.emit("pause",n.time);break}}),this._tickSource.forEachTickBetween(e,t,(n,i)=>{this.callback(n,i)}))}getStateAtTime(e){const t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}bn.mixin(Cn);class Mt extends ${constructor(){const e=F(Mt.getDefaults(),arguments,["delayTime","maxDelay"]);super(e),this.name="Delay";const t=this.toSeconds(e.maxDelay);this._maxDelay=Math.max(t,this.toSeconds(e.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(t),this.delayTime=new ce({context:this.context,param:this._delayNode.delayTime,units:"time",value:e.delayTime,minValue:0,maxValue:this.maxDelay}),ne(this,"delayTime")}static getDefaults(){return Object.assign($.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}}class Ut extends ${constructor(){const e=F(Ut.getDefaults(),arguments,["volume"]);super(e),this.name="Volume",this.input=this.output=new Y({context:this.context,gain:e.volume,units:"decibels"}),this.volume=this.output.gain,ne(this,"volume"),this._unmutedVolume=e.volume,this.mute=e.mute}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class ca extends ${constructor(){const e=F(ca.getDefaults(),arguments);super(e),this.name="Destination",this.input=new Ut({context:this.context}),this.output=new Y({context:this.context}),this.volume=this.input.volume,Nt(this.input,this.output,this.context.rawContext.destination),this.mute=e.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),Nt(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}ur(s=>{s.destination=new ca({context:s})});hr(s=>{s.destination.dispose()});class qg extends ${constructor(){super(...arguments),this.name="Listener",this.positionX=new ce({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ce({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ce({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ce({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ce({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ce({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ce({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ce({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ce({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign($.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}}ur(s=>{s.listener=new qg({context:s})});hr(s=>{s.listener.dispose()});function jg(s,e){return Ae(this,arguments,void 0,function*(t,n,i=2,r=fe().sampleRate){const o=fe(),a=new wn(i,n,r);Hn(a),yield t(a);const c=a.render();Hn(o);const l=yield c;return new xe(l)})}class Sn extends ms{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const e=F(Sn.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=e.baseUrl,Object.keys(e.urls).forEach(t=>{this._loadingCount++;const n=e.urls[t];this.add(t,n,this._bufferLoaded.bind(this,e.onload),e.onerror)})}static getDefaults(){return{baseUrl:"",onerror:ge,onload:ge,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return K(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,n=ge,i=ge){return Xt(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(e.toString(),new xe(this.baseUrl+t,n,i))):this._buffers.set(e.toString(),new xe(t,n,i)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}}class pn extends vt{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(e){return xs(super._frequencyToUnits(e))}_ticksToUnits(e){return xs(super._ticksToUnits(e))}_beatsToUnits(e){return xs(super._beatsToUnits(e))}_secondsToUnits(e){return xs(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return sa(this.toMidi())}transpose(e){return new pn(this.context,this.toMidi()+e)}}function Lg(s,e){return new pn(fe(),s,e)}class Fe extends Le{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}function zg(s,e){return new Fe(fe(),s,e)}class Zg extends et{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Et,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){const e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}ur(s=>{s.draw=new Zg({context:s})});hr(s=>{s.draw.dispose()});class iu extends ms{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(e){K(he(e.time),"Events must have a time property"),K(he(e.duration),"Events must have a duration parameter"),e.time=e.time.valueOf();let t=new Gg(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){const t=[];this._root.search(e.time,t);for(const n of t)if(n.event===e){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,t=>this.remove(t)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent!==null?(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent)):this._setRoot(t)}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{const t=e.getBalance();let n,i=null;if(t>0)if(e.left.right===null)n=e.left,n.right=e.right,i=n;else{for(n=e.left.right;n.right!==null;)n=n.right;n.parent&&(n.parent.right=n.left,i=n.parent,n.left=e.left,n.right=e.right)}else if(e.right.left===null)n=e.right,n.left=e.left,i=n;else{for(n=e.right.left;n.left!==null;)n=n.left;n.parent&&(n.parent.left=n.right,i=n.parent,n.left=e.left,n.right=e.right)}e.parent!==null?e.isLeftChild()?e.parent.left=n:e.parent.right=n:this._setRoot(n),i&&this._rebalance(i)}e.dispose()}_rotateLeft(e){const t=e.parent,n=e.isLeftChild(),i=e.right;i&&(e.right=i.left,i.left=e),t!==null?n?t.left=i:t.right=i:this._setRoot(i)}_rotateRight(e){const t=e.parent,n=e.isLeftChild(),i=e.left;i&&(e.left=i.right,i.right=e),t!==null?n?t.left=i:t.right=i:this._setRoot(i)}_rebalance(e){const t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){const t=[];if(this._root.search(e,t),t.length>0){let n=t[0];for(let i=1;i<t.length;i++)t[i].low>n.low&&(n=t[i]);return n.event}}return null}forEach(e){if(this._root!==null){const t=[];this._root.traverse(n=>t.push(n)),t.forEach(n=>{n.event&&e(n.event)})}return this}forEachAtTime(e,t){if(this._root!==null){const n=[];this._root.search(e,n),n.forEach(i=>{i.event&&t(i.event)})}return this}forEachFrom(e,t){if(this._root!==null){const n=[];this._root.searchAfter(e,n),n.forEach(i=>{i.event&&t(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}}class Gg{constructor(e,t,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),!(this.low>e)&&this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left!==null?e=this.left.height+1:this.right!==null&&(e=-(this.right.height+1)),e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}const Xg=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));class Hg extends ms{constructor(e){super(),this.name="TimelineValue",this._timeline=new Et({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){const t=this._timeline.get(e);return t?t.value:this._initialValue}}class Ft extends ${constructor(){super(F(Ft.getDefaults(),arguments,["context"]))}connect(e,t=0,n=0){return ui(this,e,t,n),this}}class Kt extends Ft{constructor(){const e=F(Kt.getDefaults(),arguments,["mapping","length"]);super(e),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,at(e.mapping)||e.mapping instanceof Float32Array?this.curve=Float32Array.from(e.mapping):Ul(e.mapping)&&this.setMap(e.mapping,e.length)}static getDefaults(){return Object.assign(oe.getDefaults(),{length:1024})}setMap(e,t=1024){const n=new Float32Array(t);for(let i=0,r=t;i<r;i++){const o=i/(r-1)*2-1;n[i]=e(o,i)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){const t=["none","2x","4x"].some(n=>n.includes(e));K(t,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class Tn extends Ft{constructor(){const e=F(Tn.getDefaults(),arguments,["value"]);super(e),this.name="Pow",this._exponentScaler=this.input=this.output=new Kt({context:this.context,mapping:this._expFunc(e.value),length:8192}),this._exponent=e.value}static getDefaults(){return Object.assign(Ft.getDefaults(),{value:1})}_expFunc(e){return t=>Math.pow(Math.abs(t),e)}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class Ts{constructor(e,t){this.id=Ts._eventId++,this._remainderTime=0;const n=Object.assign(Ts.getDefaults(),t);this.transport=e,this.callback=n.callback,this._once=n.once,this.time=Math.floor(n.time),this._remainderTime=n.time-this.time}static getDefaults(){return{callback:ge,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){const t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}}Ts._eventId=0;class la extends Ts{constructor(e,t){super(e,t),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(la.getDefaults(),t);this.duration=n.duration,this._interval=n.interval,this._nextTick=n.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Ts.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return Ui(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Fe(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){Ui(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Fe(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;const t=this.transport.getTicksAtTime(e);ln(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}}class fr extends et{constructor(){const e=F(fr.getDefaults(),arguments);super(e),this.name="Transport",this._loop=new Hg(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Et,this._repeatedEvents=new iu,this._syncedSignals=[],this._swingAmount=0,this._ppq=e.ppq,this._clock=new Cn({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=e.ppq,this.bpm.setValueAtTime(e.bpm,0),ne(this,"bpm"),this._timeSignature=e.timeSignature,this._swingTicks=e.ppq/2}static getDefaults(){return Object.assign(et.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit("loopEnd",e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit("loopStart",e,this._clock.getSecondsAtTime(e)),this.emit("loop",e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!==0){const n=t%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(n*Math.PI)*this._swingAmount;e+=new Fe(this.context,this._swingTicks*2/3).toSeconds()*i}yo(!0),this._timeline.forEachAtTime(t,n=>n.invoke(e)),yo(!1)}schedule(e,t){const n=new Ts(this,{callback:e,time:new Le(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(e,t,n,i=1/0){const r=new la(this,{callback:e,duration:new Dt(this.context,i).toTicks(),interval:new Dt(this.context,t).toTicks(),time:new Le(this.context,n).toTicks()});return this._addEvent(r,this._repeatedEvents)}scheduleOnce(e,t){const n=new Ts(this,{callback:e,once:!0,time:new Le(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){const t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){const t=this.toTicks(e);return this._timeline.forEachFrom(t,n=>this.clear(n.id)),this._repeatedEvents.forEachFrom(t,n=>this.clear(n.id)),this}_bindClockEvents(){this._clock.on("start",(e,t)=>{t=new Fe(this.context,t).toSeconds(),this.emit("start",e,t)}),this._clock.on("stop",e=>{this.emit("stop",e)}),this._clock.on("pause",e=>{this.emit("pause",e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let n;return he(t)&&(n=this.toTicks(t)),this._clock.start(e,n),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)!=="started"?this.start(e):this.stop(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){at(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new Dt(this.context,this._loopStart,"i").toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new Dt(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new Fe(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){const e=this.now(),t=this._clock.getTicksAtTime(e);return new Fe(this.context,t).toBarsBeatsSixteenths()}set position(e){const t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){const t=this.now(),n=this._clock.frequency.timeToTicks(e,t);this.ticks=n}get progress(){if(this.loop){const e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){const t=this.now();if(this.state==="started"){const n=this._clock.getTicksAtTime(t),i=this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,t),r=t+i;this.emit("stop",r),this._clock.setTicksAtTime(e,r),this.emit("start",r,this._clock.getSecondsAtTime(r))}else this.emit("ticks",t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!=="started")return 0;{const t=this.now(),n=this.getTicksAtTime(t),i=e-n%e;return this._clock.nextTickTime(i,t)}}syncSignal(e,t){const n=this.now();let i=this.bpm,r=1/(60/i.getValueAtTime(n)/this.PPQ),o=[];if(e.units==="time"){const c=.015625/r,l=new Y(c),u=new Tn(-1),h=new Y(c);i.chain(l,u,h),i=h,r=1/r,o=[l,u,h]}t||(e.getValueAtTime(n)!==0?t=e.getValueAtTime(n)/r:t=0);const a=new Y(t);return i.connect(a),a.connect(e._param),o.push(a),this._syncedSignals.push({initial:e.value,nodes:o,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){const n=this._syncedSignals[t];n.signal===e&&(n.nodes.forEach(i=>i.dispose()),n.signal.value=n.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),ci(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}bn.mixin(fr);ur(s=>{s.transport=new fr({context:s})});hr(s=>{s.transport.dispose()});class Be extends ${constructor(e){super(e),this.input=void 0,this._state=new xn("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=ge,this._syncedStop=ge,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Ut({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume"),this.onstop=e.onstop}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,onstop:ge,volume:0})}get state(){return this._synced?this.context.transport.state==="started"?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,n){let i=Tt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")K(ln(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,t,n);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){const r=this._state.get(i);r&&(r.offset=this.toSeconds(Bt(t,0)),r.duration=n?this.toSeconds(n):void 0);const o=this.context.transport.schedule(a=>{this._start(a,t,n)},i);this._scheduled.push(o),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else Ko(this.context),this._start(i,t,n);return this}stop(e){let t=Tt(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)==="started"||he(this._state.getNextState("started",t))){if(this.log("stop",t),!this._synced)this._stop(t);else{const n=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(n)}this._state.cancel(t),this._state.setStateAtTime("stopped",t)}return this}restart(e,t,n){return e=this.toSeconds(e),this._state.getValueAtTime(e)==="started"&&(this._state.cancel(e),this._restart(e,t,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>{if(ln(t,0)){const n=this._state.get(t);if(n&&n.state==="started"&&n.time!==t){const i=t-this.toSeconds(n.time);let r;n.duration&&(r=this.toSeconds(n.duration)-i),this._start(e,this.toSeconds(n.offset)+i,r)}}},this._syncedStop=e=>{const t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)==="started"&&this._stop(e)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=ge,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Es extends dn{constructor(){const e=F(Es.getDefaults(),arguments,["url","onload"]);super(e),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,dt(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ce({context:this.context,param:this._source.playbackRate,units:"positive",value:e.playbackRate}),this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this._buffer=new xe(e.url,e.onload,e.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(dn.getDefaults(),{url:new xe,loop:!1,loopEnd:0,loopStart:0,onload:ge,onerror:ge,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,n,i=1){K(this.buffer.loaded,"buffer is either not set or not loaded");const r=this.toSeconds(e);this._startGain(r,i),this.loop?t=Bt(t,this.loopStart):t=Bt(t,0);let o=Math.max(this.toSeconds(t),0);if(this.loop){const a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),l=a-c;bo(o,a)&&(o=(o-c)%l+c),zt(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Ui(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(r,o)),he(n)){let a=this.toSeconds(n);a=Math.max(a,0),this.stop(r+a)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class ks extends Be{constructor(){const e=F(ks.getDefaults(),arguments,["type"]);super(e),this.name="Noise",this._source=null,this._playbackRate=e.playbackRate,this.type=e.type,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Be.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(e){if(K(e in cc,"Noise: invalid type: "+e),this._type!==e&&(this._type=e,this.state==="started")){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){const t=cc[this._type];this._source=new Es({url:t,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&(this._source.stop(this.toSeconds(e)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Ks=44100*5,to=2,as={brown:null,pink:null,white:null},cc={get brown(){if(!as.brown){const s=[];for(let e=0;e<to;e++){const t=new Float32Array(Ks);s[e]=t;let n=0;for(let i=0;i<Ks;i++){const r=Math.random()*2-1;t[i]=(n+.02*r)/1.02,n=t[i],t[i]*=3.5}}as.brown=new xe().fromArray(s)}return as.brown},get pink(){if(!as.pink){const s=[];for(let e=0;e<to;e++){const t=new Float32Array(Ks);s[e]=t;let n,i,r,o,a,c,l;n=i=r=o=a=c=l=0;for(let u=0;u<Ks;u++){const h=Math.random()*2-1;n=.99886*n+h*.0555179,i=.99332*i+h*.0750759,r=.969*r+h*.153852,o=.8665*o+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,t[u]=n+i+r+o+a+c+l+h*.5362,t[u]*=.11,l=h*.115926}}as.pink=new xe().fromArray(s)}return as.pink},get white(){if(!as.white){const s=[];for(let e=0;e<to;e++){const t=new Float32Array(Ks);s[e]=t;for(let n=0;n<Ks;n++)t[n]=Math.random()*2-1}as.white=new xe().fromArray(s)}return as.white}};class Zn extends ${constructor(){const e=F(Zn.getDefaults(),arguments,["volume"]);super(e),this.name="UserMedia",this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume"),this.mute=e.mute}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,volume:0})}open(e){return Ae(this,void 0,void 0,function*(){K(Zn.supported,"UserMedia is not supported"),this.state==="started"&&this.close();const t=yield Zn.enumerateDevices();Ot(e)?this._device=t[e]:(this._device=t.find(r=>r.label===e||r.deviceId===e),!this._device&&t.length>0&&(this._device=t[0]),K(he(this._device),`No matching device ${e}`));const n={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(n.audio.deviceId=this._device.deviceId);const i=yield navigator.mediaDevices.getUserMedia(n);if(!this._stream){this._stream=i;const r=this.context.createMediaStreamSource(i);dt(r,this.output),this._mediaStream=r}return this})}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach(e=>{e.stop()}),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return Ae(this,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind==="audioinput")})}get state(){return this._stream&&this._stream.active?"started":"stopped"}get deviceId(){if(this._device)return this._device.deviceId}get groupId(){if(this._device)return this._device.groupId}get label(){if(this._device)return this._device.label}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return he(navigator.mediaDevices)&&he(navigator.mediaDevices.getUserMedia)}}function zs(s,e){return Ae(this,void 0,void 0,function*(){const t=e/s.context.sampleRate,n=new wn(1,t,s.context.sampleRate);return new s.constructor(Object.assign(s.get(),{frequency:2/t,detune:0,context:n})).toDestination().start(0),(yield n.render()).getChannelData(0)})}class hi extends dn{constructor(){const e=F(hi.getDefaults(),arguments,["frequency","type"]);super(e),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],dt(this._oscillator,this._gainNode),this.type=e.type,this.frequency=new ce({context:this.context,param:this._oscillator.frequency,units:"frequency",value:e.frequency}),this.detune=new ce({context:this.context,param:this._oscillator.detune,units:"cents",value:e.detune}),ne(this,["frequency","detune"])}static getDefaults(){return Object.assign(dn.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(e){const t=this.toSeconds(e);return this.log("start",t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class Ve extends Be{constructor(){const e=F(Ve.getDefaults(),arguments,["frequency","type"]);super(e),this.name="Oscillator",this._oscillator=null,this.frequency=new oe({context:this.context,units:"frequency",value:e.frequency}),ne(this,"frequency"),this.detune=new oe({context:this.context,units:"cents",value:e.detune}),ne(this,"detune"),this._partials=e.partials,this._partialCount=e.partialCount,this._type=e.type,e.partialCount&&e.type!=="custom"&&(this._type=this.baseType+e.partialCount.toString()),this.phase=e.phase}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(e){const t=this.toSeconds(e),n=new hi({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(t)}_stop(e){const t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){const t=this.toSeconds(e);return this.log("restart",t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return Ve._periodicWaveCache.find(t=>t.phase===this._phase&&Ig(t.partials,this._partials));{const e=Ve._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=e?e.partialCount:this._partialCount,e}}get type(){return this._type}set type(e){this._type=e;const t=["sine","square","sawtooth","triangle"].indexOf(e)!==-1;if(this._phase===0&&t)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=e);else{const n=this._getCachedPeriodicWave();if(he(n)){const{partials:i,wave:r}=n;this._wave=r,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{const[i,r]=this._getRealImaginary(e,this._phase),o=this.context.createPeriodicWave(i,r);this._wave=o,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),Ve._periodicWaveCache.push({imag:r,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),Ve._periodicWaveCache.length>100&&Ve._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(e){this.partialCount&&this._type!=="custom"&&e!=="custom"?this.type=e+this.partialCount:this.type=e}get partialCount(){return this._partialCount}set partialCount(e){Xe(e,0);let t=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(t=n[1]),this._type!=="custom")e===0?this.type=t:this.type=t+e.toString();else{const i=new Float32Array(e);this._partials.forEach((r,o)=>i[o]=r),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(e,t){let i=2048;const r=new Float32Array(i),o=new Float32Array(i);let a=1;if(e==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[r,o]}else{const c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),e=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){const l=2/(c*Math.PI);let u;switch(e){case"sine":u=c<=a?1:0,this._partials[c-1]=u;break;case"square":u=c&1?2*l:0,this._partials[c-1]=u;break;case"sawtooth":u=l*(c&1?1:-1),this._partials[c-1]=u;break;case"triangle":c&1?u=2*(l*l)*(c-1>>1&1?-1:1):u=0,this._partials[c-1]=u;break;case"custom":u=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+e)}u!==0?(r[c]=-u*Math.sin(t*c),o[c]=u*Math.cos(t*c)):(r[c]=0,o[c]=0)}return[r,o]}_inverseFFT(e,t,n){let i=0;const r=e.length;for(let o=0;o<r;o++)i+=e[o]*Math.cos(o*n)+t[o]*Math.sin(o*n);return i}getInitialValue(){const[e,t]=this._getRealImaginary(this._type,0);let n=0;const i=Math.PI*2,r=32;for(let o=0;o<r;o++)n=Math.max(this._inverseFFT(e,t,o/r*i),n);return js(-this._inverseFFT(e,t,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}Ve._periodicWaveCache=[];class mr extends Ft{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Kt({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Pe extends oe{constructor(){const e=F(Pe.getDefaults(),arguments,["value"]);super(e),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Y({context:this.context,minValue:e.minValue,maxValue:e.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(e.value,0)}static getDefaults(){return Object.assign(oe.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class di extends Be{constructor(){const e=F(di.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="AMOscillator",this._modulationScale=new mr({context:this.context}),this._modulationNode=new Y({context:this.context}),this._carrier=new Ve({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Ve({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new Pe({context:this.context,units:"positive",value:e.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),ne(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ve.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}}class kn extends Be{constructor(){const e=F(kn.getDefaults(),arguments,["frequency","type","modulationType"]);super(e),this.name="FMOscillator",this._modulationNode=new Y({context:this.context,gain:0}),this._carrier=new Ve({context:this.context,detune:e.detune,frequency:0,onstop:()=>this.onstop(this),phase:e.phase,type:e.type}),this.detune=this._carrier.detune,this.frequency=new oe({context:this.context,units:"frequency",value:e.frequency}),this._modulator=new Ve({context:this.context,phase:e.phase,type:e.modulationType}),this.harmonicity=new Pe({context:this.context,units:"positive",value:e.harmonicity}),this.modulationIndex=new Pe({context:this.context,units:"positive",value:e.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),ne(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ve.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class An extends Be{constructor(){const e=F(An.getDefaults(),arguments,["frequency","width"]);super(e),this.name="PulseOscillator",this._widthGate=new Y({context:this.context,gain:0}),this._thresh=new Kt({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new oe({context:this.context,units:"audioRange",value:e.width}),this._triangle=new Ve({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),ne(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class pi extends Be{constructor(){const e=F(pi.getDefaults(),arguments,["frequency","type","spread"]);super(e),this.name="FatOscillator",this._oscillators=[],this.frequency=new oe({context:this.context,units:"frequency",value:e.frequency}),this.detune=new oe({context:this.context,units:"cents",value:e.detune}),this._spread=e.spread,this._type=e.type,this._phase=e.phase,this._partials=e.partials,this._partialCount=e.partialCount,this.count=e.count,ne(this,["frequency","detune"])}static getDefaults(){return Object.assign(Ve.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){const t=-e/2,n=e/(this._oscillators.length-1);this._forEach((i,r)=>i.detune.value=t+n*r)}}get count(){return this._oscillators.length}set count(e){if(Xe(e,1),this._oscillators.length!==e){this._forEach(t=>t.dispose()),this._oscillators=[];for(let t=0;t<e;t++){const n=new Ve({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):ge});this.type==="custom"&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[t]=n}this.spread=this._spread,this.state==="started"&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((t,n)=>t.phase=this._phase+n/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type="custom",this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}}class fi extends Be{constructor(){const e=F(fi.getDefaults(),arguments,["frequency","modulationFrequency"]);super(e),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Pe({context:this.context,value:2}),this._pulse=new An({context:this.context,frequency:e.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Ve({context:this.context,detune:e.detune,frequency:e.frequency,onstop:()=>this.onstop(this),phase:e.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),ne(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Be.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const lc={am:di,fat:pi,fm:kn,oscillator:Ve,pulse:An,pwm:fi};class ps extends Be{constructor(){const e=F(ps.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OmniOscillator",this.frequency=new oe({context:this.context,units:"frequency",value:e.frequency}),this.detune=new oe({context:this.context,units:"cents",value:e.detune}),ne(this,["frequency","detune"]),this.set(e)}static getDefaults(){return Object.assign(Ve.getDefaults(),kn.getDefaults(),di.getDefaults(),pi.getDefaults(),An.getDefaults(),fi.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):e==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,"type")&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;const t=lc[e],n=this.now();if(this._oscillator){const i=this._oscillator;i.stop(n),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new t({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(t=this._oscillator.type),e==="fm"?this.type="fm"+t:e==="am"?this.type="am"+t:e==="fat"?this.type="fat"+t:e==="oscillator"?this.type=t:e==="pulse"?this.type="pulse":e==="pwm"&&(this.type="pwm")}_getOscType(e,t){return e instanceof lc[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&e!=="pulse"&&e!=="pwm"&&(this._oscillator.baseType=e)}get width(){if(this._getOscType(this._oscillator,"pulse"))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.count}set count(e){this._getOscType(this._oscillator,"fat")&&Ot(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,"fat")&&Ot(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&Xt(e)&&(this._oscillator.modulationType=e)}get modulationIndex(){if(this._getOscType(this._oscillator,"fm"))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,"pwm"))return this._oscillator.modulationFrequency}asArray(){return Ae(this,arguments,void 0,function*(e=1024){return zs(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class Zs extends oe{constructor(){super(F(Zs.getDefaults(),arguments,["value"])),this.override=!1,this.name="Add",this._sum=new Y({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,Nt(this._constantSource,this._sum)}static getDefaults(){return Object.assign(oe.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class fs extends Ft{constructor(){const e=F(fs.getDefaults(),arguments,["min","max"]);super(e),this.name="Scale",this._mult=this.input=new Pe({context:this.context,value:e.max-e.min}),this._add=this.output=new Zs({context:this.context,value:e.min}),this._min=e.min,this._max=e.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(Ft.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(e){this._min=e,this._setRange()}get max(){return this._max}set max(e){this._max=e,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}}class gr extends Ft{constructor(){super(F(gr.getDefaults(),arguments)),this.name="Zero",this._gain=new Y({context:this.context}),this.output=this._gain,this.input=void 0,dt(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),ia(this.context.getConstant(0),this._gain),this}}class yt extends ${constructor(){const e=F(yt.getDefaults(),arguments,["frequency","min","max"]);super(e),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=ce.prototype._fromType,this._toType=ce.prototype._toType,this._is=ce.prototype._is,this._clampValue=ce.prototype._clampValue,this._oscillator=new Ve(e),this.frequency=this._oscillator.frequency,this._amplitudeGain=new Y({context:this.context,gain:e.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new oe({context:this.context,units:"audioRange",value:0}),this._zeros=new gr({context:this.context}),this._a2g=new mr({context:this.context}),this._scaler=this.output=new fs({context:this.context,max:e.max,min:e.min}),this.units=e.units,this.min=e.min,this.max=e.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),ne(this,["amplitude","frequency"]),this.phase=e.phase}static getDefaults(){return Object.assign(Ve.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,type:"sine",units:"number"})}start(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(0,e),this._oscillator.start(e),this}stop(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(this._stoppedValue,e),this._oscillator.stop(e),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}_setStoppedValue(){this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get min(){return this._toType(this._scaler.min)}set min(e){e=this._fromType(e),this._scaler.min=e}get max(){return this._toType(this._scaler.max)}set max(e){e=this._fromType(e),this._scaler.max=e}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(e){this._oscillator.partials=e,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e,this._setStoppedValue()}get units(){return this._units}set units(e){const t=this.min,n=this.max;this._units=e,this.min=t,this.max=n}get state(){return this._oscillator.state}connect(e,t,n){return(e instanceof ce||e instanceof oe)&&(this.convert=e.convert,this.units=e.units),ui(this,e,t,n),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}}function ru(s,e=1/0){const t=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(r){Xe(r,s,e),t.set(this,r)}})}}function gs(s,e=1/0){const t=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return t.get(this)},set:function(r){Xe(this.toSeconds(r),s,e),t.set(this,r)}})}}class Gs extends Be{constructor(){const e=F(Gs.getDefaults(),arguments,["url","onload"]);super(e),this.name="Player",this._activeSources=new Set,this._buffer=new xe({onload:this._onload.bind(this,e.onload),onerror:e.onerror,reverse:e.reverse,url:e.url}),this.autostart=e.autostart,this._loop=e.loop,this._loopStart=e.loopStart,this._loopEnd=e.loopEnd,this._playbackRate=e.playbackRate,this.fadeIn=e.fadeIn,this.fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Be.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:ge,onerror:ge,playbackRate:1,reverse:!1})}load(e){return Ae(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=ge){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(e,t,n){return super.start(e,t,n),this}_start(e,t,n){this._loop?t=Bt(t,this._loopStart):t=Bt(t,0);const i=this.toSeconds(t),r=n;n=Bt(n,Math.max(this._buffer.duration-i,0));let o=this.toSeconds(n);o=o/this._playbackRate,e=this.toSeconds(e);const a=new Es({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(e+o),this._state.setStateAtTime("stopped",e+o,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Tt(r)?a.start(e,i):a.start(e,i,o-this.toSeconds(this.fadeOut))}_stop(e){const t=this.toSeconds(e);this._activeSources.forEach(n=>n.stop(t))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(e),this._start(e,t,n)}seek(e,t){const n=this.toSeconds(t);if(this._state.getValueAtTime(n)==="started"){const i=this.toSeconds(e);this._stop(n),this._start(n,i)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&Xe(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&Xe(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;const t=this.now(),n=this._state.getNextState("stopped",t);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}}Yt([gs(0)],Gs.prototype,"fadeIn",void 0);Yt([gs(0)],Gs.prototype,"fadeOut",void 0);class ua extends ${constructor(){const e=F(ua.getDefaults(),arguments,["urls","onload"],"urls");super(e),this.name="Players",this.input=void 0,this._players=new Map,this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume"),this._buffers=new Sn({urls:e.urls,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.mute=e.mute,this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut}static getDefaults(){return Object.assign(Be.getDefaults(),{baseUrl:"",fadeIn:0,fadeOut:0,mute:!1,onload:ge,onerror:ge,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._players.forEach(t=>{t.fadeIn=e})}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._players.forEach(t=>{t.fadeOut=e})}get state(){return Array.from(this._players).some(([t,n])=>n.state==="started")?"started":"stopped"}has(e){return this._buffers.has(e)}player(e){if(K(this.has(e),`No Player with the name ${e} exists on this object`),!this._players.has(e)){const t=new Gs({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(e)}).connect(this.output);this._players.set(e,t)}return this._players.get(e)}get loaded(){return this._buffers.loaded}add(e,t,n){return K(!this._buffers.has(e),"A buffer with that name already exists on this object"),this._buffers.add(e,t,n),this}stopAll(e){return this._players.forEach(t=>t.stop(e)),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach(e=>e.dispose()),this._buffers.dispose(),this}}class ha extends Be{constructor(){const e=F(ha.getDefaults(),arguments,["url","onload"]);super(e),this.name="GrainPlayer",this._loopStart=0,this._loopEnd=0,this._activeSources=[],this.buffer=new xe({onload:e.onload,onerror:e.onerror,reverse:e.reverse,url:e.url}),this._clock=new Cn({context:this.context,callback:this._tick.bind(this),frequency:1/e.grainSize}),this._playbackRate=e.playbackRate,this._grainSize=e.grainSize,this._overlap=e.overlap,this.detune=e.detune,this.overlap=e.overlap,this.loop=e.loop,this.playbackRate=e.playbackRate,this.grainSize=e.grainSize,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.reverse=e.reverse,this._clock.on("stop",this._onstop.bind(this))}static getDefaults(){return Object.assign(Be.getDefaults(),{onload:ge,onerror:ge,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(e,t,n){t=Bt(t,0),t=this.toSeconds(t),e=this.toSeconds(e);const i=1/this._clock.frequency.getValueAtTime(e);this._clock.start(e,t/i),n&&this.stop(e+this.toSeconds(n))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){this._stop(e),this._start(e,t,n)}_stop(e){this._clock.stop(e)}_onstop(e){this._activeSources.forEach(t=>{t.fadeOut=0,t.stop(e)}),this.onstop(this)}_tick(e){const t=this._clock.getTicksAtTime(e),n=t*this._grainSize;if(this.log("offset",n),!this.loop&&n>this.buffer.duration){this.stop(e);return}const i=n<this._overlap?0:this._overlap,r=new Es({context:this.context,url:this.buffer,fadeIn:i,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:hn(this.detune/100)}).connect(this.output);r.start(e,this._grainSize*t),r.stop(e+this._grainSize/this.playbackRate),this._activeSources.push(r),r.onended=()=>{const o=this._activeSources.indexOf(r);o!==-1&&this._activeSources.splice(o,1)}}get playbackRate(){return this._playbackRate}set playbackRate(e){Xe(e,.001),this._playbackRate=e,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(e){this.buffer.loaded&&Xe(this.toSeconds(e),0,this.buffer.duration),this._loopStart=this.toSeconds(e)}get loopEnd(){return this._loopEnd}set loopEnd(e){this.buffer.loaded&&Xe(this.toSeconds(e),0,this.buffer.duration),this._loopEnd=this.toSeconds(e)}get reverse(){return this.buffer.reverse}set reverse(e){this.buffer.reverse=e}get grainSize(){return this._grainSize}set grainSize(e){this._grainSize=this.toSeconds(e),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(e){const t=this.toSeconds(e);Xe(t,0),this._overlap=t}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach(e=>e.dispose()),this}}class ou extends Ft{constructor(){super(...arguments),this.name="Abs",this._abs=new Kt({context:this.context,mapping:e=>Math.abs(e)<.001?0:Math.abs(e)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}}class au extends Ft{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Kt({context:this.context,mapping:e=>Math.abs(e)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class da extends Ft{constructor(){super(...arguments),this.name="Negate",this._multiply=new Pe({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}}class Xs extends oe{constructor(){super(F(Xs.getDefaults(),arguments,["value"])),this.override=!1,this.name="Subtract",this._sum=new Y({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new da({context:this.context}),this.subtrahend=this._param,Nt(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(oe.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}}class _r extends Ft{constructor(){super(F(_r.getDefaults(),arguments)),this.name="GreaterThanZero",this._thresh=this.output=new Kt({context:this.context,length:127,mapping:e=>e<=0?0:1}),this._scale=this.input=new Pe({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}}class vr extends oe{constructor(){const e=F(vr.getDefaults(),arguments,["value"]);super(e),this.name="GreaterThan",this.override=!1,this._subtract=this.input=new Xs({context:this.context,value:e.value}),this._gtz=this.output=new _r({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,ne(this,"comparator"),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(oe.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}}class yr extends fs{constructor(){const e=F(yr.getDefaults(),arguments,["min","max","exponent"]);super(e),this.name="ScaleExp",this.input=this._exp=new Tn({context:this.context,value:e.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(fs.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(e){this._exp.value=e}dispose(){return super.dispose(),this._exp.dispose(),this}}class Yg extends oe{constructor(){const e=F(oe.getDefaults(),arguments,["value","units"]);super(e),this.name="SyncedSignal",this.override=!1,this._lastVal=e.value,this._synced=this.context.transport.scheduleRepeat(this._onTick.bind(this),"1i"),this._syncedCallback=this._anchorValue.bind(this),this.context.transport.on("start",this._syncedCallback),this.context.transport.on("pause",this._syncedCallback),this.context.transport.on("stop",this._syncedCallback),this._constantSource.disconnect(),this._constantSource.stop(0),this._constantSource=this.output=new pr({context:this.context,offset:e.value,units:e.units}).start(0),this.setValueAtTime(e.value,0)}_onTick(e){const t=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==t&&(this._lastVal=t,this._constantSource.offset.setValueAtTime(t,e))}_anchorValue(e){const t=super.getValueAtTime(this.context.transport.seconds);this._lastVal=t,this._constantSource.offset.cancelAndHoldAtTime(e),this._constantSource.offset.setValueAtTime(t,e)}getValueAtTime(e){const t=new Le(this.context,e).toSeconds();return super.getValueAtTime(t)}setValueAtTime(e,t){const n=new Le(this.context,t).toSeconds();return super.setValueAtTime(e,n),this}linearRampToValueAtTime(e,t){const n=new Le(this.context,t).toSeconds();return super.linearRampToValueAtTime(e,n),this}exponentialRampToValueAtTime(e,t){const n=new Le(this.context,t).toSeconds();return super.exponentialRampToValueAtTime(e,n),this}setTargetAtTime(e,t,n){const i=new Le(this.context,t).toSeconds();return super.setTargetAtTime(e,i,n),this}cancelScheduledValues(e){const t=new Le(this.context,e).toSeconds();return super.cancelScheduledValues(t),this}setValueCurveAtTime(e,t,n,i){const r=new Le(this.context,t).toSeconds();return n=this.toSeconds(n),super.setValueCurveAtTime(e,r,n,i),this}cancelAndHoldAtTime(e){const t=new Le(this.context,e).toSeconds();return super.cancelAndHoldAtTime(t),this}setRampPoint(e){const t=new Le(this.context,e).toSeconds();return super.setRampPoint(t),this}exponentialRampTo(e,t,n){const i=new Le(this.context,n).toSeconds();return super.exponentialRampTo(e,t,i),this}linearRampTo(e,t,n){const i=new Le(this.context,n).toSeconds();return super.linearRampTo(e,t,i),this}targetRampTo(e,t,n){const i=new Le(this.context,n).toSeconds();return super.targetRampTo(e,t,i),this}dispose(){return super.dispose(),this.context.transport.clear(this._synced),this.context.transport.off("start",this._syncedCallback),this.context.transport.off("pause",this._syncedCallback),this.context.transport.off("stop",this._syncedCallback),this._constantSource.dispose(),this}}class ct extends ${constructor(){const e=F(ct.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="Envelope",this._sig=new oe({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve,this.decayCurve=e.decayCurve}static getDefaults(){return Object.assign($.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(Xt(e))return e;{let n;for(n in Oi)if(Oi[n][t]===e)return n;return e}}_setCurve(e,t,n){if(Xt(n)&&Reflect.has(Oi,n)){const i=Oi[n];ds(i)?e!=="_decayCurve"&&(this[e]=i[t]):this[e]=i}else if(at(n)&&e!=="_decayCurve")this[e]=n;else throw new Error("Envelope: invalid curve: "+n)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(e){this._setCurve("_attackCurve","In",e)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(e){this._setCurve("_releaseCurve","Out",e)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(e){this._setCurve("_decayCurve","Out",e)}triggerAttack(e,t=1){this.log("triggerAttack",e,t),e=this.toSeconds(e);let i=this.toSeconds(this.attack);const r=this.toSeconds(this.decay),o=this.getValueAtTime(e);if(o>0){const a=1/i;i=(1-o)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve==="linear")this._sig.linearRampTo(t,i,e);else if(this._attackCurve==="exponential")this._sig.targetRampTo(t,i,e);else{this._sig.cancelAndHoldAtTime(e);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=o&&o<=a[c]){a=this._attackCurve.slice(c),a[0]=o;break}this._sig.setValueCurveAtTime(a,e,i,t)}if(r&&this.sustain<1){const a=t*this.sustain,c=e+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,r+c):this._sig.exponentialApproachValueAtTime(a,c,r)}return this}triggerRelease(e){this.log("triggerRelease",e),e=this.toSeconds(e);const t=this.getValueAtTime(e);if(t>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve==="linear"?this._sig.linearRampTo(0,n,e):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,n,e):(K(at(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,n,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),this.triggerAttack(t,n),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}connect(e,t=0,n=0){return ui(this,e,t,n),this}asArray(){return Ae(this,arguments,void 0,function*(e=1024){const t=e/this.context.sampleRate,n=new wn(1,t,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),r=i+this.toSeconds(this.release),o=r*.1,a=r+o,c=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/a,decay:t*this.toSeconds(this.decay)/a,release:t*this.toSeconds(this.release)/a,context:n}));return c._sig.toDestination(),c.triggerAttackRelease(t*(i+o)/a,0),(yield n.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}}Yt([gs(0)],ct.prototype,"attack",void 0);Yt([gs(0)],ct.prototype,"decay",void 0);Yt([ru(0,1)],ct.prototype,"sustain",void 0);Yt([gs(0)],ct.prototype,"release",void 0);const Oi=(()=>{let e,t;const n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));const i=[],r=6.4;for(e=0;e<127;e++){t=e/127;const p=Math.sin(t*(Math.PI*2)*r-Math.PI/2)+1;i[e]=p/10+t*.83}i[127]=1;const o=[],a=5;for(e=0;e<128;e++)o[e]=Math.ceil(e/127*a)/a;const c=[];for(e=0;e<128;e++)t=e/127,c[e]=.5*(1-Math.cos(Math.PI*t));const l=[];for(e=0;e<128;e++){t=e/127;const p=Math.pow(t,3)*4+.2,d=Math.cos(p*Math.PI*2*t);l[e]=Math.abs(d*(1-t))}function u(p){const d=new Array(p.length);for(let f=0;f<p.length;f++)d[f]=1-p[f];return d}function h(p){return p.slice(0).reverse()}return{bounce:{In:u(l),Out:l},cosine:{In:n,Out:h(n)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:u(i)},sine:{In:c,Out:u(c)},step:{In:o,Out:u(o)}}})();class $t extends ${constructor(){const e=F($t.getDefaults(),arguments);super(e),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=t=>this._original_triggerRelease(t),this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,ne(this,"volume")}static getDefaults(){return Object.assign($.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){const n=this["_original_"+e]=this[e];this[e]=(...i)=>{const r=i[t],o=this.context.transport.schedule(a=>{i[t]=a,n.apply(this,i)},r);this._scheduledEvents.push(o)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(e,t,n,i){const r=this.toSeconds(n),o=this.toSeconds(t);return this.triggerAttack(e,r,i),this.triggerRelease(r+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class ot extends $t{constructor(){const e=F(ot.getDefaults(),arguments);super(e),this.portamento=e.portamento,this.onsilence=e.onsilence}static getDefaults(){return Object.assign($t.getDefaults(),{detune:0,onsilence:ge,portamento:0})}triggerAttack(e,t,n=1){this.log("triggerAttack",e,t,n);const i=this.toSeconds(t);return this._triggerEnvelopeAttack(i,n),this.setNote(e,i),this}triggerRelease(e){this.log("triggerRelease",e);const t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){const n=this.toSeconds(t),i=e instanceof vt?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const r=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,r,n)}else this.frequency.setValueAtTime(i,n);return this}}Yt([gs(0)],ot.prototype,"portamento",void 0);class In extends ct{constructor(){super(F(In.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Y({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}}class As extends ot{constructor(){const e=F(As.getDefaults(),arguments);super(e),this.name="Synth",this.oscillator=new ps(Object.assign({context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)},e.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new In(Object.assign({context:this.context},e.envelope)),this.oscillator.chain(this.envelope,this.output),ne(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ot.getDefaults(),{envelope:Object.assign(rt(ct.getDefaults(),Object.keys($.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(rt(ps.getDefaults(),[...Object.keys(Be.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){const n=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+n+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class Yn extends ot{constructor(){const e=F(Yn.getDefaults(),arguments);super(e),this.name="ModulationSynth",this._carrier=new As({context:this.context,oscillator:e.oscillator,envelope:e.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new As({context:this.context,oscillator:e.modulation,envelope:e.modulationEnvelope,volume:-10}),this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope,this.modulation=this._modulator.oscillator,this.modulationEnvelope=this._modulator.envelope,this.frequency=new oe({context:this.context,units:"frequency"}),this.detune=new oe({context:this.context,value:e.detune,units:"cents"}),this.harmonicity=new Pe({context:this.context,value:e.harmonicity,minValue:0}),this._modulationNode=new Y({context:this.context,gain:0}),ne(this,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])}static getDefaults(){return Object.assign(ot.getDefaults(),{harmonicity:3,oscillator:Object.assign(rt(ps.getDefaults(),[...Object.keys(Be.getDefaults()),"frequency","detune"]),{type:"sine"}),envelope:Object.assign(rt(ct.getDefaults(),Object.keys($.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(rt(ps.getDefaults(),[...Object.keys(Be.getDefaults()),"frequency","detune"]),{type:"square"}),modulationEnvelope:Object.assign(rt(ct.getDefaults(),Object.keys($.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(e,t){this._carrier._triggerEnvelopeAttack(e,t),this._modulator._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this._carrier._triggerEnvelopeRelease(e),this._modulator._triggerEnvelopeRelease(e),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}}class pa extends Yn{constructor(){super(F(pa.getDefaults(),arguments)),this.name="AMSynth",this._modulationScale=new mr({context:this.context}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output)}dispose(){return super.dispose(),this._modulationScale.dispose(),this}}class Un extends ${constructor(){const e=F(Un.getDefaults(),arguments,["frequency","type"]);super(e),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ce({context:this.context,units:"number",value:e.Q,param:this._filter.Q}),this.frequency=new ce({context:this.context,units:"frequency",value:e.frequency,param:this._filter.frequency}),this.detune=new ce({context:this.context,units:"cents",value:e.detune,param:this._filter.detune}),this.gain=new ce({context:this.context,units:"decibels",convert:!1,value:e.gain,param:this._filter.gain}),this.type=e.type}static getDefaults(){return Object.assign($.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){K(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){const t=new Float32Array(e);for(let o=0;o<e;o++){const c=Math.pow(o/e,2)*19980+20;t[o]=c}const n=new Float32Array(e),i=new Float32Array(e),r=this.context.createBiquadFilter();return r.type=this.type,r.Q.value=this.Q.value,r.frequency.value=this.frequency.value,r.gain.value=this.gain.value,r.getFrequencyResponse(t,n,i),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}class Rt extends ${constructor(){const e=F(Rt.getDefaults(),arguments,["frequency","type","rolloff"]);super(e),this.name="Filter",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._filters=[],this._filters=[],this.Q=new oe({context:this.context,units:"positive",value:e.Q}),this.frequency=new oe({context:this.context,units:"frequency",value:e.frequency}),this.detune=new oe({context:this.context,units:"cents",value:e.detune}),this.gain=new oe({context:this.context,units:"decibels",convert:!1,value:e.gain}),this._type=e.type,this.rolloff=e.rolloff,ne(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign($.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(e){K(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(n=>n.type=e)}get rolloff(){return this._rolloff}set rolloff(e){const t=Ot(e)?e:parseInt(e,10),n=[-12,-24,-48,-96];let i=n.indexOf(t);K(i!==-1,`rolloff can only be ${n.join(", ")}`),i+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(r=>r.disconnect()),this._filters=new Array(i);for(let r=0;r<i;r++){const o=new Un({context:this.context});o.type=this._type,this.frequency.connect(o.frequency),this.detune.connect(o.detune),this.Q.connect(o.Q),this.gain.connect(o.gain),this._filters[r]=o}this._internalChannels=this._filters,Nt(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){const t=new Un({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(e).map(()=>1);return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((r,o)=>n[o]*=r)}),t.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),ci(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class Kn extends ct{constructor(){const e=F(Kn.getDefaults(),arguments,["attack","decay","sustain","release"]);super(e),this.name="FrequencyEnvelope",this._octaves=e.octaves,this._baseFrequency=this.toFrequency(e.baseFrequency),this._exponent=this.input=new Tn({context:this.context,value:e.exponent}),this._scale=this.output=new fs({context:this.context,min:this._baseFrequency,max:this._baseFrequency*Math.pow(2,this._octaves)}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(ct.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){const t=this.toFrequency(e);Xe(t,0),this._baseFrequency=t,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._scale.max=this._baseFrequency*Math.pow(2,e)}get exponent(){return this._exponent.value}set exponent(e){this._exponent.value=e}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class Ps extends ot{constructor(){const e=F(Ps.getDefaults(),arguments);super(e),this.name="MonoSynth",this.oscillator=new ps(Object.assign(e.oscillator,{context:this.context,detune:e.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new Rt(Object.assign(e.filter,{context:this.context})),this.filterEnvelope=new Kn(Object.assign(e.filterEnvelope,{context:this.context})),this.envelope=new In(Object.assign(e.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),ne(this,["oscillator","frequency","detune","filter","filterEnvelope","envelope"])}static getDefaults(){return Object.assign(ot.getDefaults(),{envelope:Object.assign(rt(ct.getDefaults(),Object.keys($.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(rt(Rt.getDefaults(),Object.keys($.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(rt(Kn.getDefaults(),Object.keys($.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(rt(ps.getDefaults(),Object.keys(Be.getDefaults())),{type:"sawtooth"})})}_triggerEnvelopeAttack(e,t=1){if(this.envelope.triggerAttack(e,t),this.filterEnvelope.triggerAttack(e),this.oscillator.start(e),this.envelope.sustain===0){const n=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+n+i)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.filterEnvelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}}class fa extends ot{constructor(){const e=F(fa.getDefaults(),arguments);super(e),this.name="DuoSynth",this.voice0=new Ps(Object.assign(e.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new Ps(Object.assign(e.voice1,{context:this.context})),this.harmonicity=new Pe({context:this.context,units:"positive",value:e.harmonicity}),this._vibrato=new yt({frequency:e.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new Y({context:this.context,units:"normalRange",gain:e.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new oe({context:this.context,units:"frequency",value:440}),this.detune=new oe({context:this.context,units:"cents",value:e.detune}),this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.detune.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),ne(this,["voice0","voice1","frequency","vibratoAmount","vibratoRate"])}getLevelAtTime(e){return e=this.toSeconds(e),this.voice0.envelope.getValueAtTime(e)+this.voice1.envelope.getValueAtTime(e)}static getDefaults(){return Wt(ot.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:Wt(rt(Ps.getDefaults(),Object.keys(ot.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:Wt(rt(Ps.getDefaults(),Object.keys(ot.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(e,t){this.voice0._triggerEnvelopeAttack(e,t),this.voice1._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this.voice0._triggerEnvelopeRelease(e),this.voice1._triggerEnvelopeRelease(e),this}dispose(){return super.dispose(),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this.detune.dispose(),this._vibrato.dispose(),this.vibratoRate.dispose(),this._vibratoGain.dispose(),this.harmonicity.dispose(),this}}class ma extends Yn{constructor(){const e=F(ma.getDefaults(),arguments);super(e),this.name="FMSynth",this.modulationIndex=new Pe({context:this.context,value:e.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output)}static getDefaults(){return Object.assign(Yn.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}}const uc=[1,1.483,1.932,2.546,2.63,3.897];class ga extends ot{constructor(){const e=F(ga.getDefaults(),arguments);super(e),this.name="MetalSynth",this._oscillators=[],this._freqMultipliers=[],this.detune=new oe({context:this.context,units:"cents",value:e.detune}),this.frequency=new oe({context:this.context,units:"frequency"}),this._amplitude=new Y({context:this.context,gain:0}).connect(this.output),this._highpass=new Rt({Q:0,context:this.context,type:"highpass"}).connect(this._amplitude);for(let t=0;t<uc.length;t++){const n=new kn({context:this.context,harmonicity:e.harmonicity,modulationIndex:e.modulationIndex,modulationType:"square",onstop:t===0?()=>this.onsilence(this):ge,type:"square"});n.connect(this._highpass),this._oscillators[t]=n;const i=new Pe({context:this.context,value:uc[t]});this._freqMultipliers[t]=i,this.frequency.chain(i,n.frequency),this.detune.connect(n.detune)}this._filterFreqScaler=new fs({context:this.context,max:7e3,min:this.toFrequency(e.resonance)}),this.envelope=new ct({attack:e.envelope.attack,attackCurve:"linear",context:this.context,decay:e.envelope.decay,release:e.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=e.octaves,this.octaves=e.octaves}static getDefaults(){return Wt(ot.getDefaults(),{envelope:Object.assign(rt(ct.getDefaults(),Object.keys($.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(e,t=1){return this.envelope.triggerAttack(e,t),this._oscillators.forEach(n=>n.start(e)),this.envelope.sustain===0&&this._oscillators.forEach(n=>{n.stop(e+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))}),this}_triggerEnvelopeRelease(e){return this.envelope.triggerRelease(e),this._oscillators.forEach(t=>t.stop(e+this.toSeconds(this.envelope.release))),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(e){this._oscillators.forEach(t=>t.modulationIndex.value=e)}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(e){this._oscillators.forEach(t=>t.harmonicity.value=e)}get resonance(){return this._filterFreqScaler.min}set resonance(e){this._filterFreqScaler.min=this.toFrequency(e),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,e)}dispose(){return super.dispose(),this._oscillators.forEach(e=>e.dispose()),this._freqMultipliers.forEach(e=>e.dispose()),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}}class mi extends As{constructor(){const e=F(mi.getDefaults(),arguments);super(e),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=e.pitchDecay,this.octaves=e.octaves,ne(this,["oscillator","envelope"])}static getDefaults(){return Wt(ot.getDefaults(),As.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(e,t){const n=this.toSeconds(t),i=this.toFrequency(e instanceof vt?e.toFrequency():e),r=i*this.octaves;return this.oscillator.frequency.setValueAtTime(r,n),this.oscillator.frequency.exponentialRampToValueAtTime(i,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}Yt([ru(0)],mi.prototype,"octaves",void 0);Yt([gs(0)],mi.prototype,"pitchDecay",void 0);class _a extends $t{constructor(){const e=F(_a.getDefaults(),arguments);super(e),this.name="NoiseSynth",this.noise=new ks(Object.assign({context:this.context},e.noise)),this.envelope=new In(Object.assign({context:this.context},e.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign($t.getDefaults(),{envelope:Object.assign(rt(ct.getDefaults(),Object.keys($.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(rt(ks.getDefaults(),Object.keys(Be.getDefaults())),{type:"white"})})}triggerAttack(e,t=1){return e=this.toSeconds(e),this.envelope.triggerAttack(e,t),this.noise.start(e),this.envelope.sustain===0&&this.noise.stop(e+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(e){return e=this.toSeconds(e),this.envelope.triggerRelease(e),this.noise.stop(e+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0)),this}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),e=this.toSeconds(e),this.triggerAttack(t,n),this.triggerRelease(t+e),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}const va=new Set;function ya(s){va.add(s)}function cu(s,e){const t=`registerProcessor("${s}", ${e})`;va.add(t)}function Ug(){return Array.from(va).join(`
19
+ `)}class wo extends ${constructor(e){super(e),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=ge;const t=URL.createObjectURL(new Blob([Ug()],{type:"text/javascript"})),n=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(t).then(()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(n,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))})}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage("dispose"),this._worklet.disconnect()),this}}const Kg=`
20
20
  /**
21
21
  * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
22
22
  */
@@ -187,7 +187,7 @@
187
187
  return delayedSample;
188
188
  }
189
189
  }
190
- `;cu(lu,e_);class gi extends wo{constructor(){const e=F(gi.getDefaults(),arguments,["delayTime","resonance"]);super(e),this.name="FeedbackCombFilter",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.delayTime=new ae({context:this.context,value:e.delayTime,units:"time",minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new ae({context:this.context,value:e.resonance,units:"normalRange",param:this._dummyParam,swappable:!0}),ne(this,["resonance","delayTime"])}_audioWorkletName(){return lu}static getDefaults(){return Object.assign($.getDefaults(),{delayTime:.1,resonance:.5})}onReady(e){Nt(this.input,e,this.output);const t=e.parameters.get("delayTime");this.delayTime.setParam(t);const n=e.parameters.get("feedback");this.resonance.setParam(n)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}}class _i extends ${constructor(){const e=F(_i.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OnePoleFilter",this._frequency=e.frequency,this._type=e.type,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign($.getDefaults(),{frequency:880,type:"lowpass"})}_createFilter(){const e=this._filter,t=this.toFrequency(this._frequency),n=1/(2*Math.PI*t);if(this._type==="lowpass"){const i=1/(n*this.context.sampleRate),r=i-1;this._filter=this.context.createIIRFilter([i,0],[1,r])}else{const i=1/(n*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,i])}this.input.chain(this._filter,this.output),e&&this.context.setTimeout(()=>{this.disposed||(this.input.disconnect(e),e.disconnect())},this.blockTime)}get frequency(){return this._frequency}set frequency(e){this._frequency=e,this._createFilter()}get type(){return this._type}set type(e){this._type=e,this._createFilter()}getFrequencyResponse(e=128){const t=new Float32Array(e);for(let r=0;r<e;r++){const a=Math.pow(r/e,2)*19980+20;t[r]=a}const n=new Float32Array(e),i=new Float32Array(e);return this._filter.getFrequencyResponse(t,n,i),n}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this._filter.disconnect(),this}}class vi extends ${constructor(){const e=F(vi.getDefaults(),arguments,["delayTime","resonance","dampening"]);super(e),this.name="LowpassCombFilter",this._combFilter=this.output=new gi({context:this.context,delayTime:e.delayTime,resonance:e.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new _i({context:this.context,frequency:e.dampening,type:"lowpass"}),this._lowpass.connect(this._combFilter)}static getDefaults(){return Object.assign($.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})}get dampening(){return this._lowpass.frequency}set dampening(e){this._lowpass.frequency=e}dispose(){return super.dispose(),this._combFilter.dispose(),this._lowpass.dispose(),this}}class ba extends qt{constructor(){const e=F(ba.getDefaults(),arguments);super(e),this.name="PluckSynth",this._noise=new ks({context:this.context,type:"pink"}),this.attackNoise=e.attackNoise,this._lfcf=new vi({context:this.context,dampening:e.dampening,resonance:e.resonance}),this.resonance=e.resonance,this.release=e.release,this._noise.connect(this._lfcf),this._lfcf.connect(this.output)}static getDefaults(){return Bt(qt.getDefaults(),{attackNoise:1,dampening:4e3,resonance:.7,release:1})}get dampening(){return this._lfcf.dampening}set dampening(e){this._lfcf.dampening=e}triggerAttack(e,t){const n=this.toFrequency(e);t=this.toSeconds(t);const i=1/n;return this._lfcf.delayTime.setValueAtTime(i,t),this._noise.start(t),this._noise.stop(t+i*this.attackNoise),this._lfcf.resonance.cancelScheduledValues(t),this._lfcf.resonance.setValueAtTime(this.resonance,t),this}triggerRelease(e){return this._lfcf.resonance.linearRampTo(0,this.release,e),this}dispose(){return super.dispose(),this._noise.dispose(),this._lfcf.dispose(),this}}class wa extends qt{constructor(){const e=F(wa.getDefaults(),arguments,["voice","options"]);super(e),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=i=>this.releaseAll(i),K(!Ot(e.voice),"DEPRECATED: The polyphony count is no longer the first argument.");const t=e.voice.getDefaults();this.options=Object.assign(t,e.options),this.voice=e.voice,this.maxPolyphony=e.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();const n=this._voices.indexOf(this._dummyVoice);this._voices.splice(n,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(qt.getDefaults(),{maxPolyphony:32,options:{},voice:As})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(e){this._availableVoices.push(e);const t=this._activeVoices.findIndex(n=>n.voice===e);this._activeVoices.splice(t,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){const e=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return K(e instanceof rt,"Voice must extend Monophonic class"),e.connect(this.output),this._voices.push(e),e}else vn("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){const e=this._availableVoices.shift(),t=this._voices.indexOf(e);this._voices.splice(t,1),this.context.isOffline||e.dispose()}}_triggerAttack(e,t,n){e.forEach(i=>{const r=new dn(this.context,i).toMidi(),o=this._getNextAvailableVoice();o&&(o.triggerAttack(i,t,n),this._activeVoices.push({midi:r,voice:o,released:!1}),this.log("triggerAttack",i,t))})}_triggerRelease(e,t){e.forEach(n=>{const i=new dn(this.context,n).toMidi(),r=this._activeVoices.find(({midi:o,released:a})=>o===i&&!a);r&&(r.voice.triggerRelease(t),r.released=!0,this.log("triggerRelease",n,t))})}_scheduleEvent(e,t,n,i){K(!this.disposed,"Synth was already disposed"),n<=this.now()?e==="attack"?this._triggerAttack(t,n,i):this._triggerRelease(t,n):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(e,t,n,i)},n-this.now())}triggerAttack(e,t,n){Array.isArray(e)||(e=[e]);const i=this.toSeconds(t);return this._scheduleEvent("attack",e,i,n),this}triggerRelease(e,t){Array.isArray(e)||(e=[e]);const n=this.toSeconds(t);return this._scheduleEvent("release",e,n),this}triggerAttackRelease(e,t,n,i){const r=this.toSeconds(n);if(this.triggerAttack(e,r,i),ot(t)){K(ot(e),"If the duration is an array, the notes must also be an array"),e=e;for(let o=0;o<e.length;o++){const a=t[Math.min(o,t.length-1)],c=this.toSeconds(a);K(c>0,"The duration must be greater than 0"),this.triggerRelease(e[o],r+c)}}else{const o=this.toSeconds(t);K(o>0,"The duration must be greater than 0"),this.triggerRelease(e,r+o)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}set(e){const t=it(e,["onsilence","context"]);return this.options=Bt(this.options,t),this._voices.forEach(n=>n.set(t)),this._dummyVoice.set(t),this}get(){return this._dummyVoice.get()}releaseAll(e){const t=this.toSeconds(e);return this._activeVoices.forEach(({voice:n})=>{n.triggerRelease(t)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(e=>e.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}}class yi extends qt{constructor(){const e=F(yi.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(e),this.name="Sampler",this._activeSources=new Map;const t={};Object.keys(e.urls).forEach(n=>{const i=parseInt(n,10);if(K(Ln(n)||Ot(i)&&isFinite(i),`url key is neither a note or midi pitch: ${n}`),Ln(n)){const r=new vt(this.context,n).toMidi();t[r]=e.urls[n]}else Ot(i)&&isFinite(i)&&(t[i]=e.urls[i])}),this._buffers=new Cn({urls:t,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.attack=e.attack,this.release=e.release,this.curve=e.curve,this._buffers.loaded&&Promise.resolve().then(e.onload)}static getDefaults(){return Object.assign(qt.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:_e,onerror:_e,release:.1,urls:{}})}_findClosest(e){let n=0;for(;n<96;){if(this._buffers.has(e+n))return-n;if(this._buffers.has(e-n))return n;n++}throw new Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,n=1){return this.log("triggerAttack",e,t,n),Array.isArray(e)||(e=[e]),e.forEach(i=>{const r=nu(new vt(this.context,i).toFrequency()),o=Math.round(r),a=r-o,c=this._findClosest(o),l=o-c,u=this._buffers.get(l),h=un(c+a),p=new Es({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);p.start(t,0,u.duration/h,n),ot(this._activeSources.get(o))||this._activeSources.set(o,[]),this._activeSources.get(o).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(o)){const d=this._activeSources.get(o),f=d.indexOf(p);f!==-1&&d.splice(f,1)}}}),this}triggerRelease(e,t){return this.log("triggerRelease",e,t),Array.isArray(e)||(e=[e]),e.forEach(n=>{const i=new vt(this.context,n).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){const r=this._activeSources.get(i);t=this.toSeconds(t),r.forEach(o=>{o.stop(t)}),this._activeSources.set(i,[])}}),this}releaseAll(e){const t=this.toSeconds(e);return this._activeSources.forEach(n=>{for(;n.length;)n.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(e,t,n,i=1){const r=this.toSeconds(n);return this.triggerAttack(e,r,i),ot(t)?(K(ot(e),"notes must be an array when duration is array"),e.forEach((o,a)=>{const c=t[Math.min(a,t.length-1)];this.triggerRelease(o,r+this.toSeconds(c))})):this.triggerRelease(e,r+this.toSeconds(t)),this}add(e,t,n){if(K(Ln(e)||isFinite(e),`note must be a pitch or midi: ${e}`),Ln(e)){const i=new vt(this.context,e).toMidi();this._buffers.add(i,t,n)}else this._buffers.add(e,t,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(t=>t.dispose())}),this._activeSources.clear(),this}}Yt([_s(0)],yi.prototype,"attack",void 0);Yt([_s(0)],yi.prototype,"release",void 0);class Jt extends nt{constructor(){const e=F(Jt.getDefaults(),arguments,["callback","value"]);super(e),this.name="ToneEvent",this._state=new wn("stopped"),this._startOffset=0,this._loop=e.loop,this.callback=e.callback,this.value=e.value,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._playbackRate=e.playbackRate,this._probability=e.probability,this._humanize=e.humanize,this.mute=e.mute,this._playbackRate=e.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(nt.getDefaults(),{callback:_e,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(e=-1){this._state.forEachFrom(e,t=>{let n;if(t.state==="started"){t.id!==-1&&this.context.transport.clear(t.id);const i=t.time+Math.round(this.startOffset/this._playbackRate);if(this._loop===!0||Ot(this._loop)&&this._loop>1){n=1/0,Ot(this._loop)&&(n=this._loop*this._getLoopDuration());const r=this._state.getAfter(i);r!==null&&(n=Math.min(n,r.time-i)),n!==1/0&&(n=new Oe(this.context,n));const o=new Oe(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),o,new Oe(this.context,i),n)}else t.id=this.context.transport.schedule(this._tick.bind(this),new Oe(this.context,i))}})}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e}get probability(){return this._probability}set probability(e){this._probability=e}get humanize(){return this._humanize}set humanize(e){this._humanize=e}start(e){const t=this.toTicks(e);return this._state.getValueAtTime(t)==="stopped"&&(this._state.add({id:-1,state:"started",time:t}),this._rescheduleEvents(t)),this}stop(e){this.cancel(e);const t=this.toTicks(e);if(this._state.getValueAtTime(t)==="started"){this._state.setStateAtTime("stopped",t,{id:-1});const n=this._state.getBefore(t);let i=t;n!==null&&(i=n.time),this._rescheduleEvents(i)}return this}cancel(e){e=$t(e,-1/0);const t=this.toTicks(e);return this._state.forEachFrom(t,n=>{this.context.transport.clear(n.id)}),this._state.cancel(t),this}_tick(e){const t=this.context.transport.getTicksAtTime(e);if(!this.mute&&this._state.getValueAtTime(t)==="started"){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let n=.02;Uo(this.humanize)||(n=this.toSeconds(this.humanize)),e+=(Math.random()*2-1)*n}this.callback(e,this.value)}}_getLoopDuration(){return(this._loopEnd-this._loopStart)/this._playbackRate}get loop(){return this._loop}set loop(e){this._loop=e,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._rescheduleEvents()}get loopEnd(){return new Oe(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._rescheduleEvents()}get loopStart(){return new Oe(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const e=this.context.transport.ticks,t=this._state.get(e);if(t!==null&&t.state==="started"){const n=this._getLoopDuration();return(e-t.time)%n/n}else return 0}else return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class Qn extends nt{constructor(){const e=F(Qn.getDefaults(),arguments,["callback","interval"]);super(e),this.name="Loop",this._event=new Jt({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:e.interval,playbackRate:e.playbackRate,probability:e.probability,humanize:e.humanize}),this.callback=e.callback,this.iterations=e.iterations}static getDefaults(){return Object.assign(nt.getDefaults(),{interval:"4n",callback:_e,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(e){return this._event.start(e),this}stop(e){return this._event.stop(e),this}cancel(e){return this._event.cancel(e),this}_tick(e){this.callback(e)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(e){this._event.loopEnd=e}get playbackRate(){return this._event.playbackRate}set playbackRate(e){this._event.playbackRate=e}get humanize(){return this._event.humanize}set humanize(e){this._event.humanize=e}get probability(){return this._event.probability}set probability(e){this._event.probability=e}get mute(){return this._event.mute}set mute(e){this._event.mute=e}get iterations(){return this._event.loop===!0?1/0:this._event.loop}set iterations(e){e===1/0?this._event.loop=!0:this._event.loop=e}dispose(){return super.dispose(),this._event.dispose(),this}}class Jn extends Jt{constructor(){const e=F(Jn.getDefaults(),arguments,["callback","events"]);super(e),this.name="Part",this._state=new wn("stopped"),this._events=new Set,this._state.increasing=!0,e.events.forEach(t=>{ot(t)?this.add(t[0],t[1]):this.add(t)})}static getDefaults(){return Object.assign(Jt.getDefaults(),{events:[]})}start(e,t){const n=this.toTicks(e);if(this._state.getValueAtTime(n)!=="started"){t=$t(t,this._loop?this._loopStart:0),this._loop?t=$t(t,this._loopStart):t=$t(t,0);const i=this.toTicks(t);this._state.add({id:-1,offset:i,state:"started",time:n}),this._forEach(r=>{this._startNote(r,n,i)})}return this}_startNote(e,t,n){t-=n,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<n&&(t+=this._getLoopDuration()),e.start(new Oe(this.context,t))):e.startOffset<this._loopStart&&e.startOffset>=n&&(e.loop=!1,e.start(new Oe(this.context,t))):e.startOffset>=n&&e.start(new Oe(this.context,t))}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e,this._forEach(t=>{t.startOffset+=this._startOffset})}stop(e){const t=this.toTicks(e);return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._forEach(n=>{n.stop(e)}),this}at(e,t){const n=new Xe(this.context,e).toTicks(),i=new Oe(this.context,1).toSeconds(),r=this._events.values();let o=r.next();for(;!o.done;){const a=o.value;if(Math.abs(n-a.startOffset)<i)return de(t)&&(a.value=t),a;o=r.next()}return de(t)?(this.add(e,t),this.at(e)):null}add(e,t){e instanceof Object&&Reflect.has(e,"time")&&(t=e,e=t.time);const n=this.toTicks(e);let i;return t instanceof Jt?(i=t,i.callback=this._tick.bind(this)):i=new Jt({callback:this._tick.bind(this),context:this.context,value:t}),i.startOffset=n,i.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(i),this._restartEvent(i),this}_restartEvent(e){this._state.forEach(t=>{t.state==="started"?this._startNote(e,t.time,t.offset):e.stop(new Oe(this.context,t.time))})}remove(e,t){return ps(e)&&e.hasOwnProperty("time")&&(t=e,e=t.time),e=this.toTicks(e),this._events.forEach(n=>{n.startOffset===e&&(Tt(t)||de(t)&&n.value===t)&&(this._events.delete(n),n.dispose())}),this}clear(){return this._forEach(e=>e.dispose()),this._events.clear(),this}cancel(e){return this._forEach(t=>t.cancel(e)),this._state.cancel(this.toTicks(e)),this}_forEach(e){return this._events&&this._events.forEach(t=>{t instanceof Jn?t._forEach(e):e(t)}),this}_setAll(e,t){this._forEach(n=>{n[e]=t})}_tick(e,t){this.mute||this.callback(e,t)}_testLoopBoundries(e){this._loop&&(e.startOffset<this._loopStart||e.startOffset>=this._loopEnd)?e.cancel(0):e.state==="stopped"&&this._restartEvent(e)}get probability(){return this._probability}set probability(e){this._probability=e,this._setAll("probability",e)}get humanize(){return this._humanize}set humanize(e){this._humanize=e,this._setAll("humanize",e)}get loop(){return this._loop}set loop(e){this._loop=e,this._forEach(t=>{t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.loop=e,this._testLoopBoundries(t)})}get loopEnd(){return new Oe(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._forEach(t=>{t.loopEnd=e,this._testLoopBoundries(t)})}get loopStart(){return new Oe(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._forEach(t=>{t.loopStart=this.loopStart,this._testLoopBoundries(t)})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._setAll("playbackRate",e)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}function*t_(s){let e=0;for(;e<s;)e=qs(e,0,s-1),yield e,e++}function*s_(s){let e=s-1;for(;e>=0;)e=qs(e,0,s-1),yield e,e--}function*Wn(s,e){for(;;)yield*e(s)}function*hc(s,e){let t=e?0:s-1;for(;;)t=qs(t,0,s-1),yield t,e?(t++,t>=s-1&&(e=!1)):(t--,t<=0&&(e=!0))}function*n_(s){let e=0,t=0;for(;e<s;)e=qs(e,0,s-1),yield e,t++,e+=t%2?2:-1}function*i_(s){let e=s-1,t=0;for(;e>=0;)e=qs(e,0,s-1),yield e,t++,e+=t%2?-2:1}function*r_(s){for(;;)yield Math.floor(Math.random()*s)}function*o_(s){const e=[];for(let t=0;t<s;t++)e.push(t);for(;e.length>0;){const t=e.splice(Math.floor(e.length*Math.random()),1);yield qs(t[0],0,s-1)}}function*a_(s){let e=Math.floor(Math.random()*s);for(;;)e===0?e++:e===s-1||Math.random()<.5?e--:e++,yield e}function*dc(s,e="up",t=0){switch(K(s>=1,"The number of values must be at least one"),e){case"up":yield*Wn(s,t_);case"down":yield*Wn(s,s_);case"upDown":yield*hc(s,!0);case"downUp":yield*hc(s,!1);case"alternateUp":yield*Wn(s,n_);case"alternateDown":yield*Wn(s,i_);case"random":yield*r_(s);case"randomOnce":yield*Wn(s,o_);case"randomWalk":yield*a_(s)}}class xa extends Qn{constructor(){const e=F(xa.getDefaults(),arguments,["callback","values","pattern"]);super(e),this.name="Pattern",this.callback=e.callback,this._values=e.values,this._pattern=dc(e.values.length,e.pattern),this._type=e.pattern}static getDefaults(){return Object.assign(Qn.getDefaults(),{pattern:"up",values:[],callback:_e})}_tick(e){const t=this._pattern.next();this._index=t.value,this._value=this._values[t.value],this.callback(e,this._value)}get values(){return this._values}set values(e){this._values=e,this.pattern=this._type}get value(){return this._value}get index(){return this._index}get pattern(){return this._type}set pattern(e){this._type=e,this._pattern=dc(this._values.length,this._type)}}class Ca extends Jt{constructor(){const e=F(Ca.getDefaults(),arguments,["callback","events","subdivision"]);super(e),this.name="Sequence",this._part=new Jn({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[],this._subdivision=this.toTicks(e.subdivision),this.events=e.events,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.playbackRate=e.playbackRate,this.probability=e.probability,this.humanize=e.humanize,this.mute=e.mute,this.playbackRate=e.playbackRate}static getDefaults(){return Object.assign(it(Jt.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})}_seqCallback(e,t){t!==null&&!this.mute&&this.callback(e,t)}get events(){return this._events}set events(e){this.clear(),this._eventsArray=e,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(e,t){return this._part.start(e,t&&this._indexTime(t)),this}stop(e){return this._part.stop(e),this}get subdivision(){return new Oe(this.context,this._subdivision).toSeconds()}_createSequence(e){return new Proxy(e,{get:(t,n)=>t[n],set:(t,n,i)=>(Xt(n)&&isFinite(parseInt(n,10))&&ot(i)?t[n]=this._createSequence(i):t[n]=i,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(e,t,n){e.forEach((i,r)=>{const o=r*t+n;if(ot(i))this._rescheduleSequence(i,t/i.length,o);else{const a=new Oe(this.context,o,"i").toSeconds();this._part.add(a,i)}})}_indexTime(e){return new Oe(this.context,e*this._subdivision+this.startOffset).toSeconds()}clear(){return this._part.clear(),this}dispose(){return super.dispose(),this._part.dispose(),this}get loop(){return this._part.loop}set loop(e){this._part.loop=e}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this._part.loopStart=this._indexTime(e)}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,e===0?this._part.loopEnd=this._indexTime(this._eventsArray.length):this._part.loopEnd=this._indexTime(e)}get startOffset(){return this._part.startOffset}set startOffset(e){this._part.startOffset=e}get playbackRate(){return this._part.playbackRate}set playbackRate(e){this._part.playbackRate=e}get probability(){return this._part.probability}set probability(e){this._part.probability=e}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(e){this._part.humanize=e}get length(){return this._part.length}}class In extends ${constructor(){const e=F(In.getDefaults(),arguments,["fade"]);super(e),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new au({context:this.context}),this.a=new Y({context:this.context,gain:0}),this.b=new Y({context:this.context,gain:0}),this.output=new Y({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new re({context:this.context,units:"normalRange",value:e.fade}),ne(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",pt(this._split,this.a.gain,0),pt(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign($.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}}class Ke extends ${constructor(e){super(e),this.name="Effect",this._dryWet=new In({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Y({context:this.context}),this.effectReturn=new Y({context:this.context}),this.input=new Y({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(e.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],ne(this,"wet")}static getDefaults(){return Object.assign($.getDefaults(),{wet:1})}connectEffect(e){return this._internalChannels.push(e),this.effectSend.chain(e,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}}class Ki extends Ke{constructor(e){super(e),this.name="LFOEffect",this._lfo=new yt({context:this.context,frequency:e.frequency,amplitude:e.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=e.type,ne(this,["frequency","depth"])}static getDefaults(){return Object.assign(Ke.getDefaults(),{frequency:1,type:"sine",depth:1})}start(e){return this._lfo.start(e),this}stop(e){return this._lfo.stop(e),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class br extends Ki{constructor(){const e=F(br.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);super(e),this.name="AutoFilter",this.filter=new Rt(Object.assign(e.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=e.octaves,this.baseFrequency=e.baseFrequency}static getDefaults(){return Object.assign(Ki.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(e){this._lfo.min=this.toFrequency(e),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._lfo.max=this._lfo.min*Math.pow(2,e)}dispose(){return super.dispose(),this.filter.dispose(),this}}class Dn extends ${constructor(){const e=F(Dn.getDefaults(),arguments,["pan"]);super(e),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ae({context:this.context,param:this._panner.pan,value:e.pan,minValue:-1,maxValue:1}),this._panner.channelCount=e.channelCount,this._panner.channelCountMode="explicit",ne(this,"pan")}static getDefaults(){return Object.assign($.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}class wr extends Ki{constructor(){const e=F(wr.getDefaults(),arguments,["frequency"]);super(e),this.name="AutoPanner",this._panner=new Dn({context:this.context,channelCount:e.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(Ki.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}}class bi extends ${constructor(){const e=F(bi.getDefaults(),arguments,["smoothing"]);super(e),this.name="Follower",this._abs=this.input=new ou({context:this.context}),this._lowpass=this.output=new _i({context:this.context,frequency:1/this.toSeconds(e.smoothing),type:"lowpass"}),this._abs.connect(this._lowpass),this._smoothing=e.smoothing}static getDefaults(){return Object.assign($.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(e){this._smoothing=e,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}}class xr extends Ke{constructor(){const e=F(xr.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);super(e),this.name="AutoWah",this._follower=new bi({context:this.context,smoothing:e.follower}),this._sweepRange=new yr({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(e.baseFrequency),this._octaves=e.octaves,this._inputBoost=new Y({context:this.context}),this._bandpass=new Rt({context:this.context,rolloff:-48,frequency:0,Q:e.Q}),this._peaking=new Rt({context:this.context,type:"peaking"}),this._peaking.gain.value=e.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=e.sensitivity,ne(this,["gain","Q"])}static getDefaults(){return Object.assign(Ke.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(e){this._follower.smoothing=e}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){this._baseFrequency=this.toFrequency(e),this._setSweepRange()}get sensitivity(){return li(1/this._inputBoost.gain.value)}set sensitivity(e){this._inputBoost.gain.value=1/ln(e)}_setSweepRange(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)}dispose(){return super.dispose(),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.dispose(),this._peaking.dispose(),this._inputBoost.dispose(),this}}const uu="bit-crusher",c_=`
190
+ `;cu(lu,e_);class gi extends wo{constructor(){const e=F(gi.getDefaults(),arguments,["delayTime","resonance"]);super(e),this.name="FeedbackCombFilter",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.delayTime=new ce({context:this.context,value:e.delayTime,units:"time",minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new ce({context:this.context,value:e.resonance,units:"normalRange",param:this._dummyParam,swappable:!0}),ne(this,["resonance","delayTime"])}_audioWorkletName(){return lu}static getDefaults(){return Object.assign($.getDefaults(),{delayTime:.1,resonance:.5})}onReady(e){Nt(this.input,e,this.output);const t=e.parameters.get("delayTime");this.delayTime.setParam(t);const n=e.parameters.get("feedback");this.resonance.setParam(n)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}}class _i extends ${constructor(){const e=F(_i.getDefaults(),arguments,["frequency","type"]);super(e),this.name="OnePoleFilter",this._frequency=e.frequency,this._type=e.type,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign($.getDefaults(),{frequency:880,type:"lowpass"})}_createFilter(){const e=this._filter,t=this.toFrequency(this._frequency),n=1/(2*Math.PI*t);if(this._type==="lowpass"){const i=1/(n*this.context.sampleRate),r=i-1;this._filter=this.context.createIIRFilter([i,0],[1,r])}else{const i=1/(n*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,i])}this.input.chain(this._filter,this.output),e&&this.context.setTimeout(()=>{this.disposed||(this.input.disconnect(e),e.disconnect())},this.blockTime)}get frequency(){return this._frequency}set frequency(e){this._frequency=e,this._createFilter()}get type(){return this._type}set type(e){this._type=e,this._createFilter()}getFrequencyResponse(e=128){const t=new Float32Array(e);for(let r=0;r<e;r++){const a=Math.pow(r/e,2)*19980+20;t[r]=a}const n=new Float32Array(e),i=new Float32Array(e);return this._filter.getFrequencyResponse(t,n,i),n}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this._filter.disconnect(),this}}class vi extends ${constructor(){const e=F(vi.getDefaults(),arguments,["delayTime","resonance","dampening"]);super(e),this.name="LowpassCombFilter",this._combFilter=this.output=new gi({context:this.context,delayTime:e.delayTime,resonance:e.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new _i({context:this.context,frequency:e.dampening,type:"lowpass"}),this._lowpass.connect(this._combFilter)}static getDefaults(){return Object.assign($.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})}get dampening(){return this._lowpass.frequency}set dampening(e){this._lowpass.frequency=e}dispose(){return super.dispose(),this._combFilter.dispose(),this._lowpass.dispose(),this}}class ba extends $t{constructor(){const e=F(ba.getDefaults(),arguments);super(e),this.name="PluckSynth",this._noise=new ks({context:this.context,type:"pink"}),this.attackNoise=e.attackNoise,this._lfcf=new vi({context:this.context,dampening:e.dampening,resonance:e.resonance}),this.resonance=e.resonance,this.release=e.release,this._noise.connect(this._lfcf),this._lfcf.connect(this.output)}static getDefaults(){return Wt($t.getDefaults(),{attackNoise:1,dampening:4e3,resonance:.7,release:1})}get dampening(){return this._lfcf.dampening}set dampening(e){this._lfcf.dampening=e}triggerAttack(e,t){const n=this.toFrequency(e);t=this.toSeconds(t);const i=1/n;return this._lfcf.delayTime.setValueAtTime(i,t),this._noise.start(t),this._noise.stop(t+i*this.attackNoise),this._lfcf.resonance.cancelScheduledValues(t),this._lfcf.resonance.setValueAtTime(this.resonance,t),this}triggerRelease(e){return this._lfcf.resonance.linearRampTo(0,this.release,e),this}dispose(){return super.dispose(),this._noise.dispose(),this._lfcf.dispose(),this}}class wa extends $t{constructor(){const e=F(wa.getDefaults(),arguments,["voice","options"]);super(e),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=i=>this.releaseAll(i),K(!Ot(e.voice),"DEPRECATED: The polyphony count is no longer the first argument.");const t=e.voice.getDefaults();this.options=Object.assign(t,e.options),this.voice=e.voice,this.maxPolyphony=e.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();const n=this._voices.indexOf(this._dummyVoice);this._voices.splice(n,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign($t.getDefaults(),{maxPolyphony:32,options:{},voice:As})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(e){this._availableVoices.push(e);const t=this._activeVoices.findIndex(n=>n.voice===e);this._activeVoices.splice(t,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){const e=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return K(e instanceof ot,"Voice must extend Monophonic class"),e.connect(this.output),this._voices.push(e),e}else yn("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){const e=this._availableVoices.shift(),t=this._voices.indexOf(e);this._voices.splice(t,1),this.context.isOffline||e.dispose()}}_triggerAttack(e,t,n){e.forEach(i=>{const r=new pn(this.context,i).toMidi(),o=this._getNextAvailableVoice();o&&(o.triggerAttack(i,t,n),this._activeVoices.push({midi:r,voice:o,released:!1}),this.log("triggerAttack",i,t))})}_triggerRelease(e,t){e.forEach(n=>{const i=new pn(this.context,n).toMidi(),r=this._activeVoices.find(({midi:o,released:a})=>o===i&&!a);r&&(r.voice.triggerRelease(t),r.released=!0,this.log("triggerRelease",n,t))})}_scheduleEvent(e,t,n,i){K(!this.disposed,"Synth was already disposed"),n<=this.now()?e==="attack"?this._triggerAttack(t,n,i):this._triggerRelease(t,n):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(e,t,n,i)},n-this.now())}triggerAttack(e,t,n){Array.isArray(e)||(e=[e]);const i=this.toSeconds(t);return this._scheduleEvent("attack",e,i,n),this}triggerRelease(e,t){Array.isArray(e)||(e=[e]);const n=this.toSeconds(t);return this._scheduleEvent("release",e,n),this}triggerAttackRelease(e,t,n,i){const r=this.toSeconds(n);if(this.triggerAttack(e,r,i),at(t)){K(at(e),"If the duration is an array, the notes must also be an array"),e=e;for(let o=0;o<e.length;o++){const a=t[Math.min(o,t.length-1)],c=this.toSeconds(a);K(c>0,"The duration must be greater than 0"),this.triggerRelease(e[o],r+c)}}else{const o=this.toSeconds(t);K(o>0,"The duration must be greater than 0"),this.triggerRelease(e,r+o)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}set(e){const t=rt(e,["onsilence","context"]);return this.options=Wt(this.options,t),this._voices.forEach(n=>n.set(t)),this._dummyVoice.set(t),this}get(){return this._dummyVoice.get()}releaseAll(e){const t=this.toSeconds(e);return this._activeVoices.forEach(({voice:n})=>{n.triggerRelease(t)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(e=>e.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}}class yi extends $t{constructor(){const e=F(yi.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(e),this.name="Sampler",this._activeSources=new Map;const t={};Object.keys(e.urls).forEach(n=>{const i=parseInt(n,10);if(K(Ln(n)||Ot(i)&&isFinite(i),`url key is neither a note or midi pitch: ${n}`),Ln(n)){const r=new vt(this.context,n).toMidi();t[r]=e.urls[n]}else Ot(i)&&isFinite(i)&&(t[i]=e.urls[i])}),this._buffers=new Sn({urls:t,onload:e.onload,baseUrl:e.baseUrl,onerror:e.onerror}),this.attack=e.attack,this.release=e.release,this.curve=e.curve,this._buffers.loaded&&Promise.resolve().then(e.onload)}static getDefaults(){return Object.assign($t.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:ge,onerror:ge,release:.1,urls:{}})}_findClosest(e){let n=0;for(;n<96;){if(this._buffers.has(e+n))return-n;if(this._buffers.has(e-n))return n;n++}throw new Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,n=1){return this.log("triggerAttack",e,t,n),Array.isArray(e)||(e=[e]),e.forEach(i=>{const r=nu(new vt(this.context,i).toFrequency()),o=Math.round(r),a=r-o,c=this._findClosest(o),l=o-c,u=this._buffers.get(l),h=hn(c+a),p=new Es({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);p.start(t,0,u.duration/h,n),at(this._activeSources.get(o))||this._activeSources.set(o,[]),this._activeSources.get(o).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(o)){const d=this._activeSources.get(o),f=d.indexOf(p);f!==-1&&d.splice(f,1)}}}),this}triggerRelease(e,t){return this.log("triggerRelease",e,t),Array.isArray(e)||(e=[e]),e.forEach(n=>{const i=new vt(this.context,n).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){const r=this._activeSources.get(i);t=this.toSeconds(t),r.forEach(o=>{o.stop(t)}),this._activeSources.set(i,[])}}),this}releaseAll(e){const t=this.toSeconds(e);return this._activeSources.forEach(n=>{for(;n.length;)n.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(e,t,n,i=1){const r=this.toSeconds(n);return this.triggerAttack(e,r,i),at(t)?(K(at(e),"notes must be an array when duration is array"),e.forEach((o,a)=>{const c=t[Math.min(a,t.length-1)];this.triggerRelease(o,r+this.toSeconds(c))})):this.triggerRelease(e,r+this.toSeconds(t)),this}add(e,t,n){if(K(Ln(e)||isFinite(e),`note must be a pitch or midi: ${e}`),Ln(e)){const i=new vt(this.context,e).toMidi();this._buffers.add(i,t,n)}else this._buffers.add(e,t,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(t=>t.dispose())}),this._activeSources.clear(),this}}Yt([gs(0)],yi.prototype,"attack",void 0);Yt([gs(0)],yi.prototype,"release",void 0);class Qt extends et{constructor(){const e=F(Qt.getDefaults(),arguments,["callback","value"]);super(e),this.name="ToneEvent",this._state=new xn("stopped"),this._startOffset=0,this._loop=e.loop,this.callback=e.callback,this.value=e.value,this._loopStart=this.toTicks(e.loopStart),this._loopEnd=this.toTicks(e.loopEnd),this._playbackRate=e.playbackRate,this._probability=e.probability,this._humanize=e.humanize,this.mute=e.mute,this._playbackRate=e.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(et.getDefaults(),{callback:ge,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(e=-1){this._state.forEachFrom(e,t=>{let n;if(t.state==="started"){t.id!==-1&&this.context.transport.clear(t.id);const i=t.time+Math.round(this.startOffset/this._playbackRate);if(this._loop===!0||Ot(this._loop)&&this._loop>1){n=1/0,Ot(this._loop)&&(n=this._loop*this._getLoopDuration());const r=this._state.getAfter(i);r!==null&&(n=Math.min(n,r.time-i)),n!==1/0&&(n=new Fe(this.context,n));const o=new Fe(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),o,new Fe(this.context,i),n)}else t.id=this.context.transport.schedule(this._tick.bind(this),new Fe(this.context,i))}})}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e}get probability(){return this._probability}set probability(e){this._probability=e}get humanize(){return this._humanize}set humanize(e){this._humanize=e}start(e){const t=this.toTicks(e);return this._state.getValueAtTime(t)==="stopped"&&(this._state.add({id:-1,state:"started",time:t}),this._rescheduleEvents(t)),this}stop(e){this.cancel(e);const t=this.toTicks(e);if(this._state.getValueAtTime(t)==="started"){this._state.setStateAtTime("stopped",t,{id:-1});const n=this._state.getBefore(t);let i=t;n!==null&&(i=n.time),this._rescheduleEvents(i)}return this}cancel(e){e=Bt(e,-1/0);const t=this.toTicks(e);return this._state.forEachFrom(t,n=>{this.context.transport.clear(n.id)}),this._state.cancel(t),this}_tick(e){const t=this.context.transport.getTicksAtTime(e);if(!this.mute&&this._state.getValueAtTime(t)==="started"){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let n=.02;Uo(this.humanize)||(n=this.toSeconds(this.humanize)),e+=(Math.random()*2-1)*n}this.callback(e,this.value)}}_getLoopDuration(){return(this._loopEnd-this._loopStart)/this._playbackRate}get loop(){return this._loop}set loop(e){this._loop=e,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._rescheduleEvents()}get loopEnd(){return new Fe(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._rescheduleEvents()}get loopStart(){return new Fe(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const e=this.context.transport.ticks,t=this._state.get(e);if(t!==null&&t.state==="started"){const n=this._getLoopDuration();return(e-t.time)%n/n}else return 0}else return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class Qn extends et{constructor(){const e=F(Qn.getDefaults(),arguments,["callback","interval"]);super(e),this.name="Loop",this._event=new Qt({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:e.interval,playbackRate:e.playbackRate,probability:e.probability,humanize:e.humanize}),this.callback=e.callback,this.iterations=e.iterations}static getDefaults(){return Object.assign(et.getDefaults(),{interval:"4n",callback:ge,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(e){return this._event.start(e),this}stop(e){return this._event.stop(e),this}cancel(e){return this._event.cancel(e),this}_tick(e){this.callback(e)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(e){this._event.loopEnd=e}get playbackRate(){return this._event.playbackRate}set playbackRate(e){this._event.playbackRate=e}get humanize(){return this._event.humanize}set humanize(e){this._event.humanize=e}get probability(){return this._event.probability}set probability(e){this._event.probability=e}get mute(){return this._event.mute}set mute(e){this._event.mute=e}get iterations(){return this._event.loop===!0?1/0:this._event.loop}set iterations(e){e===1/0?this._event.loop=!0:this._event.loop=e}dispose(){return super.dispose(),this._event.dispose(),this}}class Jn extends Qt{constructor(){const e=F(Jn.getDefaults(),arguments,["callback","events"]);super(e),this.name="Part",this._state=new xn("stopped"),this._events=new Set,this._state.increasing=!0,e.events.forEach(t=>{at(t)?this.add(t[0],t[1]):this.add(t)})}static getDefaults(){return Object.assign(Qt.getDefaults(),{events:[]})}start(e,t){const n=this.toTicks(e);if(this._state.getValueAtTime(n)!=="started"){t=Bt(t,this._loop?this._loopStart:0),this._loop?t=Bt(t,this._loopStart):t=Bt(t,0);const i=this.toTicks(t);this._state.add({id:-1,offset:i,state:"started",time:n}),this._forEach(r=>{this._startNote(r,n,i)})}return this}_startNote(e,t,n){t-=n,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<n&&(t+=this._getLoopDuration()),e.start(new Fe(this.context,t))):e.startOffset<this._loopStart&&e.startOffset>=n&&(e.loop=!1,e.start(new Fe(this.context,t))):e.startOffset>=n&&e.start(new Fe(this.context,t))}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e,this._forEach(t=>{t.startOffset+=this._startOffset})}stop(e){const t=this.toTicks(e);return this._state.cancel(t),this._state.setStateAtTime("stopped",t),this._forEach(n=>{n.stop(e)}),this}at(e,t){const n=new Le(this.context,e).toTicks(),i=new Fe(this.context,1).toSeconds(),r=this._events.values();let o=r.next();for(;!o.done;){const a=o.value;if(Math.abs(n-a.startOffset)<i)return he(t)&&(a.value=t),a;o=r.next()}return he(t)?(this.add(e,t),this.at(e)):null}add(e,t){e instanceof Object&&Reflect.has(e,"time")&&(t=e,e=t.time);const n=this.toTicks(e);let i;return t instanceof Qt?(i=t,i.callback=this._tick.bind(this)):i=new Qt({callback:this._tick.bind(this),context:this.context,value:t}),i.startOffset=n,i.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(i),this._restartEvent(i),this}_restartEvent(e){this._state.forEach(t=>{t.state==="started"?this._startNote(e,t.time,t.offset):e.stop(new Fe(this.context,t.time))})}remove(e,t){return ds(e)&&e.hasOwnProperty("time")&&(t=e,e=t.time),e=this.toTicks(e),this._events.forEach(n=>{n.startOffset===e&&(Tt(t)||he(t)&&n.value===t)&&(this._events.delete(n),n.dispose())}),this}clear(){return this._forEach(e=>e.dispose()),this._events.clear(),this}cancel(e){return this._forEach(t=>t.cancel(e)),this._state.cancel(this.toTicks(e)),this}_forEach(e){return this._events&&this._events.forEach(t=>{t instanceof Jn?t._forEach(e):e(t)}),this}_setAll(e,t){this._forEach(n=>{n[e]=t})}_tick(e,t){this.mute||this.callback(e,t)}_testLoopBoundries(e){this._loop&&(e.startOffset<this._loopStart||e.startOffset>=this._loopEnd)?e.cancel(0):e.state==="stopped"&&this._restartEvent(e)}get probability(){return this._probability}set probability(e){this._probability=e,this._setAll("probability",e)}get humanize(){return this._humanize}set humanize(e){this._humanize=e,this._setAll("humanize",e)}get loop(){return this._loop}set loop(e){this._loop=e,this._forEach(t=>{t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.loop=e,this._testLoopBoundries(t)})}get loopEnd(){return new Fe(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._forEach(t=>{t.loopEnd=e,this._testLoopBoundries(t)})}get loopStart(){return new Fe(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._forEach(t=>{t.loopStart=this.loopStart,this._testLoopBoundries(t)})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._setAll("playbackRate",e)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}function*t_(s){let e=0;for(;e<s;)e=js(e,0,s-1),yield e,e++}function*s_(s){let e=s-1;for(;e>=0;)e=js(e,0,s-1),yield e,e--}function*Wn(s,e){for(;;)yield*e(s)}function*hc(s,e){let t=e?0:s-1;for(;;)t=js(t,0,s-1),yield t,e?(t++,t>=s-1&&(e=!1)):(t--,t<=0&&(e=!0))}function*n_(s){let e=0,t=0;for(;e<s;)e=js(e,0,s-1),yield e,t++,e+=t%2?2:-1}function*i_(s){let e=s-1,t=0;for(;e>=0;)e=js(e,0,s-1),yield e,t++,e+=t%2?-2:1}function*r_(s){for(;;)yield Math.floor(Math.random()*s)}function*o_(s){const e=[];for(let t=0;t<s;t++)e.push(t);for(;e.length>0;){const t=e.splice(Math.floor(e.length*Math.random()),1);yield js(t[0],0,s-1)}}function*a_(s){let e=Math.floor(Math.random()*s);for(;;)e===0?e++:e===s-1||Math.random()<.5?e--:e++,yield e}function*dc(s,e="up",t=0){switch(K(s>=1,"The number of values must be at least one"),e){case"up":yield*Wn(s,t_);case"down":yield*Wn(s,s_);case"upDown":yield*hc(s,!0);case"downUp":yield*hc(s,!1);case"alternateUp":yield*Wn(s,n_);case"alternateDown":yield*Wn(s,i_);case"random":yield*r_(s);case"randomOnce":yield*Wn(s,o_);case"randomWalk":yield*a_(s)}}class xa extends Qn{constructor(){const e=F(xa.getDefaults(),arguments,["callback","values","pattern"]);super(e),this.name="Pattern",this.callback=e.callback,this._values=e.values,this._pattern=dc(e.values.length,e.pattern),this._type=e.pattern}static getDefaults(){return Object.assign(Qn.getDefaults(),{pattern:"up",values:[],callback:ge})}_tick(e){const t=this._pattern.next();this._index=t.value,this._value=this._values[t.value],this.callback(e,this._value)}get values(){return this._values}set values(e){this._values=e,this.pattern=this._type}get value(){return this._value}get index(){return this._index}get pattern(){return this._type}set pattern(e){this._type=e,this._pattern=dc(this._values.length,this._type)}}class Ca extends Qt{constructor(){const e=F(Ca.getDefaults(),arguments,["callback","events","subdivision"]);super(e),this.name="Sequence",this._part=new Jn({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[],this._subdivision=this.toTicks(e.subdivision),this.events=e.events,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.playbackRate=e.playbackRate,this.probability=e.probability,this.humanize=e.humanize,this.mute=e.mute,this.playbackRate=e.playbackRate}static getDefaults(){return Object.assign(rt(Qt.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})}_seqCallback(e,t){t!==null&&!this.mute&&this.callback(e,t)}get events(){return this._events}set events(e){this.clear(),this._eventsArray=e,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(e,t){return this._part.start(e,t&&this._indexTime(t)),this}stop(e){return this._part.stop(e),this}get subdivision(){return new Fe(this.context,this._subdivision).toSeconds()}_createSequence(e){return new Proxy(e,{get:(t,n)=>t[n],set:(t,n,i)=>(Xt(n)&&isFinite(parseInt(n,10))&&at(i)?t[n]=this._createSequence(i):t[n]=i,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(e,t,n){e.forEach((i,r)=>{const o=r*t+n;if(at(i))this._rescheduleSequence(i,t/i.length,o);else{const a=new Fe(this.context,o,"i").toSeconds();this._part.add(a,i)}})}_indexTime(e){return new Fe(this.context,e*this._subdivision+this.startOffset).toSeconds()}clear(){return this._part.clear(),this}dispose(){return super.dispose(),this._part.dispose(),this}get loop(){return this._part.loop}set loop(e){this._part.loop=e}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this._part.loopStart=this._indexTime(e)}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,e===0?this._part.loopEnd=this._indexTime(this._eventsArray.length):this._part.loopEnd=this._indexTime(e)}get startOffset(){return this._part.startOffset}set startOffset(e){this._part.startOffset=e}get playbackRate(){return this._part.playbackRate}set playbackRate(e){this._part.playbackRate=e}get probability(){return this._part.probability}set probability(e){this._part.probability=e}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(e){this._part.humanize=e}get length(){return this._part.length}}class Dn extends ${constructor(){const e=F(Dn.getDefaults(),arguments,["fade"]);super(e),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new au({context:this.context}),this.a=new Y({context:this.context,gain:0}),this.b=new Y({context:this.context,gain:0}),this.output=new Y({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new oe({context:this.context,units:"normalRange",value:e.fade}),ne(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",dt(this._split,this.a.gain,0),dt(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign($.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}}class Ye extends ${constructor(e){super(e),this.name="Effect",this._dryWet=new Dn({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Y({context:this.context}),this.effectReturn=new Y({context:this.context}),this.input=new Y({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(e.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],ne(this,"wet")}static getDefaults(){return Object.assign($.getDefaults(),{wet:1})}connectEffect(e){return this._internalChannels.push(e),this.effectSend.chain(e,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}}class Ki extends Ye{constructor(e){super(e),this.name="LFOEffect",this._lfo=new yt({context:this.context,frequency:e.frequency,amplitude:e.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=e.type,ne(this,["frequency","depth"])}static getDefaults(){return Object.assign(Ye.getDefaults(),{frequency:1,type:"sine",depth:1})}start(e){return this._lfo.start(e),this}stop(e){return this._lfo.stop(e),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class br extends Ki{constructor(){const e=F(br.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);super(e),this.name="AutoFilter",this.filter=new Rt(Object.assign(e.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=e.octaves,this.baseFrequency=e.baseFrequency}static getDefaults(){return Object.assign(Ki.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(e){this._lfo.min=this.toFrequency(e),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._lfo.max=this._lfo.min*Math.pow(2,e)}dispose(){return super.dispose(),this.filter.dispose(),this}}class Rn extends ${constructor(){const e=F(Rn.getDefaults(),arguments,["pan"]);super(e),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ce({context:this.context,param:this._panner.pan,value:e.pan,minValue:-1,maxValue:1}),this._panner.channelCount=e.channelCount,this._panner.channelCountMode="explicit",ne(this,"pan")}static getDefaults(){return Object.assign($.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}class wr extends Ki{constructor(){const e=F(wr.getDefaults(),arguments,["frequency"]);super(e),this.name="AutoPanner",this._panner=new Rn({context:this.context,channelCount:e.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(Ki.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}}class bi extends ${constructor(){const e=F(bi.getDefaults(),arguments,["smoothing"]);super(e),this.name="Follower",this._abs=this.input=new ou({context:this.context}),this._lowpass=this.output=new _i({context:this.context,frequency:1/this.toSeconds(e.smoothing),type:"lowpass"}),this._abs.connect(this._lowpass),this._smoothing=e.smoothing}static getDefaults(){return Object.assign($.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(e){this._smoothing=e,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}}class xr extends Ye{constructor(){const e=F(xr.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);super(e),this.name="AutoWah",this._follower=new bi({context:this.context,smoothing:e.follower}),this._sweepRange=new yr({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(e.baseFrequency),this._octaves=e.octaves,this._inputBoost=new Y({context:this.context}),this._bandpass=new Rt({context:this.context,rolloff:-48,frequency:0,Q:e.Q}),this._peaking=new Rt({context:this.context,type:"peaking"}),this._peaking.gain.value=e.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=e.sensitivity,ne(this,["gain","Q"])}static getDefaults(){return Object.assign(Ye.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(e){this._follower.smoothing=e}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){this._baseFrequency=this.toFrequency(e),this._setSweepRange()}get sensitivity(){return li(1/this._inputBoost.gain.value)}set sensitivity(e){this._inputBoost.gain.value=1/un(e)}_setSweepRange(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)}dispose(){return super.dispose(),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.dispose(),this._peaking.dispose(),this._inputBoost.dispose(),this}}const uu="bit-crusher",c_=`
191
191
  class BitCrusherWorklet extends SingleIOProcessor {
192
192
 
193
193
  static get parameterDescriptors() {
@@ -206,26 +206,26 @@
206
206
  return val;
207
207
  }
208
208
  }
209
- `;cu(uu,c_);class Cr extends Ke{constructor(){const e=F(Cr.getDefaults(),arguments,["bits"]);super(e),this.name="BitCrusher",this._bitCrusherWorklet=new Sa({context:this.context,bits:e.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(Ke.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}}class Sa extends wo{constructor(){const e=F(Sa.getDefaults(),arguments);super(e),this.name="BitCrusherWorklet",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.bits=new ae({context:this.context,value:e.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(wo.getDefaults(),{bits:12})}_audioWorkletName(){return uu}onReady(e){Nt(this.input,e,this.output);const t=e.parameters.get("bits");this.bits.setParam(t)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class Sr extends Ke{constructor(){const e=F(Sr.getDefaults(),arguments,["order"]);super(e),this.name="Chebyshev",this._shaper=new Kt({context:this.context,length:4096}),this._order=e.order,this.connectEffect(this._shaper),this.order=e.order,this.oversample=e.oversample}static getDefaults(){return Object.assign(Ke.getDefaults(),{order:1,oversample:"none"})}_getCoefficient(e,t,n){return n.has(t)||(t===0?n.set(t,0):t===1?n.set(t,e):n.set(t,2*e*this._getCoefficient(e,t-1,n)-this._getCoefficient(e,t-2,n))),n.get(t)}get order(){return this._order}set order(e){K(Number.isInteger(e),"'order' must be an integer"),this._order=e,this._shaper.setMap(t=>this._getCoefficient(t,e,new Map))}get oversample(){return this._shaper.oversample}set oversample(e){this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.dispose(),this}}class Xs extends ${constructor(){const e=F(Xs.getDefaults(),arguments,["channels"]);super(e),this.name="Split",this._splitter=this.input=this.output=this.context.createChannelSplitter(e.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign($.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}}class Ms extends ${constructor(){const e=F(Ms.getDefaults(),arguments,["channels"]);super(e),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(e.channels)}static getDefaults(){return Object.assign($.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}class ts extends ${constructor(e){super(e),this.name="StereoEffect",this.input=new Y({context:this.context}),this.input.channelCount=2,this.input.channelCountMode="explicit",this._dryWet=this.output=new In({context:this.context,fade:e.wet}),this.wet=this._dryWet.fade,this._split=new Xs({context:this.context,channels:2}),this._merge=new Ms({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),ne(this,["wet"])}connectEffectLeft(...e){this._split.connect(e[0],0,0),Nt(...e),pt(e[e.length-1],this._merge,0,0)}connectEffectRight(...e){this._split.connect(e[0],1,0),Nt(...e),pt(e[e.length-1],this._merge,0,1)}static getDefaults(){return Object.assign($.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}}class xo extends ts{constructor(e){super(e),this.feedback=new re({context:this.context,value:e.feedback,units:"normalRange"}),this._feedbackL=new Y({context:this.context}),this._feedbackR=new Y({context:this.context}),this._feedbackSplit=new Xs({context:this.context,channels:2}),this._feedbackMerge=new Ms({context:this.context,channels:2}),this._merge.connect(this._feedbackSplit),this._feedbackMerge.connect(this._split),this._feedbackSplit.connect(this._feedbackL,0,0),this._feedbackL.connect(this._feedbackMerge,0,0),this._feedbackSplit.connect(this._feedbackR,1,0),this._feedbackR.connect(this._feedbackMerge,0,1),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),ne(this,["feedback"])}static getDefaults(){return Object.assign(ts.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}}class Tr extends xo{constructor(){const e=F(Tr.getDefaults(),arguments,["frequency","delayTime","depth"]);super(e),this.name="Chorus",this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new yt({context:this.context,frequency:e.frequency,min:0,max:1}),this._lfoR=new yt({context:this.context,frequency:e.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Mt({context:this.context}),this._delayNodeR=new Mt({context:this.context}),this.frequency=this._lfoL.frequency,ne(this,["frequency"]),this._lfoL.frequency.connect(this._lfoR.frequency),this.connectEffectLeft(this._delayNodeL),this.connectEffectRight(this._delayNodeR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this.depth=this._depth,this.type=e.type,this.spread=e.spread}static getDefaults(){return Object.assign(xo.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(e){this._depth=e;const t=this._delayTime*e;this._lfoL.min=Math.max(this._delayTime-t,0),this._lfoL.max=this._delayTime+t,this._lfoR.min=Math.max(this._delayTime-t,0),this._lfoR.max=this._delayTime+t}get delayTime(){return this._delayTime*1e3}set delayTime(e){this._delayTime=e/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(e){this._lfoL.type=e,this._lfoR.type=e}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(e){this._lfoL.phase=90-e/2,this._lfoR.phase=e/2+90}start(e){return this._lfoL.start(e),this._lfoR.start(e),this}stop(e){return this._lfoL.stop(e),this._lfoR.stop(e),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.dispose(),this._delayNodeR.dispose(),this.frequency.dispose(),this}}class kr extends Ke{constructor(){const e=F(kr.getDefaults(),arguments,["distortion"]);super(e),this.name="Distortion",this._shaper=new Kt({context:this.context,length:4096}),this._distortion=e.distortion,this.connectEffect(this._shaper),this.distortion=e.distortion,this.oversample=e.oversample}static getDefaults(){return Object.assign(Ke.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(e){this._distortion=e;const t=e*100,n=Math.PI/180;this._shaper.setMap(i=>Math.abs(i)<.001?0:(3+t)*i*20*n/(Math.PI+t*Math.abs(i)))}get oversample(){return this._shaper.oversample}set oversample(e){this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.dispose(),this}}class Qi extends Ke{constructor(e){super(e),this.name="FeedbackEffect",this._feedbackGain=new Y({context:this.context,gain:e.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,ne(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(Ke.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class Ar extends Qi{constructor(){const e=F(Ar.getDefaults(),arguments,["delayTime","feedback"]);super(e),this.name="FeedbackDelay",this._delayNode=new Mt({context:this.context,delayTime:e.delayTime,maxDelay:e.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),ne(this,"delayTime")}static getDefaults(){return Object.assign(Qi.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}class l_ extends ${constructor(e){super(e),this.name="PhaseShiftAllpass",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.offset90=new Y({context:this.context});const t=[.6923878,.9360654322959,.988229522686,.9987488452737],n=[.4021921162426,.856171088242,.9722909545651,.9952884791278];this._bank0=this._createAllPassFilterBank(t),this._bank1=this._createAllPassFilterBank(n),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),Nt(this.input,...this._bank0,this._oneSampleDelay,this.output),Nt(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(e){return e.map(n=>{const i=[[n*n,0,-1],[1,0,-(n*n)]];return this.context.createIIRFilter(i[0],i[1])})}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach(e=>e.disconnect()),this._bank1.forEach(e=>e.disconnect()),this._oneSampleDelay.disconnect(),this}}class Ta extends Ke{constructor(){const e=F(Ta.getDefaults(),arguments,["frequency"]);super(e),this.name="FrequencyShifter",this.frequency=new re({context:this.context,units:"frequency",value:e.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new hi({context:this.context,type:"sine"}),this._cosine=new Ne({context:this.context,phase:-90,type:"sine"}),this._sineMultiply=new Fe({context:this.context}),this._cosineMultiply=new Fe({context:this.context}),this._negate=new da({context:this.context}),this._add=new zs({context:this.context}),this._phaseShifter=new l_({context:this.context}),this.effectSend.connect(this._phaseShifter),this.frequency.fan(this._sine.frequency,this._cosine.frequency),this._phaseShifter.offset90.connect(this._cosineMultiply),this._cosine.connect(this._cosineMultiply.factor),this._phaseShifter.connect(this._sineMultiply),this._sine.connect(this._sineMultiply.factor),this._sineMultiply.connect(this._negate),this._cosineMultiply.connect(this._add),this._negate.connect(this._add.addend),this._add.connect(this.effectReturn);const t=this.immediate();this._sine.start(t),this._cosine.start(t)}static getDefaults(){return Object.assign(Ke.getDefaults(),{frequency:0})}dispose(){return super.dispose(),this.frequency.dispose(),this._add.dispose(),this._cosine.dispose(),this._cosineMultiply.dispose(),this._negate.dispose(),this._phaseShifter.dispose(),this._sine.dispose(),this._sineMultiply.dispose(),this}}const pc=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],fc=[225,556,441,341];class Ir extends ts{constructor(){const e=F(Ir.getDefaults(),arguments,["roomSize","dampening"]);super(e),this.name="Freeverb",this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[],this.roomSize=new re({context:this.context,value:e.roomSize,units:"normalRange"}),this._allpassFiltersL=fc.map(t=>{const n=this.context.createBiquadFilter();return n.type="allpass",n.frequency.value=t,n}),this._allpassFiltersR=fc.map(t=>{const n=this.context.createBiquadFilter();return n.type="allpass",n.frequency.value=t,n}),this._combFilters=pc.map((t,n)=>{const i=new vi({context:this.context,dampening:e.dampening,delayTime:t});return n<pc.length/2?this.connectEffectLeft(i,...this._allpassFiltersL):this.connectEffectRight(i,...this._allpassFiltersR),this.roomSize.connect(i.resonance),i}),ne(this,["roomSize"])}static getDefaults(){return Object.assign(ts.getDefaults(),{roomSize:.7,dampening:3e3})}get dampening(){return this._combFilters[0].dampening}set dampening(e){this._combFilters.forEach(t=>t.dampening=e)}dispose(){return super.dispose(),this._allpassFiltersL.forEach(e=>e.disconnect()),this._allpassFiltersR.forEach(e=>e.disconnect()),this._combFilters.forEach(e=>e.dispose()),this.roomSize.dispose(),this}}const mc=[1687/25e3,1601/25e3,2053/25e3,2251/25e3],u_=[.773,.802,.753,.733],h_=[347,113,37];class Dr extends ts{constructor(){const e=F(Dr.getDefaults(),arguments,["roomSize"]);super(e),this.name="JCReverb",this._allpassFilters=[],this._feedbackCombFilters=[],this.roomSize=new re({context:this.context,value:e.roomSize,units:"normalRange"}),this._scaleRoomSize=new ms({context:this.context,min:-.733,max:.197}),this._allpassFilters=h_.map(t=>{const n=this.context.createBiquadFilter();return n.type="allpass",n.frequency.value=t,n}),this._feedbackCombFilters=mc.map((t,n)=>{const i=new gi({context:this.context,delayTime:t});return this._scaleRoomSize.connect(i.resonance),i.resonance.value=u_[n],n<mc.length/2?this.connectEffectLeft(...this._allpassFilters,i):this.connectEffectRight(...this._allpassFilters,i),i}),this.roomSize.connect(this._scaleRoomSize),ne(this,["roomSize"])}static getDefaults(){return Object.assign(ts.getDefaults(),{roomSize:.5})}dispose(){return super.dispose(),this._allpassFilters.forEach(e=>e.disconnect()),this._feedbackCombFilters.forEach(e=>e.dispose()),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}}class gc extends xo{constructor(e){super(e),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),ne(this,["feedback"])}}class Rr extends gc{constructor(){const e=F(Rr.getDefaults(),arguments,["delayTime","feedback"]);super(e),this.name="PingPongDelay",this._leftDelay=new Mt({context:this.context,maxDelay:e.maxDelay}),this._rightDelay=new Mt({context:this.context,maxDelay:e.maxDelay}),this._rightPreDelay=new Mt({context:this.context,maxDelay:e.maxDelay}),this.delayTime=new re({context:this.context,units:"time",value:e.delayTime}),this.connectEffectLeft(this._leftDelay),this.connectEffectRight(this._rightPreDelay,this._rightDelay),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackL.disconnect(),this._feedbackL.connect(this._rightDelay),ne(this,["delayTime"])}static getDefaults(){return Object.assign(gc.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}}class ka extends Qi{constructor(){const e=F(ka.getDefaults(),arguments,["pitch"]);super(e),this.name="PitchShift",this._frequency=new re({context:this.context}),this._delayA=new Mt({maxDelay:1,context:this.context}),this._lfoA=new yt({context:this.context,min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new Mt({maxDelay:1,context:this.context}),this._lfoB=new yt({context:this.context,min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new In({context:this.context}),this._crossFadeLFO=new yt({context:this.context,min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Mt({delayTime:e.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,ne(this,"delayTime"),this._pitch=e.pitch,this._windowSize=e.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);const t=this.now();this._lfoA.start(t),this._lfoB.start(t),this._crossFadeLFO.start(t),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(Qi.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(e){this._pitch=e;let t=0;e<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,t=un(e-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,t=un(e)-1),this._frequency.value=t*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(e){this._windowSize=this.toSeconds(e),this.pitch=this._pitch}dispose(){return super.dispose(),this._frequency.dispose(),this._delayA.dispose(),this._delayB.dispose(),this._lfoA.dispose(),this._lfoB.dispose(),this._crossFade.dispose(),this._crossFadeLFO.dispose(),this._feedbackDelay.dispose(),this}}class Er extends ts{constructor(){const e=F(Er.getDefaults(),arguments,["frequency","octaves","baseFrequency"]);super(e),this.name="Phaser",this._lfoL=new yt({context:this.context,frequency:e.frequency,min:0,max:1}),this._lfoR=new yt({context:this.context,frequency:e.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(e.baseFrequency),this._octaves=e.octaves,this.Q=new re({context:this.context,value:e.Q,units:"positive"}),this._filtersL=this._makeFilters(e.stages,this._lfoL),this._filtersR=this._makeFilters(e.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=e.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=e.baseFrequency,this.octaves=e.octaves,this._lfoL.start(),this._lfoR.start(),ne(this,["frequency","Q"])}static getDefaults(){return Object.assign(ts.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(e,t){const n=[];for(let i=0;i<e;i++){const r=this.context.createBiquadFilter();r.type="allpass",this.Q.connect(r.Q),t.connect(r.frequency),n.push(r)}return n}get octaves(){return this._octaves}set octaves(e){this._octaves=e;const t=this._baseFrequency*Math.pow(2,e);this._lfoL.max=t,this._lfoR.max=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){this._baseFrequency=this.toFrequency(e),this._lfoL.min=this._baseFrequency,this._lfoR.min=this._baseFrequency,this.octaves=this._octaves}dispose(){return super.dispose(),this.Q.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._filtersL.forEach(e=>e.disconnect()),this._filtersR.forEach(e=>e.disconnect()),this.frequency.dispose(),this}}class Mr extends Ke{constructor(){const e=F(Mr.getDefaults(),arguments,["decay"]);super(e),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const t=this.toSeconds(e.decay);Ye(t,.001),this._decay=t;const n=this.toSeconds(e.preDelay);Ye(n,0),this._preDelay=n,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Ke.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(e){e=this.toSeconds(e),Ye(e,.001),this._decay=e,this.generate()}get preDelay(){return this._preDelay}set preDelay(e){e=this.toSeconds(e),Ye(e,0),this._preDelay=e,this.generate()}generate(){return ke(this,void 0,void 0,function*(){const e=this.ready,t=new bn(2,this._decay+this._preDelay,this.context.sampleRate),n=new ks({context:t}),i=new ks({context:t}),r=new Ms({context:t});n.connect(r,0,0),i.connect(r,0,1);const o=new Y({context:t}).toDestination();r.connect(o),n.start(0),i.start(0),o.gain.setValueAtTime(0,0),o.gain.setValueAtTime(1,this._preDelay),o.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const a=t.render();return this.ready=a.then(_e),yield e,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}}class wi extends ${constructor(){super(F(wi.getDefaults(),arguments)),this.name="MidSideSplit",this._split=this.input=new Xs({channels:2,context:this.context}),this._midAdd=new zs({context:this.context}),this.mid=new Fe({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new Gs({context:this.context}),this.side=new Fe({context:this.context,value:Math.SQRT1_2}),this._split.connect(this._midAdd,0),this._split.connect(this._midAdd.addend,1),this._split.connect(this._sideSubtract,0),this._split.connect(this._sideSubtract.subtrahend,1),this._midAdd.connect(this.mid),this._sideSubtract.connect(this.side)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midAdd.dispose(),this._sideSubtract.dispose(),this._split.dispose(),this}}class xi extends ${constructor(){super(F(xi.getDefaults(),arguments)),this.name="MidSideMerge",this.mid=new Y({context:this.context}),this.side=new Y({context:this.context}),this._left=new zs({context:this.context}),this._leftMult=new Fe({context:this.context,value:Math.SQRT1_2}),this._right=new Gs({context:this.context}),this._rightMult=new Fe({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Ms({context:this.context}),this.mid.fan(this._left),this.side.connect(this._left.addend),this.mid.connect(this._right),this.side.connect(this._right.subtrahend),this._left.connect(this._leftMult),this._right.connect(this._rightMult),this._leftMult.connect(this._merge,0,0),this._rightMult.connect(this._merge,0,1)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._leftMult.dispose(),this._rightMult.dispose(),this._left.dispose(),this._right.dispose(),this}}class _c extends Ke{constructor(e){super(e),this.name="MidSideEffect",this._midSideMerge=new xi({context:this.context}),this._midSideSplit=new wi({context:this.context}),this._midSend=this._midSideSplit.mid,this._sideSend=this._midSideSplit.side,this._midReturn=this._midSideMerge.mid,this._sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)}connectEffectMid(...e){this._midSend.chain(...e,this._midReturn)}connectEffectSide(...e){this._sideSend.chain(...e,this._sideReturn)}dispose(){return super.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this._midSend.dispose(),this._sideSend.dispose(),this._midReturn.dispose(),this._sideReturn.dispose(),this}}class Or extends _c{constructor(){const e=F(Or.getDefaults(),arguments,["width"]);super(e),this.name="StereoWidener",this.width=new re({context:this.context,value:e.width,units:"normalRange"}),ne(this,["width"]),this._twoTimesWidthMid=new Fe({context:this.context,value:2}),this._twoTimesWidthSide=new Fe({context:this.context,value:2}),this._midMult=new Fe({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new Gs({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),pt(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new Fe({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(_c.getDefaults(),{width:.5})}dispose(){return super.dispose(),this.width.dispose(),this._midMult.dispose(),this._sideMult.dispose(),this._twoTimesWidthMid.dispose(),this._twoTimesWidthSide.dispose(),this._oneMinusWidth.dispose(),this}}class Nr extends ts{constructor(){const e=F(Nr.getDefaults(),arguments,["frequency","depth"]);super(e),this.name="Tremolo",this._lfoL=new yt({context:this.context,type:e.type,min:1,max:0}),this._lfoR=new yt({context:this.context,type:e.type,min:1,max:0}),this._amplitudeL=new Y({context:this.context}),this._amplitudeR=new Y({context:this.context}),this.frequency=new re({context:this.context,value:e.frequency,units:"frequency"}),this.depth=new re({context:this.context,value:e.depth,units:"normalRange"}),ne(this,["frequency","depth"]),this.connectEffectLeft(this._amplitudeL),this.connectEffectRight(this._amplitudeR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.spread=e.spread}static getDefaults(){return Object.assign(ts.getDefaults(),{frequency:10,type:"sine",depth:.5,spread:180})}start(e){return this._lfoL.start(e),this._lfoR.start(e),this}stop(e){return this._lfoL.stop(e),this._lfoR.stop(e),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this.context.transport.syncSignal(this.frequency),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this.context.transport.unsyncSignal(this.frequency),this}get type(){return this._lfoL.type}set type(e){this._lfoL.type=e,this._lfoR.type=e}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(e){this._lfoL.phase=90-e/2,this._lfoR.phase=e/2+90}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._amplitudeL.dispose(),this._amplitudeR.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Fr extends Ke{constructor(){const e=F(Fr.getDefaults(),arguments,["frequency","depth"]);super(e),this.name="Vibrato",this._delayNode=new Mt({context:this.context,delayTime:0,maxDelay:e.maxDelay}),this._lfo=new yt({context:this.context,type:e.type,min:0,max:e.maxDelay,frequency:e.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=e.depth,ne(this,["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(Ke.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:"sine"})}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Hs extends ${constructor(){const e=F(Hs.getDefaults(),arguments,["type","size"]);super(e),this.name="Analyser",this._analysers=[],this._buffers=[],this.input=this.output=this._gain=new Y({context:this.context}),this._split=new Xs({context:this.context,channels:e.channels}),this.input.connect(this._split),Ye(e.channels,1);for(let t=0;t<e.channels;t++)this._analysers[t]=this.context.createAnalyser(),this._split.connect(this._analysers[t],t,0);this.size=e.size,this.type=e.type,this.smoothing=e.smoothing}static getDefaults(){return Object.assign($.getDefaults(),{size:1024,smoothing:.8,type:"fft",channels:1})}getValue(){return this._analysers.forEach((e,t)=>{const n=this._buffers[t];this._type==="fft"?e.getFloatFrequencyData(n):this._type==="waveform"&&e.getFloatTimeDomainData(n)}),this.channels===1?this._buffers[0]:this._buffers}get size(){return this._analysers[0].frequencyBinCount}set size(e){this._analysers.forEach((t,n)=>{t.fftSize=e*2,this._buffers[n]=new Float32Array(e)})}get channels(){return this._analysers.length}get type(){return this._type}set type(e){K(e==="waveform"||e==="fft",`Analyser: invalid type: ${e}`),this._type=e}get smoothing(){return this._analysers[0].smoothingTimeConstant}set smoothing(e){this._analysers.forEach(t=>t.smoothingTimeConstant=e)}dispose(){return super.dispose(),this._analysers.forEach(e=>e.disconnect()),this._split.dispose(),this._gain.dispose(),this}}class Is extends ${constructor(){super(F(Is.getDefaults(),arguments)),this.name="MeterBase",this.input=this.output=this._analyser=new Hs({context:this.context,size:256,type:"waveform"})}dispose(){return super.dispose(),this._analyser.dispose(),this}}class Vr extends Is{constructor(){const e=F(Vr.getDefaults(),arguments,["smoothing"]);super(e),this.name="Meter",this.input=this.output=this._analyser=new Hs({context:this.context,size:256,type:"waveform",channels:e.channelCount}),this.smoothing=e.smoothing,this.normalRange=e.normalRange,this._rms=new Array(e.channelCount),this._rms.fill(0)}static getDefaults(){return Object.assign(Is.getDefaults(),{smoothing:.8,normalRange:!1,channelCount:1})}getLevel(){return vn("'getLevel' has been changed to 'getValue'"),this.getValue()}getValue(){const e=this._analyser.getValue(),n=(this.channels===1?[e]:e).map((i,r)=>{const o=i.reduce((c,l)=>c+l*l,0),a=Math.sqrt(o/i.length);return this._rms[r]=Math.max(a,this._rms[r]*this.smoothing),this.normalRange?this._rms[r]:li(this._rms[r])});return this.channels===1?n[0]:n}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}}class Aa extends Is{constructor(){const e=F(Aa.getDefaults(),arguments,["size"]);super(e),this.name="FFT",this.normalRange=e.normalRange,this._analyser.type="fft",this.size=e.size}static getDefaults(){return Object.assign($.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map(t=>this.normalRange?ln(t):t)}get size(){return this._analyser.size}set size(e){this._analyser.size=e}get smoothing(){return this._analyser.smoothing}set smoothing(e){this._analyser.smoothing=e}getFrequencyOfIndex(e){return K(0<=e&&e<this.size,`index must be greater than or equal to 0 and less than ${this.size}`),e*this.context.sampleRate/(this.size*2)}}class Ia extends Is{constructor(){super(F(Ia.getDefaults(),arguments)),this.name="DCMeter",this._analyser.type="waveform",this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}}let d_=class hu extends Is{constructor(){const e=F(hu.getDefaults(),arguments,["size"]);super(e),this.name="Waveform",this._analyser.type="waveform",this.size=e.size}static getDefaults(){return Object.assign(Is.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(e){this._analyser.size=e}};class Le extends ${constructor(){const e=F(Le.getDefaults(),arguments,["solo"]);super(e),this.name="Solo",this.input=this.output=new Y({context:this.context}),Le._allSolos.has(this.context)||Le._allSolos.set(this.context,new Set),Le._allSolos.get(this.context).add(this),this.solo=e.solo}static getDefaults(){return Object.assign($.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(e){e?this._addSolo():this._removeSolo(),Le._allSolos.get(this.context).forEach(t=>t._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){Le._soloed.has(this.context)||Le._soloed.set(this.context,new Set),Le._soloed.get(this.context).add(this)}_removeSolo(){Le._soloed.has(this.context)&&Le._soloed.get(this.context).delete(this)}_isSoloed(){return Le._soloed.has(this.context)&&Le._soloed.get(this.context).has(this)}_noSolos(){return!Le._soloed.has(this.context)||Le._soloed.has(this.context)&&Le._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),Le._allSolos.get(this.context).delete(this),this._removeSolo(),this}}Le._allSolos=new Map;Le._soloed=new Map;class Pr extends ${constructor(){const e=F(Pr.getDefaults(),arguments,["pan","volume"]);super(e),this.name="PanVol",this._panner=this.input=new Dn({context:this.context,pan:e.pan,channelCount:e.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=e.mute,ne(this,["pan","volume"])}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}let du=class zn extends ${constructor(){const e=F(zn.getDefaults(),arguments,["volume","pan"]);super(e),this.name="Channel",this._solo=this.input=new Le({solo:e.solo,context:this.context}),this._panVol=this.output=new Pr({context:this.context,pan:e.pan,volume:e.volume,mute:e.mute,channelCount:e.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),ne(this,["pan","volume"])}static getDefaults(){return Object.assign($.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(e){return zn.buses.has(e)||zn.buses.set(e,new Y({context:this.context})),zn.buses.get(e)}send(e,t=0){const n=this._getBus(e),i=new Y({context:this.context,units:"decibels",gain:t});return this.connect(i),i.connect(n),i}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};du.buses=new Map;class Da extends ${constructor(){super(F(Da.getDefaults(),arguments)),this.name="Mono",this.input=new Y({context:this.context}),this._merge=this.output=new Ms({channels:2,context:this.context}),this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1)}dispose(){return super.dispose(),this._merge.dispose(),this.input.dispose(),this}}class Ci extends ${constructor(){const e=F(Ci.getDefaults(),arguments,["lowFrequency","highFrequency"]);super(e),this.name="MultibandSplit",this.input=new Y({context:this.context}),this.output=void 0,this.low=new Rt({context:this.context,frequency:0,type:"lowpass"}),this._lowMidFilter=new Rt({context:this.context,frequency:0,type:"highpass"}),this.mid=new Rt({context:this.context,frequency:0,type:"lowpass"}),this.high=new Rt({context:this.context,frequency:0,type:"highpass"}),this._internalChannels=[this.low,this.mid,this.high],this.lowFrequency=new re({context:this.context,units:"frequency",value:e.lowFrequency}),this.highFrequency=new re({context:this.context,units:"frequency",value:e.highFrequency}),this.Q=new re({context:this.context,units:"positive",value:e.Q}),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.fan(this.low.frequency,this._lowMidFilter.frequency),this.highFrequency.fan(this.mid.frequency,this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),ne(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign($.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),ci(this,["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this._lowMidFilter.dispose(),this.mid.dispose(),this.high.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this.Q.dispose(),this}}class Ra extends ${constructor(){const e=F(Ra.getDefaults(),arguments,["positionX","positionY","positionZ"]);super(e),this.name="Panner3D",this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=e.panningModel,this.maxDistance=e.maxDistance,this.distanceModel=e.distanceModel,this.coneOuterGain=e.coneOuterGain,this.coneOuterAngle=e.coneOuterAngle,this.coneInnerAngle=e.coneInnerAngle,this.refDistance=e.refDistance,this.rolloffFactor=e.rolloffFactor,this.positionX=new ae({context:this.context,param:this._panner.positionX,value:e.positionX}),this.positionY=new ae({context:this.context,param:this._panner.positionY,value:e.positionY}),this.positionZ=new ae({context:this.context,param:this._panner.positionZ,value:e.positionZ}),this.orientationX=new ae({context:this.context,param:this._panner.orientationX,value:e.orientationX}),this.orientationY=new ae({context:this.context,param:this._panner.orientationY,value:e.orientationY}),this.orientationZ=new ae({context:this.context,param:this._panner.orientationZ,value:e.orientationZ})}static getDefaults(){return Object.assign($.getDefaults(),{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:0,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1})}setPosition(e,t,n){return this.positionX.value=e,this.positionY.value=t,this.positionZ.value=n,this}setOrientation(e,t,n){return this.orientationX.value=e,this.orientationY.value=t,this.orientationZ.value=n,this}get panningModel(){return this._panner.panningModel}set panningModel(e){this._panner.panningModel=e}get refDistance(){return this._panner.refDistance}set refDistance(e){this._panner.refDistance=e}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(e){this._panner.rolloffFactor=e}get distanceModel(){return this._panner.distanceModel}set distanceModel(e){this._panner.distanceModel=e}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(e){this._panner.coneInnerAngle=e}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(e){this._panner.coneOuterAngle=e}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(e){this._panner.coneOuterGain=e}get maxDistance(){return this._panner.maxDistance}set maxDistance(e){this._panner.maxDistance=e}dispose(){return super.dispose(),this._panner.disconnect(),this.orientationX.dispose(),this.orientationY.dispose(),this.orientationZ.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this}}class Ji extends ${constructor(){const e=F(Ji.getDefaults(),arguments);super(e),this.name="Recorder",this.input=new Y({context:this.context}),K(Ji.supported,"Media Recorder API is not available"),this._stream=this.context.createMediaStreamDestination(),this.input.connect(this._stream),this._recorder=new MediaRecorder(this._stream.stream,{mimeType:e.mimeType})}static getDefaults(){return $.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return gt!==null&&Reflect.has(gt,"MediaRecorder")}get state(){return this._recorder.state==="inactive"?"stopped":this._recorder.state==="paused"?"paused":"started"}start(){return ke(this,void 0,void 0,function*(){K(this.state!=="started","Recorder is already started");const e=new Promise(t=>{const n=()=>{this._recorder.removeEventListener("start",n,!1),t()};this._recorder.addEventListener("start",n,!1)});return this.state==="stopped"?this._recorder.start():this._recorder.resume(),yield e})}stop(){return ke(this,void 0,void 0,function*(){K(this.state!=="stopped","Recorder is not started");const e=new Promise(t=>{const n=i=>{this._recorder.removeEventListener("dataavailable",n,!1),t(i.data)};this._recorder.addEventListener("dataavailable",n,!1)});return this._recorder.stop(),yield e})}pause(){return K(this.state==="started","Recorder must be started"),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}}class es extends ${constructor(){const e=F(es.getDefaults(),arguments,["threshold","ratio"]);super(e),this.name="Compressor",this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor,this.threshold=new ae({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:"decibels",value:e.threshold}),this.attack=new ae({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:"time",value:e.attack}),this.release=new ae({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:"time",value:e.release}),this.knee=new ae({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:"decibels",value:e.knee}),this.ratio=new ae({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:"positive",value:e.ratio}),ne(this,["knee","release","attack","ratio","threshold"])}static getDefaults(){return Object.assign($.getDefaults(),{attack:.003,knee:30,ratio:12,release:.25,threshold:-24})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.disconnect(),this.attack.dispose(),this.release.dispose(),this.threshold.dispose(),this.ratio.dispose(),this.knee.dispose(),this}}class Wr extends ${constructor(){const e=F(Wr.getDefaults(),arguments,["threshold","smoothing"]);super(e),this.name="Gate",this._follower=new bi({context:this.context,smoothing:e.smoothing}),this._gt=new vr({context:this.context,value:ln(e.threshold)}),this.input=new Y({context:this.context}),this._gate=this.output=new Y({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign($.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return li(this._gt.value)}set threshold(e){this._gt.value=ln(e)}get smoothing(){return this._follower.smoothing}set smoothing(e){this._follower.smoothing=e}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}}class Br extends ${constructor(){const e=F(Br.getDefaults(),arguments,["threshold"]);super(e),this.name="Limiter",this._compressor=this.input=this.output=new es({context:this.context,ratio:20,attack:.003,release:.01,threshold:e.threshold}),this.threshold=this._compressor.threshold,ne(this,"threshold")}static getDefaults(){return Object.assign($.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}}class Ea extends ${constructor(){const e=F(Ea.getDefaults(),arguments);super(e),this.name="MidSideCompressor",this._midSideSplit=this.input=new wi({context:this.context}),this._midSideMerge=this.output=new xi({context:this.context}),this.mid=new es(Object.assign(e.mid,{context:this.context})),this.side=new es(Object.assign(e.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),ne(this,["mid","side"])}static getDefaults(){return Object.assign($.getDefaults(),{mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}})}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this}}class Ma extends ${constructor(){const e=F(Ma.getDefaults(),arguments);super(e),this.name="MultibandCompressor",this._splitter=this.input=new Ci({context:this.context,lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new Y({context:this.context}),this.low=new es(Object.assign(e.low,{context:this.context})),this.mid=new es(Object.assign(e.mid,{context:this.context})),this.high=new es(Object.assign(e.high,{context:this.context})),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),ne(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign($.getDefaults(),{lowFrequency:250,highFrequency:2e3,low:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10},mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},high:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16}})}dispose(){return super.dispose(),this._splitter.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.output.dispose(),this}}class $r extends ${constructor(){const e=F($r.getDefaults(),arguments,["low","mid","high"]);super(e),this.name="EQ3",this.output=new Y({context:this.context}),this._internalChannels=[],this.input=this._multibandSplit=new Ci({context:this.context,highFrequency:e.highFrequency,lowFrequency:e.lowFrequency}),this._lowGain=new Y({context:this.context,gain:e.low,units:"decibels"}),this._midGain=new Y({context:this.context,gain:e.mid,units:"decibels"}),this._highGain=new Y({context:this.context,gain:e.high,units:"decibels"}),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),ne(this,["low","mid","high","lowFrequency","highFrequency"]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign($.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),ci(this,["low","mid","high","lowFrequency","highFrequency"]),this._multibandSplit.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this._lowGain.dispose(),this._midGain.dispose(),this._highGain.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.Q.dispose(),this}}class Oa extends ${constructor(){const e=F(Oa.getDefaults(),arguments,["url","onload"]);super(e),this.name="Convolver",this._convolver=this.context.createConvolver(),this._buffer=new xe(e.url,t=>{this.buffer=t,e.onload()}),this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=e.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign($.getDefaults(),{normalize:!0,onload:_e})}load(e){return ke(this,void 0,void 0,function*(){this.buffer=yield this._buffer.load(e)})}get buffer(){return this._buffer.length?this._buffer:null}set buffer(e){e&&this._buffer.set(e),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));const t=this._buffer.get();this._convolver.buffer=t||null}get normalize(){return this._convolver.normalize}set normalize(e){this._convolver.normalize=e}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}}function en(){return me().now()}function p_(){return me().immediate()}const f_=me().transport;function Ns(){return me().transport}const m_=me().destination,g_=me().destination;function Na(){return me().destination}const __=me().listener;function v_(){return me().listener}const y_=me().draw;function b_(){return me().draw}const w_=me();function x_(){return xe.loaded()}const C_=xe,S_=Cn,T_=Es,pu=Object.freeze(Object.defineProperty({__proto__:null,AMOscillator:di,AMSynth:pa,Abs:ou,Add:zs,AmplitudeEnvelope:An,Analyser:Hs,AudioToGain:mr,AutoFilter:br,AutoPanner:wr,AutoWah:xr,BaseContext:ea,BiquadFilter:Un,BitCrusher:Cr,Buffer:C_,BufferSource:T_,Buffers:S_,Channel:du,Chebyshev:Sr,Chorus:Tr,Clock:xn,Compressor:es,Context:js,Convolver:Oa,CrossFade:In,DCMeter:Ia,Delay:Mt,Destination:m_,Distortion:kr,Draw:y_,DuoSynth:fa,EQ3:$r,Emitter:yn,Envelope:at,FFT:Aa,FMOscillator:Tn,FMSynth:ma,FatOscillator:pi,FeedbackCombFilter:gi,FeedbackDelay:Ar,Filter:Rt,Follower:bi,Freeverb:Ir,Frequency:Wg,FrequencyClass:vt,FrequencyEnvelope:Kn,FrequencyShifter:Ta,Gain:Y,GainToAudio:au,Gate:Wr,GrainPlayer:ha,GreaterThan:vr,GreaterThanZero:_r,IntervalTimeline:iu,JCReverb:Dr,LFO:yt,Limiter:Br,Listener:__,Loop:Qn,LowpassCombFilter:vi,Master:g_,MembraneSynth:mi,Merge:Ms,MetalSynth:ga,Meter:Vr,MidSideCompressor:Ea,MidSideMerge:xi,MidSideSplit:wi,Midi:Lg,MidiClass:dn,Mono:Da,MonoSynth:Vs,MultibandCompressor:Ma,MultibandSplit:Ci,Multiply:Fe,Negate:da,Noise:ks,NoiseSynth:_a,Offline:jg,OfflineContext:bn,OmniOscillator:fs,OnePoleFilter:_i,Oscillator:Ne,PWMOscillator:fi,PanVol:Pr,Panner:Dn,Panner3D:Ra,Param:ae,Part:Jn,Pattern:xa,Phaser:Er,PingPongDelay:Rr,PitchShift:ka,Player:Zs,Players:ua,PluckSynth:ba,PolySynth:wa,Pow:Sn,PulseOscillator:kn,Recorder:Ji,Reverb:Mr,Sampler:yi,Scale:ms,ScaleExp:yr,Sequence:Ca,Signal:re,Solo:Le,Split:Xs,StateTimeline:wn,StereoWidener:Or,Subtract:Gs,SyncedSignal:Yg,Synth:As,Ticks:zg,TicksClass:Oe,Time:Fg,TimeClass:Dt,Timeline:Et,ToneAudioBuffer:xe,ToneAudioBuffers:Cn,ToneAudioNode:$,ToneBufferSource:Es,ToneEvent:Jt,ToneOscillatorNode:hi,Transport:f_,TransportTime:Bg,TransportTimeClass:Xe,Tremolo:Nr,Unit:Xg,UserMedia:Zn,Vibrato:Fr,Volume:Ut,WaveShaper:Kt,Waveform:d_,Zero:gr,connect:pt,connectSeries:Nt,connectSignal:ui,context:w_,dbToGain:ln,debug:bg,defaultArg:$t,disconnect:ia,fanIn:$g,ftom:xs,gainToDb:li,getContext:me,getDestination:Na,getDraw:b_,getListener:v_,getTransport:Ns,immediate:p_,intervalToFrequencyRatio:un,isArray:ot,isBoolean:Uo,isDefined:de,isFunction:Ul,isNote:Ln,isNumber:Ot,isObject:ps,isString:Xt,isUndef:Tt,loaded:x_,mtof:sa,now:en,optionsFromArguments:F,setContext:Hn,start:ta,supported:vg,version:Eo},Symbol.toStringTag,{value:"Module"}));var Ni={exports:{}},Bn={};var vc;function k_(){if(vc)return Bn;vc=1;var s=S,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(a,c,l){var u,h={},p=null,d=null;l!==void 0&&(p=""+l),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(d=c.ref);for(u in c)n.call(c,u)&&!r.hasOwnProperty(u)&&(h[u]=c[u]);if(a&&a.defaultProps)for(u in c=a.defaultProps,c)h[u]===void 0&&(h[u]=c[u]);return{$$typeof:e,type:a,key:p,ref:d,props:h,_owner:i.current}}return Bn.Fragment=t,Bn.jsx=o,Bn.jsxs=o,Bn}var $n={};var yc;function A_(){return yc||(yc=1,process.env.NODE_ENV!=="production"&&(function(){var s=S,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),d=Symbol.for("react.offscreen"),f=Symbol.iterator,_="@@iterator";function m(C){if(C===null||typeof C!="object")return null;var O=f&&C[f]||C[_];return typeof O=="function"?O:null}var g=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(C){{for(var O=arguments.length,P=new Array(O>1?O-1:0),te=1;te<O;te++)P[te-1]=arguments[te];x("error",C,P)}}function x(C,O,P){{var te=g.ReactDebugCurrentFrame,J=te.getStackAddendum();J!==""&&(O+="%s",P=P.concat([J]));var ve=P.map(function(fe){return String(fe)});ve.unshift("Warning: "+O),Function.prototype.apply.call(console[C],console,ve)}}var w=!1,v=!1,b=!1,k=!1,T=!1,R;R=Symbol.for("react.module.reference");function I(C){return!!(typeof C=="string"||typeof C=="function"||C===n||C===r||T||C===i||C===l||C===u||k||C===d||w||v||b||typeof C=="object"&&C!==null&&(C.$$typeof===p||C.$$typeof===h||C.$$typeof===o||C.$$typeof===a||C.$$typeof===c||C.$$typeof===R||C.getModuleId!==void 0))}function A(C,O,P){var te=C.displayName;if(te)return te;var J=O.displayName||O.name||"";return J!==""?P+"("+J+")":P}function D(C){return C.displayName||"Context"}function M(C){if(C==null)return null;if(typeof C.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof C=="function")return C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case n:return"Fragment";case t:return"Portal";case r:return"Profiler";case i:return"StrictMode";case l:return"Suspense";case u:return"SuspenseList"}if(typeof C=="object")switch(C.$$typeof){case a:var O=C;return D(O)+".Consumer";case o:var P=C;return D(P._context)+".Provider";case c:return A(C,C.render,"ForwardRef");case h:var te=C.displayName||null;return te!==null?te:M(C.type)||"Memo";case p:{var J=C,ve=J._payload,fe=J._init;try{return M(fe(ve))}catch{return null}}}return null}var N=Object.assign,q=0,V,j,G,B,Z,X,ee;function pe(){}pe.__reactDisabledLog=!0;function ie(){{if(q===0){V=console.log,j=console.info,G=console.warn,B=console.error,Z=console.group,X=console.groupCollapsed,ee=console.groupEnd;var C={configurable:!0,enumerable:!0,value:pe,writable:!0};Object.defineProperties(console,{info:C,log:C,warn:C,error:C,group:C,groupCollapsed:C,groupEnd:C})}q++}}function Q(){{if(q--,q===0){var C={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},C,{value:V}),info:N({},C,{value:j}),warn:N({},C,{value:G}),error:N({},C,{value:B}),group:N({},C,{value:Z}),groupCollapsed:N({},C,{value:X}),groupEnd:N({},C,{value:ee})})}q<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=g.ReactCurrentDispatcher,Ee;function z(C,O,P){{if(Ee===void 0)try{throw Error()}catch(J){var te=J.stack.trim().match(/\n( *(at )?)/);Ee=te&&te[1]||""}return`
210
- `+Ee+C}}var Je=!1,lt;{var Vt=typeof WeakMap=="function"?WeakMap:Map;lt=new Vt}function U(C,O){if(!C||Je)return"";{var P=lt.get(C);if(P!==void 0)return P}var te;Je=!0;var J=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ve;ve=ye.current,ye.current=null,ie();try{if(O){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(Ct){te=Ct}Reflect.construct(C,[],fe)}else{try{fe.call()}catch(Ct){te=Ct}C.call(fe.prototype)}}else{try{throw Error()}catch(Ct){te=Ct}C()}}catch(Ct){if(Ct&&te&&typeof Ct.stack=="string"){for(var he=Ct.stack.split(`
211
- `),je=te.stack.split(`
212
- `),Ve=he.length-1,Pe=je.length-1;Ve>=1&&Pe>=0&&he[Ve]!==je[Pe];)Pe--;for(;Ve>=1&&Pe>=0;Ve--,Pe--)if(he[Ve]!==je[Pe]){if(Ve!==1||Pe!==1)do if(Ve--,Pe--,Pe<0||he[Ve]!==je[Pe]){var Ie=`
213
- `+he[Ve].replace(" at new "," at ");return C.displayName&&Ie.includes("<anonymous>")&&(Ie=Ie.replace("<anonymous>",C.displayName)),typeof C=="function"&&lt.set(C,Ie),Ie}while(Ve>=1&&Pe>=0);break}}}finally{Je=!1,ye.current=ve,Q(),Error.prepareStackTrace=J}var Qt=C?C.displayName||C.name:"",Os=Qt?z(Qt):"";return typeof C=="function"&&lt.set(C,Os),Os}function ut(C,O,P){return U(C,!1)}function $e(C){var O=C.prototype;return!!(O&&O.isReactComponent)}function L(C,O,P){if(C==null)return"";if(typeof C=="function")return U(C,$e(C));if(typeof C=="string")return z(C);switch(C){case l:return z("Suspense");case u:return z("SuspenseList")}if(typeof C=="object")switch(C.$$typeof){case c:return ut(C.render);case h:return L(C.type,O,P);case p:{var te=C,J=te._payload,ve=te._init;try{return L(ve(J),O,P)}catch{}}}return""}var H=Object.prototype.hasOwnProperty,be={},we=g.ReactDebugCurrentFrame;function ce(C){if(C){var O=C._owner,P=L(C.type,C._source,O?O.type:null);we.setExtraStackFrame(P)}else we.setExtraStackFrame(null)}function Ce(C,O,P,te,J){{var ve=Function.call.bind(H);for(var fe in C)if(ve(C,fe)){var he=void 0;try{if(typeof C[fe]!="function"){var je=Error((te||"React class")+": "+P+" type `"+fe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof C[fe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw je.name="Invariant Violation",je}he=C[fe](O,fe,te,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ve){he=Ve}he&&!(he instanceof Error)&&(ce(J),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",te||"React class",P,fe,typeof he),ce(null)),he instanceof Error&&!(he.message in be)&&(be[he.message]=!0,ce(J),y("Failed %s type: %s",P,he.message),ce(null))}}}var He=Array.isArray;function Ze(C){return He(C)}function Pt(C){{var O=typeof Symbol=="function"&&Symbol.toStringTag,P=O&&C[Symbol.toStringTag]||C.constructor.name||"Object";return P}}function oe(C){try{return ge(C),!1}catch{return!0}}function ge(C){return""+C}function Ae(C){if(oe(C))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Pt(C)),ge(C)}var qe=g.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0},xt,Se;function Lt(C){if(H.call(C,"ref")){var O=Object.getOwnPropertyDescriptor(C,"ref").get;if(O&&O.isReactWarning)return!1}return C.ref!==void 0}function ht(C){if(H.call(C,"key")){var O=Object.getOwnPropertyDescriptor(C,"key").get;if(O&&O.isReactWarning)return!1}return C.key!==void 0}function It(C,O){typeof C.ref=="string"&&qe.current}function dt(C,O){{var P=function(){xt||(xt=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};P.isReactWarning=!0,Object.defineProperty(C,"key",{get:P,configurable:!0})}}function et(C,O){{var P=function(){Se||(Se=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};P.isReactWarning=!0,Object.defineProperty(C,"ref",{get:P,configurable:!0})}}var as=function(C,O,P,te,J,ve,fe){var he={$$typeof:e,type:C,key:O,ref:P,props:fe,_owner:ve};return he._store={},Object.defineProperty(he._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(he,"_self",{configurable:!1,enumerable:!1,writable:!1,value:te}),Object.defineProperty(he,"_source",{configurable:!1,enumerable:!1,writable:!1,value:J}),Object.freeze&&(Object.freeze(he.props),Object.freeze(he)),he};function En(C,O,P,te,J){{var ve,fe={},he=null,je=null;P!==void 0&&(Ae(P),he=""+P),ht(O)&&(Ae(O.key),he=""+O.key),Lt(O)&&(je=O.ref,It(O,J));for(ve in O)H.call(O,ve)&&!Ge.hasOwnProperty(ve)&&(fe[ve]=O[ve]);if(C&&C.defaultProps){var Ve=C.defaultProps;for(ve in Ve)fe[ve]===void 0&&(fe[ve]=Ve[ve])}if(he||je){var Pe=typeof C=="function"?C.displayName||C.name||"Unknown":C;he&&dt(fe,Pe),je&&et(fe,Pe)}return as(C,he,je,J,te,qe.current,fe)}}var Mn=g.ReactCurrentOwner,Ti=g.ReactDebugCurrentFrame;function vs(C){if(C){var O=C._owner,P=L(C.type,C._source,O?O.type:null);Ti.setExtraStackFrame(P)}else Ti.setExtraStackFrame(null)}var On;On=!1;function Nn(C){return typeof C=="object"&&C!==null&&C.$$typeof===e}function ki(){{if(Mn.current){var C=M(Mn.current.type);if(C)return`
209
+ `;cu(uu,c_);class Cr extends Ye{constructor(){const e=F(Cr.getDefaults(),arguments,["bits"]);super(e),this.name="BitCrusher",this._bitCrusherWorklet=new Sa({context:this.context,bits:e.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(Ye.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}}class Sa extends wo{constructor(){const e=F(Sa.getDefaults(),arguments);super(e),this.name="BitCrusherWorklet",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.bits=new ce({context:this.context,value:e.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(wo.getDefaults(),{bits:12})}_audioWorkletName(){return uu}onReady(e){Nt(this.input,e,this.output);const t=e.parameters.get("bits");this.bits.setParam(t)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class Sr extends Ye{constructor(){const e=F(Sr.getDefaults(),arguments,["order"]);super(e),this.name="Chebyshev",this._shaper=new Kt({context:this.context,length:4096}),this._order=e.order,this.connectEffect(this._shaper),this.order=e.order,this.oversample=e.oversample}static getDefaults(){return Object.assign(Ye.getDefaults(),{order:1,oversample:"none"})}_getCoefficient(e,t,n){return n.has(t)||(t===0?n.set(t,0):t===1?n.set(t,e):n.set(t,2*e*this._getCoefficient(e,t-1,n)-this._getCoefficient(e,t-2,n))),n.get(t)}get order(){return this._order}set order(e){K(Number.isInteger(e),"'order' must be an integer"),this._order=e,this._shaper.setMap(t=>this._getCoefficient(t,e,new Map))}get oversample(){return this._shaper.oversample}set oversample(e){this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.dispose(),this}}class Hs extends ${constructor(){const e=F(Hs.getDefaults(),arguments,["channels"]);super(e),this.name="Split",this._splitter=this.input=this.output=this.context.createChannelSplitter(e.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign($.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}}class Ms extends ${constructor(){const e=F(Ms.getDefaults(),arguments,["channels"]);super(e),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(e.channels)}static getDefaults(){return Object.assign($.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}class es extends ${constructor(e){super(e),this.name="StereoEffect",this.input=new Y({context:this.context}),this.input.channelCount=2,this.input.channelCountMode="explicit",this._dryWet=this.output=new Dn({context:this.context,fade:e.wet}),this.wet=this._dryWet.fade,this._split=new Hs({context:this.context,channels:2}),this._merge=new Ms({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),ne(this,["wet"])}connectEffectLeft(...e){this._split.connect(e[0],0,0),Nt(...e),dt(e[e.length-1],this._merge,0,0)}connectEffectRight(...e){this._split.connect(e[0],1,0),Nt(...e),dt(e[e.length-1],this._merge,0,1)}static getDefaults(){return Object.assign($.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}}class xo extends es{constructor(e){super(e),this.feedback=new oe({context:this.context,value:e.feedback,units:"normalRange"}),this._feedbackL=new Y({context:this.context}),this._feedbackR=new Y({context:this.context}),this._feedbackSplit=new Hs({context:this.context,channels:2}),this._feedbackMerge=new Ms({context:this.context,channels:2}),this._merge.connect(this._feedbackSplit),this._feedbackMerge.connect(this._split),this._feedbackSplit.connect(this._feedbackL,0,0),this._feedbackL.connect(this._feedbackMerge,0,0),this._feedbackSplit.connect(this._feedbackR,1,0),this._feedbackR.connect(this._feedbackMerge,0,1),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),ne(this,["feedback"])}static getDefaults(){return Object.assign(es.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}}class Tr extends xo{constructor(){const e=F(Tr.getDefaults(),arguments,["frequency","delayTime","depth"]);super(e),this.name="Chorus",this._depth=e.depth,this._delayTime=e.delayTime/1e3,this._lfoL=new yt({context:this.context,frequency:e.frequency,min:0,max:1}),this._lfoR=new yt({context:this.context,frequency:e.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Mt({context:this.context}),this._delayNodeR=new Mt({context:this.context}),this.frequency=this._lfoL.frequency,ne(this,["frequency"]),this._lfoL.frequency.connect(this._lfoR.frequency),this.connectEffectLeft(this._delayNodeL),this.connectEffectRight(this._delayNodeR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this.depth=this._depth,this.type=e.type,this.spread=e.spread}static getDefaults(){return Object.assign(xo.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(e){this._depth=e;const t=this._delayTime*e;this._lfoL.min=Math.max(this._delayTime-t,0),this._lfoL.max=this._delayTime+t,this._lfoR.min=Math.max(this._delayTime-t,0),this._lfoR.max=this._delayTime+t}get delayTime(){return this._delayTime*1e3}set delayTime(e){this._delayTime=e/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(e){this._lfoL.type=e,this._lfoR.type=e}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(e){this._lfoL.phase=90-e/2,this._lfoR.phase=e/2+90}start(e){return this._lfoL.start(e),this._lfoR.start(e),this}stop(e){return this._lfoL.stop(e),this._lfoR.stop(e),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.dispose(),this._delayNodeR.dispose(),this.frequency.dispose(),this}}class kr extends Ye{constructor(){const e=F(kr.getDefaults(),arguments,["distortion"]);super(e),this.name="Distortion",this._shaper=new Kt({context:this.context,length:4096}),this._distortion=e.distortion,this.connectEffect(this._shaper),this.distortion=e.distortion,this.oversample=e.oversample}static getDefaults(){return Object.assign(Ye.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(e){this._distortion=e;const t=e*100,n=Math.PI/180;this._shaper.setMap(i=>Math.abs(i)<.001?0:(3+t)*i*20*n/(Math.PI+t*Math.abs(i)))}get oversample(){return this._shaper.oversample}set oversample(e){this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.dispose(),this}}class Qi extends Ye{constructor(e){super(e),this.name="FeedbackEffect",this._feedbackGain=new Y({context:this.context,gain:e.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,ne(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(Ye.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class Ar extends Qi{constructor(){const e=F(Ar.getDefaults(),arguments,["delayTime","feedback"]);super(e),this.name="FeedbackDelay",this._delayNode=new Mt({context:this.context,delayTime:e.delayTime,maxDelay:e.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),ne(this,"delayTime")}static getDefaults(){return Object.assign(Qi.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}class l_ extends ${constructor(e){super(e),this.name="PhaseShiftAllpass",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.offset90=new Y({context:this.context});const t=[.6923878,.9360654322959,.988229522686,.9987488452737],n=[.4021921162426,.856171088242,.9722909545651,.9952884791278];this._bank0=this._createAllPassFilterBank(t),this._bank1=this._createAllPassFilterBank(n),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),Nt(this.input,...this._bank0,this._oneSampleDelay,this.output),Nt(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(e){return e.map(n=>{const i=[[n*n,0,-1],[1,0,-(n*n)]];return this.context.createIIRFilter(i[0],i[1])})}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach(e=>e.disconnect()),this._bank1.forEach(e=>e.disconnect()),this._oneSampleDelay.disconnect(),this}}class Ta extends Ye{constructor(){const e=F(Ta.getDefaults(),arguments,["frequency"]);super(e),this.name="FrequencyShifter",this.frequency=new oe({context:this.context,units:"frequency",value:e.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new hi({context:this.context,type:"sine"}),this._cosine=new Ve({context:this.context,phase:-90,type:"sine"}),this._sineMultiply=new Pe({context:this.context}),this._cosineMultiply=new Pe({context:this.context}),this._negate=new da({context:this.context}),this._add=new Zs({context:this.context}),this._phaseShifter=new l_({context:this.context}),this.effectSend.connect(this._phaseShifter),this.frequency.fan(this._sine.frequency,this._cosine.frequency),this._phaseShifter.offset90.connect(this._cosineMultiply),this._cosine.connect(this._cosineMultiply.factor),this._phaseShifter.connect(this._sineMultiply),this._sine.connect(this._sineMultiply.factor),this._sineMultiply.connect(this._negate),this._cosineMultiply.connect(this._add),this._negate.connect(this._add.addend),this._add.connect(this.effectReturn);const t=this.immediate();this._sine.start(t),this._cosine.start(t)}static getDefaults(){return Object.assign(Ye.getDefaults(),{frequency:0})}dispose(){return super.dispose(),this.frequency.dispose(),this._add.dispose(),this._cosine.dispose(),this._cosineMultiply.dispose(),this._negate.dispose(),this._phaseShifter.dispose(),this._sine.dispose(),this._sineMultiply.dispose(),this}}const pc=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],fc=[225,556,441,341];class Ir extends es{constructor(){const e=F(Ir.getDefaults(),arguments,["roomSize","dampening"]);super(e),this.name="Freeverb",this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[],this.roomSize=new oe({context:this.context,value:e.roomSize,units:"normalRange"}),this._allpassFiltersL=fc.map(t=>{const n=this.context.createBiquadFilter();return n.type="allpass",n.frequency.value=t,n}),this._allpassFiltersR=fc.map(t=>{const n=this.context.createBiquadFilter();return n.type="allpass",n.frequency.value=t,n}),this._combFilters=pc.map((t,n)=>{const i=new vi({context:this.context,dampening:e.dampening,delayTime:t});return n<pc.length/2?this.connectEffectLeft(i,...this._allpassFiltersL):this.connectEffectRight(i,...this._allpassFiltersR),this.roomSize.connect(i.resonance),i}),ne(this,["roomSize"])}static getDefaults(){return Object.assign(es.getDefaults(),{roomSize:.7,dampening:3e3})}get dampening(){return this._combFilters[0].dampening}set dampening(e){this._combFilters.forEach(t=>t.dampening=e)}dispose(){return super.dispose(),this._allpassFiltersL.forEach(e=>e.disconnect()),this._allpassFiltersR.forEach(e=>e.disconnect()),this._combFilters.forEach(e=>e.dispose()),this.roomSize.dispose(),this}}const mc=[1687/25e3,1601/25e3,2053/25e3,2251/25e3],u_=[.773,.802,.753,.733],h_=[347,113,37];class Dr extends es{constructor(){const e=F(Dr.getDefaults(),arguments,["roomSize"]);super(e),this.name="JCReverb",this._allpassFilters=[],this._feedbackCombFilters=[],this.roomSize=new oe({context:this.context,value:e.roomSize,units:"normalRange"}),this._scaleRoomSize=new fs({context:this.context,min:-.733,max:.197}),this._allpassFilters=h_.map(t=>{const n=this.context.createBiquadFilter();return n.type="allpass",n.frequency.value=t,n}),this._feedbackCombFilters=mc.map((t,n)=>{const i=new gi({context:this.context,delayTime:t});return this._scaleRoomSize.connect(i.resonance),i.resonance.value=u_[n],n<mc.length/2?this.connectEffectLeft(...this._allpassFilters,i):this.connectEffectRight(...this._allpassFilters,i),i}),this.roomSize.connect(this._scaleRoomSize),ne(this,["roomSize"])}static getDefaults(){return Object.assign(es.getDefaults(),{roomSize:.5})}dispose(){return super.dispose(),this._allpassFilters.forEach(e=>e.disconnect()),this._feedbackCombFilters.forEach(e=>e.dispose()),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}}class gc extends xo{constructor(e){super(e),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),ne(this,["feedback"])}}class Rr extends gc{constructor(){const e=F(Rr.getDefaults(),arguments,["delayTime","feedback"]);super(e),this.name="PingPongDelay",this._leftDelay=new Mt({context:this.context,maxDelay:e.maxDelay}),this._rightDelay=new Mt({context:this.context,maxDelay:e.maxDelay}),this._rightPreDelay=new Mt({context:this.context,maxDelay:e.maxDelay}),this.delayTime=new oe({context:this.context,units:"time",value:e.delayTime}),this.connectEffectLeft(this._leftDelay),this.connectEffectRight(this._rightPreDelay,this._rightDelay),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackL.disconnect(),this._feedbackL.connect(this._rightDelay),ne(this,["delayTime"])}static getDefaults(){return Object.assign(gc.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}}class ka extends Qi{constructor(){const e=F(ka.getDefaults(),arguments,["pitch"]);super(e),this.name="PitchShift",this._frequency=new oe({context:this.context}),this._delayA=new Mt({maxDelay:1,context:this.context}),this._lfoA=new yt({context:this.context,min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new Mt({maxDelay:1,context:this.context}),this._lfoB=new yt({context:this.context,min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new Dn({context:this.context}),this._crossFadeLFO=new yt({context:this.context,min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Mt({delayTime:e.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,ne(this,"delayTime"),this._pitch=e.pitch,this._windowSize=e.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);const t=this.now();this._lfoA.start(t),this._lfoB.start(t),this._crossFadeLFO.start(t),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(Qi.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(e){this._pitch=e;let t=0;e<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,t=hn(e-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,t=hn(e)-1),this._frequency.value=t*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(e){this._windowSize=this.toSeconds(e),this.pitch=this._pitch}dispose(){return super.dispose(),this._frequency.dispose(),this._delayA.dispose(),this._delayB.dispose(),this._lfoA.dispose(),this._lfoB.dispose(),this._crossFade.dispose(),this._crossFadeLFO.dispose(),this._feedbackDelay.dispose(),this}}class Er extends es{constructor(){const e=F(Er.getDefaults(),arguments,["frequency","octaves","baseFrequency"]);super(e),this.name="Phaser",this._lfoL=new yt({context:this.context,frequency:e.frequency,min:0,max:1}),this._lfoR=new yt({context:this.context,frequency:e.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(e.baseFrequency),this._octaves=e.octaves,this.Q=new oe({context:this.context,value:e.Q,units:"positive"}),this._filtersL=this._makeFilters(e.stages,this._lfoL),this._filtersR=this._makeFilters(e.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=e.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=e.baseFrequency,this.octaves=e.octaves,this._lfoL.start(),this._lfoR.start(),ne(this,["frequency","Q"])}static getDefaults(){return Object.assign(es.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(e,t){const n=[];for(let i=0;i<e;i++){const r=this.context.createBiquadFilter();r.type="allpass",this.Q.connect(r.Q),t.connect(r.frequency),n.push(r)}return n}get octaves(){return this._octaves}set octaves(e){this._octaves=e;const t=this._baseFrequency*Math.pow(2,e);this._lfoL.max=t,this._lfoR.max=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){this._baseFrequency=this.toFrequency(e),this._lfoL.min=this._baseFrequency,this._lfoR.min=this._baseFrequency,this.octaves=this._octaves}dispose(){return super.dispose(),this.Q.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._filtersL.forEach(e=>e.disconnect()),this._filtersR.forEach(e=>e.disconnect()),this.frequency.dispose(),this}}class Mr extends Ye{constructor(){const e=F(Mr.getDefaults(),arguments,["decay"]);super(e),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const t=this.toSeconds(e.decay);Xe(t,.001),this._decay=t;const n=this.toSeconds(e.preDelay);Xe(n,0),this._preDelay=n,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Ye.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(e){e=this.toSeconds(e),Xe(e,.001),this._decay=e,this.generate()}get preDelay(){return this._preDelay}set preDelay(e){e=this.toSeconds(e),Xe(e,0),this._preDelay=e,this.generate()}generate(){return Ae(this,void 0,void 0,function*(){const e=this.ready,t=new wn(2,this._decay+this._preDelay,this.context.sampleRate),n=new ks({context:t}),i=new ks({context:t}),r=new Ms({context:t});n.connect(r,0,0),i.connect(r,0,1);const o=new Y({context:t}).toDestination();r.connect(o),n.start(0),i.start(0),o.gain.setValueAtTime(0,0),o.gain.setValueAtTime(1,this._preDelay),o.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const a=t.render();return this.ready=a.then(ge),yield e,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}}class wi extends ${constructor(){super(F(wi.getDefaults(),arguments)),this.name="MidSideSplit",this._split=this.input=new Hs({channels:2,context:this.context}),this._midAdd=new Zs({context:this.context}),this.mid=new Pe({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new Xs({context:this.context}),this.side=new Pe({context:this.context,value:Math.SQRT1_2}),this._split.connect(this._midAdd,0),this._split.connect(this._midAdd.addend,1),this._split.connect(this._sideSubtract,0),this._split.connect(this._sideSubtract.subtrahend,1),this._midAdd.connect(this.mid),this._sideSubtract.connect(this.side)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midAdd.dispose(),this._sideSubtract.dispose(),this._split.dispose(),this}}class xi extends ${constructor(){super(F(xi.getDefaults(),arguments)),this.name="MidSideMerge",this.mid=new Y({context:this.context}),this.side=new Y({context:this.context}),this._left=new Zs({context:this.context}),this._leftMult=new Pe({context:this.context,value:Math.SQRT1_2}),this._right=new Xs({context:this.context}),this._rightMult=new Pe({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Ms({context:this.context}),this.mid.fan(this._left),this.side.connect(this._left.addend),this.mid.connect(this._right),this.side.connect(this._right.subtrahend),this._left.connect(this._leftMult),this._right.connect(this._rightMult),this._leftMult.connect(this._merge,0,0),this._rightMult.connect(this._merge,0,1)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._leftMult.dispose(),this._rightMult.dispose(),this._left.dispose(),this._right.dispose(),this}}class _c extends Ye{constructor(e){super(e),this.name="MidSideEffect",this._midSideMerge=new xi({context:this.context}),this._midSideSplit=new wi({context:this.context}),this._midSend=this._midSideSplit.mid,this._sideSend=this._midSideSplit.side,this._midReturn=this._midSideMerge.mid,this._sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)}connectEffectMid(...e){this._midSend.chain(...e,this._midReturn)}connectEffectSide(...e){this._sideSend.chain(...e,this._sideReturn)}dispose(){return super.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this._midSend.dispose(),this._sideSend.dispose(),this._midReturn.dispose(),this._sideReturn.dispose(),this}}class Or extends _c{constructor(){const e=F(Or.getDefaults(),arguments,["width"]);super(e),this.name="StereoWidener",this.width=new oe({context:this.context,value:e.width,units:"normalRange"}),ne(this,["width"]),this._twoTimesWidthMid=new Pe({context:this.context,value:2}),this._twoTimesWidthSide=new Pe({context:this.context,value:2}),this._midMult=new Pe({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new Xs({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),dt(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new Pe({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(_c.getDefaults(),{width:.5})}dispose(){return super.dispose(),this.width.dispose(),this._midMult.dispose(),this._sideMult.dispose(),this._twoTimesWidthMid.dispose(),this._twoTimesWidthSide.dispose(),this._oneMinusWidth.dispose(),this}}class Nr extends es{constructor(){const e=F(Nr.getDefaults(),arguments,["frequency","depth"]);super(e),this.name="Tremolo",this._lfoL=new yt({context:this.context,type:e.type,min:1,max:0}),this._lfoR=new yt({context:this.context,type:e.type,min:1,max:0}),this._amplitudeL=new Y({context:this.context}),this._amplitudeR=new Y({context:this.context}),this.frequency=new oe({context:this.context,value:e.frequency,units:"frequency"}),this.depth=new oe({context:this.context,value:e.depth,units:"normalRange"}),ne(this,["frequency","depth"]),this.connectEffectLeft(this._amplitudeL),this.connectEffectRight(this._amplitudeR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.spread=e.spread}static getDefaults(){return Object.assign(es.getDefaults(),{frequency:10,type:"sine",depth:.5,spread:180})}start(e){return this._lfoL.start(e),this._lfoR.start(e),this}stop(e){return this._lfoL.stop(e),this._lfoR.stop(e),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this.context.transport.syncSignal(this.frequency),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this.context.transport.unsyncSignal(this.frequency),this}get type(){return this._lfoL.type}set type(e){this._lfoL.type=e,this._lfoR.type=e}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(e){this._lfoL.phase=90-e/2,this._lfoR.phase=e/2+90}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._amplitudeL.dispose(),this._amplitudeR.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Fr extends Ye{constructor(){const e=F(Fr.getDefaults(),arguments,["frequency","depth"]);super(e),this.name="Vibrato",this._delayNode=new Mt({context:this.context,delayTime:0,maxDelay:e.maxDelay}),this._lfo=new yt({context:this.context,type:e.type,min:0,max:e.maxDelay,frequency:e.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=e.depth,ne(this,["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(Ye.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:"sine"})}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Ys extends ${constructor(){const e=F(Ys.getDefaults(),arguments,["type","size"]);super(e),this.name="Analyser",this._analysers=[],this._buffers=[],this.input=this.output=this._gain=new Y({context:this.context}),this._split=new Hs({context:this.context,channels:e.channels}),this.input.connect(this._split),Xe(e.channels,1);for(let t=0;t<e.channels;t++)this._analysers[t]=this.context.createAnalyser(),this._split.connect(this._analysers[t],t,0);this.size=e.size,this.type=e.type,this.smoothing=e.smoothing}static getDefaults(){return Object.assign($.getDefaults(),{size:1024,smoothing:.8,type:"fft",channels:1})}getValue(){return this._analysers.forEach((e,t)=>{const n=this._buffers[t];this._type==="fft"?e.getFloatFrequencyData(n):this._type==="waveform"&&e.getFloatTimeDomainData(n)}),this.channels===1?this._buffers[0]:this._buffers}get size(){return this._analysers[0].frequencyBinCount}set size(e){this._analysers.forEach((t,n)=>{t.fftSize=e*2,this._buffers[n]=new Float32Array(e)})}get channels(){return this._analysers.length}get type(){return this._type}set type(e){K(e==="waveform"||e==="fft",`Analyser: invalid type: ${e}`),this._type=e}get smoothing(){return this._analysers[0].smoothingTimeConstant}set smoothing(e){this._analysers.forEach(t=>t.smoothingTimeConstant=e)}dispose(){return super.dispose(),this._analysers.forEach(e=>e.disconnect()),this._split.dispose(),this._gain.dispose(),this}}class Is extends ${constructor(){super(F(Is.getDefaults(),arguments)),this.name="MeterBase",this.input=this.output=this._analyser=new Ys({context:this.context,size:256,type:"waveform"})}dispose(){return super.dispose(),this._analyser.dispose(),this}}class Vr extends Is{constructor(){const e=F(Vr.getDefaults(),arguments,["smoothing"]);super(e),this.name="Meter",this.input=this.output=this._analyser=new Ys({context:this.context,size:256,type:"waveform",channels:e.channelCount}),this.smoothing=e.smoothing,this.normalRange=e.normalRange,this._rms=new Array(e.channelCount),this._rms.fill(0)}static getDefaults(){return Object.assign(Is.getDefaults(),{smoothing:.8,normalRange:!1,channelCount:1})}getLevel(){return yn("'getLevel' has been changed to 'getValue'"),this.getValue()}getValue(){const e=this._analyser.getValue(),n=(this.channels===1?[e]:e).map((i,r)=>{const o=i.reduce((c,l)=>c+l*l,0),a=Math.sqrt(o/i.length);return this._rms[r]=Math.max(a,this._rms[r]*this.smoothing),this.normalRange?this._rms[r]:li(this._rms[r])});return this.channels===1?n[0]:n}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}}class Aa extends Is{constructor(){const e=F(Aa.getDefaults(),arguments,["size"]);super(e),this.name="FFT",this.normalRange=e.normalRange,this._analyser.type="fft",this.size=e.size}static getDefaults(){return Object.assign($.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map(t=>this.normalRange?un(t):t)}get size(){return this._analyser.size}set size(e){this._analyser.size=e}get smoothing(){return this._analyser.smoothing}set smoothing(e){this._analyser.smoothing=e}getFrequencyOfIndex(e){return K(0<=e&&e<this.size,`index must be greater than or equal to 0 and less than ${this.size}`),e*this.context.sampleRate/(this.size*2)}}class Ia extends Is{constructor(){super(F(Ia.getDefaults(),arguments)),this.name="DCMeter",this._analyser.type="waveform",this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}}let d_=class hu extends Is{constructor(){const e=F(hu.getDefaults(),arguments,["size"]);super(e),this.name="Waveform",this._analyser.type="waveform",this.size=e.size}static getDefaults(){return Object.assign(Is.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(e){this._analyser.size=e}};class qe extends ${constructor(){const e=F(qe.getDefaults(),arguments,["solo"]);super(e),this.name="Solo",this.input=this.output=new Y({context:this.context}),qe._allSolos.has(this.context)||qe._allSolos.set(this.context,new Set),qe._allSolos.get(this.context).add(this),this.solo=e.solo}static getDefaults(){return Object.assign($.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(e){e?this._addSolo():this._removeSolo(),qe._allSolos.get(this.context).forEach(t=>t._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){qe._soloed.has(this.context)||qe._soloed.set(this.context,new Set),qe._soloed.get(this.context).add(this)}_removeSolo(){qe._soloed.has(this.context)&&qe._soloed.get(this.context).delete(this)}_isSoloed(){return qe._soloed.has(this.context)&&qe._soloed.get(this.context).has(this)}_noSolos(){return!qe._soloed.has(this.context)||qe._soloed.has(this.context)&&qe._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),qe._allSolos.get(this.context).delete(this),this._removeSolo(),this}}qe._allSolos=new Map;qe._soloed=new Map;class Pr extends ${constructor(){const e=F(Pr.getDefaults(),arguments,["pan","volume"]);super(e),this.name="PanVol",this._panner=this.input=new Rn({context:this.context,pan:e.pan,channelCount:e.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Ut({context:this.context,volume:e.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=e.mute,ne(this,["pan","volume"])}static getDefaults(){return Object.assign($.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}let du=class zn extends ${constructor(){const e=F(zn.getDefaults(),arguments,["volume","pan"]);super(e),this.name="Channel",this._solo=this.input=new qe({solo:e.solo,context:this.context}),this._panVol=this.output=new Pr({context:this.context,pan:e.pan,volume:e.volume,mute:e.mute,channelCount:e.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),ne(this,["pan","volume"])}static getDefaults(){return Object.assign($.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(e){return zn.buses.has(e)||zn.buses.set(e,new Y({context:this.context})),zn.buses.get(e)}send(e,t=0){const n=this._getBus(e),i=new Y({context:this.context,units:"decibels",gain:t});return this.connect(i),i.connect(n),i}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};du.buses=new Map;class Da extends ${constructor(){super(F(Da.getDefaults(),arguments)),this.name="Mono",this.input=new Y({context:this.context}),this._merge=this.output=new Ms({channels:2,context:this.context}),this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1)}dispose(){return super.dispose(),this._merge.dispose(),this.input.dispose(),this}}class Ci extends ${constructor(){const e=F(Ci.getDefaults(),arguments,["lowFrequency","highFrequency"]);super(e),this.name="MultibandSplit",this.input=new Y({context:this.context}),this.output=void 0,this.low=new Rt({context:this.context,frequency:0,type:"lowpass"}),this._lowMidFilter=new Rt({context:this.context,frequency:0,type:"highpass"}),this.mid=new Rt({context:this.context,frequency:0,type:"lowpass"}),this.high=new Rt({context:this.context,frequency:0,type:"highpass"}),this._internalChannels=[this.low,this.mid,this.high],this.lowFrequency=new oe({context:this.context,units:"frequency",value:e.lowFrequency}),this.highFrequency=new oe({context:this.context,units:"frequency",value:e.highFrequency}),this.Q=new oe({context:this.context,units:"positive",value:e.Q}),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.fan(this.low.frequency,this._lowMidFilter.frequency),this.highFrequency.fan(this.mid.frequency,this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),ne(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign($.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),ci(this,["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this._lowMidFilter.dispose(),this.mid.dispose(),this.high.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this.Q.dispose(),this}}class Ra extends ${constructor(){const e=F(Ra.getDefaults(),arguments,["positionX","positionY","positionZ"]);super(e),this.name="Panner3D",this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=e.panningModel,this.maxDistance=e.maxDistance,this.distanceModel=e.distanceModel,this.coneOuterGain=e.coneOuterGain,this.coneOuterAngle=e.coneOuterAngle,this.coneInnerAngle=e.coneInnerAngle,this.refDistance=e.refDistance,this.rolloffFactor=e.rolloffFactor,this.positionX=new ce({context:this.context,param:this._panner.positionX,value:e.positionX}),this.positionY=new ce({context:this.context,param:this._panner.positionY,value:e.positionY}),this.positionZ=new ce({context:this.context,param:this._panner.positionZ,value:e.positionZ}),this.orientationX=new ce({context:this.context,param:this._panner.orientationX,value:e.orientationX}),this.orientationY=new ce({context:this.context,param:this._panner.orientationY,value:e.orientationY}),this.orientationZ=new ce({context:this.context,param:this._panner.orientationZ,value:e.orientationZ})}static getDefaults(){return Object.assign($.getDefaults(),{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:0,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1})}setPosition(e,t,n){return this.positionX.value=e,this.positionY.value=t,this.positionZ.value=n,this}setOrientation(e,t,n){return this.orientationX.value=e,this.orientationY.value=t,this.orientationZ.value=n,this}get panningModel(){return this._panner.panningModel}set panningModel(e){this._panner.panningModel=e}get refDistance(){return this._panner.refDistance}set refDistance(e){this._panner.refDistance=e}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(e){this._panner.rolloffFactor=e}get distanceModel(){return this._panner.distanceModel}set distanceModel(e){this._panner.distanceModel=e}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(e){this._panner.coneInnerAngle=e}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(e){this._panner.coneOuterAngle=e}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(e){this._panner.coneOuterGain=e}get maxDistance(){return this._panner.maxDistance}set maxDistance(e){this._panner.maxDistance=e}dispose(){return super.dispose(),this._panner.disconnect(),this.orientationX.dispose(),this.orientationY.dispose(),this.orientationZ.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this}}class Ji extends ${constructor(){const e=F(Ji.getDefaults(),arguments);super(e),this.name="Recorder",this.input=new Y({context:this.context}),K(Ji.supported,"Media Recorder API is not available"),this._stream=this.context.createMediaStreamDestination(),this.input.connect(this._stream),this._recorder=new MediaRecorder(this._stream.stream,{mimeType:e.mimeType})}static getDefaults(){return $.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return gt!==null&&Reflect.has(gt,"MediaRecorder")}get state(){return this._recorder.state==="inactive"?"stopped":this._recorder.state==="paused"?"paused":"started"}start(){return Ae(this,void 0,void 0,function*(){K(this.state!=="started","Recorder is already started");const e=new Promise(t=>{const n=()=>{this._recorder.removeEventListener("start",n,!1),t()};this._recorder.addEventListener("start",n,!1)});return this.state==="stopped"?this._recorder.start():this._recorder.resume(),yield e})}stop(){return Ae(this,void 0,void 0,function*(){K(this.state!=="stopped","Recorder is not started");const e=new Promise(t=>{const n=i=>{this._recorder.removeEventListener("dataavailable",n,!1),t(i.data)};this._recorder.addEventListener("dataavailable",n,!1)});return this._recorder.stop(),yield e})}pause(){return K(this.state==="started","Recorder must be started"),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}}class Jt extends ${constructor(){const e=F(Jt.getDefaults(),arguments,["threshold","ratio"]);super(e),this.name="Compressor",this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor,this.threshold=new ce({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:"decibels",value:e.threshold}),this.attack=new ce({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:"time",value:e.attack}),this.release=new ce({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:"time",value:e.release}),this.knee=new ce({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:"decibels",value:e.knee}),this.ratio=new ce({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:"positive",value:e.ratio}),ne(this,["knee","release","attack","ratio","threshold"])}static getDefaults(){return Object.assign($.getDefaults(),{attack:.003,knee:30,ratio:12,release:.25,threshold:-24})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.disconnect(),this.attack.dispose(),this.release.dispose(),this.threshold.dispose(),this.ratio.dispose(),this.knee.dispose(),this}}class Wr extends ${constructor(){const e=F(Wr.getDefaults(),arguments,["threshold","smoothing"]);super(e),this.name="Gate",this._follower=new bi({context:this.context,smoothing:e.smoothing}),this._gt=new vr({context:this.context,value:un(e.threshold)}),this.input=new Y({context:this.context}),this._gate=this.output=new Y({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign($.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return li(this._gt.value)}set threshold(e){this._gt.value=un(e)}get smoothing(){return this._follower.smoothing}set smoothing(e){this._follower.smoothing=e}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}}class Br extends ${constructor(){const e=F(Br.getDefaults(),arguments,["threshold"]);super(e),this.name="Limiter",this._compressor=this.input=this.output=new Jt({context:this.context,ratio:20,attack:.003,release:.01,threshold:e.threshold}),this.threshold=this._compressor.threshold,ne(this,"threshold")}static getDefaults(){return Object.assign($.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}}class Ea extends ${constructor(){const e=F(Ea.getDefaults(),arguments);super(e),this.name="MidSideCompressor",this._midSideSplit=this.input=new wi({context:this.context}),this._midSideMerge=this.output=new xi({context:this.context}),this.mid=new Jt(Object.assign(e.mid,{context:this.context})),this.side=new Jt(Object.assign(e.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),ne(this,["mid","side"])}static getDefaults(){return Object.assign($.getDefaults(),{mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}})}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this}}class Ma extends ${constructor(){const e=F(Ma.getDefaults(),arguments);super(e),this.name="MultibandCompressor",this._splitter=this.input=new Ci({context:this.context,lowFrequency:e.lowFrequency,highFrequency:e.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new Y({context:this.context}),this.low=new Jt(Object.assign(e.low,{context:this.context})),this.mid=new Jt(Object.assign(e.mid,{context:this.context})),this.high=new Jt(Object.assign(e.high,{context:this.context})),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),ne(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign($.getDefaults(),{lowFrequency:250,highFrequency:2e3,low:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10},mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},high:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16}})}dispose(){return super.dispose(),this._splitter.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.output.dispose(),this}}class $r extends ${constructor(){const e=F($r.getDefaults(),arguments,["low","mid","high"]);super(e),this.name="EQ3",this.output=new Y({context:this.context}),this._internalChannels=[],this.input=this._multibandSplit=new Ci({context:this.context,highFrequency:e.highFrequency,lowFrequency:e.lowFrequency}),this._lowGain=new Y({context:this.context,gain:e.low,units:"decibels"}),this._midGain=new Y({context:this.context,gain:e.mid,units:"decibels"}),this._highGain=new Y({context:this.context,gain:e.high,units:"decibels"}),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),ne(this,["low","mid","high","lowFrequency","highFrequency"]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign($.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),ci(this,["low","mid","high","lowFrequency","highFrequency"]),this._multibandSplit.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this._lowGain.dispose(),this._midGain.dispose(),this._highGain.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.Q.dispose(),this}}class Oa extends ${constructor(){const e=F(Oa.getDefaults(),arguments,["url","onload"]);super(e),this.name="Convolver",this._convolver=this.context.createConvolver(),this._buffer=new xe(e.url,t=>{this.buffer=t,e.onload()}),this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=e.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign($.getDefaults(),{normalize:!0,onload:ge})}load(e){return Ae(this,void 0,void 0,function*(){this.buffer=yield this._buffer.load(e)})}get buffer(){return this._buffer.length?this._buffer:null}set buffer(e){e&&this._buffer.set(e),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));const t=this._buffer.get();this._convolver.buffer=t||null}get normalize(){return this._convolver.normalize}set normalize(e){this._convolver.normalize=e}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}}function tn(){return fe().now()}function p_(){return fe().immediate()}const f_=fe().transport;function Fs(){return fe().transport}const m_=fe().destination,g_=fe().destination;function Na(){return fe().destination}const __=fe().listener;function v_(){return fe().listener}const y_=fe().draw;function b_(){return fe().draw}const w_=fe();function x_(){return xe.loaded()}const C_=xe,S_=Sn,T_=Es,pu=Object.freeze(Object.defineProperty({__proto__:null,AMOscillator:di,AMSynth:pa,Abs:ou,Add:Zs,AmplitudeEnvelope:In,Analyser:Ys,AudioToGain:mr,AutoFilter:br,AutoPanner:wr,AutoWah:xr,BaseContext:ea,BiquadFilter:Un,BitCrusher:Cr,Buffer:C_,BufferSource:T_,Buffers:S_,Channel:du,Chebyshev:Sr,Chorus:Tr,Clock:Cn,Compressor:Jt,Context:Ls,Convolver:Oa,CrossFade:Dn,DCMeter:Ia,Delay:Mt,Destination:m_,Distortion:kr,Draw:y_,DuoSynth:fa,EQ3:$r,Emitter:bn,Envelope:ct,FFT:Aa,FMOscillator:kn,FMSynth:ma,FatOscillator:pi,FeedbackCombFilter:gi,FeedbackDelay:Ar,Filter:Rt,Follower:bi,Freeverb:Ir,Frequency:Wg,FrequencyClass:vt,FrequencyEnvelope:Kn,FrequencyShifter:Ta,Gain:Y,GainToAudio:au,Gate:Wr,GrainPlayer:ha,GreaterThan:vr,GreaterThanZero:_r,IntervalTimeline:iu,JCReverb:Dr,LFO:yt,Limiter:Br,Listener:__,Loop:Qn,LowpassCombFilter:vi,Master:g_,MembraneSynth:mi,Merge:Ms,MetalSynth:ga,Meter:Vr,MidSideCompressor:Ea,MidSideMerge:xi,MidSideSplit:wi,Midi:Lg,MidiClass:pn,Mono:Da,MonoSynth:Ps,MultibandCompressor:Ma,MultibandSplit:Ci,Multiply:Pe,Negate:da,Noise:ks,NoiseSynth:_a,Offline:jg,OfflineContext:wn,OmniOscillator:ps,OnePoleFilter:_i,Oscillator:Ve,PWMOscillator:fi,PanVol:Pr,Panner:Rn,Panner3D:Ra,Param:ce,Part:Jn,Pattern:xa,Phaser:Er,PingPongDelay:Rr,PitchShift:ka,Player:Gs,Players:ua,PluckSynth:ba,PolySynth:wa,Pow:Tn,PulseOscillator:An,Recorder:Ji,Reverb:Mr,Sampler:yi,Scale:fs,ScaleExp:yr,Sequence:Ca,Signal:oe,Solo:qe,Split:Hs,StateTimeline:xn,StereoWidener:Or,Subtract:Xs,SyncedSignal:Yg,Synth:As,Ticks:zg,TicksClass:Fe,Time:Fg,TimeClass:Dt,Timeline:Et,ToneAudioBuffer:xe,ToneAudioBuffers:Sn,ToneAudioNode:$,ToneBufferSource:Es,ToneEvent:Qt,ToneOscillatorNode:hi,Transport:f_,TransportTime:Bg,TransportTimeClass:Le,Tremolo:Nr,Unit:Xg,UserMedia:Zn,Vibrato:Fr,Volume:Ut,WaveShaper:Kt,Waveform:d_,Zero:gr,connect:dt,connectSeries:Nt,connectSignal:ui,context:w_,dbToGain:un,debug:bg,defaultArg:Bt,disconnect:ia,fanIn:$g,ftom:xs,gainToDb:li,getContext:fe,getDestination:Na,getDraw:b_,getListener:v_,getTransport:Fs,immediate:p_,intervalToFrequencyRatio:hn,isArray:at,isBoolean:Uo,isDefined:he,isFunction:Ul,isNote:Ln,isNumber:Ot,isObject:ds,isString:Xt,isUndef:Tt,loaded:x_,mtof:sa,now:tn,optionsFromArguments:F,setContext:Hn,start:ta,supported:vg,version:Eo},Symbol.toStringTag,{value:"Module"}));var Ni={exports:{}},Bn={};var vc;function k_(){if(vc)return Bn;vc=1;var s=S,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(a,c,l){var u,h={},p=null,d=null;l!==void 0&&(p=""+l),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(d=c.ref);for(u in c)n.call(c,u)&&!r.hasOwnProperty(u)&&(h[u]=c[u]);if(a&&a.defaultProps)for(u in c=a.defaultProps,c)h[u]===void 0&&(h[u]=c[u]);return{$$typeof:e,type:a,key:p,ref:d,props:h,_owner:i.current}}return Bn.Fragment=t,Bn.jsx=o,Bn.jsxs=o,Bn}var $n={};var yc;function A_(){return yc||(yc=1,process.env.NODE_ENV!=="production"&&(function(){var s=S,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),d=Symbol.for("react.offscreen"),f=Symbol.iterator,_="@@iterator";function m(C){if(C===null||typeof C!="object")return null;var M=f&&C[f]||C[_];return typeof M=="function"?M:null}var g=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(C){{for(var M=arguments.length,W=new Array(M>1?M-1:0),Z=1;Z<M;Z++)W[Z-1]=arguments[Z];x("error",C,W)}}function x(C,M,W){{var Z=g.ReactDebugCurrentFrame,pe=Z.getStackAddendum();pe!==""&&(M+="%s",W=W.concat([pe]));var be=W.map(function(ee){return String(ee)});be.unshift("Warning: "+M),Function.prototype.apply.call(console[C],console,be)}}var w=!1,v=!1,b=!1,k=!1,T=!1,R;R=Symbol.for("react.module.reference");function I(C){return!!(typeof C=="string"||typeof C=="function"||C===n||C===r||T||C===i||C===l||C===u||k||C===d||w||v||b||typeof C=="object"&&C!==null&&(C.$$typeof===p||C.$$typeof===h||C.$$typeof===o||C.$$typeof===a||C.$$typeof===c||C.$$typeof===R||C.getModuleId!==void 0))}function A(C,M,W){var Z=C.displayName;if(Z)return Z;var pe=M.displayName||M.name||"";return pe!==""?W+"("+pe+")":W}function D(C){return C.displayName||"Context"}function O(C){if(C==null)return null;if(typeof C.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof C=="function")return C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case n:return"Fragment";case t:return"Portal";case r:return"Profiler";case i:return"StrictMode";case l:return"Suspense";case u:return"SuspenseList"}if(typeof C=="object")switch(C.$$typeof){case a:var M=C;return D(M)+".Consumer";case o:var W=C;return D(W._context)+".Provider";case c:return A(C,C.render,"ForwardRef");case h:var Z=C.displayName||null;return Z!==null?Z:O(C.type)||"Memo";case p:{var pe=C,be=pe._payload,ee=pe._init;try{return O(ee(be))}catch{return null}}}return null}var N=Object.assign,q=0,V,j,X,B,G,H,te;function de(){}de.__reactDisabledLog=!0;function ie(){{if(q===0){V=console.log,j=console.info,X=console.warn,B=console.error,G=console.group,H=console.groupCollapsed,te=console.groupEnd;var C={configurable:!0,enumerable:!0,value:de,writable:!0};Object.defineProperties(console,{info:C,log:C,warn:C,error:C,group:C,groupCollapsed:C,groupEnd:C})}q++}}function Q(){{if(q--,q===0){var C={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},C,{value:V}),info:N({},C,{value:j}),warn:N({},C,{value:X}),error:N({},C,{value:B}),group:N({},C,{value:G}),groupCollapsed:N({},C,{value:H}),groupEnd:N({},C,{value:te})})}q<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _e=g.ReactCurrentDispatcher,Me;function z(C,M,W){{if(Me===void 0)try{throw Error()}catch(pe){var Z=pe.stack.trim().match(/\n( *(at )?)/);Me=Z&&Z[1]||""}return`
210
+ `+Me+C}}var Ke=!1,ut;{var Vt=typeof WeakMap=="function"?WeakMap:Map;ut=new Vt}function U(C,M){if(!C||Ke)return"";{var W=ut.get(C);if(W!==void 0)return W}var Z;Ke=!0;var pe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var be;be=_e.current,_e.current=null,ie();try{if(M){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch(Se){Z=Se}Reflect.construct(C,[],ee)}else{try{ee.call()}catch(Se){Z=Se}C.call(ee.prototype)}}else{try{throw Error()}catch(Se){Z=Se}C()}}catch(Se){if(Se&&Z&&typeof Se.stack=="string"){for(var re=Se.stack.split(`
211
+ `),De=Z.stack.split(`
212
+ `),ke=re.length-1,Oe=De.length-1;ke>=1&&Oe>=0&&re[ke]!==De[Oe];)Oe--;for(;ke>=1&&Oe>=0;ke--,Oe--)if(re[ke]!==De[Oe]){if(ke!==1||Oe!==1)do if(ke--,Oe--,Oe<0||re[ke]!==De[Oe]){var it=`
213
+ `+re[ke].replace(" at new "," at ");return C.displayName&&it.includes("<anonymous>")&&(it=it.replace("<anonymous>",C.displayName)),typeof C=="function"&&ut.set(C,it),it}while(ke>=1&&Oe>=0);break}}}finally{Ke=!1,_e.current=be,Q(),Error.prepareStackTrace=pe}var vs=C?C.displayName||C.name:"",os=vs?z(vs):"";return typeof C=="function"&&ut.set(C,os),os}function ht(C,M,W){return U(C,!1)}function $e(C){var M=C.prototype;return!!(M&&M.isReactComponent)}function L(C,M,W){if(C==null)return"";if(typeof C=="function")return U(C,$e(C));if(typeof C=="string")return z(C);switch(C){case l:return z("Suspense");case u:return z("SuspenseList")}if(typeof C=="object")switch(C.$$typeof){case c:return ht(C.render);case h:return L(C.type,M,W);case p:{var Z=C,pe=Z._payload,be=Z._init;try{return L(be(pe),M,W)}catch{}}}return""}var J=Object.prototype.hasOwnProperty,ve={},ye=g.ReactDebugCurrentFrame;function le(C){if(C){var M=C._owner,W=L(C.type,C._source,M?M.type:null);ye.setExtraStackFrame(W)}else ye.setExtraStackFrame(null)}function we(C,M,W,Z,pe){{var be=Function.call.bind(J);for(var ee in C)if(be(C,ee)){var re=void 0;try{if(typeof C[ee]!="function"){var De=Error((Z||"React class")+": "+W+" type `"+ee+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof C[ee]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw De.name="Invariant Violation",De}re=C[ee](M,ee,Z,W,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ke){re=ke}re&&!(re instanceof Error)&&(le(pe),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Z||"React class",W,ee,typeof re),le(null)),re instanceof Error&&!(re.message in ve)&&(ve[re.message]=!0,le(pe),y("Failed %s type: %s",W,re.message),le(null))}}}var ze=Array.isArray;function tt(C){return ze(C)}function xt(C){{var M=typeof Symbol=="function"&&Symbol.toStringTag,W=M&&C[Symbol.toStringTag]||C.constructor.name||"Object";return W}}function ae(C){try{return me(C),!1}catch{return!0}}function me(C){return""+C}function Ie(C){if(ae(C))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",xt(C)),me(C)}var st=g.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Ge,Ce;function jt(C){if(J.call(C,"ref")){var M=Object.getOwnPropertyDescriptor(C,"ref").get;if(M&&M.isReactWarning)return!1}return C.ref!==void 0}function Lt(C){if(J.call(C,"key")){var M=Object.getOwnPropertyDescriptor(C,"key").get;if(M&&M.isReactWarning)return!1}return C.key!==void 0}function ft(C,M){typeof C.ref=="string"&&st.current}function It(C,M){{var W=function(){Ge||(Ge=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",M))};W.isReactWarning=!0,Object.defineProperty(C,"key",{get:W,configurable:!0})}}function Ct(C,M){{var W=function(){Ce||(Ce=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",M))};W.isReactWarning=!0,Object.defineProperty(C,"ref",{get:W,configurable:!0})}}var nt=function(C,M,W,Z,pe,be,ee){var re={$$typeof:e,type:C,key:M,ref:W,props:ee,_owner:be};return re._store={},Object.defineProperty(re._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(re,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Z}),Object.defineProperty(re,"_source",{configurable:!1,enumerable:!1,writable:!1,value:pe}),Object.freeze&&(Object.freeze(re.props),Object.freeze(re)),re};function Os(C,M,W,Z,pe){{var be,ee={},re=null,De=null;W!==void 0&&(Ie(W),re=""+W),Lt(M)&&(Ie(M.key),re=""+M.key),jt(M)&&(De=M.ref,ft(M,pe));for(be in M)J.call(M,be)&&!Ze.hasOwnProperty(be)&&(ee[be]=M[be]);if(C&&C.defaultProps){var ke=C.defaultProps;for(be in ke)ee[be]===void 0&&(ee[be]=ke[be])}if(re||De){var Oe=typeof C=="function"?C.displayName||C.name||"Unknown":C;re&&It(ee,Oe),De&&Ct(ee,Oe)}return nt(C,re,De,pe,Z,st.current,ee)}}var Mn=g.ReactCurrentOwner,Ti=g.ReactDebugCurrentFrame;function _s(C){if(C){var M=C._owner,W=L(C.type,C._source,M?M.type:null);Ti.setExtraStackFrame(W)}else Ti.setExtraStackFrame(null)}var On;On=!1;function Nn(C){return typeof C=="object"&&C!==null&&C.$$typeof===e}function ki(){{if(Mn.current){var C=O(Mn.current.type);if(C)return`
214
214
 
215
- Check the render method of \``+C+"`."}return""}}function Hr(C){return""}var Ai={};function Yr(C){{var O=ki();if(!O){var P=typeof C=="string"?C:C.displayName||C.name;P&&(O=`
215
+ Check the render method of \``+C+"`."}return""}}function Hr(C){return""}var Ai={};function Yr(C){{var M=ki();if(!M){var W=typeof C=="string"?C:C.displayName||C.name;W&&(M=`
216
216
 
217
- Check the top-level render call using <`+P+">.")}return O}}function Fn(C,O){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var P=Yr(O);if(Ai[P])return;Ai[P]=!0;var te="";C&&C._owner&&C._owner!==Mn.current&&(te=" It was passed a child from "+M(C._owner.type)+"."),vs(C),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,te),vs(null)}}function Ii(C,O){{if(typeof C!="object")return;if(Ze(C))for(var P=0;P<C.length;P++){var te=C[P];Nn(te)&&Fn(te,O)}else if(Nn(C))C._store&&(C._store.validated=!0);else if(C){var J=m(C);if(typeof J=="function"&&J!==C.entries)for(var ve=J.call(C),fe;!(fe=ve.next()).done;)Nn(fe.value)&&Fn(fe.value,O)}}}function Di(C){{var O=C.type;if(O==null||typeof O=="string")return;var P;if(typeof O=="function")P=O.propTypes;else if(typeof O=="object"&&(O.$$typeof===c||O.$$typeof===h))P=O.propTypes;else return;if(P){var te=M(O);Ce(P,C.props,"prop",te,C)}else if(O.PropTypes!==void 0&&!On){On=!0;var J=M(O);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",J||"Unknown")}typeof O.getDefaultProps=="function"&&!O.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ri(C){{for(var O=Object.keys(C.props),P=0;P<O.length;P++){var te=O[P];if(te!=="children"&&te!=="key"){vs(C),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",te),vs(null);break}}C.ref!==null&&(vs(C),y("Invalid attribute `ref` supplied to `React.Fragment`."),vs(null))}}var Vn={};function Pn(C,O,P,te,J,ve){{var fe=I(C);if(!fe){var he="";(C===void 0||typeof C=="object"&&C!==null&&Object.keys(C).length===0)&&(he+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var je=Hr();je?he+=je:he+=ki();var Ve;C===null?Ve="null":Ze(C)?Ve="array":C!==void 0&&C.$$typeof===e?(Ve="<"+(M(C.type)||"Unknown")+" />",he=" Did you accidentally export a JSX literal instead of a component?"):Ve=typeof C,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ve,he)}var Pe=En(C,O,P,J,ve);if(Pe==null)return Pe;if(fe){var Ie=O.children;if(Ie!==void 0)if(te)if(Ze(Ie)){for(var Qt=0;Qt<Ie.length;Qt++)Ii(Ie[Qt],C);Object.freeze&&Object.freeze(Ie)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ii(Ie,C)}if(H.call(O,"key")){var Os=M(C),Ct=Object.keys(O).filter(function(Xu){return Xu!=="key"}),Qr=Ct.length>0?"{key: someKey, "+Ct.join(": ..., ")+": ...}":"{key: someKey}";if(!Vn[Os+Qr]){var Gu=Ct.length>0?"{"+Ct.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
217
+ Check the top-level render call using <`+W+">.")}return M}}function Ii(C,M){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var W=Yr(M);if(Ai[W])return;Ai[W]=!0;var Z="";C&&C._owner&&C._owner!==Mn.current&&(Z=" It was passed a child from "+O(C._owner.type)+"."),_s(C),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',W,Z),_s(null)}}function Fn(C,M){{if(typeof C!="object")return;if(tt(C))for(var W=0;W<C.length;W++){var Z=C[W];Nn(Z)&&Ii(Z,M)}else if(Nn(C))C._store&&(C._store.validated=!0);else if(C){var pe=m(C);if(typeof pe=="function"&&pe!==C.entries)for(var be=pe.call(C),ee;!(ee=be.next()).done;)Nn(ee.value)&&Ii(ee.value,M)}}}function Ur(C){{var M=C.type;if(M==null||typeof M=="string")return;var W;if(typeof M=="function")W=M.propTypes;else if(typeof M=="object"&&(M.$$typeof===c||M.$$typeof===h))W=M.propTypes;else return;if(W){var Z=O(M);we(W,C.props,"prop",Z,C)}else if(M.PropTypes!==void 0&&!On){On=!0;var pe=O(M);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",pe||"Unknown")}typeof M.getDefaultProps=="function"&&!M.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Di(C){{for(var M=Object.keys(C.props),W=0;W<M.length;W++){var Z=M[W];if(Z!=="children"&&Z!=="key"){_s(C),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Z),_s(null);break}}C.ref!==null&&(_s(C),y("Invalid attribute `ref` supplied to `React.Fragment`."),_s(null))}}var Vn={};function Pn(C,M,W,Z,pe,be){{var ee=I(C);if(!ee){var re="";(C===void 0||typeof C=="object"&&C!==null&&Object.keys(C).length===0)&&(re+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var De=Hr();De?re+=De:re+=ki();var ke;C===null?ke="null":tt(C)?ke="array":C!==void 0&&C.$$typeof===e?(ke="<"+(O(C.type)||"Unknown")+" />",re=" Did you accidentally export a JSX literal instead of a component?"):ke=typeof C,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ke,re)}var Oe=Os(C,M,W,pe,be);if(Oe==null)return Oe;if(ee){var it=M.children;if(it!==void 0)if(Z)if(tt(it)){for(var vs=0;vs<it.length;vs++)Fn(it[vs],C);Object.freeze&&Object.freeze(it)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Fn(it,C)}if(J.call(M,"key")){var os=O(C),Se=Object.keys(M).filter(function(Xu){return Xu!=="key"}),Ns=Se.length>0?"{key: someKey, "+Se.join(": ..., ")+": ...}":"{key: someKey}";if(!Vn[os+Ns]){var Gu=Se.length>0?"{"+Se.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
218
218
  let props = %s;
219
219
  <%s {...props} />
220
220
  React keys must be passed directly to JSX without using spread:
221
221
  let props = %s;
222
- <%s key={someKey} {...props} />`,Qr,Os,Gu,Os),Vn[Os+Qr]=!0}}return C===n?Ri(Pe):Di(Pe),Pe}}function Ur(C,O,P){return Pn(C,O,P,!0)}function Kr(C,O,P){return Pn(C,O,P,!1)}var se=Kr,ue=Ur;$n.Fragment=n,$n.jsx=se,$n.jsxs=ue})()),$n}var bc;function I_(){return bc||(bc=1,process.env.NODE_ENV==="production"?Ni.exports=k_():Ni.exports=A_()),Ni.exports}var E=I_();function wc(s,e){const t=new Float32Array(s),n=s-1;for(let i=0;i<s;i++){const r=i/n;t[i]=e?r:1-r}return t}function D_(s,e){const t=new Float32Array(s),n=s-1;for(let i=0;i<s;i++){const r=i/n,o=e?i:s-1-i;t[o]=Math.exp(2*r-1)/Math.E}return t}function R_(s,e){const t=new Float32Array(s),n=e?Math.PI/2:-Math.PI/2;for(let i=0;i<s;i++)t[i]=Math.sin(Math.PI*i/s-n)/2+.5;return t}function E_(s,e,t=10){const n=new Float32Array(s);for(let i=0;i<s;i++){const r=e?i:s-1-i,o=i/s;n[r]=Math.log(1+t*o)/Math.log(1+t)}return n}function fu(s,e,t){switch(s){case"linear":return wc(e,t);case"exponential":return D_(e,t);case"sCurve":return R_(e,t);case"logarithmic":return E_(e,t);default:return wc(e,t)}}function xc(s,e,t,n="linear",i=0,r=1){if(!(t<=0))if(n==="linear")s.setValueAtTime(i,e),s.linearRampToValueAtTime(r,e+t);else if(n==="exponential")s.setValueAtTime(Math.max(i,.001),e),s.exponentialRampToValueAtTime(Math.max(r,.001),e+t);else{const o=fu(n,1e4,!0),a=new Float32Array(o.length),c=r-i;for(let l=0;l<o.length;l++)a[l]=i+o[l]*c;s.setValueCurveAtTime(a,e,t)}}function Cc(s,e,t,n="linear",i=1,r=0){if(!(t<=0))if(n==="linear")s.setValueAtTime(i,e),s.linearRampToValueAtTime(r,e+t);else if(n==="exponential")s.setValueAtTime(Math.max(i,.001),e),s.exponentialRampToValueAtTime(Math.max(r,.001),e+t);else{const o=fu(n,1e4,!1),a=new Float32Array(o.length),c=i-r;for(let l=0;l<o.length;l++)a[l]=r+o[l]*c;s.setValueCurveAtTime(a,e,t)}}var M_=class{constructor(s){this.activePlayers=0,this.track=s.track,this.volumeNode=new Ut(this.gainToDb(s.track.gain)),this.panNode=new Dn(s.track.stereoPan),this.muteGain=new Y(s.track.muted?0:1);const e=s.destination||Na();if(s.effects){const n=s.effects(this.muteGain,e,!1);n&&(this.effectsCleanup=n)}else this.muteGain.connect(e);const t=s.clips||(s.buffer?[{buffer:s.buffer,startTime:0,duration:s.buffer.duration,offset:0,fadeIn:s.track.fadeIn,fadeOut:s.track.fadeOut,gain:1}]:[]);this.clips=t.map(n=>{const i=new Zs({url:n.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),r=new Y(n.gain);return i.connect(r),r.chain(this.volumeNode,this.panNode,this.muteGain),{player:i,clipInfo:n,fadeGain:r,pausedPosition:0,playStartTime:0}})}scheduleFades(s,e,t=0){const{clipInfo:n,fadeGain:i}=s,r=i.gain._param;r.cancelScheduledValues(0);const o=t-n.offset;if(n.fadeIn&&o<n.fadeIn.duration){const a=n.fadeIn.duration;if(o<=0)xc(r,e,a,n.fadeIn.type||"linear",0,n.gain);else{const c=a-o,l=o/a,u=n.gain*l;xc(r,e,c,n.fadeIn.type||"linear",u,n.gain)}}else r.setValueAtTime(n.gain,e);if(n.fadeOut){const c=n.duration-n.fadeOut.duration-o;if(c>0){const l=e+c;Cc(r,l,n.fadeOut.duration,n.fadeOut.type||"linear",n.gain,0)}else if(c>-n.fadeOut.duration){const l=-c,u=n.fadeOut.duration-l,h=l/n.fadeOut.duration,p=n.gain*(1-h);Cc(r,e,u,n.fadeOut.type||"linear",p,0)}}}gainToDb(s){return 20*Math.log10(s)}setVolume(s){this.track.gain=s,this.volumeNode.volume.value=this.gainToDb(s)}setPan(s){this.track.stereoPan=s,this.panNode.pan.value=s}setMute(s){this.track.muted=s,this.muteGain.gain.value=s?0:1}setSolo(s){this.track.soloed=s}play(s,e=0,t){const n=s??en();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(i=>{const{player:r,clipInfo:o}=i,a=e,c=o.startTime,l=o.startTime+o.duration;if(a<l)if(this.activePlayers++,i.playStartTime=en(),a>=c){const u=a-c+o.offset,h=o.duration-(a-c),p=t?Math.min(t,h):h;i.pausedPosition=u,this.scheduleFades(i,n,u),r.start(n,u,p)}else{const u=c-a,h=t?Math.min(t-u,o.duration):o.duration;u<(t??1/0)?(i.pausedPosition=o.offset,this.scheduleFades(i,n+u,o.offset),r.start(n+u,o.offset,h)):this.activePlayers--}})}pause(){this.clips.forEach(s=>{if(s.player.state==="started"){const e=(en()-s.playStartTime)*s.player.playbackRate;s.pausedPosition=s.pausedPosition+e}s.player.stop()}),this.activePlayers=0}stop(s){const e=s??en();this.clips.forEach(t=>{t.player.stop(e),t.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(s=>{s.player.dispose(),s.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const s=this.clips[this.clips.length-1];return s.clipInfo.startTime+s.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(s=>s.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(s){this.onStopCallback=s}},O_=class{constructor(s={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new Ut(this.gainToDb(s.masterGain??1)),s.effects){const e=s.effects(this.masterVolume,Na(),!1);e&&(this.effectsCleanup=e)}else this.masterVolume.toDestination();s.tracks&&s.tracks.forEach(e=>{this.tracks.set(e.id,e),this.manualMuteState.set(e.id,e.muted)})}gainToDb(s){return 20*Math.log10(s)}async init(){this.isInitialized||(await ta(),this.isInitialized=!0)}addTrack(s){const e={...s,destination:this.masterVolume},t=new M_(e);return this.tracks.set(t.id,t),this.manualMuteState.set(t.id,s.track.muted??!1),t}removeTrack(s){const e=this.tracks.get(s);e&&(e.dispose(),this.tracks.delete(s),this.manualMuteState.delete(s),this.soloedTracks.delete(s))}getTrack(s){return this.tracks.get(s)}play(s,e,t){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const n=s??en(),i=e??0;this.playbackSessionId++;const r=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const a=o.startTime;if(i>=a){const c=i-a;t!==void 0&&(this.activeTracks.set(o.id,r),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===r&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(n,c,t)}else{const c=a-i;t!==void 0&&(this.activeTracks.set(o.id,r),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===r&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(n+c,0,t)}}),e!==void 0?Ns().start(n,e):Ns().start(n)}pause(){Ns().pause(),this.tracks.forEach(s=>{s.pause()})}stop(){Ns().stop(),this.tracks.forEach(s=>{s.stop()})}setMasterGain(s){this.masterVolume.volume.value=this.gainToDb(s)}setSolo(s,e){const t=this.tracks.get(s);t&&(t.setSolo(e),e?this.soloedTracks.add(s):this.soloedTracks.delete(s),this.updateSoloMuting())}updateSoloMuting(){const s=this.soloedTracks.size>0;this.tracks.forEach((e,t)=>{if(s)if(!this.soloedTracks.has(t))e.setMute(!0);else{const n=this.manualMuteState.get(t)??!1;e.setMute(n)}else{const n=this.manualMuteState.get(t)??!1;e.setMute(n)}})}setMute(s,e){const t=this.tracks.get(s);t&&(this.manualMuteState.set(s,e),t.setMute(e))}getCurrentTime(){return Ns().seconds}seekTo(s){Ns().seconds=s}dispose(){this.tracks.forEach(s=>{s.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return me()}get sampleRate(){return me().sampleRate}setOnPlaybackComplete(s){this.onPlaybackCompleteCallback=s}},Fi=null;function N_(){return Fi||(Fi=new js,Hn(Fi)),Fi}async function so(){const s=N_();s.state!=="running"&&await s.resume()}const F_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fa(s){const e=Object.prototype.toString.call(s);return e==="[object Window]"||e==="[object global]"}function mu(s){return"nodeType"in s}function Rn(s){var e,t;return s?Fa(s)?s:mu(s)&&(e=(t=s.ownerDocument)==null?void 0:t.defaultView)!=null?e:window:window}function V_(s){const{Document:e}=Rn(s);return s instanceof e}function P_(s){return Fa(s)?!1:s instanceof Rn(s).HTMLElement}function W_(s){return s instanceof Rn(s).SVGElement}function qr(s){return s?Fa(s)?s.document:mu(s)?V_(s)?s:P_(s)||W_(s)?s.ownerDocument:document:document:document}const jr=F_?S.useLayoutEffect:S.useEffect;function B_(s){const e=S.useRef(s);return jr(()=>{e.current=s}),S.useCallback(function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}function gu(s,e){e===void 0&&(e=[s]);const t=S.useRef(s);return jr(()=>{t.current!==s&&(t.current=s)},e),t}function er(s){const e=B_(s),t=S.useRef(null),n=S.useCallback(i=>{i!==t.current&&e?.(i,t.current),t.current=i},[]);return[t,n]}let no={};function _u(s,e){return S.useMemo(()=>{const t=no[s]==null?0:no[s]+1;return no[s]=t,s+"-"+t},[s,e])}function $_(s){return function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return n.reduce((r,o)=>{const a=Object.entries(o);for(const[c,l]of a){const u=r[c];u!=null&&(r[c]=u+s*l)}return r},{...e})}}const q_=$_(-1);function j_(s){return"clientX"in s&&"clientY"in s}function L_(s){if(!s)return!1;const{TouchEvent:e}=Rn(s.target);return e&&s instanceof e}function Sc(s){if(L_(s)){if(s.touches&&s.touches.length){const{clientX:e,clientY:t}=s.touches[0];return{x:e,y:t}}else if(s.changedTouches&&s.changedTouches.length){const{clientX:e,clientY:t}=s.changedTouches[0];return{x:e,y:t}}}return j_(s)?{x:s.clientX,y:s.clientY}:null}const Co=Object.freeze({Translate:{toString(s){if(!s)return;const{x:e,y:t}=s;return"translate3d("+(e?Math.round(e):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(s){if(!s)return;const{scaleX:e,scaleY:t}=s;return"scaleX("+e+") scaleY("+t+")"}},Transform:{toString(s){if(s)return[Co.Translate.toString(s),Co.Scale.toString(s)].join(" ")}},Transition:{toString(s){let{property:e,duration:t,easing:n}=s;return e+" "+t+"ms "+n}}});var Tc;(function(s){s.DragStart="dragStart",s.DragMove="dragMove",s.DragEnd="dragEnd",s.DragCancel="dragCancel",s.DragOver="dragOver",s.RegisterDroppable="registerDroppable",s.SetDroppableDisabled="setDroppableDisabled",s.UnregisterDroppable="unregisterDroppable"})(Tc||(Tc={}));function kc(){}function z_(s,e){return S.useMemo(()=>({sensor:s,options:e??{}}),[s,e])}function Z_(){for(var s=arguments.length,e=new Array(s),t=0;t<s;t++)e[t]=arguments[t];return S.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const So=Object.freeze({x:0,y:0});var tn;(function(s){s[s.Forward=1]="Forward",s[s.Backward=-1]="Backward"})(tn||(tn={}));class io{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(t=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...t)})},this.target=e}add(e,t,n){var i;(i=this.target)==null||i.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function G_(s){const{EventTarget:e}=Rn(s);return s instanceof e?s:qr(s)}function ro(s,e){const t=Math.abs(s.x),n=Math.abs(s.y);return typeof e=="number"?Math.sqrt(t**2+n**2)>e:"x"in e&&"y"in e?t>e.x&&n>e.y:"x"in e?t>e.x:"y"in e?n>e.y:!1}var us;(function(s){s.Click="click",s.DragStart="dragstart",s.Keydown="keydown",s.ContextMenu="contextmenu",s.Resize="resize",s.SelectionChange="selectionchange",s.VisibilityChange="visibilitychange"})(us||(us={}));function Ac(s){s.preventDefault()}function X_(s){s.stopPropagation()}var hs;(function(s){s.Space="Space",s.Down="ArrowDown",s.Right="ArrowRight",s.Left="ArrowLeft",s.Up="ArrowUp",s.Esc="Escape",s.Enter="Enter",s.Tab="Tab"})(hs||(hs={}));hs.Space,hs.Enter,hs.Esc,hs.Space,hs.Enter,hs.Tab;function Ic(s){return!!(s&&"distance"in s)}function Dc(s){return!!(s&&"delay"in s)}class Va{constructor(e,t,n){var i;n===void 0&&(n=G_(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:o}=r;this.props=e,this.events=t,this.document=qr(o),this.documentListeners=new io(this.document),this.listeners=new io(n),this.windowListeners=new io(Rn(o)),this.initialCoordinates=(i=Sc(r))!=null?i:So,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(us.Resize,this.handleCancel),this.windowListeners.add(us.DragStart,Ac),this.windowListeners.add(us.VisibilityChange,this.handleCancel),this.windowListeners.add(us.ContextMenu,Ac),this.documentListeners.add(us.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Dc(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Ic(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:i}=this.props;i(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(us.Click,X_,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(us.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:i,props:r}=this,{onMove:o,options:{activationConstraint:a}}=r;if(!i)return;const c=(t=Sc(e))!=null?t:So,l=q_(i,c);if(!n&&a){if(Ic(a)){if(a.tolerance!=null&&ro(l,a.tolerance))return this.handleCancel();if(ro(l,a.distance))return this.handleStart()}if(Dc(a)&&ro(l,a.tolerance))return this.handleCancel();this.handlePending(a,l);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===hs.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const H_={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class vu extends Va{constructor(e){const{event:t}=e,n=qr(t.target);super(e,H_,n)}}vu.activators=[{eventName:"onPointerDown",handler:(s,e)=>{let{nativeEvent:t}=s,{onActivation:n}=e;return!t.isPrimary||t.button!==0?!1:(n?.({event:t}),!0)}}];const Y_={move:{name:"mousemove"},end:{name:"mouseup"}};var To;(function(s){s[s.RightClick=2]="RightClick"})(To||(To={}));class U_ extends Va{constructor(e){super(e,Y_,qr(e.event.target))}}U_.activators=[{eventName:"onMouseDown",handler:(s,e)=>{let{nativeEvent:t}=s,{onActivation:n}=e;return t.button===To.RightClick?!1:(n?.({event:t}),!0)}}];const oo={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class K_ extends Va{constructor(e){super(e,oo)}static setup(){return window.addEventListener(oo.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(oo.move.name,e)};function e(){}}}K_.activators=[{eventName:"onTouchStart",handler:(s,e)=>{let{nativeEvent:t}=s,{onActivation:n}=e;const{touches:i}=t;return i.length>1?!1:(n?.({event:t}),!0)}}];var Rc;(function(s){s[s.Pointer=0]="Pointer",s[s.DraggableRect=1]="DraggableRect"})(Rc||(Rc={}));var Ec;(function(s){s[s.TreeOrder=0]="TreeOrder",s[s.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ec||(Ec={}));tn.Backward+"",tn.Forward+"",tn.Backward+"",tn.Forward+"";var ko;(function(s){s[s.Always=0]="Always",s[s.BeforeDragging=1]="BeforeDragging",s[s.WhileDragging=2]="WhileDragging"})(ko||(ko={}));var Ao;(function(s){s.Optimized="optimized"})(Ao||(Ao={}));function Q_(s,e){return S.useMemo(()=>s.reduce((t,n)=>{let{eventName:i,handler:r}=n;return t[i]=o=>{r(o,e)},t},{}),[s,e])}ko.WhileDragging,Ao.Optimized;const J_={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kc,draggableNodes:new Map,over:null,measureDroppableContainers:kc},e0=S.createContext(J_),t0=S.createContext({...So,scaleX:1,scaleY:1});var Mc;(function(s){s[s.Uninitialized=0]="Uninitialized",s[s.Initializing=1]="Initializing",s[s.Initialized=2]="Initialized"})(Mc||(Mc={}));const s0=S.createContext(null),Oc="button",n0="Draggable";function ao(s){let{id:e,data:t,disabled:n=!1,attributes:i}=s;const r=_u(n0),{activators:o,activatorEvent:a,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:h,over:p}=S.useContext(e0),{role:d=Oc,roleDescription:f="draggable",tabIndex:_=0}=i??{},m=c?.id===e,g=S.useContext(m?t0:s0),[y,x]=er(),[w,v]=er(),b=Q_(o,e),k=gu(t);jr(()=>(h.set(e,{id:e,key:r,node:y,activatorNode:w,data:k}),()=>{const R=h.get(e);R&&R.key===r&&h.delete(e)}),[h,e]);const T=S.useMemo(()=>({role:d,tabIndex:_,"aria-disabled":n,"aria-pressed":m&&d===Oc?!0:void 0,"aria-roledescription":f,"aria-describedby":u.draggable}),[n,d,_,m,f,u.draggable]);return{active:c,activatorEvent:a,activeNodeRect:l,attributes:T,isDragging:m,listeners:n?void 0:b,node:y,over:p,setNodeRef:x,setActivatorNodeRef:v,transform:g}}const i0=new Map([["bold",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),le.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",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.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"}))]]),r0=new Map([["bold",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),le.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",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.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",le.createElement(le.Fragment,null,le.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"}))]]),o0=S.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Pa=le.forwardRef((s,e)=>{const{alt:t,color:n,size:i,weight:r,mirrored:o,children:a,weights:c,...l}=s,{color:u="currentColor",size:h,weight:p="regular",mirrored:d=!1,...f}=le.useContext(o0);return le.createElement("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:i??h,height:i??h,fill:n??u,viewBox:"0 0 256 256",transform:o||d?"scale(-1, 1)":void 0,...f,...l},!!t&&le.createElement("title",null,t),a,c.get(r??p))});Pa.displayName="IconBase";const yu=le.forwardRef((s,e)=>le.createElement(Pa,{ref:e,...s,weights:i0}));yu.displayName="SpeakerHighIcon";const bu=le.forwardRef((s,e)=>le.createElement(Pa,{ref:e,...s,weights:r0}));bu.displayName="SpeakerLowIcon";W.span`
222
+ <%s key={someKey} {...props} />`,Ns,os,Gu,os),Vn[os+Ns]=!0}}return C===n?Di(Oe):Ur(Oe),Oe}}function Ri(C,M,W){return Pn(C,M,W,!0)}function Kr(C,M,W){return Pn(C,M,W,!1)}var Qr=Kr,se=Ri;$n.Fragment=n,$n.jsx=Qr,$n.jsxs=se})()),$n}var bc;function I_(){return bc||(bc=1,process.env.NODE_ENV==="production"?Ni.exports=k_():Ni.exports=A_()),Ni.exports}var E=I_();function wc(s,e){const t=new Float32Array(s),n=s-1;for(let i=0;i<s;i++){const r=i/n;t[i]=e?r:1-r}return t}function D_(s,e){const t=new Float32Array(s),n=s-1;for(let i=0;i<s;i++){const r=i/n,o=e?i:s-1-i;t[o]=Math.exp(2*r-1)/Math.E}return t}function R_(s,e){const t=new Float32Array(s),n=e?Math.PI/2:-Math.PI/2;for(let i=0;i<s;i++)t[i]=Math.sin(Math.PI*i/s-n)/2+.5;return t}function E_(s,e,t=10){const n=new Float32Array(s);for(let i=0;i<s;i++){const r=e?i:s-1-i,o=i/s;n[r]=Math.log(1+t*o)/Math.log(1+t)}return n}function fu(s,e,t){switch(s){case"linear":return wc(e,t);case"exponential":return D_(e,t);case"sCurve":return R_(e,t);case"logarithmic":return E_(e,t);default:return wc(e,t)}}function xc(s,e,t,n="linear",i=0,r=1){if(!(t<=0))if(n==="linear")s.setValueAtTime(i,e),s.linearRampToValueAtTime(r,e+t);else if(n==="exponential")s.setValueAtTime(Math.max(i,.001),e),s.exponentialRampToValueAtTime(Math.max(r,.001),e+t);else{const o=fu(n,1e4,!0),a=new Float32Array(o.length),c=r-i;for(let l=0;l<o.length;l++)a[l]=i+o[l]*c;s.setValueCurveAtTime(a,e,t)}}function Cc(s,e,t,n="linear",i=1,r=0){if(!(t<=0))if(n==="linear")s.setValueAtTime(i,e),s.linearRampToValueAtTime(r,e+t);else if(n==="exponential")s.setValueAtTime(Math.max(i,.001),e),s.exponentialRampToValueAtTime(Math.max(r,.001),e+t);else{const o=fu(n,1e4,!1),a=new Float32Array(o.length),c=i-r;for(let l=0;l<o.length;l++)a[l]=r+o[l]*c;s.setValueCurveAtTime(a,e,t)}}var M_=class{constructor(s){this.activePlayers=0,this.track=s.track,this.volumeNode=new Ut(this.gainToDb(s.track.gain)),this.panNode=new Rn(s.track.stereoPan),this.muteGain=new Y(s.track.muted?0:1);const e=s.destination||Na();if(s.effects){const n=s.effects(this.muteGain,e,!1);n&&(this.effectsCleanup=n)}else this.muteGain.connect(e);const t=s.clips||(s.buffer?[{buffer:s.buffer,startTime:0,duration:s.buffer.duration,offset:0,fadeIn:s.track.fadeIn,fadeOut:s.track.fadeOut,gain:1}]:[]);this.clips=t.map(n=>{const i=new Gs({url:n.buffer,loop:!1,onstop:()=>{this.activePlayers--,this.activePlayers===0&&this.onStopCallback&&this.onStopCallback()}}),r=new Y(n.gain);return i.connect(r),r.chain(this.volumeNode,this.panNode,this.muteGain),{player:i,clipInfo:n,fadeGain:r,pausedPosition:0,playStartTime:0}})}scheduleFades(s,e,t=0){const{clipInfo:n,fadeGain:i}=s,r=i.gain._param;r.cancelScheduledValues(0);const o=t-n.offset;if(n.fadeIn&&o<n.fadeIn.duration){const a=n.fadeIn.duration;if(o<=0)xc(r,e,a,n.fadeIn.type||"linear",0,n.gain);else{const c=a-o,l=o/a,u=n.gain*l;xc(r,e,c,n.fadeIn.type||"linear",u,n.gain)}}else r.setValueAtTime(n.gain,e);if(n.fadeOut){const c=n.duration-n.fadeOut.duration-o;if(c>0){const l=e+c;Cc(r,l,n.fadeOut.duration,n.fadeOut.type||"linear",n.gain,0)}else if(c>-n.fadeOut.duration){const l=-c,u=n.fadeOut.duration-l,h=l/n.fadeOut.duration,p=n.gain*(1-h);Cc(r,e,u,n.fadeOut.type||"linear",p,0)}}}gainToDb(s){return 20*Math.log10(s)}setVolume(s){this.track.gain=s,this.volumeNode.volume.value=this.gainToDb(s)}setPan(s){this.track.stereoPan=s,this.panNode.pan.value=s}setMute(s){this.track.muted=s,this.muteGain.gain.value=s?0:1}setSolo(s){this.track.soloed=s}play(s,e=0,t){const n=s??tn();this.isPlaying&&this.stop(),this.activePlayers=0,this.clips.forEach(i=>{const{player:r,clipInfo:o}=i,a=e,c=o.startTime,l=o.startTime+o.duration;if(a<l)if(this.activePlayers++,i.playStartTime=tn(),a>=c){const u=a-c+o.offset,h=o.duration-(a-c),p=t?Math.min(t,h):h;i.pausedPosition=u,this.scheduleFades(i,n,u),r.start(n,u,p)}else{const u=c-a,h=t?Math.min(t-u,o.duration):o.duration;u<(t??1/0)?(i.pausedPosition=o.offset,this.scheduleFades(i,n+u,o.offset),r.start(n+u,o.offset,h)):this.activePlayers--}})}pause(){this.clips.forEach(s=>{if(s.player.state==="started"){const e=(tn()-s.playStartTime)*s.player.playbackRate;s.pausedPosition=s.pausedPosition+e}s.player.stop()}),this.activePlayers=0}stop(s){const e=s??tn();this.clips.forEach(t=>{t.player.stop(e),t.pausedPosition=0}),this.activePlayers=0}dispose(){this.effectsCleanup&&this.effectsCleanup(),this.clips.forEach(s=>{s.player.dispose(),s.fadeGain.dispose()}),this.volumeNode.dispose(),this.panNode.dispose(),this.muteGain.dispose()}get id(){return this.track.id}get duration(){if(this.clips.length===0)return 0;const s=this.clips[this.clips.length-1];return s.clipInfo.startTime+s.clipInfo.duration}get buffer(){return this.clips[0]?.clipInfo.buffer}get isPlaying(){return this.clips.some(s=>s.player.state==="started")}get muted(){return this.track.muted}get startTime(){return this.track.startTime}setOnStopCallback(s){this.onStopCallback=s}},O_=class{constructor(s={}){if(this.tracks=new Map,this.isInitialized=!1,this.soloedTracks=new Set,this.manualMuteState=new Map,this.activeTracks=new Map,this.playbackSessionId=0,this.masterVolume=new Ut(this.gainToDb(s.masterGain??1)),s.effects){const e=s.effects(this.masterVolume,Na(),!1);e&&(this.effectsCleanup=e)}else this.masterVolume.toDestination();s.tracks&&s.tracks.forEach(e=>{this.tracks.set(e.id,e),this.manualMuteState.set(e.id,e.muted)})}gainToDb(s){return 20*Math.log10(s)}async init(){this.isInitialized||(await ta(),this.isInitialized=!0)}addTrack(s){const e={...s,destination:this.masterVolume},t=new M_(e);return this.tracks.set(t.id,t),this.manualMuteState.set(t.id,s.track.muted??!1),s.track.soloed&&this.soloedTracks.add(t.id),t}applyInitialSoloState(){this.updateSoloMuting()}removeTrack(s){const e=this.tracks.get(s);e&&(e.dispose(),this.tracks.delete(s),this.manualMuteState.delete(s),this.soloedTracks.delete(s))}getTrack(s){return this.tracks.get(s)}play(s,e,t){if(!this.isInitialized){console.warn("TonePlayout not initialized. Call init() first.");return}const n=s??tn(),i=e??0;this.playbackSessionId++;const r=this.playbackSessionId;this.activeTracks.clear(),this.tracks.forEach(o=>{const a=o.startTime;if(i>=a){const c=i-a;t!==void 0&&(this.activeTracks.set(o.id,r),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===r&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(n,c,t)}else{const c=a-i;t!==void 0&&(this.activeTracks.set(o.id,r),o.setOnStopCallback(()=>{this.activeTracks.get(o.id)===r&&(this.activeTracks.delete(o.id),this.activeTracks.size===0&&this.onPlaybackCompleteCallback&&this.onPlaybackCompleteCallback())})),o.play(n+c,0,t)}}),e!==void 0?Fs().start(n,e):Fs().start(n)}pause(){Fs().pause(),this.tracks.forEach(s=>{s.pause()})}stop(){Fs().stop(),this.tracks.forEach(s=>{s.stop()})}setMasterGain(s){this.masterVolume.volume.value=this.gainToDb(s)}setSolo(s,e){const t=this.tracks.get(s);t&&(t.setSolo(e),e?this.soloedTracks.add(s):this.soloedTracks.delete(s),this.updateSoloMuting())}updateSoloMuting(){const s=this.soloedTracks.size>0;this.tracks.forEach((e,t)=>{if(s)if(!this.soloedTracks.has(t))e.setMute(!0);else{const n=this.manualMuteState.get(t)??!1;e.setMute(n)}else{const n=this.manualMuteState.get(t)??!1;e.setMute(n)}})}setMute(s,e){const t=this.tracks.get(s);t&&(this.manualMuteState.set(s,e),t.setMute(e))}getCurrentTime(){return Fs().seconds}seekTo(s){Fs().seconds=s}dispose(){this.tracks.forEach(s=>{s.dispose()}),this.tracks.clear(),this.effectsCleanup&&this.effectsCleanup(),this.masterVolume.dispose()}get context(){return fe()}get sampleRate(){return fe().sampleRate}setOnPlaybackComplete(s){this.onPlaybackCompleteCallback=s}},Fi=null;function N_(){return Fi||(Fi=new Ls,Hn(Fi)),Fi}async function so(){const s=N_();s.state!=="running"&&await s.resume()}const F_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fa(s){const e=Object.prototype.toString.call(s);return e==="[object Window]"||e==="[object global]"}function mu(s){return"nodeType"in s}function En(s){var e,t;return s?Fa(s)?s:mu(s)&&(e=(t=s.ownerDocument)==null?void 0:t.defaultView)!=null?e:window:window}function V_(s){const{Document:e}=En(s);return s instanceof e}function P_(s){return Fa(s)?!1:s instanceof En(s).HTMLElement}function W_(s){return s instanceof En(s).SVGElement}function qr(s){return s?Fa(s)?s.document:mu(s)?V_(s)?s:P_(s)||W_(s)?s.ownerDocument:document:document:document}const jr=F_?S.useLayoutEffect:S.useEffect;function B_(s){const e=S.useRef(s);return jr(()=>{e.current=s}),S.useCallback(function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return e.current==null?void 0:e.current(...n)},[])}function gu(s,e){e===void 0&&(e=[s]);const t=S.useRef(s);return jr(()=>{t.current!==s&&(t.current=s)},e),t}function er(s){const e=B_(s),t=S.useRef(null),n=S.useCallback(i=>{i!==t.current&&e?.(i,t.current),t.current=i},[]);return[t,n]}let no={};function _u(s,e){return S.useMemo(()=>{const t=no[s]==null?0:no[s]+1;return no[s]=t,s+"-"+t},[s,e])}function $_(s){return function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return n.reduce((r,o)=>{const a=Object.entries(o);for(const[c,l]of a){const u=r[c];u!=null&&(r[c]=u+s*l)}return r},{...e})}}const q_=$_(-1);function j_(s){return"clientX"in s&&"clientY"in s}function L_(s){if(!s)return!1;const{TouchEvent:e}=En(s.target);return e&&s instanceof e}function Sc(s){if(L_(s)){if(s.touches&&s.touches.length){const{clientX:e,clientY:t}=s.touches[0];return{x:e,y:t}}else if(s.changedTouches&&s.changedTouches.length){const{clientX:e,clientY:t}=s.changedTouches[0];return{x:e,y:t}}}return j_(s)?{x:s.clientX,y:s.clientY}:null}const Co=Object.freeze({Translate:{toString(s){if(!s)return;const{x:e,y:t}=s;return"translate3d("+(e?Math.round(e):0)+"px, "+(t?Math.round(t):0)+"px, 0)"}},Scale:{toString(s){if(!s)return;const{scaleX:e,scaleY:t}=s;return"scaleX("+e+") scaleY("+t+")"}},Transform:{toString(s){if(s)return[Co.Translate.toString(s),Co.Scale.toString(s)].join(" ")}},Transition:{toString(s){let{property:e,duration:t,easing:n}=s;return e+" "+t+"ms "+n}}});var Tc;(function(s){s.DragStart="dragStart",s.DragMove="dragMove",s.DragEnd="dragEnd",s.DragCancel="dragCancel",s.DragOver="dragOver",s.RegisterDroppable="registerDroppable",s.SetDroppableDisabled="setDroppableDisabled",s.UnregisterDroppable="unregisterDroppable"})(Tc||(Tc={}));function kc(){}function z_(s,e){return S.useMemo(()=>({sensor:s,options:e??{}}),[s,e])}function Z_(){for(var s=arguments.length,e=new Array(s),t=0;t<s;t++)e[t]=arguments[t];return S.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const So=Object.freeze({x:0,y:0});var sn;(function(s){s[s.Forward=1]="Forward",s[s.Backward=-1]="Backward"})(sn||(sn={}));class io{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(t=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...t)})},this.target=e}add(e,t,n){var i;(i=this.target)==null||i.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function G_(s){const{EventTarget:e}=En(s);return s instanceof e?s:qr(s)}function ro(s,e){const t=Math.abs(s.x),n=Math.abs(s.y);return typeof e=="number"?Math.sqrt(t**2+n**2)>e:"x"in e&&"y"in e?t>e.x&&n>e.y:"x"in e?t>e.x:"y"in e?n>e.y:!1}var ls;(function(s){s.Click="click",s.DragStart="dragstart",s.Keydown="keydown",s.ContextMenu="contextmenu",s.Resize="resize",s.SelectionChange="selectionchange",s.VisibilityChange="visibilitychange"})(ls||(ls={}));function Ac(s){s.preventDefault()}function X_(s){s.stopPropagation()}var us;(function(s){s.Space="Space",s.Down="ArrowDown",s.Right="ArrowRight",s.Left="ArrowLeft",s.Up="ArrowUp",s.Esc="Escape",s.Enter="Enter",s.Tab="Tab"})(us||(us={}));us.Space,us.Enter,us.Esc,us.Space,us.Enter,us.Tab;function Ic(s){return!!(s&&"distance"in s)}function Dc(s){return!!(s&&"delay"in s)}class Va{constructor(e,t,n){var i;n===void 0&&(n=G_(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:o}=r;this.props=e,this.events=t,this.document=qr(o),this.documentListeners=new io(this.document),this.listeners=new io(n),this.windowListeners=new io(En(o)),this.initialCoordinates=(i=Sc(r))!=null?i:So,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ls.Resize,this.handleCancel),this.windowListeners.add(ls.DragStart,Ac),this.windowListeners.add(ls.VisibilityChange,this.handleCancel),this.windowListeners.add(ls.ContextMenu,Ac),this.documentListeners.add(ls.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Dc(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Ic(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:i}=this.props;i(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(ls.Click,X_,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ls.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:i,props:r}=this,{onMove:o,options:{activationConstraint:a}}=r;if(!i)return;const c=(t=Sc(e))!=null?t:So,l=q_(i,c);if(!n&&a){if(Ic(a)){if(a.tolerance!=null&&ro(l,a.tolerance))return this.handleCancel();if(ro(l,a.distance))return this.handleStart()}if(Dc(a)&&ro(l,a.tolerance))return this.handleCancel();this.handlePending(a,l);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===us.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const H_={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class vu extends Va{constructor(e){const{event:t}=e,n=qr(t.target);super(e,H_,n)}}vu.activators=[{eventName:"onPointerDown",handler:(s,e)=>{let{nativeEvent:t}=s,{onActivation:n}=e;return!t.isPrimary||t.button!==0?!1:(n?.({event:t}),!0)}}];const Y_={move:{name:"mousemove"},end:{name:"mouseup"}};var To;(function(s){s[s.RightClick=2]="RightClick"})(To||(To={}));class U_ extends Va{constructor(e){super(e,Y_,qr(e.event.target))}}U_.activators=[{eventName:"onMouseDown",handler:(s,e)=>{let{nativeEvent:t}=s,{onActivation:n}=e;return t.button===To.RightClick?!1:(n?.({event:t}),!0)}}];const oo={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class K_ extends Va{constructor(e){super(e,oo)}static setup(){return window.addEventListener(oo.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(oo.move.name,e)};function e(){}}}K_.activators=[{eventName:"onTouchStart",handler:(s,e)=>{let{nativeEvent:t}=s,{onActivation:n}=e;const{touches:i}=t;return i.length>1?!1:(n?.({event:t}),!0)}}];var Rc;(function(s){s[s.Pointer=0]="Pointer",s[s.DraggableRect=1]="DraggableRect"})(Rc||(Rc={}));var Ec;(function(s){s[s.TreeOrder=0]="TreeOrder",s[s.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ec||(Ec={}));sn.Backward+"",sn.Forward+"",sn.Backward+"",sn.Forward+"";var ko;(function(s){s[s.Always=0]="Always",s[s.BeforeDragging=1]="BeforeDragging",s[s.WhileDragging=2]="WhileDragging"})(ko||(ko={}));var Ao;(function(s){s.Optimized="optimized"})(Ao||(Ao={}));function Q_(s,e){return S.useMemo(()=>s.reduce((t,n)=>{let{eventName:i,handler:r}=n;return t[i]=o=>{r(o,e)},t},{}),[s,e])}ko.WhileDragging,Ao.Optimized;const J_={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kc,draggableNodes:new Map,over:null,measureDroppableContainers:kc},e0=S.createContext(J_),t0=S.createContext({...So,scaleX:1,scaleY:1});var Mc;(function(s){s[s.Uninitialized=0]="Uninitialized",s[s.Initializing=1]="Initializing",s[s.Initialized=2]="Initialized"})(Mc||(Mc={}));const s0=S.createContext(null),Oc="button",n0="Draggable";function ao(s){let{id:e,data:t,disabled:n=!1,attributes:i}=s;const r=_u(n0),{activators:o,activatorEvent:a,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:h,over:p}=S.useContext(e0),{role:d=Oc,roleDescription:f="draggable",tabIndex:_=0}=i??{},m=c?.id===e,g=S.useContext(m?t0:s0),[y,x]=er(),[w,v]=er(),b=Q_(o,e),k=gu(t);jr(()=>(h.set(e,{id:e,key:r,node:y,activatorNode:w,data:k}),()=>{const R=h.get(e);R&&R.key===r&&h.delete(e)}),[h,e]);const T=S.useMemo(()=>({role:d,tabIndex:_,"aria-disabled":n,"aria-pressed":m&&d===Oc?!0:void 0,"aria-roledescription":f,"aria-describedby":u.draggable}),[n,d,_,m,f,u.draggable]);return{active:c,activatorEvent:a,activeNodeRect:l,attributes:T,isDragging:m,listeners:n?void 0:b,node:y,over:p,setNodeRef:x,setActivatorNodeRef:v,transform:g}}const i0=new Map([["bold",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),ue.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",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.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"}))]]),r0=new Map([["bold",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.createElement("path",{d:"M80,88v80H32a8,8,0,0,1-8-8V96a8,8,0,0,1,8-8Z",opacity:"0.2"}),ue.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",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.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",ue.createElement(ue.Fragment,null,ue.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"}))]]),o0=S.createContext({color:"currentColor",size:"1em",weight:"regular",mirrored:!1}),Pa=ue.forwardRef((s,e)=>{const{alt:t,color:n,size:i,weight:r,mirrored:o,children:a,weights:c,...l}=s,{color:u="currentColor",size:h,weight:p="regular",mirrored:d=!1,...f}=ue.useContext(o0);return ue.createElement("svg",{ref:e,xmlns:"http://www.w3.org/2000/svg",width:i??h,height:i??h,fill:n??u,viewBox:"0 0 256 256",transform:o||d?"scale(-1, 1)":void 0,...f,...l},!!t&&ue.createElement("title",null,t),a,c.get(r??p))});Pa.displayName="IconBase";const yu=ue.forwardRef((s,e)=>ue.createElement(Pa,{ref:e,...s,weights:i0}));yu.displayName="SpeakerHighIcon";const bu=ue.forwardRef((s,e)=>ue.createElement(Pa,{ref:e,...s,weights:r0}));bu.displayName="SpeakerLowIcon";P.span`
223
223
  font-family: 'Courier New', Monaco, monospace;
224
224
  font-size: 1rem;
225
225
  font-weight: 600;
226
226
  color: ${s=>s.theme?.textColor||"#333"};
227
227
  user-select: none;
228
- `;var Wa=W.button`
228
+ `;var Wa=P.button`
229
229
  display: inline-flex;
230
230
  align-items: center;
231
231
  justify-content: center;
@@ -254,37 +254,37 @@ React keys must be passed directly to JSX without using spread:
254
254
  opacity: 0.6;
255
255
  cursor: not-allowed;
256
256
  }
257
- `;W(Wa)`
257
+ `;P(Wa)`
258
258
  padding: 0.25rem 0.5rem;
259
259
  font-size: ${s=>s.theme.fontSizeSmall};
260
- `;W(Wa)`
260
+ `;P(Wa)`
261
261
  padding: 0.5rem;
262
262
  min-width: 2.25rem;
263
263
  min-height: 2.25rem;
264
- `;W(Wa)`
264
+ `;P(Wa)`
265
265
  padding: 0.25rem;
266
266
  min-width: 1.75rem;
267
267
  min-height: 1.75rem;
268
268
  font-size: ${s=>s.theme.fontSizeSmall};
269
- `;var Lr=W.div`
269
+ `;var Lr=P.div`
270
270
  display: inline-flex;
271
271
  align-items: center;
272
272
  gap: 0.5rem;
273
- `,zr=W.input`
273
+ `,zr=P.input`
274
274
  cursor: pointer;
275
275
  accent-color: ${s=>s.theme.inputFocusBorder};
276
276
 
277
277
  &:disabled {
278
278
  cursor: not-allowed;
279
279
  }
280
- `,Zr=W.label`
280
+ `,Zr=P.label`
281
281
  margin: 0;
282
282
  cursor: pointer;
283
283
  user-select: none;
284
284
  font-family: ${s=>s.theme.fontFamily};
285
285
  font-size: ${s=>s.theme.fontSize};
286
286
  color: ${s=>s.theme.textColor};
287
- `,rs=W.button`
287
+ `,is=P.button`
288
288
  padding: 0.5rem 1rem;
289
289
  background: ${s=>s.theme.buttonBackground||"#007bff"};
290
290
  color: ${s=>s.theme.buttonText||"white"};
@@ -310,7 +310,7 @@ React keys must be passed directly to JSX without using spread:
310
310
  cursor: not-allowed;
311
311
  opacity: 0.6;
312
312
  }
313
- `,wu=W.input`
313
+ `,wu=P.input`
314
314
  padding: 0.5rem 0.75rem;
315
315
  font-family: ${s=>s.theme.fontFamily};
316
316
  font-size: ${s=>s.theme.fontSize};
@@ -334,17 +334,17 @@ React keys must be passed directly to JSX without using spread:
334
334
  opacity: 0.6;
335
335
  cursor: not-allowed;
336
336
  }
337
- `;W(wu)`
337
+ `;P(wu)`
338
338
  padding: 0.25rem 0.5rem;
339
339
  font-size: ${s=>s.theme.fontSizeSmall};
340
- `;var xu=W.label`
340
+ `;var xu=P.label`
341
341
  font-family: ${s=>s.theme.fontFamily};
342
342
  font-size: ${s=>s.theme.fontSizeSmall};
343
343
  font-weight: 500;
344
344
  color: ${s=>s.theme.textColorMuted};
345
345
  margin-bottom: 0.25rem;
346
346
  display: block;
347
- `;W.label`
347
+ `;P.label`
348
348
  font-family: ${s=>s.theme.fontFamily};
349
349
  font-size: ${s=>s.theme.fontSize};
350
350
  color: ${s=>s.theme.textColor};
@@ -352,7 +352,7 @@ React keys must be passed directly to JSX without using spread:
352
352
  align-items: center;
353
353
  gap: 0.5rem;
354
354
  cursor: pointer;
355
- `;var a0=W.span`
355
+ `;var a0=P.span`
356
356
  position: absolute;
357
357
  width: 1px;
358
358
  height: 1px;
@@ -362,7 +362,7 @@ React keys must be passed directly to JSX without using spread:
362
362
  clip: rect(0, 0, 0, 0);
363
363
  white-space: nowrap;
364
364
  border: 0;
365
- `,Ba=W.select`
365
+ `,Ba=P.select`
366
366
  padding: 0.5rem 2rem 0.5rem 0.75rem;
367
367
  font-family: ${s=>s.theme.fontFamily};
368
368
  font-size: ${s=>s.theme.fontSize};
@@ -393,10 +393,10 @@ React keys must be passed directly to JSX without using spread:
393
393
  color: ${s=>s.theme.inputText};
394
394
  background-color: ${s=>s.theme.inputBackground};
395
395
  }
396
- `;W(Ba)`
396
+ `;P(Ba)`
397
397
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
398
398
  font-size: ${s=>s.theme.fontSizeSmall};
399
- `;var Cu=W.input.attrs({type:"range"})`
399
+ `;var Cu=P.input.attrs({type:"range"})`
400
400
  -webkit-appearance: none;
401
401
  appearance: none;
402
402
  width: 100%;
@@ -472,7 +472,7 @@ React keys must be passed directly to JSX without using spread:
472
472
  &:disabled::-moz-range-thumb {
473
473
  cursor: not-allowed;
474
474
  }
475
- `,c0=({checked:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.checked)};return E.jsxs(Lr,{className:n,children:[E.jsx(zr,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:s,onChange:i,disabled:t}),E.jsx(Zr,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Su(s){return typeof s=="object"&&s!==null&&"type"in s}function tr(s){if(!Su(s))return s;const e=s.direction==="vertical"?"to bottom":"to right",t=s.stops.map(n=>`${n.color} ${n.offset*100}%`).join(", ");return`linear-gradient(${e}, ${t})`}var l0={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)",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},u0=1e3;function h0(s,e,t,n){if(!Su(e))return e;let i;e.direction==="vertical"?i=s.createLinearGradient(0,0,0,n):i=s.createLinearGradient(0,0,t,0);for(const r of e.stops)i.addColorStop(r.offset,r.color);return i}var d0=W.canvas.attrs(s=>({style:{width:`${s.$cssWidth}px`,height:`${s.$waveHeight}px`}}))`
475
+ `,c0=({checked:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.checked)};return E.jsxs(Lr,{className:n,children:[E.jsx(zr,{type:"checkbox",id:"automatic-scroll",className:"automatic-scroll",checked:s,onChange:i,disabled:t}),E.jsx(Zr,{htmlFor:"automatic-scroll",children:"Automatic Scroll"})]})};function Su(s){return typeof s=="object"&&s!==null&&"type"in s}function tr(s){if(!Su(s))return s;const e=s.direction==="vertical"?"to bottom":"to right",t=s.stops.map(n=>`${n.color} ${n.offset*100}%`).join(", ");return`linear-gradient(${e}, ${t})`}var l0={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)",clipHeaderBackgroundColor:"rgba(0, 0, 0, 0.1)",clipHeaderBorderColor:"rgba(0, 0, 0, 0.2)",clipHeaderTextColor:"#333",clipHeaderFontFamily:"inherit",selectedClipHeaderBackgroundColor:"#b3d9ff",fadeOverlayColor:"rgba(0, 0, 0, 0.4)",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#ddd",textColor:"#333",textColorMuted:"#666",inputBackground:"#ffffff",inputBorder:"#ccc",inputText:"#333",inputPlaceholder:"#999",inputFocusBorder:"#0066cc",buttonBackground:"#0091ff",buttonText:"#ffffff",buttonBorder:"#0081e6",buttonHoverBackground:"#0081e6",sliderTrackColor:"#ddd",sliderThumbColor:"#daa520",annotationBoxBackground:"rgba(255, 255, 255, 0.85)",annotationBoxActiveBackground:"rgba(255, 255, 255, 0.95)",annotationBoxHoverBackground:"rgba(255, 255, 255, 0.98)",annotationBoxBorder:"#ff9800",annotationBoxActiveBorder:"#d67600",annotationLabelColor:"#2a2a2a",annotationResizeHandleColor:"rgba(0, 0, 0, 0.4)",annotationResizeHandleActiveColor:"rgba(0, 0, 0, 0.8)",annotationTextItemHoverBackground:"rgba(0, 0, 0, 0.03)",borderRadius:"4px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',fontSize:"14px",fontSizeSmall:"12px"},u0=1e3;function h0(s,e,t,n){if(!Su(e))return e;let i;e.direction==="vertical"?i=s.createLinearGradient(0,0,0,n):i=s.createLinearGradient(0,0,t,0);for(const r of e.stops)i.addColorStop(r.offset,r.color);return i}var d0=P.canvas.attrs(s=>({style:{width:`${s.$cssWidth}px`,height:`${s.$waveHeight}px`}}))`
476
476
  float: left;
477
477
  position: relative;
478
478
  /* Promote to own compositing layer for smoother scrolling */
@@ -480,13 +480,13 @@ React keys must be passed directly to JSX without using spread:
480
480
  /* Disable image rendering interpolation */
481
481
  image-rendering: pixelated;
482
482
  image-rendering: crisp-edges;
483
- `,p0=W.div.attrs(s=>({style:{top:`${s.$waveHeight*s.$index}px`,width:`${s.$cssWidth}px`,height:`${s.$waveHeight}px`}}))`
483
+ `,p0=P.div.attrs(s=>({style:{top:`${s.$waveHeight*s.$index}px`,width:`${s.$cssWidth}px`,height:`${s.$waveHeight}px`}}))`
484
484
  position: absolute;
485
485
  background: ${s=>s.$waveFillColor};
486
486
  /* Force GPU compositing layer to reduce scroll flickering */
487
487
  transform: translateZ(0);
488
488
  backface-visibility: hidden;
489
- `,f0=s=>{const{data:e,bits:t,length:n,index:i,className:r,devicePixelRatio:o=1,waveHeight:a=80,waveOutlineColor:c="#E0EFF1",waveFillColor:l="grey",barWidth:u=1,barGap:h=0,transparentBackground:p=!1,drawMode:d="inverted"}=s,f=S.useRef([]),_=S.useCallback(v=>{if(v!==null){const b=parseInt(v.dataset.index,10);f.current[b]=v}},[]);S.useLayoutEffect(()=>{const v=f.current,b=u+h;let k=0;for(let T=0;T<v.length;T++){const R=v[T],I=R.getContext("2d"),A=Math.floor(a/2),D=2**(t-1);if(I){I.resetTransform(),I.clearRect(0,0,R.width,R.height),I.imageSmoothingEnabled=!1,I.scale(o,o);const M=R.width/o;let N;d==="normal"?N=l:N=c,I.fillStyle=h0(I,N,M,a);const q=k,V=k+M,j=Math.floor((q-u+b)/b)*b;for(let G=Math.max(0,j);G<V;G+=b){const B=G-q;if(B+u<=0)continue;const Z=G;if(Z*2+1<e.length){const X=e[Z*2]/D,ee=e[Z*2+1]/D,pe=Math.abs(X*A),ie=Math.abs(ee*A);d==="normal"?I.fillRect(B,A-ie,u,ie+pe):(I.fillRect(B,0,u,A-ie),I.fillRect(B,A+pe,u,A-pe))}}}k+=R.width/o}},[e,t,a,c,l,o,n,u,h,d]);let m=n,g=0;const y=[];for(;m>0;){const v=Math.min(m,u0),b=E.jsx(d0,{$cssWidth:v,width:v*o,height:a*o,$waveHeight:a,"data-index":g,ref:_},`${n}-${g}`);y.push(b),m-=v,g+=1}const w=p?"transparent":tr(l);return E.jsx(p0,{$index:i,$cssWidth:n,className:r,$waveHeight:a,$waveFillColor:w,children:y})},Tu=22,ku=W.div`
489
+ `,f0=s=>{const{data:e,bits:t,length:n,index:i,className:r,devicePixelRatio:o=1,waveHeight:a=80,waveOutlineColor:c="#E0EFF1",waveFillColor:l="grey",barWidth:u=1,barGap:h=0,transparentBackground:p=!1,drawMode:d="inverted"}=s,f=S.useRef([]),_=S.useCallback(v=>{if(v!==null){const b=parseInt(v.dataset.index,10);f.current[b]=v}},[]);S.useLayoutEffect(()=>{const v=f.current,b=u+h;let k=0;for(let T=0;T<v.length;T++){const R=v[T],I=R.getContext("2d"),A=Math.floor(a/2),D=2**(t-1);if(I){I.resetTransform(),I.clearRect(0,0,R.width,R.height),I.imageSmoothingEnabled=!1,I.scale(o,o);const O=R.width/o;let N;d==="normal"?N=l:N=c,I.fillStyle=h0(I,N,O,a);const q=k,V=k+O,j=Math.floor((q-u+b)/b)*b;for(let X=Math.max(0,j);X<V;X+=b){const B=X-q;if(B+u<=0)continue;const G=X;if(G*2+1<e.length){const H=e[G*2]/D,te=e[G*2+1]/D,de=Math.abs(H*A),ie=Math.abs(te*A);d==="normal"?I.fillRect(B,A-ie,u,ie+de):(I.fillRect(B,0,u,A-ie),I.fillRect(B,A+de,u,A-de))}}}k+=R.width/o}},[e,t,a,c,l,o,n,u,h,d]);let m=n,g=0;const y=[];for(;m>0;){const v=Math.min(m,u0),b=E.jsx(d0,{$cssWidth:v,width:v*o,height:a*o,$waveHeight:a,"data-index":g,ref:_},`${n}-${g}`);y.push(b),m-=v,g+=1}const w=p?"transparent":tr(l);return E.jsx(p0,{$index:i,$cssWidth:n,className:r,$waveHeight:a,$waveFillColor:w,children:y})},Tu=22,ku=P.div`
490
490
  position: relative;
491
491
  height: ${Tu}px;
492
492
  background: ${s=>s.$isSelected?s.theme.selectedClipHeaderBackgroundColor:s.theme.clipHeaderBackgroundColor};
@@ -509,7 +509,7 @@ React keys must be passed directly to JSX without using spread:
509
509
  cursor: grabbing;
510
510
  }
511
511
  `}
512
- `,Au=W.span`
512
+ `,Au=P.span`
513
513
  font-size: 11px;
514
514
  font-weight: 600;
515
515
  font-family: ${s=>s.theme.clipHeaderFontFamily};
@@ -517,7 +517,7 @@ React keys must be passed directly to JSX without using spread:
517
517
  white-space: nowrap;
518
518
  overflow: hidden;
519
519
  text-overflow: ellipsis;
520
- `,m0=({trackName:s,isSelected:e=!1})=>E.jsx(ku,{$isDragging:!1,$interactive:!1,$isSelected:e,children:E.jsx(Au,{children:s})}),g0=({clipId:s,trackIndex:e,clipIndex:t,trackName:n,isSelected:i=!1,disableDrag:r=!1,dragHandleProps:o})=>{if(r||!o)return E.jsx(m0,{trackName:n,isSelected:i});const{attributes:a,listeners:c,setActivatorNodeRef:l}=o;return E.jsx(ku,{ref:l,"data-clip-id":s,$interactive:!0,$isSelected:i,...c,...a,children:E.jsx(Au,{children:n})})},_0=8,v0=W.div`
520
+ `,m0=({trackName:s,isSelected:e=!1})=>E.jsx(ku,{$isDragging:!1,$interactive:!1,$isSelected:e,children:E.jsx(Au,{children:s})}),g0=({clipId:s,trackIndex:e,clipIndex:t,trackName:n,isSelected:i=!1,disableDrag:r=!1,dragHandleProps:o})=>{if(r||!o)return E.jsx(m0,{trackName:n,isSelected:i});const{attributes:a,listeners:c,setActivatorNodeRef:l}=o;return E.jsx(ku,{ref:l,"data-clip-id":s,$interactive:!0,$isSelected:i,...c,...a,children:E.jsx(Au,{children:n})})},_0=8,v0=P.div`
521
521
  position: absolute;
522
522
  ${s=>s.$edge==="left"?"left: 0;":"right: 0;"}
523
523
  top: 0;
@@ -544,19 +544,19 @@ React keys must be passed directly to JSX without using spread:
544
544
  background: rgba(255, 255, 255, 0.4);
545
545
  ${s=>s.$edge==="left"?"border-left: 2px solid rgba(255, 255, 255, 0.8);":"border-right: 2px solid rgba(255, 255, 255, 0.8);"}
546
546
  }
547
- `,Nc=({clipId:s,trackIndex:e,clipIndex:t,edge:n,dragHandleProps:i})=>{const[r,o]=S.useState(!1);if(!i)return null;const{attributes:a,listeners:c,setActivatorNodeRef:l,isDragging:u}=i;return E.jsx(v0,{ref:l,"data-clip-id":s,"data-boundary-edge":n,$edge:n,$isDragging:u,$isHovered:r,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),...c,...a})},y0=W.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
547
+ `,Nc=({clipId:s,trackIndex:e,clipIndex:t,edge:n,dragHandleProps:i})=>{const[r,o]=S.useState(!1);if(!i)return null;const{attributes:a,listeners:c,setActivatorNodeRef:l,isDragging:u}=i;return E.jsx(v0,{ref:l,"data-clip-id":s,"data-boundary-edge":n,$edge:n,$isDragging:u,$isHovered:r,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),...c,...a})},y0=P.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
548
548
  position: absolute;
549
549
  top: 0;
550
550
  bottom: 0;
551
551
  pointer-events: none;
552
552
  z-index: 50;
553
- `,b0=W.svg`
553
+ `,b0=P.svg`
554
554
  width: 100%;
555
555
  height: 100%;
556
556
  display: block;
557
557
  /* Flip horizontally for fadeOut - makes it mirror of fadeIn */
558
558
  transform: ${s=>s.$type==="fadeOut"?"scaleX(-1)":"none"};
559
- `;function w0(s,e,t="logarithmic"){const n=[],i=Math.max(20,Math.min(s,100));for(let r=0;r<=i;r++){const o=r/i*s,a=r/i;let c;switch(t){case"linear":c=a;break;case"exponential":c=a*a;break;case"sCurve":c=(1-Math.cos(a*Math.PI))/2;break;case"logarithmic":default:c=Math.log10(1+a*9)/Math.log10(10);break}const l=(1-c)*e;n.push(`${o},${l}`)}return`M 0,${e} L ${n.join(" L ")} L ${s},0 L 0,0 Z`}var Fc=({left:s,width:e,type:t,curveType:n="logarithmic",color:i})=>{const r=W.useTheme();if(e<1)return null;const o=i||r?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return E.jsx(y0,{$left:s,$width:e,$type:t,children:E.jsx(b0,{$type:t,viewBox:`0 0 ${e} 100`,preserveAspectRatio:"none",children:E.jsx("path",{d:w0(e,100,n),fill:o})})})},x0=W.div.attrs(s=>({style:s.$isOverlay?{}:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
559
+ `;function w0(s,e,t="logarithmic"){const n=[],i=Math.max(20,Math.min(s,100));for(let r=0;r<=i;r++){const o=r/i*s,a=r/i;let c;switch(t){case"linear":c=a;break;case"exponential":c=a*a;break;case"sCurve":c=(1-Math.cos(a*Math.PI))/2;break;case"logarithmic":default:c=Math.log10(1+a*9)/Math.log10(10);break}const l=(1-c)*e;n.push(`${o},${l}`)}return`M 0,${e} L ${n.join(" L ")} L ${s},0 L 0,0 Z`}var Fc=({left:s,width:e,type:t,curveType:n="logarithmic",color:i})=>{const r=P.useTheme();if(e<1)return null;const o=i||r?.fadeOverlayColor||"rgba(0, 0, 0, 0.4)";return E.jsx(y0,{$left:s,$width:e,$type:t,children:E.jsx(b0,{$type:t,viewBox:`0 0 ${e} 100`,preserveAspectRatio:"none",children:E.jsx("path",{d:w0(e,100,n),fill:o})})})},x0=P.div.attrs(s=>({style:s.$isOverlay?{}:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
560
560
  position: ${s=>s.$isOverlay?"relative":"absolute"};
561
561
  top: 0;
562
562
  height: ${s=>s.$isOverlay?"auto":"100%"};
@@ -570,20 +570,20 @@ React keys must be passed directly to JSX without using spread:
570
570
  &:hover {
571
571
  background: rgba(255, 255, 255, 0.08);
572
572
  }
573
- `,C0=W.div`
573
+ `,C0=P.div`
574
574
  flex: 1;
575
575
  position: relative;
576
576
  overflow: ${s=>s.$isOverlay?"visible":"hidden"};
577
- `,Vc=({children:s,className:e,clipId:t,trackIndex:n,clipIndex:i,trackName:r,startSample:o,durationSamples:a,samplesPerPixel:c,showHeader:l=!1,disableHeaderDrag:u=!1,isOverlay:h=!1,isSelected:p=!1,onMouseDown:d,trackId:f,fadeIn:_,fadeOut:m,sampleRate:g=44100,showFades:y=!1})=>{const x=Math.floor(o/c),v=Math.floor((o+a)/c)-x,b=l&&!u&&!h,k=`clip-${n}-${i}`,{attributes:T,listeners:R,setNodeRef:I,setActivatorNodeRef:A,transform:D,isDragging:M}=ao({id:k,data:{clipId:t,trackIndex:n,clipIndex:i},disabled:!b}),N=`clip-boundary-left-${n}-${i}`,{attributes:q,listeners:V,setActivatorNodeRef:j,isDragging:G}=ao({id:N,data:{clipId:t,trackIndex:n,clipIndex:i,boundary:"left"},disabled:!b}),B=`clip-boundary-right-${n}-${i}`,{attributes:Z,listeners:X,setActivatorNodeRef:ee,isDragging:pe}=ao({id:B,data:{clipId:t,trackIndex:n,clipIndex:i,boundary:"right"},disabled:!b}),ie=D?{transform:Co.Translate.toString(D),zIndex:M?100:void 0}:void 0;return E.jsxs(x0,{ref:I,style:ie,className:e,$left:x,$width:v,$isOverlay:h,"data-clip-container":"true","data-track-id":f,onMouseDown:d,children:[l&&E.jsx(g0,{clipId:t,trackIndex:n,clipIndex:i,trackName:r,isSelected:p,disableDrag:u,dragHandleProps:b?{attributes:T,listeners:R,setActivatorNodeRef:A}:void 0}),E.jsxs(C0,{$isOverlay:h,children:[s,y&&_&&_.duration>0&&E.jsx(Fc,{left:0,width:Math.floor(_.duration*g/c),type:"fadeIn",curveType:_.type}),y&&m&&m.duration>0&&E.jsx(Fc,{left:v-Math.floor(m.duration*g/c),width:Math.floor(m.duration*g/c),type:"fadeOut",curveType:m.type})]}),l&&!u&&!h&&E.jsxs(E.Fragment,{children:[E.jsx(Nc,{clipId:t,trackIndex:n,clipIndex:i,edge:"left",dragHandleProps:{attributes:q,listeners:V,setActivatorNodeRef:j,isDragging:G}}),E.jsx(Nc,{clipId:t,trackIndex:n,clipIndex:i,edge:"right",dragHandleProps:{attributes:Z,listeners:X,setActivatorNodeRef:ee,isDragging:pe}})]})]})},S0=W.div`
577
+ `,Vc=({children:s,className:e,clipId:t,trackIndex:n,clipIndex:i,trackName:r,startSample:o,durationSamples:a,samplesPerPixel:c,showHeader:l=!1,disableHeaderDrag:u=!1,isOverlay:h=!1,isSelected:p=!1,onMouseDown:d,trackId:f,fadeIn:_,fadeOut:m,sampleRate:g=44100,showFades:y=!1})=>{const x=Math.floor(o/c),v=Math.floor((o+a)/c)-x,b=l&&!u&&!h,k=`clip-${n}-${i}`,{attributes:T,listeners:R,setNodeRef:I,setActivatorNodeRef:A,transform:D,isDragging:O}=ao({id:k,data:{clipId:t,trackIndex:n,clipIndex:i},disabled:!b}),N=`clip-boundary-left-${n}-${i}`,{attributes:q,listeners:V,setActivatorNodeRef:j,isDragging:X}=ao({id:N,data:{clipId:t,trackIndex:n,clipIndex:i,boundary:"left"},disabled:!b}),B=`clip-boundary-right-${n}-${i}`,{attributes:G,listeners:H,setActivatorNodeRef:te,isDragging:de}=ao({id:B,data:{clipId:t,trackIndex:n,clipIndex:i,boundary:"right"},disabled:!b}),ie=D?{transform:Co.Translate.toString(D),zIndex:O?100:void 0}:void 0;return E.jsxs(x0,{ref:I,style:ie,className:e,$left:x,$width:v,$isOverlay:h,"data-clip-container":"true","data-track-id":f,onMouseDown:d,children:[l&&E.jsx(g0,{clipId:t,trackIndex:n,clipIndex:i,trackName:r,isSelected:p,disableDrag:u,dragHandleProps:b?{attributes:T,listeners:R,setActivatorNodeRef:A}:void 0}),E.jsxs(C0,{$isOverlay:h,children:[s,y&&_&&_.duration>0&&E.jsx(Fc,{left:0,width:Math.floor(_.duration*g/c),type:"fadeIn",curveType:_.type}),y&&m&&m.duration>0&&E.jsx(Fc,{left:v-Math.floor(m.duration*g/c),width:Math.floor(m.duration*g/c),type:"fadeOut",curveType:m.type})]}),l&&!u&&!h&&E.jsxs(E.Fragment,{children:[E.jsx(Nc,{clipId:t,trackIndex:n,clipIndex:i,edge:"left",dragHandleProps:{attributes:q,listeners:V,setActivatorNodeRef:j,isDragging:X}}),E.jsx(Nc,{clipId:t,trackIndex:n,clipIndex:i,edge:"right",dragHandleProps:{attributes:G,listeners:H,setActivatorNodeRef:te,isDragging:de}})]})]})},S0=P.div`
578
578
  display: inline-flex;
579
579
  align-items: center;
580
580
  gap: 0.5rem;
581
- `,T0=W(xu)`
581
+ `,T0=P(xu)`
582
582
  margin: 0;
583
583
  white-space: nowrap;
584
- `,k0=W(Cu)`
584
+ `,k0=P(Cu)`
585
585
  width: 120px;
586
- `,A0=({volume:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(parseFloat(r.target.value)/100)};return E.jsxs(S0,{className:n,children:[E.jsx(T0,{htmlFor:"master-gain",children:"Master Volume"}),E.jsx(k0,{min:"0",max:"100",value:s*100,onChange:i,disabled:t,id:"master-gain"})]})};W.div.attrs(s=>({style:{transform:`translate3d(${s.$position}px, 0, 0)`}}))`
586
+ `,A0=({volume:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(parseFloat(r.target.value)/100)};return E.jsxs(S0,{className:n,children:[E.jsx(T0,{htmlFor:"master-gain",children:"Master Volume"}),E.jsx(k0,{min:"0",max:"100",value:s*100,onChange:i,disabled:t,id:"master-gain"})]})};P.div.attrs(s=>({style:{transform:`translate3d(${s.$position}px, 0, 0)`}}))`
587
587
  position: absolute;
588
588
  top: 0;
589
589
  left: 0;
@@ -593,7 +593,7 @@ React keys must be passed directly to JSX without using spread:
593
593
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
594
594
  pointer-events: none;
595
595
  will-change: transform;
596
- `;W.div`
596
+ `;P.div`
597
597
  position: absolute;
598
598
  top: 0;
599
599
  left: 0;
@@ -601,7 +601,7 @@ React keys must be passed directly to JSX without using spread:
601
601
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
602
602
  pointer-events: none;
603
603
  will-change: transform;
604
- `;W.div`
604
+ `;P.div`
605
605
  position: absolute;
606
606
  top: -10px;
607
607
  left: -6px;
@@ -610,29 +610,29 @@ React keys must be passed directly to JSX without using spread:
610
610
  border-left: 7px solid transparent;
611
611
  border-right: 7px solid transparent;
612
612
  border-top: 10px solid ${s=>s.$color};
613
- `;W.div`
613
+ `;P.div`
614
614
  position: absolute;
615
615
  top: 0;
616
616
  left: 0;
617
617
  width: 2px;
618
618
  height: 100%;
619
619
  background: ${s=>s.$color};
620
- `;var I0=W.div`
620
+ `;var I0=P.div`
621
621
  overflow-y: hidden;
622
622
  overflow-x: auto;
623
623
  position: relative;
624
- `,D0=W.div.attrs(s=>({style:s.$width!==void 0?{width:`${s.$width}px`}:{}}))`
624
+ `,D0=P.div.attrs(s=>({style:s.$width!==void 0?{width:`${s.$width}px`}:{}}))`
625
625
  position: relative;
626
626
  background: ${s=>s.$backgroundColor||"transparent"};
627
- `,R0=W.div.attrs(s=>({style:s.$width?{minWidth:`${s.$width}px`}:{}}))`
627
+ `,R0=P.div.attrs(s=>({style:s.$width?{minWidth:`${s.$width}px`}:{}}))`
628
628
  background: ${s=>s.$backgroundColor||"white"};
629
629
  width: 100%;
630
630
  overflow: visible;
631
- `,E0=W.div.attrs(s=>({style:s.$width!==void 0?{minWidth:`${s.$width}px`}:{}}))`
631
+ `,E0=P.div.attrs(s=>({style:s.$width!==void 0?{minWidth:`${s.$width}px`}:{}}))`
632
632
  position: relative;
633
633
  background: ${s=>s.$backgroundColor||"transparent"};
634
634
  width: 100%;
635
- `,M0=W.div`
635
+ `,M0=P.div`
636
636
  position: absolute;
637
637
  top: 0;
638
638
  left: 0;
@@ -640,7 +640,7 @@ React keys must be passed directly to JSX without using spread:
640
640
  bottom: 0;
641
641
  cursor: crosshair;
642
642
  z-index: 1; /* Low z-index - clip headers and boundaries have higher z-index */
643
- `,Iu=({children:s,backgroundColor:e,timescaleBackgroundColor:t,timescale:n,timescaleWidth:i,tracksWidth:r,scrollContainerWidth:o,controlsWidth:a,onTracksClick:c,onTracksMouseDown:l,onTracksMouseMove:u,onTracksMouseUp:h,scrollContainerRef:p})=>E.jsx(I0,{"data-scroll-container":"true",ref:p,children:E.jsxs(D0,{$backgroundColor:e,$width:o,children:[n&&E.jsx(R0,{$width:i,$backgroundColor:t,children:n}),E.jsxs(E0,{$width:r,$backgroundColor:e,children:[s,(c||l)&&E.jsx(M0,{$controlsWidth:a,onClick:c,onMouseDown:l,onMouseMove:u,onMouseUp:h})]})]})});W.withTheme(Iu);var O0=W.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
643
+ `,Iu=({children:s,backgroundColor:e,timescaleBackgroundColor:t,timescale:n,timescaleWidth:i,tracksWidth:r,scrollContainerWidth:o,controlsWidth:a,onTracksClick:c,onTracksMouseDown:l,onTracksMouseMove:u,onTracksMouseUp:h,scrollContainerRef:p})=>E.jsx(I0,{"data-scroll-container":"true",ref:p,children:E.jsxs(D0,{$backgroundColor:e,$width:o,children:[n&&E.jsx(R0,{$width:i,$backgroundColor:t,children:n}),E.jsxs(E0,{$width:r,$backgroundColor:e,children:[s,(c||l)&&E.jsx(M0,{$controlsWidth:a,onClick:c,onMouseDown:l,onMouseMove:u,onMouseUp:h})]})]})});P.withTheme(Iu);var O0=P.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
644
644
  position: absolute;
645
645
  top: 0;
646
646
  background: ${s=>s.$color};
@@ -648,34 +648,34 @@ React keys must be passed directly to JSX without using spread:
648
648
  z-index: 60; /* Above clips (z-index: 10) and fades (z-index: 50), below playhead (z-index: 100) */
649
649
  pointer-events: none;
650
650
  opacity: 0.3;
651
- `,N0=({startPosition:s,endPosition:e,color:t="#00ff00"})=>{const n=Math.max(0,e-s);return n<=0?null:E.jsx(O0,{$left:s,$width:n,$color:t,"data-selection":!0})};function qn(s,e){const t=Math.floor(s/3600)%24,n=Math.floor(s/60)%60,i=(s%60).toFixed(e);return String(t).padStart(2,"0")+":"+String(n).padStart(2,"0")+":"+i.padStart(e+3,"0")}function nn(s,e){switch(e){case"seconds":return s.toFixed(0);case"thousandths":return s.toFixed(3);case"hh:mm:ss":return qn(s,0);case"hh:mm:ss.u":return qn(s,1);case"hh:mm:ss.uu":return qn(s,2);case"hh:mm:ss.uuu":return qn(s,3);default:return qn(s,3)}}function Du(s,e){if(!s)return 0;switch(e){case"seconds":case"thousandths":return parseFloat(s)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const t=s.split(":");if(t.length!==3)return 0;const n=parseInt(t[0],10)||0,i=parseInt(t[1],10)||0,r=parseFloat(t[2])||0;return n*3600+i*60+r}default:return 0}}var Pc=({id:s,label:e,value:t,format:n,className:i,onChange:r,readOnly:o=!1})=>{const[a,c]=S.useState("");S.useEffect(()=>{const p=nn(t,n);c(p)},[t,n,s]);const l=p=>{const d=p.target.value;c(d)},u=()=>{if(r){const p=Du(a,n);r(p)}c(nn(t,n))},h=p=>{p.key==="Enter"&&p.currentTarget.blur()};return E.jsxs(E.Fragment,{children:[E.jsx(a0,{as:"label",htmlFor:s,children:e}),E.jsx(wu,{type:"text",className:i,id:s,value:a,onChange:l,onBlur:u,onKeyDown:h,readOnly:o})]})},F0=({selectionStart:s,selectionEnd:e,onSelectionChange:t,className:n})=>{const[i,r]=S.useState("hh:mm:ss.uuu");S.useEffect(()=>{const c=document.querySelector(".time-format"),l=()=>{c&&r(c.value)};return c&&(r(c.value),c.addEventListener("change",l)),()=>{c?.removeEventListener("change",l)}},[]);const o=c=>{t&&t(c,e)},a=c=>{t&&t(s,c)};return E.jsxs(E.Fragment,{children:[E.jsx(Pc,{id:"audio_start",label:"Start of audio selection",value:s,format:i,className:"audio-start form-control mr-sm-2",onChange:o}),E.jsx(Pc,{id:"audio_end",label:"End of audio selection",value:e,format:i,className:"audio-end form-control mr-sm-2",onChange:a})]})};function $i(){return window.devicePixelRatio}var Ru=S.createContext($i()),V0=({children:s})=>{const[e,t]=S.useState($i());return matchMedia(`(resolution: ${$i()}dppx)`).addEventListener("change",()=>{t($i())},{once:!0}),E.jsx(Ru.Provider,{value:Math.ceil(e),children:s})},Eu=()=>S.useContext(Ru),$a=S.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}),Gr=()=>S.useContext($a),qa=()=>S.useContext(W.ThemeContext),Mu=S.createContext(E.jsx(S.Fragment,{})),P0=()=>S.useContext(Mu),W0=0,B0=!1,$0=0,q0=0,j0={progress:W0,isPlaying:B0,selectionStart:$0,selectionEnd:q0};S.createContext(j0);S.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var L0=({isSelected:s,transparentBackground:e,...t})=>{const n=qa(),{waveHeight:i,barWidth:r,barGap:o}=Gr(),a=Eu(),c=s&&n?n.selectedWaveOutlineColor:n?.waveOutlineColor,l=s&&n?n.selectedWaveFillColor:n?.waveFillColor,u=n?.waveformDrawMode||"inverted";return E.jsx(f0,{...t,...n,waveOutlineColor:c,waveFillColor:l,waveHeight:i,devicePixelRatio:a,barWidth:r,barGap:o,transparentBackground:e,drawMode:u})};function z0(s,e,t){return Math.ceil(s*t/e)}function Z0(s){const e=Math.floor(s/1e3),t=e%60;return`${(e-t)/60}:${String(t).padStart(2,"0")}`}var G0=W.div.attrs(s=>({style:{width:`${s.$cssWidth}px`,marginLeft:`${s.$controlWidth}px`,height:`${s.$timeScaleHeight}px`}}))`
651
+ `,N0=({startPosition:s,endPosition:e,color:t="#00ff00"})=>{const n=Math.max(0,e-s);return n<=0?null:E.jsx(O0,{$left:s,$width:n,$color:t,"data-selection":!0})};function qn(s,e){const t=Math.floor(s/3600)%24,n=Math.floor(s/60)%60,i=(s%60).toFixed(e);return String(t).padStart(2,"0")+":"+String(n).padStart(2,"0")+":"+i.padStart(e+3,"0")}function rn(s,e){switch(e){case"seconds":return s.toFixed(0);case"thousandths":return s.toFixed(3);case"hh:mm:ss":return qn(s,0);case"hh:mm:ss.u":return qn(s,1);case"hh:mm:ss.uu":return qn(s,2);case"hh:mm:ss.uuu":return qn(s,3);default:return qn(s,3)}}function Du(s,e){if(!s)return 0;switch(e){case"seconds":case"thousandths":return parseFloat(s)||0;case"hh:mm:ss":case"hh:mm:ss.u":case"hh:mm:ss.uu":case"hh:mm:ss.uuu":{const t=s.split(":");if(t.length!==3)return 0;const n=parseInt(t[0],10)||0,i=parseInt(t[1],10)||0,r=parseFloat(t[2])||0;return n*3600+i*60+r}default:return 0}}var Pc=({id:s,label:e,value:t,format:n,className:i,onChange:r,readOnly:o=!1})=>{const[a,c]=S.useState("");S.useEffect(()=>{const p=rn(t,n);c(p)},[t,n,s]);const l=p=>{const d=p.target.value;c(d)},u=()=>{if(r){const p=Du(a,n);r(p)}c(rn(t,n))},h=p=>{p.key==="Enter"&&p.currentTarget.blur()};return E.jsxs(E.Fragment,{children:[E.jsx(a0,{as:"label",htmlFor:s,children:e}),E.jsx(wu,{type:"text",className:i,id:s,value:a,onChange:l,onBlur:u,onKeyDown:h,readOnly:o})]})},F0=({selectionStart:s,selectionEnd:e,onSelectionChange:t,className:n})=>{const[i,r]=S.useState("hh:mm:ss.uuu");S.useEffect(()=>{const c=document.querySelector(".time-format"),l=()=>{c&&r(c.value)};return c&&(r(c.value),c.addEventListener("change",l)),()=>{c?.removeEventListener("change",l)}},[]);const o=c=>{t&&t(c,e)},a=c=>{t&&t(s,c)};return E.jsxs(E.Fragment,{children:[E.jsx(Pc,{id:"audio_start",label:"Start of audio selection",value:s,format:i,className:"audio-start form-control mr-sm-2",onChange:o}),E.jsx(Pc,{id:"audio_end",label:"End of audio selection",value:e,format:i,className:"audio-end form-control mr-sm-2",onChange:a})]})};function $i(){return window.devicePixelRatio}var Ru=S.createContext($i()),V0=({children:s})=>{const[e,t]=S.useState($i());return matchMedia(`(resolution: ${$i()}dppx)`).addEventListener("change",()=>{t($i())},{once:!0}),E.jsx(Ru.Provider,{value:Math.ceil(e),children:s})},Eu=()=>S.useContext(Ru),$a=S.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}),Gr=()=>S.useContext($a),qa=()=>S.useContext(P.ThemeContext),Mu=S.createContext(E.jsx(S.Fragment,{})),P0=()=>S.useContext(Mu),W0=0,B0=!1,$0=0,q0=0,j0={progress:W0,isPlaying:B0,selectionStart:$0,selectionEnd:q0};S.createContext(j0);S.createContext({setIsPlaying:()=>{},setProgress:()=>{},setSelection:()=>{}});var L0=({isSelected:s,transparentBackground:e,...t})=>{const n=qa(),{waveHeight:i,barWidth:r,barGap:o}=Gr(),a=Eu(),c=s&&n?n.selectedWaveOutlineColor:n?.waveOutlineColor,l=s&&n?n.selectedWaveFillColor:n?.waveFillColor,u=n?.waveformDrawMode||"inverted";return E.jsx(f0,{...t,...n,waveOutlineColor:c,waveFillColor:l,waveHeight:i,devicePixelRatio:a,barWidth:r,barGap:o,transparentBackground:e,drawMode:u})};function z0(s,e,t){return Math.ceil(s*t/e)}function Z0(s){const e=Math.floor(s/1e3),t=e%60;return`${(e-t)/60}:${String(t).padStart(2,"0")}`}var G0=P.div.attrs(s=>({style:{width:`${s.$cssWidth}px`,marginLeft:`${s.$controlWidth}px`,height:`${s.$timeScaleHeight}px`}}))`
652
652
  position: relative;
653
653
  overflow: visible; /* Allow time labels to render above the container */
654
654
  border-bottom: 1px solid ${s=>s.theme.timeColor};
655
655
  box-sizing: border-box;
656
- `,X0=W.canvas.attrs(s=>({style:{width:`${s.$cssWidth}px`,height:`${s.$timeScaleHeight}px`}}))`
656
+ `,X0=P.canvas.attrs(s=>({style:{width:`${s.$cssWidth}px`,height:`${s.$timeScaleHeight}px`}}))`
657
657
  position: absolute;
658
658
  left: 0;
659
659
  right: 0;
660
660
  bottom: 0;
661
- `,H0=W.div.attrs(s=>({style:{left:`${s.$left+4}px`}}))`
661
+ `,H0=P.div.attrs(s=>({style:{left:`${s.$left+4}px`}}))`
662
662
  position: absolute;
663
663
  font-size: 0.75rem; /* Smaller font to prevent overflow */
664
664
  white-space: nowrap; /* Prevent text wrapping */
665
665
  color: ${s=>s.theme.timeColor}; /* Use theme color instead of inheriting */
666
- `,Y0=s=>{const{theme:{timeColor:e},duration:t,marker:n,bigStep:i,secondStep:r,renderTimestamp:o}=s,a=new Map,c=[],l=S.useRef(null),{sampleRate:u,samplesPerPixel:h,timeScaleHeight:p,controls:{show:d,width:f}}=S.useContext($a),_=Eu();S.useEffect(()=>{if(l.current!==null){const x=l.current,w=x.getContext("2d");if(w){w.resetTransform(),w.clearRect(0,0,x.width,x.height),w.imageSmoothingEnabled=!1,w.fillStyle=e,w.scale(_,_);for(const[v,b]of a.entries()){const k=p-b;w.fillRect(v,k,1,b)}}}},[t,_,e,p,i,r,n,a]);const m=z0(t/1e3,h,u),g=u/h;let y=0;for(let x=0;x<m;x+=g*r/1e3){const w=Math.floor(x);if(y%n===0){const v=y,b=Z0(v),k=o?E.jsx(S.Fragment,{children:o(v,w)},`timestamp-${y}`):E.jsx(H0,{$left:w,children:b},b);c.push(k),a.set(w,p)}else y%i===0?a.set(w,Math.floor(p/2)):y%r===0&&a.set(w,Math.floor(p/5));y+=r}return E.jsxs(G0,{$cssWidth:m,$controlWidth:d?f:0,$timeScaleHeight:p,children:[c,E.jsx(X0,{$cssWidth:m,$timeScaleHeight:p,width:m*_,height:p*_,ref:l})]})},U0=W.withTheme(Y0),K0=W.div`
666
+ `,Y0=s=>{const{theme:{timeColor:e},duration:t,marker:n,bigStep:i,secondStep:r,renderTimestamp:o}=s,a=new Map,c=[],l=S.useRef(null),{sampleRate:u,samplesPerPixel:h,timeScaleHeight:p,controls:{show:d,width:f}}=S.useContext($a),_=Eu();S.useEffect(()=>{if(l.current!==null){const x=l.current,w=x.getContext("2d");if(w){w.resetTransform(),w.clearRect(0,0,x.width,x.height),w.imageSmoothingEnabled=!1,w.fillStyle=e,w.scale(_,_);for(const[v,b]of a.entries()){const k=p-b;w.fillRect(v,k,1,b)}}}},[t,_,e,p,i,r,n,a]);const m=z0(t/1e3,h,u),g=u/h;let y=0;for(let x=0;x<m;x+=g*r/1e3){const w=Math.floor(x);if(y%n===0){const v=y,b=Z0(v),k=o?E.jsx(S.Fragment,{children:o(v,w)},`timestamp-${y}`):E.jsx(H0,{$left:w,children:b},b);c.push(k),a.set(w,p)}else y%i===0?a.set(w,Math.floor(p/2)):y%r===0&&a.set(w,Math.floor(p/5));y+=r}return E.jsxs(G0,{$cssWidth:m,$controlWidth:d?f:0,$timeScaleHeight:p,children:[c,E.jsx(X0,{$cssWidth:m,$timeScaleHeight:p,width:m*_,height:p*_,ref:l})]})},U0=P.withTheme(Y0),K0=P.div`
667
667
  display: inline-flex;
668
668
  align-items: center;
669
669
  gap: 0.5rem;
670
- `,Q0=[{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"}],J0=({value:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.value)};return E.jsx(K0,{className:n,children:E.jsx(Ba,{className:"time-format",value:s,onChange:i,disabled:t,"aria-label":"Time format selection",children:Q0.map(r=>E.jsx("option",{value:r.value,children:r.label},r.value))})})},ev=W.div.attrs(s=>({style:{height:`${s.$waveHeight*s.$numChannels+(s.$hasClipHeaders?Tu:0)}px`}}))`
670
+ `,Q0=[{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"}],J0=({value:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.value)};return E.jsx(K0,{className:n,children:E.jsx(Ba,{className:"time-format",value:s,onChange:i,disabled:t,"aria-label":"Time format selection",children:Q0.map(r=>E.jsx("option",{value:r.value,children:r.label},r.value))})})},ev=P.div.attrs(s=>({style:{height:`${s.$waveHeight*s.$numChannels+(s.$hasClipHeaders?Tu:0)}px`}}))`
671
671
  position: relative;
672
672
  display: flex;
673
673
  ${s=>s.$width!==void 0&&`width: ${s.$width}px;`}
674
- `,tv=W.div.attrs(s=>({style:{paddingLeft:`${s.$offset||0}px`}}))`
674
+ `,tv=P.div.attrs(s=>({style:{paddingLeft:`${s.$offset||0}px`}}))`
675
675
  position: relative;
676
676
  background: ${s=>s.$backgroundColor||"transparent"};
677
677
  flex: 1;
678
- `,sv=W.div.attrs(s=>({style:{width:`${s.$controlWidth}px`}}))`
678
+ `,sv=P.div.attrs(s=>({style:{width:`${s.$controlWidth}px`}}))`
679
679
  position: sticky;
680
680
  z-index: 101; /* Above waveform content, below Docusaurus navbar (z-index: 200) */
681
681
  left: 0;
@@ -689,7 +689,7 @@ React keys must be passed directly to JSX without using spread:
689
689
  ${s=>s.$isSelected&&`
690
690
  background: ${s.theme.selectedTrackControlsBackground};
691
691
  `}
692
- `,nv=({numChannels:s,children:e,className:t,backgroundColor:n,offset:i=0,width:r,hasClipHeaders:o=!1,onClick:a,trackId:c,isSelected:l=!1})=>{const{waveHeight:u,controls:{show:h,width:p}}=Gr(),d=P0();return E.jsxs(ev,{$numChannels:s,className:t,$waveHeight:u,$controlWidth:h?p:0,$width:r,$hasClipHeaders:o,$isSelected:l,children:[E.jsx(sv,{$controlWidth:h?p:0,$isSelected:l,children:d}),E.jsx(tv,{$controlWidth:h?p:0,$backgroundColor:n,$offset:i,onClick:a,"data-track-id":c,children:e})]})},Wc=W.button.attrs({type:"button"})`
692
+ `,nv=({numChannels:s,children:e,className:t,backgroundColor:n,offset:i=0,width:r,hasClipHeaders:o=!1,onClick:a,trackId:c,isSelected:l=!1})=>{const{waveHeight:u,controls:{show:h,width:p}}=Gr(),d=P0();return E.jsxs(ev,{$numChannels:s,className:t,$waveHeight:u,$controlWidth:h?p:0,$width:r,$hasClipHeaders:o,$isSelected:l,children:[E.jsx(sv,{$controlWidth:h?p:0,$isSelected:l,children:d}),E.jsx(tv,{$controlWidth:h?p:0,$backgroundColor:n,$offset:i,onClick:a,"data-track-id":c,children:e})]})},Wc=P.button.attrs({type:"button"})`
693
693
  display: inline-block;
694
694
  font-family: ${s=>s.theme.fontFamily};
695
695
  font-weight: 500;
@@ -748,7 +748,7 @@ React keys must be passed directly to JSX without using spread:
748
748
  box-shadow: 0 0 0 0.2rem ${s.theme.inputFocusBorder}33;
749
749
  }
750
750
  `}
751
- `,iv=W.div`
751
+ `,iv=P.div`
752
752
  margin-bottom: 0.3rem;
753
753
 
754
754
  button:not(:first-child) {
@@ -760,7 +760,7 @@ React keys must be passed directly to JSX without using spread:
760
760
  border-top-right-radius: 0;
761
761
  border-bottom-right-radius: 0;
762
762
  }
763
- `,rv=W.div`
763
+ `,rv=P.div`
764
764
  background: transparent;
765
765
  width: 100%;
766
766
  height: 100%;
@@ -773,7 +773,7 @@ React keys must be passed directly to JSX without using spread:
773
773
  text-align: center;
774
774
  border: 1px solid ${s=>s.theme.borderColor};
775
775
  border-radius: ${s=>s.theme.borderRadius};
776
- `,ov=W.header`
776
+ `,ov=P.header`
777
777
  overflow: hidden;
778
778
  height: 26px;
779
779
  width: 100%;
@@ -784,7 +784,7 @@ React keys must be passed directly to JSX without using spread:
784
784
  font-size: ${s=>s.theme.fontSizeSmall};
785
785
  color: ${s=>s.theme.textColor};
786
786
  background-color: transparent;
787
- `,av=s=>E.jsx(bu,{weight:"light",...s}),cv=s=>E.jsx(yu,{weight:"light",...s}),Bc=W(Cu)`
787
+ `,av=s=>E.jsx(bu,{weight:"light",...s}),cv=s=>E.jsx(yu,{weight:"light",...s}),Bc=P(Cu)`
788
788
  width: 75%;
789
789
  height: 5px;
790
790
  background: ${s=>s.theme.sliderTrackColor};
@@ -833,7 +833,7 @@ React keys must be passed directly to JSX without using spread:
833
833
  &:focus::-moz-range-thumb {
834
834
  border: 2px solid ${s=>s.theme.textColor};
835
835
  }
836
- `,$c=W.label`
836
+ `,$c=P.label`
837
837
  width: 100%;
838
838
  display: flex;
839
839
  justify-content: space-between;
@@ -841,12 +841,12 @@ React keys must be passed directly to JSX without using spread:
841
841
  padding: 0 1rem;
842
842
  margin-bottom: 0.2rem;
843
843
  font-size: 14px;
844
- `;W.div`
844
+ `;P.div`
845
845
  display: flex;
846
846
  align-items: center;
847
847
  gap: 0.25rem;
848
848
  padding: 0.5rem 0.5rem 0.25rem 0.5rem;
849
- `;W.span`
849
+ `;P.span`
850
850
  flex: 1;
851
851
  font-weight: 600;
852
852
  font-size: 0.875rem;
@@ -854,7 +854,7 @@ React keys must be passed directly to JSX without using spread:
854
854
  text-overflow: ellipsis;
855
855
  white-space: nowrap;
856
856
  margin: 0 0.25rem;
857
- `;W.button`
857
+ `;P.button`
858
858
  display: flex;
859
859
  align-items: center;
860
860
  justify-content: center;
@@ -879,7 +879,7 @@ React keys must be passed directly to JSX without using spread:
879
879
  &:active {
880
880
  transform: scale(0.9);
881
881
  }
882
- `;function lv(s){let e=1/0,t=-1/0;for(let n=0;n<s.length;n++){const i=s[n];e>i&&(e=i),t<i&&(t=i)}return{min:e,max:t}}function qc(s,e){const t=Math.pow(2,e-1),n=s<0?s*t:s*(t-1);return Math.max(-t,Math.min(t-1,n))}function Ou(s,e){switch(s){case 8:return new Int8Array(e);case 16:return new Int16Array(e)}}function jc(s,e,t){const n=s.length,i=Math.ceil(n/e),r=Ou(t,i*2);for(let o=0;o<i;o++){const a=o*e,c=Math.min((o+1)*e,n),l=s.subarray(a,c),u=lv(l),h=qc(u.min,t),p=qc(u.max,t);r[o*2]=h,r[o*2+1]=p}return r}function uv(s,e){const t=s.length,n=1/t,i=s[0].length/2,r=Ou(e,i*2);for(let o=0;o<i;o++){let a=0,c=0;for(let l=0;l<t;l++)a+=n*s[l][o*2],c+=n*s[l][o*2+1];r[o*2]=a,r[o*2+1]=c}return[r]}function hv(s,e=1e3,t=!0,n=0,i,r=16){if(r!==8&&r!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in s){const c=s.numberOfChannels,l=i??s.length;for(let u=0;u<c;u++){const p=s.getChannelData(u).subarray(n,l);o.push(jc(p,e,r))}}else{const c=i??s.length,l=s.subarray(n,c);o.push(jc(l,e,r))}return t&&o.length>1&&(o=uv(o,r)),{length:o[0].length/2,data:o,bits:r}}function dv(s,e=1e3,t=!0,n=8,i=0,r){const o=s.sampleRate,a=Math.floor(i*o),c=r!==void 0?Math.floor((i+r)*o):void 0;return hv(s,e,t,a,c,n)}var Lc;(function(s){s.DragStart="dragStart",s.DragMove="dragMove",s.DragEnd="dragEnd",s.DragCancel="dragCancel",s.DragOver="dragOver",s.RegisterDroppable="registerDroppable",s.SetDroppableDisabled="setDroppableDisabled",s.UnregisterDroppable="unregisterDroppable"})(Lc||(Lc={}));function zc(){}const pv=Object.freeze({x:0,y:0});var sn;(function(s){s[s.Forward=1]="Forward",s[s.Backward=-1]="Backward"})(sn||(sn={}));var Zc;(function(s){s.Click="click",s.DragStart="dragstart",s.Keydown="keydown",s.ContextMenu="contextmenu",s.Resize="resize",s.SelectionChange="selectionchange",s.VisibilityChange="visibilitychange"})(Zc||(Zc={}));var ws;(function(s){s.Space="Space",s.Down="ArrowDown",s.Right="ArrowRight",s.Left="ArrowLeft",s.Up="ArrowUp",s.Esc="Escape",s.Enter="Enter",s.Tab="Tab"})(ws||(ws={}));ws.Space,ws.Enter,ws.Esc,ws.Space,ws.Enter,ws.Tab;var Gc;(function(s){s[s.RightClick=2]="RightClick"})(Gc||(Gc={}));var Xc;(function(s){s[s.Pointer=0]="Pointer",s[s.DraggableRect=1]="DraggableRect"})(Xc||(Xc={}));var Hc;(function(s){s[s.TreeOrder=0]="TreeOrder",s[s.ReversedTreeOrder=1]="ReversedTreeOrder"})(Hc||(Hc={}));sn.Backward+"",sn.Forward+"",sn.Backward+"",sn.Forward+"";var Io;(function(s){s[s.Always=0]="Always",s[s.BeforeDragging=1]="BeforeDragging",s[s.WhileDragging=2]="WhileDragging"})(Io||(Io={}));var Do;(function(s){s.Optimized="optimized"})(Do||(Do={}));function fv(s,e){return S.useMemo(()=>s.reduce((t,n)=>{let{eventName:i,handler:r}=n;return t[i]=o=>{r(o,e)},t},{}),[s,e])}Io.WhileDragging,Do.Optimized;const mv={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:zc,draggableNodes:new Map,over:null,measureDroppableContainers:zc},gv=S.createContext(mv),_v=S.createContext({...pv,scaleX:1,scaleY:1});var Yc;(function(s){s[s.Uninitialized=0]="Uninitialized",s[s.Initializing=1]="Initializing",s[s.Initialized=2]="Initialized"})(Yc||(Yc={}));const vv=S.createContext(null),Uc="button",yv="Draggable";function Kc(s){let{id:e,data:t,disabled:n=!1,attributes:i}=s;const r=_u(yv),{activators:o,activatorEvent:a,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:h,over:p}=S.useContext(gv),{role:d=Uc,roleDescription:f="draggable",tabIndex:_=0}=i??{},m=c?.id===e,g=S.useContext(m?_v:vv),[y,x]=er(),[w,v]=er(),b=fv(o,e),k=gu(t);jr(()=>(h.set(e,{id:e,key:r,node:y,activatorNode:w,data:k}),()=>{const R=h.get(e);R&&R.key===r&&h.delete(e)}),[h,e]);const T=S.useMemo(()=>({role:d,tabIndex:_,"aria-disabled":n,"aria-pressed":m&&d===Uc?!0:void 0,"aria-roledescription":f,"aria-describedby":u.draggable}),[n,d,_,m,f,u.draggable]);return{active:c,activatorEvent:a,activeNodeRect:l,attributes:T,isDragging:m,listeners:n?void 0:b,node:y,over:p,setNodeRef:x,setActivatorNodeRef:v,transform:g}}function bv(s){return{id:s.id,start:parseFloat(s.begin),end:parseFloat(s.end),lines:s.lines,lang:s.language}}function wv(s){return{id:s.id,begin:s.start.toFixed(3),end:s.end.toFixed(3),lines:s.lines,language:s.lang||"en"}}W.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
882
+ `;function lv(s){let e=1/0,t=-1/0;for(let n=0;n<s.length;n++){const i=s[n];e>i&&(e=i),t<i&&(t=i)}return{min:e,max:t}}function qc(s,e){const t=Math.pow(2,e-1),n=s<0?s*t:s*(t-1);return Math.max(-t,Math.min(t-1,n))}function Ou(s,e){switch(s){case 8:return new Int8Array(e);case 16:return new Int16Array(e)}}function jc(s,e,t){const n=s.length,i=Math.ceil(n/e),r=Ou(t,i*2);for(let o=0;o<i;o++){const a=o*e,c=Math.min((o+1)*e,n),l=s.subarray(a,c),u=lv(l),h=qc(u.min,t),p=qc(u.max,t);r[o*2]=h,r[o*2+1]=p}return r}function uv(s,e){const t=s.length,n=1/t,i=s[0].length/2,r=Ou(e,i*2);for(let o=0;o<i;o++){let a=0,c=0;for(let l=0;l<t;l++)a+=n*s[l][o*2],c+=n*s[l][o*2+1];r[o*2]=a,r[o*2+1]=c}return[r]}function hv(s,e=1e3,t=!0,n=0,i,r=16){if(r!==8&&r!==16)throw new Error("Invalid number of bits specified for peaks. Must be 8 or 16.");let o=[];if("getChannelData"in s){const c=s.numberOfChannels,l=i??s.length;for(let u=0;u<c;u++){const p=s.getChannelData(u).subarray(n,l);o.push(jc(p,e,r))}}else{const c=i??s.length,l=s.subarray(n,c);o.push(jc(l,e,r))}return t&&o.length>1&&(o=uv(o,r)),{length:o[0].length/2,data:o,bits:r}}function dv(s,e=1e3,t=!0,n=8,i=0,r){const o=s.sampleRate,a=Math.floor(i*o),c=r!==void 0?Math.floor((i+r)*o):void 0;return hv(s,e,t,a,c,n)}var Lc;(function(s){s.DragStart="dragStart",s.DragMove="dragMove",s.DragEnd="dragEnd",s.DragCancel="dragCancel",s.DragOver="dragOver",s.RegisterDroppable="registerDroppable",s.SetDroppableDisabled="setDroppableDisabled",s.UnregisterDroppable="unregisterDroppable"})(Lc||(Lc={}));function zc(){}const pv=Object.freeze({x:0,y:0});var nn;(function(s){s[s.Forward=1]="Forward",s[s.Backward=-1]="Backward"})(nn||(nn={}));var Zc;(function(s){s.Click="click",s.DragStart="dragstart",s.Keydown="keydown",s.ContextMenu="contextmenu",s.Resize="resize",s.SelectionChange="selectionchange",s.VisibilityChange="visibilitychange"})(Zc||(Zc={}));var ws;(function(s){s.Space="Space",s.Down="ArrowDown",s.Right="ArrowRight",s.Left="ArrowLeft",s.Up="ArrowUp",s.Esc="Escape",s.Enter="Enter",s.Tab="Tab"})(ws||(ws={}));ws.Space,ws.Enter,ws.Esc,ws.Space,ws.Enter,ws.Tab;var Gc;(function(s){s[s.RightClick=2]="RightClick"})(Gc||(Gc={}));var Xc;(function(s){s[s.Pointer=0]="Pointer",s[s.DraggableRect=1]="DraggableRect"})(Xc||(Xc={}));var Hc;(function(s){s[s.TreeOrder=0]="TreeOrder",s[s.ReversedTreeOrder=1]="ReversedTreeOrder"})(Hc||(Hc={}));nn.Backward+"",nn.Forward+"",nn.Backward+"",nn.Forward+"";var Io;(function(s){s[s.Always=0]="Always",s[s.BeforeDragging=1]="BeforeDragging",s[s.WhileDragging=2]="WhileDragging"})(Io||(Io={}));var Do;(function(s){s.Optimized="optimized"})(Do||(Do={}));function fv(s,e){return S.useMemo(()=>s.reduce((t,n)=>{let{eventName:i,handler:r}=n;return t[i]=o=>{r(o,e)},t},{}),[s,e])}Io.WhileDragging,Do.Optimized;const mv={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:zc,draggableNodes:new Map,over:null,measureDroppableContainers:zc},gv=S.createContext(mv),_v=S.createContext({...pv,scaleX:1,scaleY:1});var Yc;(function(s){s[s.Uninitialized=0]="Uninitialized",s[s.Initializing=1]="Initializing",s[s.Initialized=2]="Initialized"})(Yc||(Yc={}));const vv=S.createContext(null),Uc="button",yv="Draggable";function Kc(s){let{id:e,data:t,disabled:n=!1,attributes:i}=s;const r=_u(yv),{activators:o,activatorEvent:a,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:h,over:p}=S.useContext(gv),{role:d=Uc,roleDescription:f="draggable",tabIndex:_=0}=i??{},m=c?.id===e,g=S.useContext(m?_v:vv),[y,x]=er(),[w,v]=er(),b=fv(o,e),k=gu(t);jr(()=>(h.set(e,{id:e,key:r,node:y,activatorNode:w,data:k}),()=>{const R=h.get(e);R&&R.key===r&&h.delete(e)}),[h,e]);const T=S.useMemo(()=>({role:d,tabIndex:_,"aria-disabled":n,"aria-pressed":m&&d===Uc?!0:void 0,"aria-roledescription":f,"aria-describedby":u.draggable}),[n,d,_,m,f,u.draggable]);return{active:c,activatorEvent:a,activeNodeRect:l,attributes:T,isDragging:m,listeners:n?void 0:b,node:y,over:p,setNodeRef:x,setActivatorNodeRef:v,transform:g}}function bv(s){return{id:s.id,start:parseFloat(s.begin),end:parseFloat(s.end),lines:s.lines,lang:s.language}}function wv(s){return{id:s.id,begin:s.start.toFixed(3),end:s.end.toFixed(3),lines:s.lines,language:s.lang||"en"}}P.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
883
883
  position: absolute;
884
884
  top: 0;
885
885
  background: ${s=>s.$color};
@@ -895,7 +895,7 @@ React keys must be passed directly to JSX without using spread:
895
895
  opacity: 0.5;
896
896
  border-color: ${s=>s.$color};
897
897
  }
898
- `;W.div`
898
+ `;P.div`
899
899
  position: absolute;
900
900
  bottom: 0;
901
901
  left: 0;
@@ -911,7 +911,7 @@ React keys must be passed directly to JSX without using spread:
911
911
  pointer-events: none;
912
912
  white-space: pre-wrap;
913
913
  word-break: break-word;
914
- `;W.textarea`
914
+ `;P.textarea`
915
915
  position: absolute;
916
916
  bottom: 0;
917
917
  left: 0;
@@ -931,7 +931,7 @@ React keys must be passed directly to JSX without using spread:
931
931
  outline: none;
932
932
  border-color: #4CAF50;
933
933
  }
934
- `;W.div`
934
+ `;P.div`
935
935
  position: absolute;
936
936
  top: 0;
937
937
  left: 0;
@@ -942,7 +942,7 @@ React keys must be passed directly to JSX without using spread:
942
942
  padding: 4px;
943
943
  justify-content: flex-start;
944
944
  align-items: center;
945
- `;W.button`
945
+ `;P.button`
946
946
  background: transparent;
947
947
  border: 1px solid rgba(255, 255, 255, 0.5);
948
948
  color: white;
@@ -964,12 +964,12 @@ React keys must be passed directly to JSX without using spread:
964
964
  &:active {
965
965
  background: rgba(255, 255, 255, 0.3);
966
966
  }
967
- `;var xv=W.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
967
+ `;var xv=P.div.attrs(s=>({style:{left:`${s.$left}px`,width:`${s.$width}px`}}))`
968
968
  position: absolute;
969
969
  top: 0;
970
970
  height: 100%;
971
971
  pointer-events: none; /* Let events pass through to children */
972
- `,Cv=W.div`
972
+ `,Cv=P.div`
973
973
  position: absolute;
974
974
  top: 0;
975
975
  left: 0;
@@ -993,7 +993,7 @@ React keys must be passed directly to JSX without using spread:
993
993
  border-width: 3px;
994
994
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
995
995
  }
996
- `,Sv=W.span`
996
+ `,Sv=P.span`
997
997
  font-size: 12px;
998
998
  font-weight: 600;
999
999
  color: ${s=>s.theme?.annotationLabelColor||"#2a2a2a"};
@@ -1003,7 +1003,7 @@ React keys must be passed directly to JSX without using spread:
1003
1003
  padding: 0 6px;
1004
1004
  letter-spacing: 0.3px;
1005
1005
  user-select: none;
1006
- `,Qc=W.div`
1006
+ `,Qc=P.div`
1007
1007
  position: absolute;
1008
1008
  top: 0;
1009
1009
  ${s=>s.$position==="left"?"left: -8px":"right: -8px"};
@@ -1038,13 +1038,13 @@ React keys must be passed directly to JSX without using spread:
1038
1038
  opacity: 1;
1039
1039
  background: ${s=>s.theme?.annotationResizeHandleActiveColor||"rgba(0, 0, 0, 0.7)"};
1040
1040
  }
1041
- `,Tv=({annotationId:s,annotationIndex:e,startPosition:t,endPosition:n,label:i,color:r="#ff9800",isActive:o=!1,onClick:a,editable:c=!0})=>{const l=Math.max(0,n-t),u=`annotation-boundary-start-${e}`,{attributes:h,listeners:p,setActivatorNodeRef:d,isDragging:f}=Kc({id:u,data:{annotationId:s,annotationIndex:e,edge:"start"},disabled:!c}),_=`annotation-boundary-end-${e}`,{attributes:m,listeners:g,setActivatorNodeRef:y,isDragging:x}=Kc({id:_,data:{annotationId:s,annotationIndex:e,edge:"end"},disabled:!c});if(l<=0)return null;const w=b=>k=>{k.stopPropagation(),b?.(k)},v=b=>{b.stopPropagation()};return E.jsxs(xv,{$left:t,$width:l,children:[E.jsx(Cv,{$color:r,$isActive:o,onClick:a,children:i&&E.jsx(Sv,{children:i})}),c&&E.jsx(Qc,{ref:d,$position:"left",$isDragging:f,onClick:v,...p,onPointerDown:w(p?.onPointerDown),...h}),c&&E.jsx(Qc,{ref:y,$position:"right",$isDragging:x,onClick:v,...g,onPointerDown:w(g?.onPointerDown),...m})]})},kv=W.div.attrs(s=>({style:{height:`${s.$height}px`}}))`
1041
+ `,Tv=({annotationId:s,annotationIndex:e,startPosition:t,endPosition:n,label:i,color:r="#ff9800",isActive:o=!1,onClick:a,editable:c=!0})=>{const l=Math.max(0,n-t),u=`annotation-boundary-start-${e}`,{attributes:h,listeners:p,setActivatorNodeRef:d,isDragging:f}=Kc({id:u,data:{annotationId:s,annotationIndex:e,edge:"start"},disabled:!c}),_=`annotation-boundary-end-${e}`,{attributes:m,listeners:g,setActivatorNodeRef:y,isDragging:x}=Kc({id:_,data:{annotationId:s,annotationIndex:e,edge:"end"},disabled:!c});if(l<=0)return null;const w=b=>k=>{k.stopPropagation(),b?.(k)},v=b=>{b.stopPropagation()};return E.jsxs(xv,{$left:t,$width:l,children:[E.jsx(Cv,{$color:r,$isActive:o,onClick:a,children:i&&E.jsx(Sv,{children:i})}),c&&E.jsx(Qc,{ref:d,$position:"left",$isDragging:f,onClick:v,...p,onPointerDown:w(p?.onPointerDown),...h}),c&&E.jsx(Qc,{ref:y,$position:"right",$isDragging:x,onClick:v,...g,onPointerDown:w(g?.onPointerDown),...m})]})},kv=P.div.attrs(s=>({style:{height:`${s.$height}px`}}))`
1042
1042
  position: relative;
1043
1043
  display: flex;
1044
1044
  ${s=>s.$width!==void 0&&`width: ${s.$width}px;`}
1045
1045
  background: transparent;
1046
1046
  z-index: 110;
1047
- `,Av=W.div`
1047
+ `,Av=P.div`
1048
1048
  position: sticky;
1049
1049
  z-index: 200;
1050
1050
  left: 0;
@@ -1052,16 +1052,16 @@ React keys must be passed directly to JSX without using spread:
1052
1052
  width: ${s=>s.$controlWidth}px;
1053
1053
  flex-shrink: 0;
1054
1054
  background: transparent;
1055
- `,Iv=W.div`
1055
+ `,Iv=P.div`
1056
1056
  position: relative;
1057
1057
  flex: 1;
1058
1058
  padding-left: ${s=>s.$offset||0}px;
1059
- `,Dv=({children:s,className:e,height:t=30,offset:n=0,width:i})=>{const{controls:{show:r,width:o}}=Gr();return E.jsxs(kv,{className:e,$height:t,$controlWidth:r?o:0,$width:i,children:[E.jsx(Av,{$controlWidth:r?o:0}),E.jsx(Iv,{$offset:n,children:s})]})};W.div.attrs(s=>({style:{height:`${s.$height}px`}}))`
1059
+ `,Dv=({children:s,className:e,height:t=30,offset:n=0,width:i})=>{const{controls:{show:r,width:o}}=Gr();return E.jsxs(kv,{className:e,$height:t,$controlWidth:r?o:0,$width:i,children:[E.jsx(Av,{$controlWidth:r?o:0}),E.jsx(Iv,{$offset:n,children:s})]})};P.div.attrs(s=>({style:{height:`${s.$height}px`}}))`
1060
1060
  position: relative;
1061
1061
  display: flex;
1062
1062
  ${s=>s.$width!==void 0&&`width: ${s.$width}px;`}
1063
1063
  background: transparent;
1064
- `;W.div`
1064
+ `;P.div`
1065
1065
  position: sticky;
1066
1066
  z-index: 200;
1067
1067
  left: 0;
@@ -1075,16 +1075,16 @@ React keys must be passed directly to JSX without using spread:
1075
1075
  font-size: 12px;
1076
1076
  color: ${s=>s.theme?.textColorMuted||"#666"};
1077
1077
  font-weight: bold;
1078
- `;W.div`
1078
+ `;P.div`
1079
1079
  position: relative;
1080
1080
  flex: 1;
1081
1081
  padding-left: ${s=>s.$offset||0}px;
1082
- `;var Rv=W.div`
1082
+ `;var Rv=P.div`
1083
1083
  background: ${s=>s.theme?.backgroundColor||"#fff"};
1084
1084
  ${s=>s.$height?`height: ${s.$height}px;`:"max-height: 200px;"}
1085
1085
  overflow-y: auto;
1086
1086
  padding: 8px;
1087
- `,Ev=W.div`
1087
+ `,Ev=P.div`
1088
1088
  padding: 12px;
1089
1089
  margin-bottom: 6px;
1090
1090
  border-left: 4px solid ${s=>s.$isActive?"#ff9800":"transparent"};
@@ -1103,16 +1103,16 @@ React keys must be passed directly to JSX without using spread:
1103
1103
  outline: 2px solid #ff9800;
1104
1104
  outline-offset: 2px;
1105
1105
  }
1106
- `,Mv=W.div`
1106
+ `,Mv=P.div`
1107
1107
  display: flex;
1108
1108
  justify-content: space-between;
1109
1109
  align-items: center;
1110
1110
  margin-bottom: 6px;
1111
- `,Ov=W.div`
1111
+ `,Ov=P.div`
1112
1112
  display: flex;
1113
1113
  align-items: center;
1114
1114
  gap: 8px;
1115
- `,Nv=W.span`
1115
+ `,Nv=P.span`
1116
1116
  font-size: 11px;
1117
1117
  font-weight: 600;
1118
1118
  color: ${s=>s.theme?.textColorMuted||"#666"};
@@ -1126,16 +1126,16 @@ React keys must be passed directly to JSX without using spread:
1126
1126
  outline: 2px solid #ff9800;
1127
1127
  background: rgba(255, 152, 0, 0.1);
1128
1128
  }
1129
- `,Fv=W.span`
1129
+ `,Fv=P.span`
1130
1130
  font-size: 12px;
1131
1131
  font-weight: 500;
1132
1132
  color: ${s=>s.theme?.textColorMuted||"#555"};
1133
1133
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
1134
1134
  letter-spacing: 0.5px;
1135
- `,Vv=W.div`
1135
+ `,Vv=P.div`
1136
1136
  display: flex;
1137
1137
  gap: 6px;
1138
- `,Pv=W.button`
1138
+ `,Pv=P.button`
1139
1139
  background: ${s=>s.theme?.surfaceColor||"#f5f5f5"};
1140
1140
  border: 1px solid ${s=>s.theme?.borderColor||"#ccc"};
1141
1141
  color: ${s=>s.theme?.textColor||"#333"};
@@ -1154,7 +1154,7 @@ React keys must be passed directly to JSX without using spread:
1154
1154
  &:active {
1155
1155
  transform: scale(0.95);
1156
1156
  }
1157
- `,Wv=W.div`
1157
+ `,Wv=P.div`
1158
1158
  font-size: 14px;
1159
1159
  line-height: 1.6;
1160
1160
  color: ${s=>s.theme?.textColor||"#2a2a2a"};
@@ -1171,7 +1171,7 @@ React keys must be passed directly to JSX without using spread:
1171
1171
  }
1172
1172
  `,Bv=({annotations:s,activeAnnotationId:e,shouldScrollToActive:t=!1,editable:n=!1,controls:i=[],annotationListConfig:r,height:o,onAnnotationClick:a,onAnnotationUpdate:c})=>{const l=S.useRef(null),u=S.useRef(null),h=S.useRef(void 0);S.useEffect(()=>{}),S.useEffect(()=>{const g=u.current;if(!g)return;const y=()=>{};return g.addEventListener("scroll",y),()=>g.removeEventListener("scroll",y)},[]),S.useEffect(()=>{e&&l.current&&t&&l.current.scrollIntoView({behavior:"smooth",block:"nearest"}),h.current=e},[e,t]);const p=g=>{if(isNaN(g)||!isFinite(g))return"0:00.000";const y=Math.floor(g/60),x=(g%60).toFixed(3);return`${y}:${x.padStart(6,"0")}`},d=(g,y)=>{if(!n||!c)return;const x=[...s];x[g]={...x[g],lines:y.split(`
1173
1173
  `)},c(x)},f=(g,y)=>{if(!n||!c)return;const x=y.trim();if(!x)return;const w=[...s];w[g]={...w[g],id:x},c(w)},_=(g,y,x)=>{if(!c)return;const w=[...s];g.action(w[x],x,w,r||{}),c(w)},m=g=>g.replace(/\./g," ");return E.jsx(Rv,{ref:u,$height:o,children:s.map((g,y)=>{const x=g.id===e;return E.jsxs(Ev,{ref:x?l:null,$isActive:x,onClick:()=>a?.(g),children:[E.jsxs(Mv,{children:[E.jsxs(Ov,{children:[E.jsx(Nv,{$isEditable:n,contentEditable:n,suppressContentEditableWarning:!0,onBlur:w=>f(y,w.currentTarget.textContent||""),children:g.id}),E.jsxs(Fv,{children:[p(g.start)," - ",p(g.end)]})]}),i.length>0&&E.jsx(Vv,{onClick:w=>w.stopPropagation(),children:i.map((w,v)=>E.jsx(Pv,{title:w.title,onClick:()=>_(w,g,y),children:w.text?w.text:E.jsx("i",{className:m(w.class||"")})},v))})]}),E.jsx(Wv,{$isEditable:n,contentEditable:n,suppressContentEditableWarning:!0,onBlur:w=>d(y,w.currentTarget.textContent||""),children:g.lines.join(`
1174
- `)})]},g.id)})})},$v=S.memo(Bv),qv=({checked:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.checked)};return E.jsxs(Lr,{className:n,children:[E.jsx(zr,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:s,onChange:i,disabled:t}),E.jsx(Zr,{htmlFor:"continuous-play",children:"Continuous Play"})]})},jv=({checked:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.checked)};return E.jsxs(Lr,{className:n,children:[E.jsx(zr,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:s,onChange:i,disabled:t}),E.jsx(Zr,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},Lv=({checked:s,onChange:e,className:t})=>E.jsxs(Lr,{className:t,children:[E.jsx(zr,{type:"checkbox",id:"editable-annotations",checked:s,onChange:n=>e(n.target.checked)}),E.jsx(Zr,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),zv=W.button`
1174
+ `)})]},g.id)})})},$v=S.memo(Bv),qv=({checked:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.checked)};return E.jsxs(Lr,{className:n,children:[E.jsx(zr,{type:"checkbox",id:"continuous-play",className:"continuous-play",checked:s,onChange:i,disabled:t}),E.jsx(Zr,{htmlFor:"continuous-play",children:"Continuous Play"})]})},jv=({checked:s,onChange:e,disabled:t=!1,className:n})=>{const i=r=>{e(r.target.checked)};return E.jsxs(Lr,{className:n,children:[E.jsx(zr,{type:"checkbox",id:"link-endpoints",className:"link-endpoints",checked:s,onChange:i,disabled:t}),E.jsx(Zr,{htmlFor:"link-endpoints",children:"Link Endpoints"})]})},Lv=({checked:s,onChange:e,className:t})=>E.jsxs(Lr,{className:t,children:[E.jsx(zr,{type:"checkbox",id:"editable-annotations",checked:s,onChange:n=>e(n.target.checked)}),E.jsx(Zr,{htmlFor:"editable-annotations",children:"Editable Annotations"})]}),zv=P.button`
1175
1175
  padding: 0.5rem 1rem;
1176
1176
  background: ${s=>s.theme?.surfaceColor||"#f5f5f5"};
1177
1177
  color: ${s=>s.theme?.textColor||"#333"};
@@ -1197,7 +1197,7 @@ React keys must be passed directly to JSX without using spread:
1197
1197
  opacity: 0.6;
1198
1198
  cursor: not-allowed;
1199
1199
  }
1200
- `,Zv=({annotations:s,filename:e="annotations.json",disabled:t=!1,className:n,children:i="Download JSON"})=>{const r=()=>{if(s.length===0)return;const o=s.map(h=>wv(h)),a=JSON.stringify(o,null,2),c=new Blob([a],{type:"application/json"}),l=URL.createObjectURL(c),u=document.createElement("a");u.href=l,u.download=e,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(l)};return E.jsx(zv,{onClick:r,disabled:t||s.length===0,className:n,title:s.length===0?"No annotations to download":"Download the annotations as JSON",children:i})};function Nu(){const[s,e]=S.useState("hh:mm:ss.uuu");return{timeFormat:s,setTimeFormat:e,formatTime:i=>nn(i,s),parseTime:i=>Du(i,s)}}const Gv=[256,512,1024,2048,4096,8192];function Fu({initialSamplesPerPixel:s,zoomLevels:e=Gv}){const[t,n]=S.useState(()=>{const l=e.indexOf(s);return l!==-1?l:Math.floor(e.length/2)}),i=e[t],r=t>0,o=t<e.length-1,a=S.useCallback(()=>{n(l=>Math.max(0,l-1))},[]),c=S.useCallback(()=>{n(l=>Math.min(e.length-1,l+1))},[e.length]);return{samplesPerPixel:i,zoomIn:a,zoomOut:c,canZoomIn:r,canZoomOut:o}}function Vu({playoutRef:s,initialVolume:e=1,onVolumeChange:t}){const[n,i]=S.useState(e),r=S.useCallback(o=>{i(o),s.current&&s.current.setMasterGain(o),t?.(o)},[s,t]);return{masterVolume:n,setMasterVolume:r}}const Xv=(s=256)=>{const e=S.useRef(null),t=S.useCallback((n,i,r)=>{const o=new Hs("fft",s);return n.connect(o),n.connect(i),e.current=o,function(){o.dispose(),e.current=null}},[s]);return{analyserRef:e,masterEffects:t}};function Ro(s){const{audioBuffer:e,startSample:t,durationSamples:n=e.length,offsetSamples:i=0,gain:r=1,name:o,color:a,fadeIn:c,fadeOut:l}=s;return{id:Pu(),audioBuffer:e,startSample:t,durationSamples:n,offsetSamples:i,gain:r,name:o,color:a,fadeIn:c,fadeOut:l}}function Hv(s){const{audioBuffer:e,startTime:t,duration:n=e.duration,offset:i=0,gain:r=1,name:o,color:a,fadeIn:c,fadeOut:l}=s,u=e.sampleRate;return Ro({audioBuffer:e,startSample:Math.round(t*u),durationSamples:Math.round(n*u),offsetSamples:Math.round(i*u),gain:r,name:o,color:a,fadeIn:c,fadeOut:l})}function Yv(s){const{name:e,clips:t=[],muted:n=!1,soloed:i=!1,volume:r=1,pan:o=0,color:a,height:c}=s;return{id:Pu(),name:e,clips:t,muted:n,soloed:i,volume:r,pan:o,color:a,height:c}}function Pu(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function Uv(s){const[e,t]=S.useState([]),[n,i]=S.useState(!0),[r,o]=S.useState(null);return S.useEffect(()=>{if(s.length===0){t([]),i(!1);return}let a=!1;return(async()=>{try{i(!0),o(null);const l=me().rawContext,u=s.map(async(p,d)=>{const f=await fetch(p.src);if(!f.ok)throw new Error(`Failed to fetch ${p.src}: ${f.statusText}`);const _=await f.arrayBuffer(),m=await l.decodeAudioData(_);if(!m||!m.sampleRate||!m.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const g=p.duration??m.duration,y=Hv({audioBuffer:m,startTime:p.startTime??0,duration:g,offset:p.offset??0,name:p.name||`Track ${d+1}`,fadeIn:p.fadeIn,fadeOut:p.fadeOut});if(isNaN(y.startSample)||isNaN(y.durationSamples)||isNaN(y.offsetSamples))throw console.error("Invalid clip values:",y),new Error(`Invalid clip values for ${p.src}`);return{...Yv({name:p.name||`Track ${d+1}`,clips:[y],muted:p.muted??!1,soloed:p.soloed??!1,volume:p.volume??1,pan:p.pan??0,color:p.color}),effects:p.effects}}),h=await Promise.all(u);a||(t(h),i(!1))}catch(l){if(!a){const u=l instanceof Error?l.message:"Unknown error loading audio";o(u),i(!1),console.error("Error loading audio tracks:",l)}}})(),()=>{a=!0}},[s]),{tracks:e,loading:n,error:r}}function Kv({tracks:s,onTracksChange:e,samplesPerPixel:t,sampleRate:n}){const i=S.useRef(null),r=S.useCallback(l=>{const{transform:u,active:h}=l;if(!h?.data?.current)return{...u,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:d,boundary:f}=h.data.current;if(f)return{...u,scaleX:1,scaleY:1};const _=s[p];if(!_)return{...u,scaleX:1,scaleY:1};const m=_.clips[d];if(!m)return{...u,scaleX:1,scaleY:1};const g=m.startSample/n,y=m.durationSamples/n,x=u.x*t/n;let w=g+x;const v=[..._.clips].sort((A,D)=>A.startSample-D.startSample),b=v.findIndex(A=>A===m);w=Math.max(0,w);const k=b>0?v[b-1]:null;if(k){const A=(k.startSample+k.durationSamples)/n;w=Math.max(w,A)}const T=b<v.length-1?v[b+1]:null;if(T){const A=w+y,D=T.startSample/n;A>D&&(w=D-y)}const I=(w-g)*n/t;return{...u,x:I,scaleX:1,scaleY:1}},[s,t,n]),o=S.useCallback(l=>{const{active:u}=l,{boundary:h}=u.data.current;if(!h){i.current=null;return}const{trackIndex:p,clipIndex:d}=u.data.current,_=s[p]?.clips[d];_&&(i.current={offsetSamples:_.offsetSamples,durationSamples:_.durationSamples,startSample:_.startSample})},[s]),a=S.useCallback(l=>{const{active:u,delta:h}=l,{boundary:p}=u.data.current;if(!p||!i.current)return;const{trackIndex:d,clipIndex:f}=u.data.current,_=h.x*t,m=Math.floor(.1*n),g=i.current,y=s.map((x,w)=>{if(w!==d)return x;const v=[...x.clips].sort((T,R)=>T.startSample-R.startSample),b=v.findIndex(T=>T===x.clips[f]),k=x.clips.map((T,R)=>{if(R!==f)return T;const I=Math.floor(T.audioBuffer.duration*n);if(p==="left"){let A=Math.floor(_);const D=-g.startSample;A<D&&(A=D);const M=-g.offsetSamples;A<M&&(A=M);const N=b>0?v[b-1]:null;if(N){const Z=N.startSample+N.durationSamples-g.startSample;A<Z&&(A=Z)}const q=g.durationSamples-m;A>q&&(A=q);const V=g.offsetSamples+A,j=g.durationSamples-A,G=g.startSample+A;return{...T,offsetSamples:V,durationSamples:j,startSample:G}}else{let A=Math.floor(g.durationSamples+_);A=Math.max(m,A),g.offsetSamples+A>I&&(A=I-g.offsetSamples);const D=b<v.length-1?v[b+1]:null;return D&&g.startSample+A>D.startSample&&(A=D.startSample-g.startSample,A=Math.max(m,A)),{...T,durationSamples:A}}});return{...x,clips:k}});e(y)},[s,e,t,n]),c=S.useCallback(l=>{const{active:u,delta:h}=l,{trackIndex:p,clipIndex:d,boundary:f}=u.data.current,_=h.x*t;if(f){i.current=null;return}const m=s.map((g,y)=>{if(y!==p)return g;const x=[...g.clips].sort((b,k)=>b.startSample-k.startSample),w=x.findIndex(b=>b===g.clips[d]),v=g.clips.map((b,k)=>{if(k!==d)return b;let T=Math.floor(b.startSample+_);T=Math.max(0,T);const R=w>0?x[w-1]:null;if(R){const A=R.startSample+R.durationSamples;T=Math.max(T,A)}const I=w<x.length-1?x[w+1]:null;return I&&T+b.durationSamples>I.startSample&&(T=I.startSample-b.durationSamples),{...b,startSample:T}});return{...g,clips:v}});e(m)},[s,e,t,n]);return{onDragStart:o,onDragMove:a,onDragEnd:c,collisionModifier:r}}const co=.01;function Qv({annotations:s,onAnnotationsChange:e,samplesPerPixel:t,sampleRate:n,duration:i,linkEndpoints:r}){const o=S.useRef(null),a=S.useCallback(u=>{const{active:h}=u,p=h.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const d=s[p.annotationIndex];d&&(o.current={start:d.start,end:d.end,annotationIndex:p.annotationIndex})},[s]),c=S.useCallback(u=>{const{active:h,delta:p}=u;if(!o.current)return;const d=h.data.current;if(!d)return;const{edge:f,annotationIndex:_}=d,m=o.current,g=p.x*t/n,y=f==="start"?m.start+g:m.end+g,x=Jv({annotationIndex:_,newTime:y,isDraggingStart:f==="start",annotations:s,duration:i,linkEndpoints:r});e(x)},[s,e,t,n,i,r]),l=S.useCallback(()=>{o.current=null},[]);return{onDragStart:a,onDragMove:c,onDragEnd:l}}function Jv({annotationIndex:s,newTime:e,isDraggingStart:t,annotations:n,duration:i,linkEndpoints:r}){const o=[...n],a=n[s];if(t){const c=Math.min(a.end-.1,Math.max(0,e)),l=c-a.start;if(o[s]={...a,start:c},r&&s>0){const u=o[s-1];Math.abs(u.end-a.start)<co?o[s-1]={...u,end:Math.max(u.start+.1,u.end+l)}:c<=u.end&&(o[s]={...o[s],start:u.end})}else!r&&s>0&&c<o[s-1].end&&(o[s-1]={...o[s-1],end:c})}else{const c=Math.max(a.start+.1,Math.min(e,i)),l=c-a.end;if(o[s]={...a,end:c},r&&s<o.length-1){const u=o[s+1];if(Math.abs(u.start-a.end)<co){const h=u.start+l;o[s+1]={...u,start:Math.min(u.end-.1,h)};let p=s+1;for(;p<o.length-1;){const d=o[p],f=o[p+1];if(Math.abs(f.start-d.end)<co){const _=d.end-n[p].end;o[p+1]={...f,start:Math.min(f.end-.1,f.start+_)},p++}else break}}else c>=u.start&&(o[s]={...o[s],end:u.start})}else if(!r&&s<o.length-1&&c>o[s+1].start){const u=o[s+1];o[s+1]={...u,start:c};let h=s+1;for(;h<o.length-1;){const p=o[h],d=o[h+1];if(p.end>d.start)o[h+1]={...d,start:p.end},h++;else break}}}return o}function ey(){return Z_(z_(vu,{activationConstraint:{distance:1}}))}const ty=s=>{const{tracks:e,onTracksChange:t,sampleRate:n}=s,{currentTimeRef:i}=At(),{selectedTrackId:r}=os(),o=S.useCallback((c,l,u)=>{const{sampleRate:h,samplesPerPixel:p}=s,d=e[c];if(!d)return!1;const f=d.clips[l];if(!f)return!1;const _=f.startSample/h,m=(f.startSample+f.durationSamples)/h;if(u<=_||u>=m)return console.warn("Split time is outside clip bounds"),!1;const g=Math.round(u*h),y=Math.floor(g/p),x=f.startSample+f.durationSamples,w=y*p,v=f.startSample,b=w-v,k=w,T=x-k,R=w-f.startSample,I=Ro({audioBuffer:f.audioBuffer,startSample:v,durationSamples:b,offsetSamples:f.offsetSamples,gain:f.gain,name:f.name?`${f.name} (1)`:void 0,color:f.color,fadeIn:f.fadeIn}),A=Ro({audioBuffer:f.audioBuffer,startSample:k,durationSamples:T,offsetSamples:f.offsetSamples+R,gain:f.gain,name:f.name?`${f.name} (2)`:void 0,color:f.color,fadeOut:f.fadeOut}),D=[...d.clips];D.splice(l,1,I,A);const M=[...e];return M[c]={...d,clips:D},t(M),!0},[e,t,s]);return{splitClipAtPlayhead:S.useCallback(()=>{if(!r)return console.log("No track selected - click a clip to select a track first"),!1;const c=e.findIndex(h=>h.id===r);if(c===-1)return console.warn("Selected track not found"),!1;const l=e[c],u=i.current??0;for(let h=0;h<l.clips.length;h++){const p=l.clips[h],d=p.startSample/n,f=(p.startSample+p.durationSamples)/n;if(u>d&&u<f)return console.log(`Splitting clip on track "${l.name}" at ${u}s`),o(c,h,u)}return console.log(`No clip found at playhead position on track "${l.name}"`),!1},[e,i,r,o,n]),splitClipAt:o}},sr=s=>{const{shortcuts:e,enabled:t=!0}=s,n=S.useCallback(i=>{if(!t)return;const r=i.target;if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)return;const o=e.find(a=>{const c=i.key.toLowerCase()===a.key.toLowerCase()||i.key===a.key,l=a.ctrlKey===void 0||i.ctrlKey===a.ctrlKey,u=a.shiftKey===void 0||i.shiftKey===a.shiftKey,h=a.metaKey===void 0||i.metaKey===a.metaKey,p=a.altKey===void 0||i.altKey===a.altKey;return c&&l&&u&&h&&p});o&&(o.preventDefault!==!1&&i.preventDefault(),o.action())},[e,t]);S.useEffect(()=>{if(t)return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[n,t])},sy=s=>{const e=[],t=typeof navigator<"u"&&navigator.platform.includes("Mac");return s.metaKey&&e.push(t?"Cmd":"Ctrl"),s.ctrlKey&&!s.metaKey&&e.push("Ctrl"),s.altKey&&e.push(t?"Option":"Alt"),s.shiftKey&&e.push("Shift"),e.push(s.key.toUpperCase()),e.join("+")},ny=(s={})=>{const{enabled:e=!0,additionalShortcuts:t=[],shortcuts:n}=s,{isPlaying:i}=At(),{setCurrentTime:r,play:o,pause:a,stop:c}=Qe(),{playoutRef:l}=wt(),u=S.useCallback(()=>{i?a():o()},[i,o,a]),h=S.useCallback(()=>{c()},[c]),p=S.useCallback(()=>{i&&l.current?(l.current.stop(),r(0),o(0)):r(0)},[i,l,r,o]),f=n??[...[{key:" ",action:u,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:h,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...t];return sr({shortcuts:f,enabled:e}),{rewindToStart:p,togglePlayPause:u,stopPlayback:h,shortcuts:f}},lo=.01,Vi=.01;function iy({annotations:s,activeAnnotationId:e,onAnnotationsChange:t,onActiveAnnotationChange:n,duration:i,linkEndpoints:r,continuousPlay:o=!1,enabled:a=!0,scrollContainerRef:c,samplesPerPixel:l,sampleRate:u,controlsWidth:h=0,onPlay:p}){const d=S.useMemo(()=>e?s.findIndex(R=>R.id===e):-1,[s,e]),f=S.useCallback(R=>{if(!c?.current||!l||!u)return;const I=s.find(B=>B.id===R);if(!I)return;const A=c.current,D=A.clientWidth,M=I.start*u/l+h,N=I.end*u/l+h,q=(M+N)/2,V=A.scrollLeft,j=V,G=V+D;if(M<j||N>G){const B=Math.max(0,q-D/2);A.scrollTo({left:B,behavior:"smooth"})}},[s,c,l,u,h]);S.useEffect(()=>{e&&c?.current&&l&&u&&f(e)},[e,f,c,l,u]);const _=S.useCallback(R=>{if(d<0)return;const I=s[d],A=Math.max(0,Math.min(I.end-.1,I.start+R)),D=A-I.start,M=[...s];if(M[d]={...I,start:A},r&&d>0){const N=M[d-1];Math.abs(N.end-I.start)<lo&&(M[d-1]={...N,end:Math.max(N.start+.1,N.end+D)})}else if(!r&&d>0){const N=M[d-1];A<N.end&&(M[d-1]={...N,end:A})}t(M)},[s,d,r,t]),m=S.useCallback(R=>{if(d<0)return;const I=s[d],A=Math.max(I.start+.1,Math.min(i,I.end+R)),D=A-I.end,M=[...s];if(M[d]={...I,end:A},r&&d<s.length-1){const N=M[d+1];if(Math.abs(N.start-I.end)<lo){const q=Math.min(N.end-.1,N.start+D);M[d+1]={...N,start:q};let V=d+1;for(;V<M.length-1;){const j=M[V],G=M[V+1];if(Math.abs(G.start-s[V].end)<lo){const B=j.end-s[V].end;M[V+1]={...G,start:Math.min(G.end-.1,G.start+B)},V++}else break}}}else if(!r&&d<s.length-1){const N=M[d+1];if(A>N.start){M[d+1]={...N,start:A};let q=d+1;for(;q<M.length-1;){const V=M[q],j=M[q+1];if(V.end>j.start)M[q+1]={...j,start:V.end},q++;else break}}}t(M)},[s,d,i,r,t]),g=S.useCallback(()=>{!n||s.length===0||(d<=0?n(s[s.length-1].id):n(s[d-1].id))},[s,d,n]),y=S.useCallback(()=>{!n||s.length===0||(d<0||d>=s.length-1?n(s[0].id):n(s[d+1].id))},[s,d,n]),x=S.useCallback(()=>{!n||s.length===0||n(s[0].id)},[s,n]),w=S.useCallback(()=>{!n||s.length===0||n(s[s.length-1].id)},[s,n]),v=S.useCallback(()=>{n&&n(null)},[n]),b=S.useCallback(()=>{if(d<0||!p)return;const R=s[d],I=o?void 0:R.end-R.start;p(R.start,I)},[s,d,o,p]),k=S.useMemo(()=>[{key:"[",action:()=>_(-Vi),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>_(Vi),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>m(-Vi),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>m(Vi),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:b,description:"Play selected annotation",preventDefault:!0}],[_,m,b]),T=S.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:x,description:"Select first annotation",preventDefault:!0},{key:"End",action:w,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:v,description:"Deselect annotation",preventDefault:!0}],[g,y,x,w,v]);return sr({shortcuts:k,enabled:a&&d>=0}),sr({shortcuts:T,enabled:a&&s.length>0&&!!n}),{moveStartBoundary:_,moveEndBoundary:m,selectPrevious:g,selectNext:y,selectFirst:x,selectLast:w,clearSelection:v,scrollToAnnotation:f,playActiveAnnotation:b}}function ry(s){const e=s.reduce((i,r)=>i+r.length,0),t=new Float32Array(e);let n=0;for(const i of s)t.set(i,n),n+=i.length;return t}function oy(s,e,t,n=1){const i=s.createBuffer(n,e.length,t),r=new Float32Array(e);return i.copyToChannel(r,0),i}function Jc(s,e,t=16){const n=Math.ceil(s.length/e),i=t===8?new Int8Array(n*2):new Int16Array(n*2),r=2**(t-1);for(let o=0;o<n;o++){const a=o*e,c=Math.min(a+e,s.length);let l=0,u=0;for(let h=a;h<c;h++){const p=s[h];p<l&&(l=p),p>u&&(u=p)}i[o*2]=Math.floor(l*r),i[o*2+1]=Math.floor(u*r)}return i}function ay(s,e,t,n,i=16){const r=2**(i-1),o=n%t;let a=0;if(o>0&&s.length>0){const u=t-o,h=Math.min(u,e.length);let p=s[s.length-2]/r,d=s[s.length-1]/r;for(let g=0;g<h;g++){const y=e[g];y<p&&(p=y),y>d&&(d=y)}const f=new(i===8?Int8Array:Int16Array)(s.length);f.set(s),f[s.length-2]=Math.floor(p*r),f[s.length-1]=Math.floor(d*r),a=h;const _=Jc(e.slice(a),t,i),m=new(i===8?Int8Array:Int16Array)(f.length+_.length);return m.set(f),m.set(_,f.length),m}const c=Jc(e.slice(a),t,i),l=new(i===8?Int8Array:Int16Array)(s.length+c.length);return l.set(s),l.set(c,s.length),l}function cy(s,e={}){const{channelCount:t=1,samplesPerPixel:n=1024}=e,[i,r]=S.useState(!1),[o,a]=S.useState(!1),[c,l]=S.useState(0),[u,h]=S.useState(new Int16Array(0)),[p,d]=S.useState(null),[f,_]=S.useState(null),[m,g]=S.useState(0),[y,x]=S.useState(0),w=16,v=S.useRef(!1),b=S.useRef(null),k=S.useRef(null),T=S.useRef([]),R=S.useRef(0),I=S.useRef(null),A=S.useRef(0),D=S.useRef(!1),M=S.useRef(!1),N=S.useCallback(async()=>{if(!v.current)try{const B=me(),Z=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:Jr&&Jr.tagName.toUpperCase()==="SCRIPT"&&Jr.src||new URL("index.js",document.baseURI).href).href;await B.addAudioWorkletModule(Z),v.current=!0}catch(B){throw console.error("Failed to load AudioWorklet module:",B),new Error("Failed to load recording processor")}},[]),q=S.useCallback(async()=>{if(!s){_(new Error("No microphone stream available"));return}try{_(null);const B=me();B.state==="suspended"&&await B.resume(),await N();const Z=B.createMediaStreamSource(s);k.current=Z;const X=B.createAudioWorkletNode("recording-processor");b.current=X,Z.connect(X),X.port.onmessage=pe=>{const{samples:ie}=pe.data;T.current.push(ie),R.current+=ie.length,h(Q=>ay(Q,ie,n,R.current-ie.length,w))},X.port.postMessage({command:"start",sampleRate:B.sampleRate,channelCount:t}),T.current=[],R.current=0,h(new Int16Array(0)),d(null),g(0),x(0),D.current=!0,M.current=!1,r(!0),a(!1),A.current=performance.now();const ee=()=>{if(D.current&&!M.current){const pe=(performance.now()-A.current)/1e3;l(pe),I.current=requestAnimationFrame(ee)}};ee()}catch(B){console.error("Failed to start recording:",B),_(B instanceof Error?B:new Error("Failed to start recording"))}},[s,t,n,N,i,o]),V=S.useCallback(async()=>{if(!i)return null;try{if(b.current){if(b.current.port.postMessage({command:"stop"}),k.current)try{k.current.disconnect(b.current)}catch{}b.current.disconnect()}I.current!==null&&(cancelAnimationFrame(I.current),I.current=null);const B=ry(T.current),X=me().rawContext,ee=oy(X,B,X.sampleRate,t);return d(ee),l(ee.duration),D.current=!1,M.current=!1,r(!1),a(!1),g(0),ee}catch(B){return console.error("Failed to stop recording:",B),_(B instanceof Error?B:new Error("Failed to stop recording")),null}},[i,t]),j=S.useCallback(()=>{i&&!o&&(I.current!==null&&(cancelAnimationFrame(I.current),I.current=null),M.current=!0,a(!0))},[i,o]),G=S.useCallback(()=>{if(i&&o){M.current=!1,a(!1),A.current=performance.now()-c*1e3;const B=()=>{if(D.current&&!M.current){const Z=(performance.now()-A.current)/1e3;l(Z),I.current=requestAnimationFrame(B)}};B()}},[i,o,c]);return S.useEffect(()=>()=>{if(b.current){if(b.current.port.postMessage({command:"stop"}),k.current)try{k.current.disconnect(b.current)}catch{}b.current.disconnect()}I.current!==null&&cancelAnimationFrame(I.current)},[]),{isRecording:i,isPaused:o,duration:c,peaks:u,audioBuffer:p,level:m,peakLevel:y,startRecording:q,stopRecording:V,pauseRecording:j,resumeRecording:G,error:f}}function ly(){const[s,e]=S.useState(null),[t,n]=S.useState([]),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[c,l]=S.useState(null),u=S.useCallback(async()=>{try{const f=(await navigator.mediaDevices.enumerateDevices()).filter(_=>_.kind==="audioinput").map(_=>({deviceId:_.deviceId,label:_.label||`Microphone ${_.deviceId.slice(0,8)}`,groupId:_.groupId}));n(f)}catch(d){console.error("Failed to enumerate devices:",d),l(d instanceof Error?d:new Error("Failed to enumerate devices"))}},[]),h=S.useCallback(async(d,f)=>{a(!0),l(null);try{s&&s.getTracks().forEach(y=>y.stop());const m={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...f,...d&&{deviceId:{exact:d}}},video:!1},g=await navigator.mediaDevices.getUserMedia(m);e(g),r(!0),await u()}catch(_){console.error("Failed to access microphone:",_),l(_ instanceof Error?_:new Error("Failed to access microphone")),r(!1)}finally{a(!1)}},[s,u]),p=S.useCallback(()=>{s&&(s.getTracks().forEach(d=>d.stop()),e(null),r(!1))},[s]);return S.useEffect(()=>(u(),()=>{s&&s.getTracks().forEach(d=>d.stop())}),[]),{stream:s,devices:t,hasPermission:i,isLoading:o,requestAccess:h,stopStream:p,error:c}}function uy(s,e={}){const{updateRate:t=60,smoothingTimeConstant:n=.8}=e,[i,r]=S.useState(0),[o,a]=S.useState(0),c=S.useRef(null),l=S.useRef(null),u=S.useRef(null),h=()=>a(0);return S.useEffect(()=>{if(!s){r(0),a(0);return}let p=!0;return(async()=>{if(!p)return;const f=me();if(f.state==="suspended"&&await f.resume(),!p)return;const _=new Vr({smoothing:n,context:f});c.current=_;const m=f.createMediaStreamSource(s);l.current=m,pt(m,_);const g=1e3/t;let y=0;const x=w=>{if(!(!p||!c.current)){if(w-y>=g){y=w;const v=c.current.getValue(),b=typeof v=="number"?v:v[0],k=Math.max(0,Math.min(1,(b+100)/100));r(k),a(T=>Math.max(T,k))}u.current=requestAnimationFrame(x)}};u.current=requestAnimationFrame(x)})(),()=>{if(p=!1,u.current&&(cancelAnimationFrame(u.current),u.current=null),l.current){try{l.current.disconnect()}catch{}l.current=null}c.current&&(c.current.dispose(),c.current=null)}},[s,n,t]),{level:i,peakLevel:o,resetPeak:h}}W.button`
1200
+ `,Zv=({annotations:s,filename:e="annotations.json",disabled:t=!1,className:n,children:i="Download JSON"})=>{const r=()=>{if(s.length===0)return;const o=s.map(h=>wv(h)),a=JSON.stringify(o,null,2),c=new Blob([a],{type:"application/json"}),l=URL.createObjectURL(c),u=document.createElement("a");u.href=l,u.download=e,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(l)};return E.jsx(zv,{onClick:r,disabled:t||s.length===0,className:n,title:s.length===0?"No annotations to download":"Download the annotations as JSON",children:i})};function Nu(){const[s,e]=S.useState("hh:mm:ss.uuu");return{timeFormat:s,setTimeFormat:e,formatTime:i=>rn(i,s),parseTime:i=>Du(i,s)}}const Gv=[256,512,1024,2048,4096,8192];function Fu({initialSamplesPerPixel:s,zoomLevels:e=Gv}){const[t,n]=S.useState(()=>{const l=e.indexOf(s);return l!==-1?l:Math.floor(e.length/2)}),i=e[t],r=t>0,o=t<e.length-1,a=S.useCallback(()=>{n(l=>Math.max(0,l-1))},[]),c=S.useCallback(()=>{n(l=>Math.min(e.length-1,l+1))},[e.length]);return{samplesPerPixel:i,zoomIn:a,zoomOut:c,canZoomIn:r,canZoomOut:o}}function Vu({playoutRef:s,initialVolume:e=1,onVolumeChange:t}){const[n,i]=S.useState(e),r=S.useCallback(o=>{i(o),s.current&&s.current.setMasterGain(o),t?.(o)},[s,t]);return{masterVolume:n,setMasterVolume:r}}const Xv=(s=256)=>{const e=S.useRef(null),t=S.useCallback((n,i,r)=>{const o=new Ys("fft",s);return n.connect(o),n.connect(i),e.current=o,function(){o.dispose(),e.current=null}},[s]);return{analyserRef:e,masterEffects:t}};function Ro(s){const{audioBuffer:e,startSample:t,durationSamples:n=e.length,offsetSamples:i=0,gain:r=1,name:o,color:a,fadeIn:c,fadeOut:l}=s;return{id:Pu(),audioBuffer:e,startSample:t,durationSamples:n,offsetSamples:i,gain:r,name:o,color:a,fadeIn:c,fadeOut:l}}function Hv(s){const{audioBuffer:e,startTime:t,duration:n=e.duration,offset:i=0,gain:r=1,name:o,color:a,fadeIn:c,fadeOut:l}=s,u=e.sampleRate;return Ro({audioBuffer:e,startSample:Math.round(t*u),durationSamples:Math.round(n*u),offsetSamples:Math.round(i*u),gain:r,name:o,color:a,fadeIn:c,fadeOut:l})}function Yv(s){const{name:e,clips:t=[],muted:n=!1,soloed:i=!1,volume:r=1,pan:o=0,color:a,height:c}=s;return{id:Pu(),name:e,clips:t,muted:n,soloed:i,volume:r,pan:o,color:a,height:c}}function Pu(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function Uv(s){const[e,t]=S.useState([]),[n,i]=S.useState(!0),[r,o]=S.useState(null);return S.useEffect(()=>{if(s.length===0){t([]),i(!1);return}let a=!1;return(async()=>{try{i(!0),o(null);const l=fe().rawContext,u=s.map(async(p,d)=>{const f=await fetch(p.src);if(!f.ok)throw new Error(`Failed to fetch ${p.src}: ${f.statusText}`);const _=await f.arrayBuffer(),m=await l.decodeAudioData(_);if(!m||!m.sampleRate||!m.duration)throw new Error(`Invalid audio buffer for ${p.src}`);const g=p.duration??m.duration,y=Hv({audioBuffer:m,startTime:p.startTime??0,duration:g,offset:p.offset??0,name:p.name||`Track ${d+1}`,fadeIn:p.fadeIn,fadeOut:p.fadeOut});if(isNaN(y.startSample)||isNaN(y.durationSamples)||isNaN(y.offsetSamples))throw console.error("Invalid clip values:",y),new Error(`Invalid clip values for ${p.src}`);return{...Yv({name:p.name||`Track ${d+1}`,clips:[y],muted:p.muted??!1,soloed:p.soloed??!1,volume:p.volume??1,pan:p.pan??0,color:p.color}),effects:p.effects}}),h=await Promise.all(u);a||(t(h),i(!1))}catch(l){if(!a){const u=l instanceof Error?l.message:"Unknown error loading audio";o(u),i(!1),console.error("Error loading audio tracks:",l)}}})(),()=>{a=!0}},[s]),{tracks:e,loading:n,error:r}}function Kv({tracks:s,onTracksChange:e,samplesPerPixel:t,sampleRate:n}){const i=S.useRef(null),r=S.useCallback(l=>{const{transform:u,active:h}=l;if(!h?.data?.current)return{...u,scaleX:1,scaleY:1};const{trackIndex:p,clipIndex:d,boundary:f}=h.data.current;if(f)return{...u,scaleX:1,scaleY:1};const _=s[p];if(!_)return{...u,scaleX:1,scaleY:1};const m=_.clips[d];if(!m)return{...u,scaleX:1,scaleY:1};const g=m.startSample/n,y=m.durationSamples/n,x=u.x*t/n;let w=g+x;const v=[..._.clips].sort((A,D)=>A.startSample-D.startSample),b=v.findIndex(A=>A===m);w=Math.max(0,w);const k=b>0?v[b-1]:null;if(k){const A=(k.startSample+k.durationSamples)/n;w=Math.max(w,A)}const T=b<v.length-1?v[b+1]:null;if(T){const A=w+y,D=T.startSample/n;A>D&&(w=D-y)}const I=(w-g)*n/t;return{...u,x:I,scaleX:1,scaleY:1}},[s,t,n]),o=S.useCallback(l=>{const{active:u}=l,{boundary:h}=u.data.current;if(!h){i.current=null;return}const{trackIndex:p,clipIndex:d}=u.data.current,_=s[p]?.clips[d];_&&(i.current={offsetSamples:_.offsetSamples,durationSamples:_.durationSamples,startSample:_.startSample})},[s]),a=S.useCallback(l=>{const{active:u,delta:h}=l,{boundary:p}=u.data.current;if(!p||!i.current)return;const{trackIndex:d,clipIndex:f}=u.data.current,_=h.x*t,m=Math.floor(.1*n),g=i.current,y=s.map((x,w)=>{if(w!==d)return x;const v=[...x.clips].sort((T,R)=>T.startSample-R.startSample),b=v.findIndex(T=>T===x.clips[f]),k=x.clips.map((T,R)=>{if(R!==f)return T;const I=Math.floor(T.audioBuffer.duration*n);if(p==="left"){let A=Math.floor(_);const D=-g.startSample;A<D&&(A=D);const O=-g.offsetSamples;A<O&&(A=O);const N=b>0?v[b-1]:null;if(N){const G=N.startSample+N.durationSamples-g.startSample;A<G&&(A=G)}const q=g.durationSamples-m;A>q&&(A=q);const V=g.offsetSamples+A,j=g.durationSamples-A,X=g.startSample+A;return{...T,offsetSamples:V,durationSamples:j,startSample:X}}else{let A=Math.floor(g.durationSamples+_);A=Math.max(m,A),g.offsetSamples+A>I&&(A=I-g.offsetSamples);const D=b<v.length-1?v[b+1]:null;return D&&g.startSample+A>D.startSample&&(A=D.startSample-g.startSample,A=Math.max(m,A)),{...T,durationSamples:A}}});return{...x,clips:k}});e(y)},[s,e,t,n]),c=S.useCallback(l=>{const{active:u,delta:h}=l,{trackIndex:p,clipIndex:d,boundary:f}=u.data.current,_=h.x*t;if(f){i.current=null;return}const m=s.map((g,y)=>{if(y!==p)return g;const x=[...g.clips].sort((b,k)=>b.startSample-k.startSample),w=x.findIndex(b=>b===g.clips[d]),v=g.clips.map((b,k)=>{if(k!==d)return b;let T=Math.floor(b.startSample+_);T=Math.max(0,T);const R=w>0?x[w-1]:null;if(R){const A=R.startSample+R.durationSamples;T=Math.max(T,A)}const I=w<x.length-1?x[w+1]:null;return I&&T+b.durationSamples>I.startSample&&(T=I.startSample-b.durationSamples),{...b,startSample:T}});return{...g,clips:v}});e(m)},[s,e,t,n]);return{onDragStart:o,onDragMove:a,onDragEnd:c,collisionModifier:r}}const co=.01;function Qv({annotations:s,onAnnotationsChange:e,samplesPerPixel:t,sampleRate:n,duration:i,linkEndpoints:r}){const o=S.useRef(null),a=S.useCallback(u=>{const{active:h}=u,p=h.data.current;if(!p||p.annotationIndex===void 0){o.current=null;return}const d=s[p.annotationIndex];d&&(o.current={start:d.start,end:d.end,annotationIndex:p.annotationIndex})},[s]),c=S.useCallback(u=>{const{active:h,delta:p}=u;if(!o.current)return;const d=h.data.current;if(!d)return;const{edge:f,annotationIndex:_}=d,m=o.current,g=p.x*t/n,y=f==="start"?m.start+g:m.end+g,x=Jv({annotationIndex:_,newTime:y,isDraggingStart:f==="start",annotations:s,duration:i,linkEndpoints:r});e(x)},[s,e,t,n,i,r]),l=S.useCallback(()=>{o.current=null},[]);return{onDragStart:a,onDragMove:c,onDragEnd:l}}function Jv({annotationIndex:s,newTime:e,isDraggingStart:t,annotations:n,duration:i,linkEndpoints:r}){const o=[...n],a=n[s];if(t){const c=Math.min(a.end-.1,Math.max(0,e)),l=c-a.start;if(o[s]={...a,start:c},r&&s>0){const u=o[s-1];Math.abs(u.end-a.start)<co?o[s-1]={...u,end:Math.max(u.start+.1,u.end+l)}:c<=u.end&&(o[s]={...o[s],start:u.end})}else!r&&s>0&&c<o[s-1].end&&(o[s-1]={...o[s-1],end:c})}else{const c=Math.max(a.start+.1,Math.min(e,i)),l=c-a.end;if(o[s]={...a,end:c},r&&s<o.length-1){const u=o[s+1];if(Math.abs(u.start-a.end)<co){const h=u.start+l;o[s+1]={...u,start:Math.min(u.end-.1,h)};let p=s+1;for(;p<o.length-1;){const d=o[p],f=o[p+1];if(Math.abs(f.start-d.end)<co){const _=d.end-n[p].end;o[p+1]={...f,start:Math.min(f.end-.1,f.start+_)},p++}else break}}else c>=u.start&&(o[s]={...o[s],end:u.start})}else if(!r&&s<o.length-1&&c>o[s+1].start){const u=o[s+1];o[s+1]={...u,start:c};let h=s+1;for(;h<o.length-1;){const p=o[h],d=o[h+1];if(p.end>d.start)o[h+1]={...d,start:p.end},h++;else break}}}return o}function ey(){return Z_(z_(vu,{activationConstraint:{distance:1}}))}const ty=s=>{const{tracks:e,onTracksChange:t,sampleRate:n}=s,{currentTimeRef:i}=At(),{selectedTrackId:r}=rs(),o=S.useCallback((c,l,u)=>{const{sampleRate:h,samplesPerPixel:p}=s,d=e[c];if(!d)return!1;const f=d.clips[l];if(!f)return!1;const _=f.startSample/h,m=(f.startSample+f.durationSamples)/h;if(u<=_||u>=m)return console.warn("Split time is outside clip bounds"),!1;const g=Math.round(u*h),y=Math.floor(g/p),x=f.startSample+f.durationSamples,w=y*p,v=f.startSample,b=w-v,k=w,T=x-k,R=w-f.startSample,I=Ro({audioBuffer:f.audioBuffer,startSample:v,durationSamples:b,offsetSamples:f.offsetSamples,gain:f.gain,name:f.name?`${f.name} (1)`:void 0,color:f.color,fadeIn:f.fadeIn}),A=Ro({audioBuffer:f.audioBuffer,startSample:k,durationSamples:T,offsetSamples:f.offsetSamples+R,gain:f.gain,name:f.name?`${f.name} (2)`:void 0,color:f.color,fadeOut:f.fadeOut}),D=[...d.clips];D.splice(l,1,I,A);const O=[...e];return O[c]={...d,clips:D},t(O),!0},[e,t,s]);return{splitClipAtPlayhead:S.useCallback(()=>{if(!r)return console.log("No track selected - click a clip to select a track first"),!1;const c=e.findIndex(h=>h.id===r);if(c===-1)return console.warn("Selected track not found"),!1;const l=e[c],u=i.current??0;for(let h=0;h<l.clips.length;h++){const p=l.clips[h],d=p.startSample/n,f=(p.startSample+p.durationSamples)/n;if(u>d&&u<f)return console.log(`Splitting clip on track "${l.name}" at ${u}s`),o(c,h,u)}return console.log(`No clip found at playhead position on track "${l.name}"`),!1},[e,i,r,o,n]),splitClipAt:o}},sr=s=>{const{shortcuts:e,enabled:t=!0}=s,n=S.useCallback(i=>{if(!t)return;const r=i.target;if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)return;const o=e.find(a=>{const c=i.key.toLowerCase()===a.key.toLowerCase()||i.key===a.key,l=a.ctrlKey===void 0||i.ctrlKey===a.ctrlKey,u=a.shiftKey===void 0||i.shiftKey===a.shiftKey,h=a.metaKey===void 0||i.metaKey===a.metaKey,p=a.altKey===void 0||i.altKey===a.altKey;return c&&l&&u&&h&&p});o&&(o.preventDefault!==!1&&i.preventDefault(),o.action())},[e,t]);S.useEffect(()=>{if(t)return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[n,t])},sy=s=>{const e=[],t=typeof navigator<"u"&&navigator.platform.includes("Mac");return s.metaKey&&e.push(t?"Cmd":"Ctrl"),s.ctrlKey&&!s.metaKey&&e.push("Ctrl"),s.altKey&&e.push(t?"Option":"Alt"),s.shiftKey&&e.push("Shift"),e.push(s.key.toUpperCase()),e.join("+")},ny=(s={})=>{const{enabled:e=!0,additionalShortcuts:t=[],shortcuts:n}=s,{isPlaying:i}=At(),{setCurrentTime:r,play:o,pause:a,stop:c}=Ue(),{playoutRef:l}=wt(),u=S.useCallback(()=>{i?a():o()},[i,o,a]),h=S.useCallback(()=>{c()},[c]),p=S.useCallback(()=>{i&&l.current?(l.current.stop(),r(0),o(0)):r(0)},[i,l,r,o]),f=n??[...[{key:" ",action:u,description:"Play/Pause",preventDefault:!0},{key:"Escape",action:h,description:"Stop",preventDefault:!0},{key:"0",action:p,description:"Rewind to start",preventDefault:!0}],...t];return sr({shortcuts:f,enabled:e}),{rewindToStart:p,togglePlayPause:u,stopPlayback:h,shortcuts:f}},lo=.01,Vi=.01;function iy({annotations:s,activeAnnotationId:e,onAnnotationsChange:t,onActiveAnnotationChange:n,duration:i,linkEndpoints:r,continuousPlay:o=!1,enabled:a=!0,scrollContainerRef:c,samplesPerPixel:l,sampleRate:u,controlsWidth:h=0,onPlay:p}){const d=S.useMemo(()=>e?s.findIndex(R=>R.id===e):-1,[s,e]),f=S.useCallback(R=>{if(!c?.current||!l||!u)return;const I=s.find(B=>B.id===R);if(!I)return;const A=c.current,D=A.clientWidth,O=I.start*u/l+h,N=I.end*u/l+h,q=(O+N)/2,V=A.scrollLeft,j=V,X=V+D;if(O<j||N>X){const B=Math.max(0,q-D/2);A.scrollTo({left:B,behavior:"smooth"})}},[s,c,l,u,h]);S.useEffect(()=>{e&&c?.current&&l&&u&&f(e)},[e,f,c,l,u]);const _=S.useCallback(R=>{if(d<0)return;const I=s[d],A=Math.max(0,Math.min(I.end-.1,I.start+R)),D=A-I.start,O=[...s];if(O[d]={...I,start:A},r&&d>0){const N=O[d-1];Math.abs(N.end-I.start)<lo&&(O[d-1]={...N,end:Math.max(N.start+.1,N.end+D)})}else if(!r&&d>0){const N=O[d-1];A<N.end&&(O[d-1]={...N,end:A})}t(O)},[s,d,r,t]),m=S.useCallback(R=>{if(d<0)return;const I=s[d],A=Math.max(I.start+.1,Math.min(i,I.end+R)),D=A-I.end,O=[...s];if(O[d]={...I,end:A},r&&d<s.length-1){const N=O[d+1];if(Math.abs(N.start-I.end)<lo){const q=Math.min(N.end-.1,N.start+D);O[d+1]={...N,start:q};let V=d+1;for(;V<O.length-1;){const j=O[V],X=O[V+1];if(Math.abs(X.start-s[V].end)<lo){const B=j.end-s[V].end;O[V+1]={...X,start:Math.min(X.end-.1,X.start+B)},V++}else break}}}else if(!r&&d<s.length-1){const N=O[d+1];if(A>N.start){O[d+1]={...N,start:A};let q=d+1;for(;q<O.length-1;){const V=O[q],j=O[q+1];if(V.end>j.start)O[q+1]={...j,start:V.end},q++;else break}}}t(O)},[s,d,i,r,t]),g=S.useCallback(()=>{!n||s.length===0||(d<=0?n(s[s.length-1].id):n(s[d-1].id))},[s,d,n]),y=S.useCallback(()=>{!n||s.length===0||(d<0||d>=s.length-1?n(s[0].id):n(s[d+1].id))},[s,d,n]),x=S.useCallback(()=>{!n||s.length===0||n(s[0].id)},[s,n]),w=S.useCallback(()=>{!n||s.length===0||n(s[s.length-1].id)},[s,n]),v=S.useCallback(()=>{n&&n(null)},[n]),b=S.useCallback(()=>{if(d<0||!p)return;const R=s[d],I=o?void 0:R.end-R.start;p(R.start,I)},[s,d,o,p]),k=S.useMemo(()=>[{key:"[",action:()=>_(-Vi),description:"Move annotation start earlier",preventDefault:!0},{key:"]",action:()=>_(Vi),description:"Move annotation start later",preventDefault:!0},{key:"{",shiftKey:!0,action:()=>m(-Vi),description:"Move annotation end earlier",preventDefault:!0},{key:"}",shiftKey:!0,action:()=>m(Vi),description:"Move annotation end later",preventDefault:!0},{key:"Enter",action:b,description:"Play selected annotation",preventDefault:!0}],[_,m,b]),T=S.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:x,description:"Select first annotation",preventDefault:!0},{key:"End",action:w,description:"Select last annotation",preventDefault:!0},{key:"Escape",action:v,description:"Deselect annotation",preventDefault:!0}],[g,y,x,w,v]);return sr({shortcuts:k,enabled:a&&d>=0}),sr({shortcuts:T,enabled:a&&s.length>0&&!!n}),{moveStartBoundary:_,moveEndBoundary:m,selectPrevious:g,selectNext:y,selectFirst:x,selectLast:w,clearSelection:v,scrollToAnnotation:f,playActiveAnnotation:b}}function ry(s){const e=s.reduce((i,r)=>i+r.length,0),t=new Float32Array(e);let n=0;for(const i of s)t.set(i,n),n+=i.length;return t}function oy(s,e,t,n=1){const i=s.createBuffer(n,e.length,t),r=new Float32Array(e);return i.copyToChannel(r,0),i}function Jc(s,e,t=16){const n=Math.ceil(s.length/e),i=t===8?new Int8Array(n*2):new Int16Array(n*2),r=2**(t-1);for(let o=0;o<n;o++){const a=o*e,c=Math.min(a+e,s.length);let l=0,u=0;for(let h=a;h<c;h++){const p=s[h];p<l&&(l=p),p>u&&(u=p)}i[o*2]=Math.floor(l*r),i[o*2+1]=Math.floor(u*r)}return i}function ay(s,e,t,n,i=16){const r=2**(i-1),o=n%t;let a=0;if(o>0&&s.length>0){const u=t-o,h=Math.min(u,e.length);let p=s[s.length-2]/r,d=s[s.length-1]/r;for(let g=0;g<h;g++){const y=e[g];y<p&&(p=y),y>d&&(d=y)}const f=new(i===8?Int8Array:Int16Array)(s.length);f.set(s),f[s.length-2]=Math.floor(p*r),f[s.length-1]=Math.floor(d*r),a=h;const _=Jc(e.slice(a),t,i),m=new(i===8?Int8Array:Int16Array)(f.length+_.length);return m.set(f),m.set(_,f.length),m}const c=Jc(e.slice(a),t,i),l=new(i===8?Int8Array:Int16Array)(s.length+c.length);return l.set(s),l.set(c,s.length),l}function cy(s,e={}){const{channelCount:t=1,samplesPerPixel:n=1024}=e,[i,r]=S.useState(!1),[o,a]=S.useState(!1),[c,l]=S.useState(0),[u,h]=S.useState(new Int16Array(0)),[p,d]=S.useState(null),[f,_]=S.useState(null),[m,g]=S.useState(0),[y,x]=S.useState(0),w=16,v=S.useRef(!1),b=S.useRef(null),k=S.useRef(null),T=S.useRef([]),R=S.useRef(0),I=S.useRef(null),A=S.useRef(0),D=S.useRef(!1),O=S.useRef(!1),N=S.useCallback(async()=>{if(!v.current)try{const B=fe(),G=new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw",typeof document>"u"?require("url").pathToFileURL(__filename).href:Jr&&Jr.tagName.toUpperCase()==="SCRIPT"&&Jr.src||new URL("index.js",document.baseURI).href).href;await B.addAudioWorkletModule(G),v.current=!0}catch(B){throw console.error("Failed to load AudioWorklet module:",B),new Error("Failed to load recording processor")}},[]),q=S.useCallback(async()=>{if(!s){_(new Error("No microphone stream available"));return}try{_(null);const B=fe();B.state==="suspended"&&await B.resume(),await N();const G=B.createMediaStreamSource(s);k.current=G;const H=B.createAudioWorkletNode("recording-processor");b.current=H,G.connect(H),H.port.onmessage=de=>{const{samples:ie}=de.data;T.current.push(ie),R.current+=ie.length,h(Q=>ay(Q,ie,n,R.current-ie.length,w))},H.port.postMessage({command:"start",sampleRate:B.sampleRate,channelCount:t}),T.current=[],R.current=0,h(new Int16Array(0)),d(null),g(0),x(0),D.current=!0,O.current=!1,r(!0),a(!1),A.current=performance.now();const te=()=>{if(D.current&&!O.current){const de=(performance.now()-A.current)/1e3;l(de),I.current=requestAnimationFrame(te)}};te()}catch(B){console.error("Failed to start recording:",B),_(B instanceof Error?B:new Error("Failed to start recording"))}},[s,t,n,N,i,o]),V=S.useCallback(async()=>{if(!i)return null;try{if(b.current){if(b.current.port.postMessage({command:"stop"}),k.current)try{k.current.disconnect(b.current)}catch{}b.current.disconnect()}I.current!==null&&(cancelAnimationFrame(I.current),I.current=null);const B=ry(T.current),H=fe().rawContext,te=oy(H,B,H.sampleRate,t);return d(te),l(te.duration),D.current=!1,O.current=!1,r(!1),a(!1),g(0),te}catch(B){return console.error("Failed to stop recording:",B),_(B instanceof Error?B:new Error("Failed to stop recording")),null}},[i,t]),j=S.useCallback(()=>{i&&!o&&(I.current!==null&&(cancelAnimationFrame(I.current),I.current=null),O.current=!0,a(!0))},[i,o]),X=S.useCallback(()=>{if(i&&o){O.current=!1,a(!1),A.current=performance.now()-c*1e3;const B=()=>{if(D.current&&!O.current){const G=(performance.now()-A.current)/1e3;l(G),I.current=requestAnimationFrame(B)}};B()}},[i,o,c]);return S.useEffect(()=>()=>{if(b.current){if(b.current.port.postMessage({command:"stop"}),k.current)try{k.current.disconnect(b.current)}catch{}b.current.disconnect()}I.current!==null&&cancelAnimationFrame(I.current)},[]),{isRecording:i,isPaused:o,duration:c,peaks:u,audioBuffer:p,level:m,peakLevel:y,startRecording:q,stopRecording:V,pauseRecording:j,resumeRecording:X,error:f}}function ly(){const[s,e]=S.useState(null),[t,n]=S.useState([]),[i,r]=S.useState(!1),[o,a]=S.useState(!1),[c,l]=S.useState(null),u=S.useCallback(async()=>{try{const f=(await navigator.mediaDevices.enumerateDevices()).filter(_=>_.kind==="audioinput").map(_=>({deviceId:_.deviceId,label:_.label||`Microphone ${_.deviceId.slice(0,8)}`,groupId:_.groupId}));n(f)}catch(d){console.error("Failed to enumerate devices:",d),l(d instanceof Error?d:new Error("Failed to enumerate devices"))}},[]),h=S.useCallback(async(d,f)=>{a(!0),l(null);try{s&&s.getTracks().forEach(y=>y.stop());const m={audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,latency:0,...f,...d&&{deviceId:{exact:d}}},video:!1},g=await navigator.mediaDevices.getUserMedia(m);e(g),r(!0),await u()}catch(_){console.error("Failed to access microphone:",_),l(_ instanceof Error?_:new Error("Failed to access microphone")),r(!1)}finally{a(!1)}},[s,u]),p=S.useCallback(()=>{s&&(s.getTracks().forEach(d=>d.stop()),e(null),r(!1))},[s]);return S.useEffect(()=>(u(),()=>{s&&s.getTracks().forEach(d=>d.stop())}),[]),{stream:s,devices:t,hasPermission:i,isLoading:o,requestAccess:h,stopStream:p,error:c}}function uy(s,e={}){const{updateRate:t=60,smoothingTimeConstant:n=.8}=e,[i,r]=S.useState(0),[o,a]=S.useState(0),c=S.useRef(null),l=S.useRef(null),u=S.useRef(null),h=()=>a(0);return S.useEffect(()=>{if(!s){r(0),a(0);return}let p=!0;return(async()=>{if(!p)return;const f=fe();if(f.state==="suspended"&&await f.resume(),!p)return;const _=new Vr({smoothing:n,context:f});c.current=_;const m=f.createMediaStreamSource(s);l.current=m,dt(m,_);const g=1e3/t;let y=0;const x=w=>{if(!(!p||!c.current)){if(w-y>=g){y=w;const v=c.current.getValue(),b=typeof v=="number"?v:v[0],k=Math.max(0,Math.min(1,(b+100)/100));r(k),a(T=>Math.max(T,k))}u.current=requestAnimationFrame(x)}};u.current=requestAnimationFrame(x)})(),()=>{if(p=!1,u.current&&(cancelAnimationFrame(u.current),u.current=null),l.current){try{l.current.disconnect()}catch{}l.current=null}c.current&&(c.current.dispose(),c.current=null)}},[s,n,t]),{level:i,peakLevel:o,resetPeak:h}}P.button`
1201
1201
  padding: 0.5rem 1rem;
1202
1202
  font-size: 0.875rem;
1203
1203
  font-weight: 500;
@@ -1227,7 +1227,7 @@ React keys must be passed directly to JSX without using spread:
1227
1227
  outline: none;
1228
1228
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
1229
1229
  }
1230
- `;W.span`
1230
+ `;P.span`
1231
1231
  display: inline-block;
1232
1232
  width: 8px;
1233
1233
  height: 8px;
@@ -1245,13 +1245,13 @@ React keys must be passed directly to JSX without using spread:
1245
1245
  opacity: 0.3;
1246
1246
  }
1247
1247
  }
1248
- `;W(Ba)`
1248
+ `;P(Ba)`
1249
1249
  min-width: 200px;
1250
- `;W(xu)`
1250
+ `;P(xu)`
1251
1251
  display: flex;
1252
1252
  flex-direction: column;
1253
1253
  gap: 0.25rem;
1254
- `;W.div`
1254
+ `;P.div`
1255
1255
  display: flex;
1256
1256
  align-items: center;
1257
1257
  gap: 0.75rem;
@@ -1259,7 +1259,7 @@ React keys must be passed directly to JSX without using spread:
1259
1259
  background: ${s=>s.$isRecording?"#fff3cd":"transparent"};
1260
1260
  border-radius: 0.25rem;
1261
1261
  transition: background 0.2s ease-in-out;
1262
- `;W.div`
1262
+ `;P.div`
1263
1263
  width: 12px;
1264
1264
  height: 12px;
1265
1265
  border-radius: 50%;
@@ -1279,18 +1279,18 @@ React keys must be passed directly to JSX without using spread:
1279
1279
  }
1280
1280
  }
1281
1281
  `}
1282
- `;W.span`
1282
+ `;P.span`
1283
1283
  font-family: 'Courier New', Monaco, monospace;
1284
1284
  font-size: 1rem;
1285
1285
  font-weight: 600;
1286
1286
  color: #495057;
1287
1287
  min-width: 70px;
1288
- `;W.span`
1288
+ `;P.span`
1289
1289
  font-size: 0.75rem;
1290
1290
  font-weight: 500;
1291
1291
  color: ${s=>s.$isPaused?"#ffc107":"#dc3545"};
1292
1292
  text-transform: uppercase;
1293
- `;var hy=W.div`
1293
+ `;var hy=P.div`
1294
1294
  position: relative;
1295
1295
  width: ${s=>s.$width}px;
1296
1296
  height: ${s=>s.$height}px;
@@ -1298,39 +1298,39 @@ React keys must be passed directly to JSX without using spread:
1298
1298
  border-radius: 4px;
1299
1299
  overflow: hidden;
1300
1300
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
1301
- `,dy=s=>s<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":s<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",py=W.div.attrs(s=>({style:{width:`${s.$level*100}%`,height:`${s.$height}px`,background:dy(s.$level),boxShadow:s.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1301
+ `,dy=s=>s<.6?"linear-gradient(90deg, #27ae60, #2ecc71)":s<.85?"linear-gradient(90deg, #f39c12, #f1c40f)":"linear-gradient(90deg, #c0392b, #e74c3c)",py=P.div.attrs(s=>({style:{width:`${s.$level*100}%`,height:`${s.$height}px`,background:dy(s.$level),boxShadow:s.$level>.01?"0 0 8px rgba(255, 255, 255, 0.3)":"none"}}))`
1302
1302
  position: absolute;
1303
1303
  left: 0;
1304
1304
  top: 0;
1305
1305
  transition: width 0.05s ease-out, background 0.1s ease-out;
1306
- `,fy=W.div.attrs(s=>({style:{left:`${s.$peakLevel*100}%`,height:`${s.$height}px`}}))`
1306
+ `,fy=P.div.attrs(s=>({style:{left:`${s.$peakLevel*100}%`,height:`${s.$height}px`}}))`
1307
1307
  position: absolute;
1308
1308
  top: 0;
1309
1309
  width: 2px;
1310
1310
  background: #ecf0f1;
1311
1311
  box-shadow: 0 0 4px rgba(236, 240, 241, 0.8);
1312
1312
  transition: left 0.1s ease-out;
1313
- `,my=W.div`
1313
+ `,my=P.div`
1314
1314
  position: absolute;
1315
1315
  top: 0;
1316
1316
  left: 0;
1317
1317
  width: 100%;
1318
1318
  height: ${s=>s.$height}px;
1319
1319
  pointer-events: none;
1320
- `,el=W.div`
1320
+ `,el=P.div`
1321
1321
  position: absolute;
1322
1322
  left: ${s=>s.$position}%;
1323
1323
  top: 0;
1324
1324
  width: 1px;
1325
1325
  height: ${s=>s.$height}px;
1326
1326
  background: rgba(255, 255, 255, 0.2);
1327
- `,gy=({level:s,peakLevel:e,width:t=200,height:n=20,className:i})=>{const r=Math.max(0,Math.min(1,s)),o=e!==void 0?Math.max(0,Math.min(1,e)):0;return E.jsxs(hy,{$width:t,$height:n,className:i,children:[E.jsx(py,{$level:r,$height:n}),e!==void 0&&o>0&&E.jsx(fy,{$peakLevel:o,$height:n}),E.jsxs(my,{$height:n,children:[E.jsx(el,{$position:60,$height:n}),E.jsx(el,{$position:85,$height:n})]})]})};S.memo(gy);function _y(s,e,t,n={}){const{currentTime:i=0,audioConstraints:r,...o}=n,[a,c]=S.useState(!1),[l,u]=S.useState(null),{stream:h,devices:p,hasPermission:d,requestAccess:f,error:_}=ly(),{level:m,peakLevel:g}=uy(h),{isRecording:y,isPaused:x,duration:w,peaks:v,startRecording:b,stopRecording:k,pauseRecording:T,resumeRecording:R,error:I}=cy(h,o),A=S.useCallback(async()=>{t&&(a||(await so(),c(!0)),await b())},[t,a,b]),D=S.useCallback(async()=>{const q=await k();if(q&&t){const V=s.findIndex(pe=>pe.id===t);if(V===-1)return;const j=s[V],G=Math.floor(i*q.sampleRate);let B=0;if(j.clips.length>0){const pe=j.clips.map(ie=>ie.startSample+ie.durationSamples);B=Math.max(...pe)}const Z=Math.max(G,B),X={id:`clip-${Date.now()}`,audioBuffer:q,startSample:Z,durationSamples:q.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},ee=s.map((pe,ie)=>ie===V?{...pe,clips:[...pe.clips,X]}:pe);e(ee)}},[t,s,e,i,k]);S.useEffect(()=>{d&&p.length>0&&l===null&&u(p[0].deviceId)},[d,p.length]);const M=S.useCallback(async()=>{await f(void 0,r),await so(),c(!0)},[f,r]),N=S.useCallback(async q=>{u(q),await f(q,r),await so(),c(!0)},[f,r]);return{isRecording:y,isPaused:x,duration:w,level:m,peakLevel:g,error:_||I,stream:h,devices:p,hasPermission:d,selectedDevice:l,startRecording:A,stopRecording:D,pauseRecording:T,resumeRecording:R,requestMicAccess:M,changeDevice:N,recordingPeaks:v}}const Si=[{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}]}],ja=s=>Si.find(e=>e.id===s),vy=s=>Si.filter(e=>e.category===s),yy=[{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"}],by={reverb:Mr,freeverb:Ir,jcReverb:Dr,feedbackDelay:Ar,pingPongDelay:Rr,chorus:Tr,phaser:Er,tremolo:Nr,vibrato:Fr,autoPanner:wr,autoFilter:br,autoWah:xr,eq3:$r,distortion:kr,bitCrusher:Cr,chebyshev:Sr,compressor:es,limiter:Br,gate:Wr,stereoWidener:Or};let wy=0;const xy=()=>`effect_${Date.now()}_${++wy}`;function ei(s,e){const t=by[s.id];if(!t)throw new Error(`Unknown effect type: ${s.id}`);const n={};s.parameters.forEach(o=>{const a=e?.[o.name]??o.default;n[o.name]=a});const i=new t(n),r=xy();return{effect:i,id:s.id,instanceId:r,dispose(){try{i.disconnect(),i.dispose()}catch{}},setParameter(o,a){o==="wet"&&i.wet?i.wet.value=a:i[o]!==void 0&&(i[o]?.value!==void 0?i[o].value=a:i[o]=a)},getParameter(o){if(o==="wet"&&i.wet)return i.wet.value;if(i[o]!==void 0)return i[o]?.value!==void 0?i[o].value:i[o]},connect(o){i.connect(o)},disconnect(){try{i.disconnect()}catch{}}}}function Cy(s){if(s.length===0)throw new Error("Cannot create effect chain with no effects");for(let e=0;e<s.length-1;e++)s[e].effect.connect(s[e+1].effect);return{input:s[0].effect,output:s[s.length-1].effect,dispose(){s.forEach(e=>e.dispose())}}}function Sy(s=256){const[e,t]=S.useState([]),n=S.useRef(e);n.current=e;const i=S.useRef(new Map),r=S.useRef(null),o=S.useRef(null),a=S.useCallback(m=>{const g=o.current;if(!g)return;const{masterGainNode:y,destination:x,analyserNode:w}=g;try{y.disconnect()}catch{}const v=m.map(b=>i.current.get(b.instanceId)).filter(b=>b!==void 0);if(v.length===0)y.connect(w),w.connect(x);else{let b=y;v.forEach(k=>{try{k.disconnect()}catch{}b.connect(k.effect),b=k.effect}),b.connect(w),w.connect(x)}},[]),c=S.useCallback(m=>{const g=ja(m);if(!g){console.error(`Unknown effect: ${m}`);return}const y={};g.parameters.forEach(v=>{y[v.name]=v.default});const x=ei(g,y);i.current.set(x.instanceId,x);const w={instanceId:x.instanceId,effectId:g.id,definition:g,params:y,bypassed:!1};t(v=>[...v,w])},[]),l=S.useCallback(m=>{const g=i.current.get(m);g&&(g.dispose(),i.current.delete(m)),t(y=>y.filter(x=>x.instanceId!==m))},[]),u=S.useCallback((m,g,y)=>{const x=i.current.get(m);x&&x.setParameter(g,y),t(w=>w.map(v=>v.instanceId===m?{...v,params:{...v.params,[g]:y}}:v))},[]),h=S.useCallback(m=>{const g=n.current.find(w=>w.instanceId===m);if(!g)return;const y=!g.bypassed,x=i.current.get(m);if(x){const w=g.params.wet??1;x.setParameter("wet",y?0:w)}t(w=>w.map(v=>v.instanceId===m?{...v,bypassed:y}:v))},[]),p=S.useCallback((m,g)=>{t(y=>{const x=[...y],[w]=x.splice(m,1);return x.splice(g,0,w),x})},[]),d=S.useCallback(()=>{i.current.forEach(m=>m.dispose()),i.current.clear(),t([])},[]);S.useEffect(()=>{a(e)},[e,a]);const f=S.useCallback((m,g,y)=>{const x=new Hs("fft",s);r.current=x,o.current={masterGainNode:m,destination:g,analyserNode:x};const v=n.current.map(b=>i.current.get(b.instanceId)).filter(b=>b!==void 0);if(v.length===0)m.connect(x),x.connect(g);else{let b=m;v.forEach(k=>{b.connect(k.effect),b=k.effect}),b.connect(x),x.connect(g)}return function(){x.dispose(),r.current=null,o.current=null}},[s]);S.useEffect(()=>()=>{i.current.forEach(m=>m.dispose()),i.current.clear()},[]);const _=S.useCallback(()=>{const m=e.filter(g=>!g.bypassed);if(m.length!==0)return(g,y,x)=>{const w=[];for(const v of m){const b=ei(v.definition,v.params);w.push(b)}if(w.length===0)g.connect(y);else{let v=g;w.forEach(b=>{v.connect(b.effect),v=b.effect}),v.connect(y)}return function(){w.forEach(b=>b.dispose())}}},[e]);return{activeEffects:e,availableEffects:Si,addEffect:c,removeEffect:l,updateParameter:u,toggleBypass:h,reorderEffects:p,clearAllEffects:d,masterEffects:f,createOfflineEffectsFunction:_,analyserRef:r}}function Ty(){const[s,e]=S.useState(new Map),t=S.useRef(new Map),n=S.useRef(new Map),i=S.useCallback((d,f)=>{const _=n.current.get(d);if(!_)return;const{graphEnd:m,masterGainNode:g}=_,y=t.current.get(d);try{m.disconnect()}catch{}const x=f.map(w=>y?.get(w.instanceId)).filter(w=>w!==void 0);if(x.length===0)m.connect(g);else{let w=m;x.forEach(v=>{try{v.disconnect()}catch{}w.connect(v.effect),w=v.effect}),w.connect(g)}},[]),r=S.useCallback((d,f)=>{const _=ja(f);if(!_){console.error(`Unknown effect: ${f}`);return}const m={};_.parameters.forEach(x=>{m[x.name]=x.default});const g=ei(_,m);t.current.has(d)||t.current.set(d,new Map),t.current.get(d).set(g.instanceId,g);const y={instanceId:g.instanceId,effectId:_.id,definition:_,params:m,bypassed:!1};e(x=>{const w=new Map(x),v=w.get(d)||[];return w.set(d,[...v,y]),w})},[]),o=S.useCallback((d,f)=>{const _=t.current.get(d),m=_?.get(f);m&&(m.dispose(),_?.delete(f)),e(g=>{const y=new Map(g),x=y.get(d)||[];return y.set(d,x.filter(w=>w.instanceId!==f)),y})},[]),a=S.useCallback((d,f,_,m)=>{const y=t.current.get(d)?.get(f);y&&y.setParameter(_,m),e(x=>{const w=new Map(x),v=w.get(d)||[];return w.set(d,v.map(b=>b.instanceId===f?{...b,params:{...b.params,[_]:m}}:b)),w})},[]),c=S.useCallback((d,f)=>{const m=(u.current.get(d)||[]).find(w=>w.instanceId===f);if(!m)return;const g=!m.bypassed,x=t.current.get(d)?.get(f);if(x){const w=m.params.wet??1;x.setParameter("wet",g?0:w)}e(w=>{const v=new Map(w),b=v.get(d)||[];return v.set(d,b.map(k=>k.instanceId===f?{...k,bypassed:g}:k)),v})},[]),l=S.useCallback(d=>{const f=t.current.get(d);f&&(f.forEach(_=>_.dispose()),f.clear()),e(_=>{const m=new Map(_);return m.set(d,[]),m})},[]),u=S.useRef(s);u.current=s;const h=S.useCallback(d=>(f,_,m)=>{n.current.set(d,{graphEnd:f,masterGainNode:_});const g=u.current.get(d)||[],y=t.current.get(d),x=g.map(w=>y?.get(w.instanceId)).filter(w=>w!==void 0);if(x.length===0)f.connect(_);else{let w=f;x.forEach(v=>{w.connect(v.effect),w=v.effect}),w.connect(_)}return function(){n.current.delete(d)}},[]);S.useEffect(()=>{s.forEach((d,f)=>{i(f,d)})},[s,i]),S.useEffect(()=>()=>{t.current.forEach(d=>{d.forEach(f=>f.dispose()),d.clear()}),t.current.clear()},[]);const p=S.useCallback(d=>{const _=(s.get(d)||[]).filter(m=>!m.bypassed);if(_.length!==0)return(m,g,y)=>{const x=[];for(const w of _){const v=ei(w.definition,w.params);x.push(v)}if(x.length===0)m.connect(g);else{let w=m;x.forEach(v=>{w.connect(v.effect),w=v.effect}),w.connect(g)}return function(){x.forEach(v=>v.dispose())}}},[s]);return{trackEffectsState:s,addEffectToTrack:r,removeEffectFromTrack:o,updateTrackEffectParameter:a,toggleBypass:c,clearTrackEffects:l,getTrackEffectsFunction:h,createOfflineTrackEffectsFunction:p,availableEffects:Si}}function ky(s,e={}){const{bitDepth:t=16}=e,n=s.numberOfChannels,i=s.sampleRate,r=s.length,o=t/8,a=n*o,c=i*a,l=r*a,u=44,h=u+l,p=new ArrayBuffer(h),d=new DataView(p);Pi(d,0,"RIFF"),d.setUint32(4,h-8,!0),Pi(d,8,"WAVE"),Pi(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,t===32?3:1,!0),d.setUint16(22,n,!0),d.setUint32(24,i,!0),d.setUint32(28,c,!0),d.setUint16(32,a,!0),d.setUint16(34,t,!0),Pi(d,36,"data"),d.setUint32(40,l,!0);const f=[];for(let m=0;m<n;m++)f.push(s.getChannelData(m));let _=u;if(t===16)for(let m=0;m<r;m++)for(let g=0;g<n;g++){const y=f[g][m],x=Math.max(-1,Math.min(1,y)),w=x<0?x*32768:x*32767;d.setInt16(_,w,!0),_+=2}else for(let m=0;m<r;m++)for(let g=0;g<n;g++)d.setFloat32(_,f[g][m],!0),_+=4;return new Blob([p],{type:"audio/wav"})}function Pi(s,e,t){for(let n=0;n<t.length;n++)s.setUint8(e+n,t.charCodeAt(n))}function Ay(s,e){const t=URL.createObjectURL(s),n=document.createElement("a");n.href=t,n.download=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}function Wu(){const[s,e]=S.useState(!1),[t,n]=S.useState(0),[i,r]=S.useState(null);return{exportWav:S.useCallback(async(a,c,l={})=>{const{filename:u="export",mode:h="master",trackIndex:p,autoDownload:d=!0,applyEffects:f=!0,effectsFunction:_,createOfflineTrackEffects:m,bitDepth:g=16,onProgress:y}=l;e(!0),n(0),r(null);try{if(a.length===0)throw new Error("No tracks to export");if(h==="individual"&&(p===void 0||p<0||p>=a.length))throw new Error("Invalid track index for individual export");const x=a[0].clips[0]?.audioBuffer.sampleRate||44100;let w=0;for(const A of a)for(const D of A.clips){const M=D.startSample+D.durationSamples;w=Math.max(w,M)}w+=Math.round(x*.1);const v=w/x,b=h==="individual"?[{track:a[p],state:c[p],index:p}]:a.map((A,D)=>({track:A,state:c[D],index:D})),k=c.some(A=>A.soloed),T=!!m;let R;if((_||T)&&f)R=await Iy(b,c,k,v,x,_,m,A=>{n(A),y?.(A)});else{const A=new OfflineAudioContext(2,w,x);let D=0;const M=b.reduce((N,{track:q})=>N+q.clips.length,0);for(const{track:N,state:q}of b)if(!(q.muted&&!q.soloed)&&!(k&&!q.soloed))for(const V of N.clips){await Ry(A,V,q,x,f),D++;const j=D/M*.5;n(j),y?.(j)}n(.5),y?.(.5),R=await A.startRendering()}n(.9),y?.(.9);const I=ky(R,{bitDepth:g});if(n(1),y?.(1),d){const A=h==="individual"?`${u}_${a[p].name}`:u;Ay(I,`${A}.wav`)}return{audioBuffer:R,blob:I,duration:v}}catch(x){const w=x instanceof Error?x.message:"Export failed";throw r(w),x}finally{e(!1)}},[]),isExporting:s,progress:t,error:i}}async function Iy(s,e,t,n,i,r,o,a){const{Offline:c,Volume:l,Gain:u,Panner:h,Player:p,ToneAudioBuffer:d}=await Promise.resolve().then(()=>pu);a(.1);let f;try{f=await c(async({transport:_,destination:m})=>{const g=new l(0);let y;r?y=r(g,m,!0):g.connect(m);for(const{track:x,state:w}of s){if(w.muted&&!w.soloed||t&&!w.soloed)continue;const v=new l(Dy(w.volume)),b=new h(w.pan),k=new u(w.muted?0:1),T=o?.(x.id);T?T(k,g,!0):k.connect(g),b.connect(k),v.connect(b);for(const R of x.clips){const{audioBuffer:I,startSample:A,durationSamples:D,offsetSamples:M,gain:N,fadeIn:q,fadeOut:V}=R,j=A/i,G=D/i,B=M/i,Z=new d(I),X=new p(Z),ee=new u(N);if(X.connect(ee),ee.connect(v),q){const pe=j,ie=j+q.duration,Q=ee.gain._param;Q.setValueAtTime(0,pe),Q.linearRampToValueAtTime(N,ie)}if(V){const pe=j+G-V.duration,ie=j+G,Q=ee.gain._param;Q.setValueAtTime(N,pe),Q.linearRampToValueAtTime(0,ie)}X.start(j,B,G)}}_.start(0)},n,2,i)}catch(_){throw _ instanceof Error?_:new Error(`Tone.Offline rendering failed: ${String(_)}`)}return a(.9),f.get()}function Dy(s){return 20*Math.log10(Math.max(s,1e-4))}async function Ry(s,e,t,n,i){const{audioBuffer:r,startSample:o,durationSamples:a,offsetSamples:c,gain:l,fadeIn:u,fadeOut:h}=e,p=o/n,d=a/n,f=c/n,_=s.createBufferSource();_.buffer=r;const m=s.createGain(),g=l*t.volume,y=s.createStereoPanner();if(y.pan.value=t.pan,_.connect(m),m.connect(y),y.connect(s.destination),i){if(u?m.gain.setValueAtTime(0,p):m.gain.setValueAtTime(g,p),u){const x=p,w=p+u.duration;tl(m.gain,x,w,0,g,u.type||"linear")}if(h){const x=p+d-h.duration,w=p+d;(!u||u.duration<d-h.duration)&&m.gain.setValueAtTime(g,x),tl(m.gain,x,w,g,0,h.type||"linear")}}else m.gain.setValueAtTime(g,p);_.start(p,f,d)}function tl(s,e,t,n,i,r){const o=t-e;if(!(o<=0))switch(r){case"linear":s.setValueAtTime(n,e),s.linearRampToValueAtTime(i,t);break;case"exponential":const a=Math.max(n,1e-4),c=Math.max(i,1e-4);s.setValueAtTime(a,e),s.exponentialRampToValueAtTime(c,t),i===0&&s.setValueAtTime(0,t);break;case"logarithmic":const l=sl(n,i,256,"logarithmic");s.setValueCurveAtTime(l,e,o);break;case"sCurve":const u=sl(n,i,256,"sCurve");s.setValueCurveAtTime(u,e,o);break;default:s.setValueAtTime(n,e),s.linearRampToValueAtTime(i,t)}}function sl(s,e,t,n){const i=new Float32Array(t),r=e-s;for(let o=0;o<t;o++){const a=o/(t-1);let c;n==="logarithmic"?r>0?c=Math.log10(1+a*9)/Math.log10(10):c=1-Math.log10(1+(1-a)*9)/Math.log10(10):c=a*a*(3-2*a),i[o]=s+r*c}return i}const Bu=S.createContext(null),$u=S.createContext(null),qu=S.createContext(null),ju=S.createContext(null),Lu=S.createContext(null),Ey=({tracks:s,timescale:e=!1,mono:t=!1,waveHeight:n=80,samplesPerPixel:i=1024,zoomLevels:r,automaticScroll:o=!1,theme:a,controls:c={show:!1,width:0},annotationList:l,effects:u,onReady:h,onAnnotationUpdate:p,barWidth:d=1,barGap:f=0,progressBarWidth:_,children:m})=>{const g=_??d+f,[y,x]=S.useState([]),[w,v]=S.useState(null),[b,k]=S.useState(!1),[T,R]=S.useState(0),[I,A]=S.useState(0),[D,M]=S.useState([]),[N,q]=S.useState([]),[V,j]=S.useState([]),[G,B]=S.useState(0),[Z,X]=S.useState(0),[ee,pe]=S.useState(null),[ie,Q]=S.useState(o),[ye,Ee]=S.useState(l?.isContinuousPlay??!1),[z,Je]=S.useState(l?.linkEndpoints??!0),[lt,Vt]=S.useState(l?.editable??!1),U=S.useRef(null),ut=S.useRef(0),$e=S.useRef(0),L=S.useRef(null),H=S.useRef(0),be=S.useRef(0),we=S.useRef(null),ce=S.useRef(null),Ce=S.useRef(!1),He=S.useRef(l?.isContinuousPlay??!1),Ze=S.useRef(null),Pt=S.useRef(i),{timeFormat:oe,setTimeFormat:ge,formatTime:Ae}=Nu(),qe=Fu({initialSamplesPerPixel:i,zoomLevels:r}),Ge=qe.samplesPerPixel,{masterVolume:xt,setMasterVolume:Se}=Vu({playoutRef:U,initialVolume:1}),Lt=S.useCallback(se=>{He.current=se,Ee(se)},[]),ht=S.useCallback(se=>{Ze.current=se,v(se)},[]);S.useEffect(()=>{Ce.current=ie},[ie]),S.useEffect(()=>{if(!ce.current||!D.length)return;const se=ce.current,ue=Pt.current,C=Ge;if(ue===C)return;const O=c.show?c.width:0,P=se.clientWidth,J=se.scrollLeft+P/2-O,ve=D[0].sampleRate,he=J*ue/ve*ve/C,je=Math.max(0,he+O-P/2);se.scrollLeft=je,Pt.current=C},[Ge,D,c]);const It=S.useRef(null);S.useEffect(()=>{if(s.length===0){M([]),A(0),j([]),q([]),U.current&&(U.current.dispose(),U.current=null);return}const se=b,ue=$e.current;return U.current&&se&&(U.current.stop(),L.current&&(cancelAnimationFrame(L.current),L.current=null),It.current={position:ue}),(async()=>{try{const O=[];s.forEach(J=>{J.clips.length>0&&O.push(J.clips[0].audioBuffer)});let P=0;s.forEach(J=>{J.clips.forEach(ve=>{const fe=ve.audioBuffer.sampleRate,je=(ve.startSample+ve.durationSamples)/fe;P=Math.max(P,je)})}),M(O),A(P),j(s.map(J=>({name:J.name,muted:J.muted,soloed:J.soloed,volume:J.volume,pan:J.pan}))),U.current&&U.current.dispose();const te=new O_({effects:u});s.forEach((J,ve)=>{if(J.clips.length>0){const fe=J.clips[0].audioBuffer.sampleRate,he=Math.min(...J.clips.map(Ie=>Ie.startSample/fe)),je=Math.max(...J.clips.map(Ie=>(Ie.startSample+Ie.durationSamples)/fe)),Ve={id:`track-${ve}`,name:J.name,gain:J.volume,muted:J.muted,soloed:J.soloed,stereoPan:J.pan,startTime:he,endTime:je},Pe=J.clips.map(Ie=>{const Qt=Ie.audioBuffer.sampleRate;return{buffer:Ie.audioBuffer,startTime:Ie.startSample/Qt-he,duration:Ie.durationSamples/Qt,offset:Ie.offsetSamples/Qt,fadeIn:Ie.fadeIn,fadeOut:Ie.fadeOut,gain:Ie.gain}});te.addTrack({clips:Pe,track:Ve,effects:J.effects})}}),U.current=te,h?.()}catch(O){console.error("Error loading audio:",O)}})(),()=>{L.current&&cancelAnimationFrame(L.current),U.current&&U.current.dispose()}},[s,h,b]),S.useEffect(()=>{if(s.length===0)return;const se=16,ue=s.map(C=>C.clips.map(P=>{const te=P.audioBuffer.sampleRate,J=dv(P.audioBuffer,Ge,t,se,P.offsetSamples/te,P.durationSamples/te);return{clipId:P.id,trackName:C.name,peaks:J,startSample:P.startSample,durationSamples:P.durationSamples,fadeIn:P.fadeIn,fadeOut:P.fadeOut}}));q(ue)},[s,Ge,t]),S.useEffect(()=>{if(l?.annotations){const se=l.annotations.map(ue=>typeof ue.start=="number"?ue:bv(ue));x(se)}},[l]);const dt=S.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null);const se=()=>{const ue=me().currentTime-H.current,C=be.current+ue;if($e.current=C,R(C),y.length>0){const O=y.find(P=>C>=P.start&&C<P.end);if(He.current){if(O&&O.id!==Ze.current)ht(O.id);else if(!O&&Ze.current!==null){const P=y[y.length-1];if(C>=P.end){U.current&&U.current.stop(),k(!1),$e.current=ut.current,R(ut.current),ht(null);return}}}else if(Ze.current){const P=y.find(te=>te.id===Ze.current);if(P&&C>=P.end){U.current&&U.current.stop(),k(!1),$e.current=ut.current,R(ut.current);return}}else O&&ht(O.id)}if(Ce.current&&ce.current&&D.length>0){const O=ce.current,P=D[0].sampleRate,te=C*P/Pt.current,J=O.clientWidth,ve=c.show?c.width:0,fe=te+ve,he=Math.max(0,fe-J/2);O.scrollLeft=he}if(we.current!==null&&C>=we.current){U.current&&U.current.stop(),k(!1),$e.current=we.current,R(we.current),we.current=null;return}if(C>=I){U.current&&U.current.stop(),k(!1),$e.current=ut.current,R(ut.current),ht(null);return}L.current=requestAnimationFrame(se)};L.current=requestAnimationFrame(se)},[I,D,Ge,y,ye]),et=S.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null)},[]);S.useEffect(()=>{(async()=>{if(b&&L.current&&U.current)if(ye){const ue=$e.current;U.current.stop(),et(),await U.current.init(),U.current.setOnPlaybackComplete(()=>{});const O=me().currentTime;H.current=O,be.current=ue,U.current.play(O,ue),dt()}else et(),dt()})()},[ye,b,dt,et]),S.useEffect(()=>{(async()=>{if(It.current&&U.current){const{position:ue}=It.current;It.current=null,await U.current.init(),U.current.setOnPlaybackComplete(()=>{});const O=me().currentTime;H.current=O,be.current=ue,U.current.play(O,ue),k(!0),dt()}})()},[s,dt]);const as=S.useCallback(async(se,ue)=>{if(!U.current||D.length===0)return;await U.current.init(),await ta();const C=se??$e.current;ut.current=C,$e.current=C,U.current.setOnPlaybackComplete(()=>{}),U.current.stop(),et();const P=me().currentTime;H.current=P,be.current=C,we.current=ue!==void 0?C+ue:null,U.current.play(P,C,ue),k(!0),dt()},[D.length,dt,et]),En=S.useCallback(()=>{if(!U.current)return;const se=me().currentTime-H.current,ue=be.current+se;U.current.pause(),k(!1),et(),$e.current=ue,R(ue)},[et]),Mn=S.useCallback(()=>{U.current&&(U.current.stop(),k(!1),et(),$e.current=ut.current,R(ut.current),ht(null))},[et]),Ti=S.useCallback(se=>{const ue=Math.max(0,Math.min(se,I));$e.current=ue,R(ue),b&&U.current&&(U.current.stop(),et(),as(ue))},[I,b,as,et]),vs=S.useCallback((se,ue)=>{const C=[...V];if(C[se]={...C[se],muted:ue},j(C),U.current){const O=`track-${se}`;U.current.setMute(O,ue)}},[V]),On=S.useCallback((se,ue)=>{const C=[...V];if(C[se]={...C[se],soloed:ue},j(C),U.current){const O=`track-${se}`;U.current.setSolo(O,ue)}},[V]),Nn=S.useCallback((se,ue)=>{const C=[...V];if(C[se]={...C[se],volume:ue},j(C),U.current){const O=`track-${se}`,P=U.current.getTrack(O);P&&P.setVolume(ue)}},[V]),ki=S.useCallback((se,ue)=>{const C=[...V];if(C[se]={...C[se],pan:ue},j(C),U.current){const O=`track-${se}`,P=U.current.getTrack(O);P&&P.setPan(ue)}},[V]),Hr=S.useCallback((se,ue)=>{B(se),X(ue),$e.current=se,R(se),b&&U.current&&(U.current.stop(),U.current.play(me().currentTime,se))},[b]),Ai=S.useCallback(se=>{ce.current=se},[]),Yr=D[0]?.sampleRate||44100,Fn=e?30:0,Ii=s.length*n+Fn,Di={isPlaying:b,currentTime:T,currentTimeRef:$e,playbackStartTimeRef:H,audioStartPositionRef:be},Ri={continuousPlay:ye,linkEndpoints:z,annotationsEditable:lt,isAutomaticScroll:ie,annotations:y,activeAnnotationId:w,selectionStart:G,selectionEnd:Z,selectedTrackId:ee},Vn={play:as,pause:En,stop:Mn,seekTo:Ti,setCurrentTime:se=>{$e.current=se,R(se)},setTrackMute:vs,setTrackSolo:On,setTrackVolume:Nn,setTrackPan:ki,setSelection:Hr,setSelectedTrackId:pe,setTimeFormat:ge,formatTime:Ae,zoomIn:qe.zoomIn,zoomOut:qe.zoomOut,setMasterVolume:Se,setAutomaticScroll:se=>{Q(se)},setScrollContainer:Ai,scrollContainerRef:ce,setContinuousPlay:Lt,setLinkEndpoints:Je,setAnnotationsEditable:Vt,setAnnotations:x,setActiveAnnotationId:ht},Pn={duration:I,audioBuffers:D,peaksDataArray:N,trackStates:V,tracks:s,sampleRate:Yr,waveHeight:n,timeScaleHeight:Fn,minimumPlaylistHeight:Ii,controls:c,playoutRef:U,samplesPerPixel:Ge,timeFormat:oe,masterVolume:xt,canZoomIn:qe.canZoomIn,canZoomOut:qe.canZoomOut,barWidth:d,barGap:f,progressBarWidth:g},Ur={...Di,...Ri,...Vn,...Pn},Kr={...l0,...a};return E.jsx(W.ThemeProvider,{theme:Kr,children:E.jsx(Bu.Provider,{value:Di,children:E.jsx($u.Provider,{value:Ri,children:E.jsx(qu.Provider,{value:Vn,children:E.jsx(ju.Provider,{value:Pn,children:E.jsx(Lu.Provider,{value:Ur,children:m})})})})})})},At=()=>{const s=S.useContext(Bu);if(!s)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return s},os=()=>{const s=S.useContext($u);if(!s)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return s},Qe=()=>{const s=S.useContext(qu);if(!s)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return s},wt=()=>{const s=S.useContext(ju);if(!s)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return s},My=()=>{const s=S.useContext(Lu);if(!s)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return s},Oy=({className:s})=>{const{isPlaying:e,currentTimeRef:t}=At(),{selectionStart:n,selectionEnd:i}=os(),{play:r}=Qe(),o=async()=>{if(n!==i&&i>n){const a=i-n;await r(n,a)}else await r(t.current??0)};return E.jsx(rs,{onClick:o,disabled:e,className:s,children:"Play"})},Ny=({className:s})=>{const{isPlaying:e}=At(),{pause:t}=Qe();return E.jsx(rs,{onClick:t,disabled:!e,className:s,children:"Pause"})},Fy=({className:s})=>{const{isPlaying:e}=At(),{stop:t}=Qe();return E.jsx(rs,{onClick:t,disabled:!e,className:s,children:"Stop"})},Vy=({className:s})=>{const{isPlaying:e}=At(),{play:t,setCurrentTime:n}=Qe(),{playoutRef:i}=wt(),r=()=>{n(0),e&&i.current&&(i.current.stop(),t(0))};return E.jsx(rs,{onClick:r,className:s,children:"Rewind"})},Py=({className:s})=>{const{isPlaying:e}=At(),{play:t,setCurrentTime:n}=Qe(),{duration:i,playoutRef:r}=wt(),o=()=>{n(i),e&&r.current&&(r.current.stop(),t(i))};return E.jsx(rs,{onClick:o,className:s,children:"Fast Forward"})},Wy=({skipAmount:s=5,className:e})=>{const{currentTimeRef:t,isPlaying:n}=At(),{play:i,setCurrentTime:r}=Qe(),{playoutRef:o}=wt(),a=()=>{const c=Math.max(0,(t.current??0)-s);r(c),n&&o.current&&(o.current.stop(),i(c))};return E.jsx(rs,{onClick:a,className:e,children:"Skip Backward"})},By=({skipAmount:s=5,className:e})=>{const{currentTimeRef:t,isPlaying:n}=At(),{play:i,setCurrentTime:r}=Qe(),{duration:o,playoutRef:a}=wt(),c=()=>{const l=Math.min(o,(t.current??0)+s);r(l),n&&a.current&&(a.current.stop(),i(l))};return E.jsx(rs,{onClick:c,className:e,children:"Skip Forward"})},$y=({className:s,disabled:e})=>{const{zoomIn:t}=Qe(),{canZoomIn:n}=wt();return E.jsx(rs,{variant:"success",onClick:t,disabled:e||!n,className:s,children:"Zoom In"})},qy=({className:s,disabled:e})=>{const{zoomOut:t}=Qe(),{canZoomOut:n}=wt();return E.jsx(rs,{variant:"success",onClick:t,disabled:e||!n,className:s,children:"Zoom Out"})},jy=({className:s})=>{const{masterVolume:e}=wt(),{setMasterVolume:t}=Qe();return E.jsx(A0,{volume:e,onChange:t,className:s})},Ly=({className:s})=>{const{timeFormat:e}=wt(),{setTimeFormat:t}=Qe();return E.jsx(J0,{value:e,onChange:t,className:s})},zy=W.span`
1327
+ `,gy=({level:s,peakLevel:e,width:t=200,height:n=20,className:i})=>{const r=Math.max(0,Math.min(1,s)),o=e!==void 0?Math.max(0,Math.min(1,e)):0;return E.jsxs(hy,{$width:t,$height:n,className:i,children:[E.jsx(py,{$level:r,$height:n}),e!==void 0&&o>0&&E.jsx(fy,{$peakLevel:o,$height:n}),E.jsxs(my,{$height:n,children:[E.jsx(el,{$position:60,$height:n}),E.jsx(el,{$position:85,$height:n})]})]})};S.memo(gy);function _y(s,e,t,n={}){const{currentTime:i=0,audioConstraints:r,...o}=n,[a,c]=S.useState(!1),[l,u]=S.useState(null),{stream:h,devices:p,hasPermission:d,requestAccess:f,error:_}=ly(),{level:m,peakLevel:g}=uy(h),{isRecording:y,isPaused:x,duration:w,peaks:v,startRecording:b,stopRecording:k,pauseRecording:T,resumeRecording:R,error:I}=cy(h,o),A=S.useCallback(async()=>{t&&(a||(await so(),c(!0)),await b())},[t,a,b]),D=S.useCallback(async()=>{const q=await k();if(q&&t){const V=s.findIndex(de=>de.id===t);if(V===-1)return;const j=s[V],X=Math.floor(i*q.sampleRate);let B=0;if(j.clips.length>0){const de=j.clips.map(ie=>ie.startSample+ie.durationSamples);B=Math.max(...de)}const G=Math.max(X,B),H={id:`clip-${Date.now()}`,audioBuffer:q,startSample:G,durationSamples:q.length,offsetSamples:0,gain:1,name:`Recording ${new Date().toLocaleTimeString()}`},te=s.map((de,ie)=>ie===V?{...de,clips:[...de.clips,H]}:de);e(te)}},[t,s,e,i,k]);S.useEffect(()=>{d&&p.length>0&&l===null&&u(p[0].deviceId)},[d,p.length]);const O=S.useCallback(async()=>{await f(void 0,r),await so(),c(!0)},[f,r]),N=S.useCallback(async q=>{u(q),await f(q,r),await so(),c(!0)},[f,r]);return{isRecording:y,isPaused:x,duration:w,level:m,peakLevel:g,error:_||I,stream:h,devices:p,hasPermission:d,selectedDevice:l,startRecording:A,stopRecording:D,pauseRecording:T,resumeRecording:R,requestMicAccess:O,changeDevice:N,recordingPeaks:v}}const Si=[{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}]}],ja=s=>Si.find(e=>e.id===s),vy=s=>Si.filter(e=>e.category===s),yy=[{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"}],by={reverb:Mr,freeverb:Ir,jcReverb:Dr,feedbackDelay:Ar,pingPongDelay:Rr,chorus:Tr,phaser:Er,tremolo:Nr,vibrato:Fr,autoPanner:wr,autoFilter:br,autoWah:xr,eq3:$r,distortion:kr,bitCrusher:Cr,chebyshev:Sr,compressor:Jt,limiter:Br,gate:Wr,stereoWidener:Or};let wy=0;const xy=()=>`effect_${Date.now()}_${++wy}`;function ei(s,e){const t=by[s.id];if(!t)throw new Error(`Unknown effect type: ${s.id}`);const n={};s.parameters.forEach(o=>{const a=e?.[o.name]??o.default;n[o.name]=a});const i=new t(n),r=xy();return{effect:i,id:s.id,instanceId:r,dispose(){try{i.disconnect(),i.dispose()}catch{}},setParameter(o,a){o==="wet"&&i.wet?i.wet.value=a:i[o]!==void 0&&(i[o]?.value!==void 0?i[o].value=a:i[o]=a)},getParameter(o){if(o==="wet"&&i.wet)return i.wet.value;if(i[o]!==void 0)return i[o]?.value!==void 0?i[o].value:i[o]},connect(o){i.connect(o)},disconnect(){try{i.disconnect()}catch{}}}}function Cy(s){if(s.length===0)throw new Error("Cannot create effect chain with no effects");for(let e=0;e<s.length-1;e++)s[e].effect.connect(s[e+1].effect);return{input:s[0].effect,output:s[s.length-1].effect,dispose(){s.forEach(e=>e.dispose())}}}function Sy(s=256){const[e,t]=S.useState([]),n=S.useRef(e);n.current=e;const i=S.useRef(new Map),r=S.useRef(null),o=S.useRef(null),a=S.useCallback(m=>{const g=o.current;if(!g)return;const{masterGainNode:y,destination:x,analyserNode:w}=g;try{y.disconnect()}catch{}const v=m.map(b=>i.current.get(b.instanceId)).filter(b=>b!==void 0);if(v.length===0)y.connect(w),w.connect(x);else{let b=y;v.forEach(k=>{try{k.disconnect()}catch{}b.connect(k.effect),b=k.effect}),b.connect(w),w.connect(x)}},[]),c=S.useCallback(m=>{const g=ja(m);if(!g){console.error(`Unknown effect: ${m}`);return}const y={};g.parameters.forEach(v=>{y[v.name]=v.default});const x=ei(g,y);i.current.set(x.instanceId,x);const w={instanceId:x.instanceId,effectId:g.id,definition:g,params:y,bypassed:!1};t(v=>[...v,w])},[]),l=S.useCallback(m=>{const g=i.current.get(m);g&&(g.dispose(),i.current.delete(m)),t(y=>y.filter(x=>x.instanceId!==m))},[]),u=S.useCallback((m,g,y)=>{const x=i.current.get(m);x&&x.setParameter(g,y),t(w=>w.map(v=>v.instanceId===m?{...v,params:{...v.params,[g]:y}}:v))},[]),h=S.useCallback(m=>{const g=n.current.find(w=>w.instanceId===m);if(!g)return;const y=!g.bypassed,x=i.current.get(m);if(x){const w=g.params.wet??1;x.setParameter("wet",y?0:w)}t(w=>w.map(v=>v.instanceId===m?{...v,bypassed:y}:v))},[]),p=S.useCallback((m,g)=>{t(y=>{const x=[...y],[w]=x.splice(m,1);return x.splice(g,0,w),x})},[]),d=S.useCallback(()=>{i.current.forEach(m=>m.dispose()),i.current.clear(),t([])},[]);S.useEffect(()=>{a(e)},[e,a]);const f=S.useCallback((m,g,y)=>{const x=new Ys("fft",s);r.current=x,o.current={masterGainNode:m,destination:g,analyserNode:x};const v=n.current.map(b=>i.current.get(b.instanceId)).filter(b=>b!==void 0);if(v.length===0)m.connect(x),x.connect(g);else{let b=m;v.forEach(k=>{b.connect(k.effect),b=k.effect}),b.connect(x),x.connect(g)}return function(){x.dispose(),r.current=null,o.current=null}},[s]);S.useEffect(()=>()=>{i.current.forEach(m=>m.dispose()),i.current.clear()},[]);const _=S.useCallback(()=>{const m=e.filter(g=>!g.bypassed);if(m.length!==0)return(g,y,x)=>{const w=[];for(const v of m){const b=ei(v.definition,v.params);w.push(b)}if(w.length===0)g.connect(y);else{let v=g;w.forEach(b=>{v.connect(b.effect),v=b.effect}),v.connect(y)}return function(){w.forEach(b=>b.dispose())}}},[e]);return{activeEffects:e,availableEffects:Si,addEffect:c,removeEffect:l,updateParameter:u,toggleBypass:h,reorderEffects:p,clearAllEffects:d,masterEffects:f,createOfflineEffectsFunction:_,analyserRef:r}}function Ty(){const[s,e]=S.useState(new Map),t=S.useRef(new Map),n=S.useRef(new Map),i=S.useCallback((d,f)=>{const _=n.current.get(d);if(!_)return;const{graphEnd:m,masterGainNode:g}=_,y=t.current.get(d);try{m.disconnect()}catch{}const x=f.map(w=>y?.get(w.instanceId)).filter(w=>w!==void 0);if(x.length===0)m.connect(g);else{let w=m;x.forEach(v=>{try{v.disconnect()}catch{}w.connect(v.effect),w=v.effect}),w.connect(g)}},[]),r=S.useCallback((d,f)=>{const _=ja(f);if(!_){console.error(`Unknown effect: ${f}`);return}const m={};_.parameters.forEach(x=>{m[x.name]=x.default});const g=ei(_,m);t.current.has(d)||t.current.set(d,new Map),t.current.get(d).set(g.instanceId,g);const y={instanceId:g.instanceId,effectId:_.id,definition:_,params:m,bypassed:!1};e(x=>{const w=new Map(x),v=w.get(d)||[];return w.set(d,[...v,y]),w})},[]),o=S.useCallback((d,f)=>{const _=t.current.get(d),m=_?.get(f);m&&(m.dispose(),_?.delete(f)),e(g=>{const y=new Map(g),x=y.get(d)||[];return y.set(d,x.filter(w=>w.instanceId!==f)),y})},[]),a=S.useCallback((d,f,_,m)=>{const y=t.current.get(d)?.get(f);y&&y.setParameter(_,m),e(x=>{const w=new Map(x),v=w.get(d)||[];return w.set(d,v.map(b=>b.instanceId===f?{...b,params:{...b.params,[_]:m}}:b)),w})},[]),c=S.useCallback((d,f)=>{const m=(u.current.get(d)||[]).find(w=>w.instanceId===f);if(!m)return;const g=!m.bypassed,x=t.current.get(d)?.get(f);if(x){const w=m.params.wet??1;x.setParameter("wet",g?0:w)}e(w=>{const v=new Map(w),b=v.get(d)||[];return v.set(d,b.map(k=>k.instanceId===f?{...k,bypassed:g}:k)),v})},[]),l=S.useCallback(d=>{const f=t.current.get(d);f&&(f.forEach(_=>_.dispose()),f.clear()),e(_=>{const m=new Map(_);return m.set(d,[]),m})},[]),u=S.useRef(s);u.current=s;const h=S.useCallback(d=>(f,_,m)=>{n.current.set(d,{graphEnd:f,masterGainNode:_});const g=u.current.get(d)||[],y=t.current.get(d),x=g.map(w=>y?.get(w.instanceId)).filter(w=>w!==void 0);if(x.length===0)f.connect(_);else{let w=f;x.forEach(v=>{w.connect(v.effect),w=v.effect}),w.connect(_)}return function(){n.current.delete(d)}},[]);S.useEffect(()=>{s.forEach((d,f)=>{i(f,d)})},[s,i]),S.useEffect(()=>()=>{t.current.forEach(d=>{d.forEach(f=>f.dispose()),d.clear()}),t.current.clear()},[]);const p=S.useCallback(d=>{const _=(s.get(d)||[]).filter(m=>!m.bypassed);if(_.length!==0)return(m,g,y)=>{const x=[];for(const w of _){const v=ei(w.definition,w.params);x.push(v)}if(x.length===0)m.connect(g);else{let w=m;x.forEach(v=>{w.connect(v.effect),w=v.effect}),w.connect(g)}return function(){x.forEach(v=>v.dispose())}}},[s]);return{trackEffectsState:s,addEffectToTrack:r,removeEffectFromTrack:o,updateTrackEffectParameter:a,toggleBypass:c,clearTrackEffects:l,getTrackEffectsFunction:h,createOfflineTrackEffectsFunction:p,availableEffects:Si}}function ky(s,e={}){const{bitDepth:t=16}=e,n=s.numberOfChannels,i=s.sampleRate,r=s.length,o=t/8,a=n*o,c=i*a,l=r*a,u=44,h=u+l,p=new ArrayBuffer(h),d=new DataView(p);Pi(d,0,"RIFF"),d.setUint32(4,h-8,!0),Pi(d,8,"WAVE"),Pi(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,t===32?3:1,!0),d.setUint16(22,n,!0),d.setUint32(24,i,!0),d.setUint32(28,c,!0),d.setUint16(32,a,!0),d.setUint16(34,t,!0),Pi(d,36,"data"),d.setUint32(40,l,!0);const f=[];for(let m=0;m<n;m++)f.push(s.getChannelData(m));let _=u;if(t===16)for(let m=0;m<r;m++)for(let g=0;g<n;g++){const y=f[g][m],x=Math.max(-1,Math.min(1,y)),w=x<0?x*32768:x*32767;d.setInt16(_,w,!0),_+=2}else for(let m=0;m<r;m++)for(let g=0;g<n;g++)d.setFloat32(_,f[g][m],!0),_+=4;return new Blob([p],{type:"audio/wav"})}function Pi(s,e,t){for(let n=0;n<t.length;n++)s.setUint8(e+n,t.charCodeAt(n))}function Ay(s,e){const t=URL.createObjectURL(s),n=document.createElement("a");n.href=t,n.download=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}function Wu(){const[s,e]=S.useState(!1),[t,n]=S.useState(0),[i,r]=S.useState(null);return{exportWav:S.useCallback(async(a,c,l={})=>{const{filename:u="export",mode:h="master",trackIndex:p,autoDownload:d=!0,applyEffects:f=!0,effectsFunction:_,createOfflineTrackEffects:m,bitDepth:g=16,onProgress:y}=l;e(!0),n(0),r(null);try{if(a.length===0)throw new Error("No tracks to export");if(h==="individual"&&(p===void 0||p<0||p>=a.length))throw new Error("Invalid track index for individual export");const x=a[0].clips[0]?.audioBuffer.sampleRate||44100;let w=0;for(const A of a)for(const D of A.clips){const O=D.startSample+D.durationSamples;w=Math.max(w,O)}w+=Math.round(x*.1);const v=w/x,b=h==="individual"?[{track:a[p],state:c[p],index:p}]:a.map((A,D)=>({track:A,state:c[D],index:D})),k=c.some(A=>A.soloed),T=!!m;let R;if((_||T)&&f)R=await Iy(b,c,k,v,x,_,m,A=>{n(A),y?.(A)});else{const A=new OfflineAudioContext(2,w,x);let D=0;const O=b.reduce((N,{track:q})=>N+q.clips.length,0);for(const{track:N,state:q}of b)if(!(q.muted&&!q.soloed)&&!(k&&!q.soloed))for(const V of N.clips){await Ry(A,V,q,x,f),D++;const j=D/O*.5;n(j),y?.(j)}n(.5),y?.(.5),R=await A.startRendering()}n(.9),y?.(.9);const I=ky(R,{bitDepth:g});if(n(1),y?.(1),d){const A=h==="individual"?`${u}_${a[p].name}`:u;Ay(I,`${A}.wav`)}return{audioBuffer:R,blob:I,duration:v}}catch(x){const w=x instanceof Error?x.message:"Export failed";throw r(w),x}finally{e(!1)}},[]),isExporting:s,progress:t,error:i}}async function Iy(s,e,t,n,i,r,o,a){const{Offline:c,Volume:l,Gain:u,Panner:h,Player:p,ToneAudioBuffer:d}=await Promise.resolve().then(()=>pu);a(.1);let f;try{f=await c(async({transport:_,destination:m})=>{const g=new l(0);let y;r?y=r(g,m,!0):g.connect(m);for(const{track:x,state:w}of s){if(w.muted&&!w.soloed||t&&!w.soloed)continue;const v=new l(Dy(w.volume)),b=new h(w.pan),k=new u(w.muted?0:1),T=o?.(x.id);T?T(k,g,!0):k.connect(g),b.connect(k),v.connect(b);for(const R of x.clips){const{audioBuffer:I,startSample:A,durationSamples:D,offsetSamples:O,gain:N,fadeIn:q,fadeOut:V}=R,j=A/i,X=D/i,B=O/i,G=new d(I),H=new p(G),te=new u(N);if(H.connect(te),te.connect(v),q){const de=j,ie=j+q.duration,Q=te.gain._param;Q.setValueAtTime(0,de),Q.linearRampToValueAtTime(N,ie)}if(V){const de=j+X-V.duration,ie=j+X,Q=te.gain._param;Q.setValueAtTime(N,de),Q.linearRampToValueAtTime(0,ie)}H.start(j,B,X)}}_.start(0)},n,2,i)}catch(_){throw _ instanceof Error?_:new Error(`Tone.Offline rendering failed: ${String(_)}`)}return a(.9),f.get()}function Dy(s){return 20*Math.log10(Math.max(s,1e-4))}async function Ry(s,e,t,n,i){const{audioBuffer:r,startSample:o,durationSamples:a,offsetSamples:c,gain:l,fadeIn:u,fadeOut:h}=e,p=o/n,d=a/n,f=c/n,_=s.createBufferSource();_.buffer=r;const m=s.createGain(),g=l*t.volume,y=s.createStereoPanner();if(y.pan.value=t.pan,_.connect(m),m.connect(y),y.connect(s.destination),i){if(u?m.gain.setValueAtTime(0,p):m.gain.setValueAtTime(g,p),u){const x=p,w=p+u.duration;tl(m.gain,x,w,0,g,u.type||"linear")}if(h){const x=p+d-h.duration,w=p+d;(!u||u.duration<d-h.duration)&&m.gain.setValueAtTime(g,x),tl(m.gain,x,w,g,0,h.type||"linear")}}else m.gain.setValueAtTime(g,p);_.start(p,f,d)}function tl(s,e,t,n,i,r){const o=t-e;if(!(o<=0))switch(r){case"linear":s.setValueAtTime(n,e),s.linearRampToValueAtTime(i,t);break;case"exponential":const a=Math.max(n,1e-4),c=Math.max(i,1e-4);s.setValueAtTime(a,e),s.exponentialRampToValueAtTime(c,t),i===0&&s.setValueAtTime(0,t);break;case"logarithmic":const l=sl(n,i,256,"logarithmic");s.setValueCurveAtTime(l,e,o);break;case"sCurve":const u=sl(n,i,256,"sCurve");s.setValueCurveAtTime(u,e,o);break;default:s.setValueAtTime(n,e),s.linearRampToValueAtTime(i,t)}}function sl(s,e,t,n){const i=new Float32Array(t),r=e-s;for(let o=0;o<t;o++){const a=o/(t-1);let c;n==="logarithmic"?r>0?c=Math.log10(1+a*9)/Math.log10(10):c=1-Math.log10(1+(1-a)*9)/Math.log10(10):c=a*a*(3-2*a),i[o]=s+r*c}return i}const Bu=S.createContext(null),$u=S.createContext(null),qu=S.createContext(null),ju=S.createContext(null),Lu=S.createContext(null),Ey=({tracks:s,timescale:e=!1,mono:t=!1,waveHeight:n=80,samplesPerPixel:i=1024,zoomLevels:r,automaticScroll:o=!1,theme:a,controls:c={show:!1,width:0},annotationList:l,effects:u,onReady:h,onAnnotationUpdate:p,barWidth:d=1,barGap:f=0,progressBarWidth:_,children:m})=>{const g=_??d+f,[y,x]=S.useState([]),[w,v]=S.useState(null),[b,k]=S.useState(!1),[T,R]=S.useState(0),[I,A]=S.useState(0),[D,O]=S.useState([]),[N,q]=S.useState([]),[V,j]=S.useState([]),[X,B]=S.useState(0),[G,H]=S.useState(0),[te,de]=S.useState(null),[ie,Q]=S.useState(o),[_e,Me]=S.useState(l?.isContinuousPlay??!1),[z,Ke]=S.useState(l?.linkEndpoints??!0),[ut,Vt]=S.useState(l?.editable??!1),U=S.useRef(null),ht=S.useRef(0),$e=S.useRef(0),L=S.useRef(null),J=S.useRef(V),ve=S.useRef(0),ye=S.useRef(0),le=S.useRef(null),we=S.useRef(null),ze=S.useRef(!1),tt=S.useRef(l?.isContinuousPlay??!1),xt=S.useRef(null),ae=S.useRef(i),{timeFormat:me,setTimeFormat:Ie,formatTime:st}=Nu(),Ze=Fu({initialSamplesPerPixel:i,zoomLevels:r}),Ge=Ze.samplesPerPixel,{masterVolume:Ce,setMasterVolume:jt}=Vu({playoutRef:U,initialVolume:1}),Lt=S.useCallback(se=>{tt.current=se,Me(se)},[]),ft=S.useCallback(se=>{xt.current=se,v(se)},[]);S.useEffect(()=>{ze.current=ie},[ie]),S.useEffect(()=>{J.current=V},[V]),S.useEffect(()=>{if(!we.current||!D.length)return;const se=we.current,C=ae.current,M=Ge;if(C===M)return;const W=c.show?c.width:0,Z=se.clientWidth,be=se.scrollLeft+Z/2-W,ee=D[0].sampleRate,De=be*C/ee*ee/M,ke=Math.max(0,De+W-Z/2);se.scrollLeft=ke,ae.current=M},[Ge,D,c]);const It=S.useRef(null);S.useEffect(()=>{if(s.length===0){O([]),A(0),j([]),q([]),U.current&&(U.current.dispose(),U.current=null);return}const se=b,C=$e.current;return U.current&&se&&(U.current.stop(),L.current&&(cancelAnimationFrame(L.current),L.current=null),It.current={position:C}),(async()=>{try{const W=[];s.forEach(ee=>{ee.clips.length>0&&W.push(ee.clips[0].audioBuffer)});let Z=0;s.forEach(ee=>{ee.clips.forEach(re=>{const De=re.audioBuffer.sampleRate,Oe=(re.startSample+re.durationSamples)/De;Z=Math.max(Z,Oe)})}),O(W),A(Z),j(ee=>ee.length===s.length?ee.map((re,De)=>({...re,name:s[De].name})):s.map(re=>({name:re.name,muted:re.muted,soloed:re.soloed,volume:re.volume,pan:re.pan}))),U.current&&U.current.dispose();const pe=new O_({effects:u}),be=J.current;s.forEach((ee,re)=>{if(ee.clips.length>0){const De=ee.clips[0].audioBuffer.sampleRate,ke=Math.min(...ee.clips.map(Se=>Se.startSample/De)),Oe=Math.max(...ee.clips.map(Se=>(Se.startSample+Se.durationSamples)/De)),it=be[re],vs={id:`track-${re}`,name:ee.name,gain:it?.volume??ee.volume,muted:it?.muted??ee.muted,soloed:it?.soloed??ee.soloed,stereoPan:it?.pan??ee.pan,startTime:ke,endTime:Oe},os=ee.clips.map(Se=>{const Ns=Se.audioBuffer.sampleRate;return{buffer:Se.audioBuffer,startTime:Se.startSample/Ns-ke,duration:Se.durationSamples/Ns,offset:Se.offsetSamples/Ns,fadeIn:Se.fadeIn,fadeOut:Se.fadeOut,gain:Se.gain}});pe.addTrack({clips:os,track:vs,effects:ee.effects})}}),pe.applyInitialSoloState(),U.current=pe,h?.()}catch(W){console.error("Error loading audio:",W)}})(),()=>{L.current&&cancelAnimationFrame(L.current),U.current&&U.current.dispose()}},[s,h,b]),S.useEffect(()=>{if(s.length===0)return;const se=16,C=s.map(M=>M.clips.map(Z=>{const pe=Z.audioBuffer.sampleRate,be=dv(Z.audioBuffer,Ge,t,se,Z.offsetSamples/pe,Z.durationSamples/pe);return{clipId:Z.id,trackName:M.name,peaks:be,startSample:Z.startSample,durationSamples:Z.durationSamples,fadeIn:Z.fadeIn,fadeOut:Z.fadeOut}}));q(C)},[s,Ge,t]),S.useEffect(()=>{if(l?.annotations){const se=l.annotations.map(C=>typeof C.start=="number"?C:bv(C));x(se)}},[l]);const Ct=S.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null);const se=()=>{const C=fe().currentTime-ve.current,M=ye.current+C;if($e.current=M,R(M),y.length>0){const W=y.find(Z=>M>=Z.start&&M<Z.end);if(tt.current){if(W&&W.id!==xt.current)ft(W.id);else if(!W&&xt.current!==null){const Z=y[y.length-1];if(M>=Z.end){U.current&&U.current.stop(),k(!1),$e.current=ht.current,R(ht.current),ft(null);return}}}else if(xt.current){const Z=y.find(pe=>pe.id===xt.current);if(Z&&M>=Z.end){U.current&&U.current.stop(),k(!1),$e.current=ht.current,R(ht.current);return}}else W&&ft(W.id)}if(ze.current&&we.current&&D.length>0){const W=we.current,Z=D[0].sampleRate,pe=M*Z/ae.current,be=W.clientWidth,ee=c.show?c.width:0,re=pe+ee,De=Math.max(0,re-be/2);W.scrollLeft=De}if(le.current!==null&&M>=le.current){U.current&&U.current.stop(),k(!1),$e.current=le.current,R(le.current),le.current=null;return}if(M>=I){U.current&&U.current.stop(),k(!1),$e.current=ht.current,R(ht.current),ft(null);return}L.current=requestAnimationFrame(se)};L.current=requestAnimationFrame(se)},[I,D,Ge,y,_e]),nt=S.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null)},[]);S.useEffect(()=>{(async()=>{if(b&&L.current&&U.current)if(_e){const C=$e.current;U.current.stop(),nt(),await U.current.init(),U.current.setOnPlaybackComplete(()=>{});const W=fe().currentTime;ve.current=W,ye.current=C,U.current.play(W,C),Ct()}else nt(),Ct()})()},[_e,b,Ct,nt]),S.useEffect(()=>{(async()=>{if(It.current&&U.current){const{position:C}=It.current;It.current=null,await U.current.init(),U.current.setOnPlaybackComplete(()=>{});const W=fe().currentTime;ve.current=W,ye.current=C,U.current.play(W,C),k(!0),Ct()}})()},[s,Ct]);const Os=S.useCallback(async(se,C)=>{if(!U.current||D.length===0)return;await U.current.init(),await ta();const M=se??$e.current;ht.current=M,$e.current=M,U.current.setOnPlaybackComplete(()=>{}),U.current.stop(),nt();const Z=fe().currentTime;ve.current=Z,ye.current=M,le.current=C!==void 0?M+C:null,U.current.play(Z,M,C),k(!0),Ct()},[D.length,Ct,nt]),Mn=S.useCallback(()=>{if(!U.current)return;const se=fe().currentTime-ve.current,C=ye.current+se;U.current.pause(),k(!1),nt(),$e.current=C,R(C)},[nt]),Ti=S.useCallback(()=>{U.current&&(U.current.stop(),k(!1),nt(),$e.current=ht.current,R(ht.current),ft(null))},[nt]),_s=S.useCallback(se=>{const C=Math.max(0,Math.min(se,I));$e.current=C,R(C),b&&U.current&&(U.current.stop(),nt(),Os(C))},[I,b,Os,nt]),On=S.useCallback((se,C)=>{const M=[...V];if(M[se]={...M[se],muted:C},j(M),U.current){const W=`track-${se}`;U.current.setMute(W,C)}},[V]),Nn=S.useCallback((se,C)=>{const M=[...V];if(M[se]={...M[se],soloed:C},j(M),U.current){const W=`track-${se}`;U.current.setSolo(W,C)}},[V]),ki=S.useCallback((se,C)=>{const M=[...V];if(M[se]={...M[se],volume:C},j(M),U.current){const W=`track-${se}`,Z=U.current.getTrack(W);Z&&Z.setVolume(C)}},[V]),Hr=S.useCallback((se,C)=>{const M=[...V];if(M[se]={...M[se],pan:C},j(M),U.current){const W=`track-${se}`,Z=U.current.getTrack(W);Z&&Z.setPan(C)}},[V]),Ai=S.useCallback((se,C)=>{B(se),H(C),$e.current=se,R(se),b&&U.current&&(U.current.stop(),U.current.play(fe().currentTime,se))},[b]),Yr=S.useCallback(se=>{we.current=se},[]),Ii=D[0]?.sampleRate||44100,Fn=e?30:0,Ur=s.length*n+Fn,Di={isPlaying:b,currentTime:T,currentTimeRef:$e,playbackStartTimeRef:ve,audioStartPositionRef:ye},Vn={continuousPlay:_e,linkEndpoints:z,annotationsEditable:ut,isAutomaticScroll:ie,annotations:y,activeAnnotationId:w,selectionStart:X,selectionEnd:G,selectedTrackId:te},Pn={play:Os,pause:Mn,stop:Ti,seekTo:_s,setCurrentTime:se=>{$e.current=se,R(se)},setTrackMute:On,setTrackSolo:Nn,setTrackVolume:ki,setTrackPan:Hr,setSelection:Ai,setSelectedTrackId:de,setTimeFormat:Ie,formatTime:st,zoomIn:Ze.zoomIn,zoomOut:Ze.zoomOut,setMasterVolume:jt,setAutomaticScroll:se=>{Q(se)},setScrollContainer:Yr,scrollContainerRef:we,setContinuousPlay:Lt,setLinkEndpoints:Ke,setAnnotationsEditable:Vt,setAnnotations:x,setActiveAnnotationId:ft},Ri={duration:I,audioBuffers:D,peaksDataArray:N,trackStates:V,tracks:s,sampleRate:Ii,waveHeight:n,timeScaleHeight:Fn,minimumPlaylistHeight:Ur,controls:c,playoutRef:U,samplesPerPixel:Ge,timeFormat:me,masterVolume:Ce,canZoomIn:Ze.canZoomIn,canZoomOut:Ze.canZoomOut,barWidth:d,barGap:f,progressBarWidth:g},Kr={...Di,...Vn,...Pn,...Ri},Qr={...l0,...a};return E.jsx(P.ThemeProvider,{theme:Qr,children:E.jsx(Bu.Provider,{value:Di,children:E.jsx($u.Provider,{value:Vn,children:E.jsx(qu.Provider,{value:Pn,children:E.jsx(ju.Provider,{value:Ri,children:E.jsx(Lu.Provider,{value:Kr,children:m})})})})})})},At=()=>{const s=S.useContext(Bu);if(!s)throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");return s},rs=()=>{const s=S.useContext($u);if(!s)throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");return s},Ue=()=>{const s=S.useContext(qu);if(!s)throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");return s},wt=()=>{const s=S.useContext(ju);if(!s)throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");return s},My=()=>{const s=S.useContext(Lu);if(!s)throw new Error("useWaveformPlaylist must be used within WaveformPlaylistProvider");return s},Oy=({className:s})=>{const{isPlaying:e,currentTimeRef:t}=At(),{selectionStart:n,selectionEnd:i}=rs(),{play:r}=Ue(),o=async()=>{if(n!==i&&i>n){const a=i-n;await r(n,a)}else await r(t.current??0)};return E.jsx(is,{onClick:o,disabled:e,className:s,children:"Play"})},Ny=({className:s})=>{const{isPlaying:e}=At(),{pause:t}=Ue();return E.jsx(is,{onClick:t,disabled:!e,className:s,children:"Pause"})},Fy=({className:s})=>{const{isPlaying:e}=At(),{stop:t}=Ue();return E.jsx(is,{onClick:t,disabled:!e,className:s,children:"Stop"})},Vy=({className:s})=>{const{isPlaying:e}=At(),{play:t,setCurrentTime:n}=Ue(),{playoutRef:i}=wt(),r=()=>{n(0),e&&i.current&&(i.current.stop(),t(0))};return E.jsx(is,{onClick:r,className:s,children:"Rewind"})},Py=({className:s})=>{const{isPlaying:e}=At(),{play:t,setCurrentTime:n}=Ue(),{duration:i,playoutRef:r}=wt(),o=()=>{n(i),e&&r.current&&(r.current.stop(),t(i))};return E.jsx(is,{onClick:o,className:s,children:"Fast Forward"})},Wy=({skipAmount:s=5,className:e})=>{const{currentTimeRef:t,isPlaying:n}=At(),{play:i,setCurrentTime:r}=Ue(),{playoutRef:o}=wt(),a=()=>{const c=Math.max(0,(t.current??0)-s);r(c),n&&o.current&&(o.current.stop(),i(c))};return E.jsx(is,{onClick:a,className:e,children:"Skip Backward"})},By=({skipAmount:s=5,className:e})=>{const{currentTimeRef:t,isPlaying:n}=At(),{play:i,setCurrentTime:r}=Ue(),{duration:o,playoutRef:a}=wt(),c=()=>{const l=Math.min(o,(t.current??0)+s);r(l),n&&a.current&&(a.current.stop(),i(l))};return E.jsx(is,{onClick:c,className:e,children:"Skip Forward"})},$y=({className:s,disabled:e})=>{const{zoomIn:t}=Ue(),{canZoomIn:n}=wt();return E.jsx(is,{variant:"success",onClick:t,disabled:e||!n,className:s,children:"Zoom In"})},qy=({className:s,disabled:e})=>{const{zoomOut:t}=Ue(),{canZoomOut:n}=wt();return E.jsx(is,{variant:"success",onClick:t,disabled:e||!n,className:s,children:"Zoom Out"})},jy=({className:s})=>{const{masterVolume:e}=wt(),{setMasterVolume:t}=Ue();return E.jsx(A0,{volume:e,onChange:t,className:s})},Ly=({className:s})=>{const{timeFormat:e}=wt(),{setTimeFormat:t}=Ue();return E.jsx(J0,{value:e,onChange:t,className:s})},zy=P.span`
1328
1328
  font-family: 'Courier New', Monaco, monospace;
1329
1329
  font-size: 1rem;
1330
1330
  font-weight: 600;
1331
1331
  color: ${s=>s.theme?.textColor||"#333"};
1332
1332
  user-select: none;
1333
- `,Zy=({className:s})=>{const e=S.useRef(null),t=S.useRef(null),{isPlaying:n,currentTimeRef:i,playbackStartTimeRef:r,audioStartPositionRef:o}=At(),{timeFormat:a}=wt(),c=a;return S.useEffect(()=>{const l=()=>{if(e.current){let u;if(n){const h=me().currentTime-(r.current??0);u=(o.current??0)+h}else u=i.current??0;e.current.textContent=nn(u,c)}n&&(t.current=requestAnimationFrame(l))};return n?t.current=requestAnimationFrame(l):l(),()=>{t.current&&(cancelAnimationFrame(t.current),t.current=null)}},[n,c,i,r,o]),S.useEffect(()=>{!n&&e.current&&(e.current.textContent=nn(i.current??0,c))}),E.jsx(zy,{ref:e,className:s,"aria-label":"Audio position",children:nn(i.current??0,c)})},Gy=({className:s})=>{const{selectionStart:e,selectionEnd:t}=os(),{setSelection:n}=Qe();return E.jsx(F0,{selectionStart:e,selectionEnd:t,onSelectionChange:n,className:s})},Xy=({className:s})=>{const{isAutomaticScroll:e}=os(),{setAutomaticScroll:t}=Qe();return E.jsx(c0,{checked:e,onChange:t,className:s})},Hy=({className:s})=>{const{continuousPlay:e}=os(),{setContinuousPlay:t}=Qe();return E.jsx(qv,{checked:e,onChange:t,className:s})},Yy=({className:s})=>{const{linkEndpoints:e}=os(),{setLinkEndpoints:t}=Qe();return E.jsx(jv,{checked:e,onChange:t,className:s})},Uy=({className:s})=>{const{annotationsEditable:e}=os(),{setAnnotationsEditable:t}=Qe();return E.jsx(Lv,{checked:e,onChange:t,className:s})},Ky=({filename:s,className:e})=>{const{annotations:t}=os();return E.jsx(Zv,{annotations:t,filename:s,className:e})},Qy=({label:s="Export WAV",filename:e="export",mode:t="master",trackIndex:n,bitDepth:i=16,applyEffects:r=!0,effectsFunction:o,createOfflineTrackEffects:a,className:c,onExportComplete:l,onExportError:u})=>{const{tracks:h,trackStates:p}=wt(),{exportWav:d,isExporting:f,progress:_}=Wu(),m=async()=>{try{const y=await d(h,p,{filename:e,mode:t,trackIndex:n,bitDepth:i,applyEffects:r,effectsFunction:o,createOfflineTrackEffects:a,autoDownload:!0});l?.(y.blob)}catch(y){u?.(y instanceof Error?y:new Error("Export failed"))}},g=f?`Exporting ${Math.round(_*100)}%`:s;return E.jsx(rs,{onClick:m,disabled:f||h.length===0,className:c,children:g})},Jy=W.div`
1333
+ `,Zy=({className:s})=>{const e=S.useRef(null),t=S.useRef(null),{isPlaying:n,currentTimeRef:i,playbackStartTimeRef:r,audioStartPositionRef:o}=At(),{timeFormat:a}=wt(),c=a;return S.useEffect(()=>{const l=()=>{if(e.current){let u;if(n){const h=fe().currentTime-(r.current??0);u=(o.current??0)+h}else u=i.current??0;e.current.textContent=rn(u,c)}n&&(t.current=requestAnimationFrame(l))};return n?t.current=requestAnimationFrame(l):l(),()=>{t.current&&(cancelAnimationFrame(t.current),t.current=null)}},[n,c,i,r,o]),S.useEffect(()=>{!n&&e.current&&(e.current.textContent=rn(i.current??0,c))}),E.jsx(zy,{ref:e,className:s,"aria-label":"Audio position",children:rn(i.current??0,c)})},Gy=({className:s})=>{const{selectionStart:e,selectionEnd:t}=rs(),{setSelection:n}=Ue();return E.jsx(F0,{selectionStart:e,selectionEnd:t,onSelectionChange:n,className:s})},Xy=({className:s})=>{const{isAutomaticScroll:e}=rs(),{setAutomaticScroll:t}=Ue();return E.jsx(c0,{checked:e,onChange:t,className:s})},Hy=({className:s})=>{const{continuousPlay:e}=rs(),{setContinuousPlay:t}=Ue();return E.jsx(qv,{checked:e,onChange:t,className:s})},Yy=({className:s})=>{const{linkEndpoints:e}=rs(),{setLinkEndpoints:t}=Ue();return E.jsx(jv,{checked:e,onChange:t,className:s})},Uy=({className:s})=>{const{annotationsEditable:e}=rs(),{setAnnotationsEditable:t}=Ue();return E.jsx(Lv,{checked:e,onChange:t,className:s})},Ky=({filename:s,className:e})=>{const{annotations:t}=rs();return E.jsx(Zv,{annotations:t,filename:s,className:e})},Qy=({label:s="Export WAV",filename:e="export",mode:t="master",trackIndex:n,bitDepth:i=16,applyEffects:r=!0,effectsFunction:o,createOfflineTrackEffects:a,className:c,onExportComplete:l,onExportError:u})=>{const{tracks:h,trackStates:p}=wt(),{exportWav:d,isExporting:f,progress:_}=Wu(),m=async()=>{try{const y=await d(h,p,{filename:e,mode:t,trackIndex:n,bitDepth:i,applyEffects:r,effectsFunction:o,createOfflineTrackEffects:a,autoDownload:!0});l?.(y.blob)}catch(y){u?.(y instanceof Error?y:new Error("Export failed"))}},g=f?`Exporting ${Math.round(_*100)}%`:s;return E.jsx(is,{onClick:m,disabled:f||h.length===0,className:c,children:g})},Jy=P.div`
1334
1334
  position: absolute;
1335
1335
  top: 0;
1336
1336
  left: 0;
@@ -1340,9 +1340,9 @@ React keys must be passed directly to JSX without using spread:
1340
1340
  z-index: 100; /* Below sticky controls (z-index: 101) so playhead is hidden when scrolled behind controls */
1341
1341
  pointer-events: none;
1342
1342
  will-change: transform;
1343
- `,eb=({color:s="#ff0000",controlsOffset:e=0})=>{const t=S.useRef(null),n=S.useRef(null),{isPlaying:i,currentTimeRef:r,playbackStartTimeRef:o,audioStartPositionRef:a}=At(),{samplesPerPixel:c,sampleRate:l,progressBarWidth:u}=wt();return S.useEffect(()=>{const h=()=>{if(t.current){let p;if(i){const f=me().currentTime-(o.current??0);p=(a.current??0)+f}else p=r.current??0;const d=p*l/c+e;t.current.style.transform=`translate3d(${d}px, 0, 0)`}i&&(n.current=requestAnimationFrame(h))};return i?n.current=requestAnimationFrame(h):h(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[i,l,c,e,r,o,a]),S.useEffect(()=>{if(!i&&t.current){const p=(r.current??0)*l/c+e;t.current.style.transform=`translate3d(${p}px, 0, 0)`}}),E.jsx(Jy,{ref:t,$color:s,$width:u,"data-playhead":!0})},tb=W.div`
1343
+ `,eb=({color:s="#ff0000",controlsOffset:e=0})=>{const t=S.useRef(null),n=S.useRef(null),{isPlaying:i,currentTimeRef:r,playbackStartTimeRef:o,audioStartPositionRef:a}=At(),{samplesPerPixel:c,sampleRate:l,progressBarWidth:u}=wt();return S.useEffect(()=>{const h=()=>{if(t.current){let p;if(i){const f=fe().currentTime-(o.current??0);p=(a.current??0)+f}else p=r.current??0;const d=p*l/c+e;t.current.style.transform=`translate3d(${d}px, 0, 0)`}i&&(n.current=requestAnimationFrame(h))};return i?n.current=requestAnimationFrame(h):h(),()=>{n.current&&(cancelAnimationFrame(n.current),n.current=null)}},[i,l,c,e,r,o,a]),S.useEffect(()=>{if(!i&&t.current){const p=(r.current??0)*l/c+e;t.current.style.transform=`translate3d(${p}px, 0, 0)`}}),E.jsx(Jy,{ref:t,$color:s,$width:u,"data-playhead":!0})},tb=P.div`
1344
1344
  position: relative;
1345
- `,sb=W.div`
1345
+ `,sb=P.div`
1346
1346
  position: absolute;
1347
1347
  top: ${s=>s.$top}px;
1348
1348
  left: 0;
@@ -1354,7 +1354,7 @@ React keys must be passed directly to JSX without using spread:
1354
1354
  transform: translateZ(0);
1355
1355
  backface-visibility: hidden;
1356
1356
  will-change: transform;
1357
- `,nb=W.div`
1357
+ `,nb=P.div`
1358
1358
  position: absolute;
1359
1359
  top: ${s=>s.$top}px;
1360
1360
  left: 0;
@@ -1363,9 +1363,9 @@ React keys must be passed directly to JSX without using spread:
1363
1363
  pointer-events: none;
1364
1364
  z-index: 1;
1365
1365
  will-change: width;
1366
- `,ib=W.div`
1366
+ `,ib=P.div`
1367
1367
  position: relative;
1368
1368
  z-index: 2;
1369
- `,nl=({clipStartSample:s,clipDurationSamples:e,...t})=>{const n=S.useRef(null),i=S.useRef(null),r=qa(),{waveHeight:o}=Gr(),{isPlaying:a,currentTimeRef:c,playbackStartTimeRef:l,audioStartPositionRef:u}=At(),{samplesPerPixel:h,sampleRate:p}=wt(),d=r?.waveProgressColor||"rgba(0, 0, 0, 0.1)";S.useEffect(()=>{const g=()=>{if(n.current){let y;if(a){const b=me().currentTime-(l.current??0);y=(u.current??0)+b}else y=c.current??0;const x=y*p,w=s+e;let v=0;if(x<=s)v=0;else if(x>=w)v=t.length;else{const b=x-s;v=Math.floor(b/h)}n.current.style.width=`${v}px`}a&&(i.current=requestAnimationFrame(g))};return a?i.current=requestAnimationFrame(g):g(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[a,p,h,s,e,t.length,c,l,u]),S.useEffect(()=>{if(!a&&n.current){const y=(c.current??0)*p,x=s+e;let w=0;if(y<=s)w=0;else if(y>=x)w=t.length;else{const v=y-s;w=Math.floor(v/h)}n.current.style.width=`${w}px`}});const f=r?.waveformDrawMode||"inverted";let _;f==="inverted"?_=t.isSelected&&r?r.selectedWaveFillColor:r?.waveFillColor||"white":_=t.isSelected&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor||"grey";const m=tr(_);return E.jsxs(tb,{children:[E.jsx(sb,{$color:m,$height:o,$top:t.index*o,$width:t.length}),E.jsx(nb,{ref:n,$color:d,$height:o,$top:t.index*o}),E.jsx(ib,{children:E.jsx(L0,{...t,transparentBackground:!0})})]})},rb=60,ob=({renderTrackControls:s,renderTimestamp:e,renderPlayhead:t,annotationControls:n,annotationListConfig:i,annotationTextHeight:r,className:o,showClipHeaders:a=!1,interactiveClips:c=!1,showFades:l=!1,recordingState:u})=>{const h=qa(),{isPlaying:p,currentTimeRef:d,playbackStartTimeRef:f,audioStartPositionRef:_}=At(),{selectionStart:m,selectionEnd:g,annotations:y,activeAnnotationId:x,annotationsEditable:w,linkEndpoints:v,continuousPlay:b,selectedTrackId:k}=os(),{setAnnotations:T,setActiveAnnotationId:R,setTrackMute:I,setTrackSolo:A,setTrackVolume:D,setTrackPan:M,setSelection:N,play:q,setScrollContainer:V,setSelectedTrackId:j,setCurrentTime:G}=Qe(),{audioBuffers:B,peaksDataArray:Z,trackStates:X,tracks:ee,duration:pe,samplesPerPixel:ie,sampleRate:Q,waveHeight:ye,timeScaleHeight:Ee,controls:z,playoutRef:Je,barWidth:lt,barGap:Vt}=wt(),[U,ut]=S.useState(!1),$e=S.useRef(null),L=S.useCallback(oe=>{$e.current=oe,V(oe)},[V]);let H=B.length>0?pe:rb;if(u?.isRecording){const ge=(u.startSample+u.durationSamples)/Q;H=Math.max(H,ge+10)}const be=Math.floor(H*Q/ie),we=async oe=>{console.log("Annotation clicked:",oe.id),R(oe.id);const ge=b?void 0:oe.end-oe.start;await q(oe.start,ge)},ce=S.useCallback(oe=>{if(oe>=0&&oe<ee.length){const ge=ee[oe];j(ge.id)}},[ee,j]),Ce=oe=>{const ge=oe.currentTarget.getBoundingClientRect(),Ae=z.show?z.width:0,Ge=(oe.clientX-ge.left-Ae)*ie/Q,Se=oe.clientY-ge.top;let Lt=0,ht=-1;for(let It=0;It<Z.length;It++){const dt=Z[It],as=(dt.length>0?Math.max(...dt.map(En=>En.peaks.data.length)):1)*ye+(a?22:0);if(Se>=Lt&&Se<Lt+as){ht=It;break}Lt+=as}ht!==-1&&ce(ht),ut(!0),G(Ge),N(Ge,Ge)},He=oe=>{if(!U)return;const ge=oe.currentTarget.getBoundingClientRect(),Ae=z.show?z.width:0,Ge=(oe.clientX-ge.left-Ae)*ie/Q,xt=Math.min(m,Ge),Se=Math.max(m,Ge);N(xt,Se)},Ze=oe=>{if(!U)return;ut(!1);const ge=oe.currentTarget.getBoundingClientRect(),Ae=z.show?z.width:0,Ge=(oe.clientX-ge.left-Ae)*ie/Q,xt=Math.min(m,Ge),Se=Math.max(m,Ge);Math.abs(Se-xt)<.1?(G(xt),p&&Je.current?(Je.current.stop(),q(xt)):Je.current&&Je.current.stop()):N(xt,Se)};return ee.some(oe=>oe.clips.length>0)&&(B.length===0||Z.length===0)?E.jsx("div",{className:o,children:"Loading waveform..."}):E.jsx(V0,{children:E.jsxs($a.Provider,{value:{samplesPerPixel:ie,sampleRate:Q,zoomLevels:[ie],waveHeight:ye,timeScaleHeight:Ee,duration:H,controls:z,barWidth:lt,barGap:Vt},children:[E.jsx(Iu,{theme:h,backgroundColor:tr(h.waveOutlineColor),timescaleBackgroundColor:h.timescaleBackgroundColor,scrollContainerWidth:be+(z.show?z.width:0),timescaleWidth:be,tracksWidth:be,controlsWidth:z.show?z.width:0,onTracksMouseDown:Ce,onTracksMouseMove:He,onTracksMouseUp:Ze,scrollContainerRef:L,timescale:Ee>0?E.jsx(U0,{duration:H*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:e}):void 0,children:E.jsxs(E.Fragment,{children:[Z.map((oe,ge)=>{const Ae=ee[ge];if(!Ae)return null;const qe=X[ge]||{name:`Track ${ge+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ge=s?s(ge):E.jsxs(rv,{onClick:()=>ce(ge),children:[E.jsx(ov,{style:{justifyContent:"center"},children:qe.name||`Track ${ge+1}`}),E.jsxs(iv,{children:[E.jsx(Wc,{$variant:qe.muted?"danger":"outline",onClick:()=>I(ge,!qe.muted),children:"Mute"}),E.jsx(Wc,{$variant:qe.soloed?"info":"outline",onClick:()=>A(ge,!qe.soloed),children:"Solo"})]}),E.jsxs($c,{children:[E.jsx(av,{}),E.jsx(Bc,{min:"0",max:"1",step:"0.01",value:qe.volume,onChange:Se=>D(ge,parseFloat(Se.target.value))}),E.jsx(cv,{})]}),E.jsxs($c,{children:[E.jsx("span",{children:"L"}),E.jsx(Bc,{min:"-1",max:"1",step:"0.01",value:qe.pan,onChange:Se=>M(ge,parseFloat(Se.target.value))}),E.jsx("span",{children:"R"})]})]}),xt=oe.length>0?Math.max(...oe.map(Se=>Se.peaks.data.length)):1;return E.jsx(Mu.Provider,{value:Ge,children:E.jsxs(nv,{numChannels:xt,backgroundColor:tr(h.waveOutlineColor),offset:0,width:be,hasClipHeaders:a,trackId:Ae.id,isSelected:Ae.id===k,children:[oe.map((Se,Lt)=>{const ht=Se.peaks,It=ht.length;return E.jsx(Vc,{clipId:Se.clipId,trackIndex:ge,clipIndex:Lt,trackName:Se.trackName,startSample:Se.startSample,durationSamples:Se.durationSamples,samplesPerPixel:ie,showHeader:a,disableHeaderDrag:!c,isSelected:Ae.id===k,trackId:Ae.id,fadeIn:Se.fadeIn,fadeOut:Se.fadeOut,sampleRate:Q,showFades:l,onMouseDown:dt=>{dt.target.closest('[role="button"][aria-roledescription="draggable"]')||ce(ge)},children:ht.data.map((dt,et)=>E.jsx(nl,{index:et,data:dt,bits:ht.bits,length:It,isSelected:Ae.id===k,clipStartSample:Se.startSample,clipDurationSamples:Se.durationSamples},`${ge}-${Lt}-${et}`))},`${ge}-${Lt}`)}),u?.isRecording&&u.trackId===Ae.id&&u.peaks.length>0&&E.jsx(Vc,{clipId:"recording-preview",trackIndex:ge,clipIndex:oe.length,trackName:"Recording...",startSample:u.startSample,durationSamples:u.durationSamples,samplesPerPixel:ie,showHeader:a,disableHeaderDrag:!0,isSelected:Ae.id===k,trackId:Ae.id,children:E.jsx(nl,{index:0,data:u.peaks,bits:16,length:Math.floor(u.peaks.length/2),isSelected:Ae.id===k,clipStartSample:u.startSample,clipDurationSamples:u.durationSamples},`${ge}-recording-0`)},`${ge}-recording`)]})},Ae.id)}),y.length>0&&E.jsx(Dv,{height:30,width:be,children:y.map((oe,ge)=>{const Ae=oe.start*Q/ie,qe=oe.end*Q/ie;return E.jsx(Tv,{annotationId:oe.id,annotationIndex:ge,startPosition:Ae,endPosition:qe,label:oe.id,color:"#ff9800",isActive:oe.id===x,onClick:()=>we(oe),editable:w},oe.id)})}),m!==g&&E.jsx(N0,{startPosition:Math.min(m,g)*Q/ie+(z.show?z.width:0),endPosition:Math.max(m,g)*Q/ie+(z.show?z.width:0),color:h.selectionColor}),(p||m===g)&&(t?t({position:(d.current??0)*Q/ie+(z.show?z.width:0),color:h.playheadColor,isPlaying:p,currentTimeRef:d,playbackStartTimeRef:f,audioStartPositionRef:_,samplesPerPixel:ie,sampleRate:Q,controlsOffset:z.show?z.width:0,getAudioContextTime:()=>me().currentTime}):E.jsx(eb,{color:h.playheadColor,controlsOffset:z.show?z.width:0}))]})}),y.length>0&&E.jsx($v,{annotations:y,activeAnnotationId:x??void 0,shouldScrollToActive:!0,editable:w,controls:w?n:void 0,annotationListConfig:{linkEndpoints:v,continuousPlay:b},height:r,onAnnotationUpdate:oe=>{T(oe)}})]})})};function Ys(s,e){this._waveformData=s,this._channelIndex=e}Ys.prototype.min_sample=function(s){var e=(s*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(e)};Ys.prototype.max_sample=function(s){var e=(s*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(e)};Ys.prototype.set_min_sample=function(s,e){var t=(s*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(t,e)};Ys.prototype.set_max_sample=function(s,e){var t=(s*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(t,e)};Ys.prototype.min_array=function(){for(var s=this._waveformData.length,e=[],t=0;t<s;t++)e.push(this.min_sample(t));return e};Ys.prototype.max_array=function(){for(var s=this._waveformData.length,e=[],t=0;t<s;t++)e.push(this.max_sample(t));return e};var ab=127,cb=-128,lb=32767,ub=-32768;function hb(s,e){var t=Math.floor(s/e),n=s-t*e;return n>0&&t++,t}function db(s){for(var e=s.scale,t=s.amplitude_scale,n=s.split_channels,i=s.length,r=s.sample_rate,o=s.channels.map(function(A){return new Float32Array(A)}),a=n?o.length:1,c=24,l=hb(i,e),u=s.bits===8?1:2,h=c+l*2*u*a,p=new ArrayBuffer(h),d=new DataView(p),f=0,_=c,m=new Array(a),g=new Array(a),y=0;y<a;y++)m[y]=1/0,g[y]=-1/0;var x=s.bits===8?cb:ub,w=s.bits===8?ab:lb;d.setInt32(0,2,!0),d.setUint32(4,s.bits===8,!0),d.setInt32(8,r,!0),d.setInt32(12,e,!0),d.setInt32(16,l,!0),d.setInt32(20,a,!0);for(var v=0;v<i;v++){var b=0;if(a===1){for(var k=0;k<o.length;++k)b+=o[k][v];b=Math.floor(w*b*t/o.length),b<m[0]&&(m[0]=b,m[0]<x&&(m[0]=x)),b>g[0]&&(g[0]=b,g[0]>w&&(g[0]=w))}else for(var T=0;T<a;++T)b=Math.floor(w*o[T][v]*t),b<m[T]&&(m[T]=b,m[T]<x&&(m[T]=x)),b>g[T]&&(g[T]=b,g[T]>w&&(g[T]=w));if(++f===e){for(var R=0;R<a;R++)s.bits===8?(d.setInt8(_++,m[R]),d.setInt8(_++,g[R])):(d.setInt16(_,m[R],!0),d.setInt16(_+2,g[R],!0),_+=4),m[R]=1/0,g[R]=-1/0;f=0}}if(f>0)for(var I=0;I<a;I++)s.bits===8?(d.setInt8(_++,m[I]),d.setInt8(_++,g[I])):(d.setInt16(_,m[I],!0),d.setInt16(_+2,g[I],!0));return p}function nr(s){"@babel/helpers - typeof";return nr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nr(s)}function pb(s){return s&&nr(s)==="object"&&"sample_rate"in s&&"samples_per_pixel"in s&&"bits"in s&&"length"in s&&"data"in s}function fb(s){var e=s&&nr(s)==="object"&&"byteLength"in s;if(e){var t=new DataView(s),n=t.getInt32(0,!0);if(n!==1&&n!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return e}function mb(s){var e=s.data,t=s.channels||1,n=24,i=s.bits===8?1:2,r=s.length*2*t;if(e.length!==r)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=n+e.length*i,a=new ArrayBuffer(o),c=new DataView(a);c.setInt32(0,2,!0),c.setUint32(4,s.bits===8,!0),c.setInt32(8,s.sample_rate,!0),c.setInt32(12,s.samples_per_pixel,!0),c.setInt32(16,s.length,!0),c.setInt32(20,t,!0);var l=n;if(s.bits===8)for(var u=0;u<e.length;u++)c.setInt8(l++,e[u],!0);else for(var h=0;h<e.length;h++)c.setInt16(l,e[h],!0),l+=2;return a}function Ks(s){return s==null}function gb(s,e){var t=atob(s);return t}function _b(s,e,t){var n=gb(s),i=n.indexOf(`
1370
- `,10)+1,r=n.substring(i)+"",o=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(o)}function vb(s,e,t){var n;return function(r){return n=n||_b(s),new Worker(n,r)}}var yb=vb("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Wt(s){if(pb(s)&&(s=mb(s)),fb(s)){this._data=new DataView(s),this._offset=this._version()===2?24:20,this._channels=[];for(var e=0;e<this.channels;e++)this._channels[e]=new Ys(this,e)}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 bb(s){var e={scale:s.scale||jn.scale,bits:s.bits||jn.bits,amplitude_scale:s.amplitude_scale||jn.amplitude_scale,split_channels:s.split_channels||jn.split_channels,disable_worker:s.disable_worker||jn.disable_worker};return e}function wb(s){for(var e=[],t=0;t<s.numberOfChannels;++t)e.push(s.getChannelData(t).buffer);return e}function zu(s,e,t){var n=wb(s);if(e.disable_worker){var i=db({scale:e.scale,bits:e.bits,amplitude_scale:e.amplitude_scale,split_channels:e.split_channels,length:s.length,sample_rate:s.sampleRate,channels:n});t(void 0,new Wt(i),s)}else{var r=new yb;r.onmessage=function(o){t(void 0,new Wt(o.data),s)},r.postMessage({scale:e.scale,bits:e.bits,amplitude_scale:e.amplitude_scale,split_channels:e.split_channels,length:s.length,sample_rate:s.sampleRate,channels:n},n)}}function xb(s,e,t,n){function i(o){o||(o=new DOMException("EncodingError")),n(o),n=function(){}}var r=s.decodeAudioData(e,function(o){zu(o,t,n)},i);r&&r.catch(i)}Wt.create=function(e){return new Wt(e)};Wt.createFromAudio=function(s,e){var t=bb(s);if(s.audio_context&&s.array_buffer)return xb(s.audio_context,s.array_buffer,t,e);if(s.audio_buffer)return zu(s.audio_buffer,t,e);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Xr(s){this._inputData=s.waveformData,this._output_samples_per_pixel=s.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var e=this._input_buffer_size*this._inputData.scale,t=Math.ceil(e/this._output_samples_per_pixel),n=24,i=this._inputData.bits===8?1:2,r=n+t*2*this._inputData.channels*i;this._output_data=new ArrayBuffer(r),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,t,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new Wt(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var a=0;a<o;++a)this._input_buffer_size>0?(this._min[a]=this._inputData.channel(a).min_sample(this._input_index),this._max[a]=this._inputData.channel(a).max_sample(this._input_index)):(this._min[a]=0,this._max[a]=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}Xr.prototype.sample_at_pixel=function(s){return Math.floor(s*this._output_samples_per_pixel)};Xr.prototype.next=function(){for(var s=0,e=1e3,t=this._inputData.channels,n;this._input_index<this._input_buffer_size&&s<e;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var i=0;i<t;++i)n=this._outputWaveformData.channel(i),n.set_min_sample(this._output_index-1,this._min[i]),n.set_max_sample(this._output_index-1,this._max[i]);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 r=0;r<t;++r)this._min[r]=this._max_value,this._max[r]=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<t;++o){n=this._inputData.channel(o);var a=n.min_sample(this._input_index);a<this._min[o]&&(this._min[o]=a),a=n.max_sample(this._input_index),a>this._max[o]&&(this._max[o]=a)}this._input_index++}s++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var c=0;c<t;++c)n=this._outputWaveformData.channel(c),n.set_min_sample(this._output_index-1,this._min[c]),n.set_max_sample(this._output_index-1,this._max[c]);return!0};Xr.prototype.getOutputData=function(){return this._output_data};Wt.prototype={_getResampleOptions:function(e){var t={};if(t.scale=e.scale,t.width=e.width,!Ks(t.width)&&(typeof t.width!="number"||t.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Ks(t.scale)&&(typeof t.scale!="number"||t.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!t.scale&&!t.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(t.width&&(t.scale=Math.floor(this.duration*this.sample_rate/t.width)),t.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+t.scale+" too low, minimum: "+this.scale);return t.abortSignal=e.abortSignal,t},resample:function(e){e=this._getResampleOptions(e),e.waveformData=this;for(var t=new Xr(e);!t.next(););return new Wt(t.getOutputData())},concat:function(){var e=this,t=Array.prototype.slice.call(arguments);t.forEach(function(i){if(e.channels!==i.channels||e.sample_rate!==i.sample_rate||e.bits!==i.bits||e.scale!==i.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var n=this._concatBuffers.apply(this,t);return Wt.create(n)},_concatBuffers:function(){for(var e=Array.prototype.slice.call(arguments),t=this._offset,n=t,i=0,r=[this].concat(e).map(function(g){return g._data.buffer}),o=0;o<r.length;o++){var a=r[o],c=new DataView(a).getInt32(16,!0);n+=a.byteLength-t,i+=c}for(var l=new ArrayBuffer(n),u=new DataView(r[0]),h=new DataView(l),p=0;p<t;p++)h.setUint8(p,u.getUint8(p));h.setInt32(16,i,!0);for(var d=0,f=new Uint8Array(l,t),_=0;_<r.length;_++){var m=r[_];f.set(new Uint8Array(m,t),d),d+=m.byteLength-t}return l},slice:function(e){var t=0,n=0;if(!Ks(e.startIndex)&&!Ks(e.endIndex)?(t=e.startIndex,n=e.endIndex):!Ks(e.startTime)&&!Ks(e.endTime)&&(t=this.at_time(e.startTime),n=this.at_time(e.endTime)),t<0)throw new RangeError("startIndex or startTime must not be negative");if(n<0)throw new RangeError("endIndex or endTime must not be negative");t>this.length&&(t=this.length),n>this.length&&(n=this.length),t>n&&(t=n);var i=n-t,r=24,o=this.bits===8?1:2,a=r+i*2*this.channels*o,c=new ArrayBuffer(a),l=new DataView(c);l.setInt32(0,2,!0),l.setUint32(4,this.bits===8,!0),l.setInt32(8,this.sample_rate,!0),l.setInt32(12,this.scale,!0),l.setInt32(16,i,!0),l.setInt32(20,this.channels,!0);for(var u=0;u<i*this.channels*2;u++){var h=this._at(t*this.channels*2+u);this.bits===8?l.setInt8(r+u,h):l.setInt16(r+u*2,h,!0)}return new Wt(c)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var s=!!this._data.getUint32(4,!0);return s?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(e){if(e>=0&&e<this._channels.length)return this._channels[e];throw new RangeError("Invalid channel: "+e)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(e){return this.bits===8?this._data.getInt8(this._offset+e):this._data.getInt16(this._offset+e*2,!0)},_set_at:function(e,t){return this.bits===8?this._data.setInt8(this._offset+e,t):this._data.setInt16(this._offset+e*2,t,!0)},at_time:function(e){return Math.floor(e*this.sample_rate/this.scale)},time:function(e){return e*this.scale/this.sample_rate},toJSON:function(){for(var e={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},t=0;t<this.length;t++)for(var n=0;n<this.channels;n++)e.data.push(this.channel(n).min_sample(t)),e.data.push(this.channel(n).max_sample(t));return e},toArrayBuffer:function(){return this._data.buffer}};async function La(s){const e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch waveform data: ${e.statusText}`);if(s.endsWith(".dat")){const n=await e.arrayBuffer();return Wt.create(n)}else{const n=await e.json();return Wt.create(n)}}function Zu(s,e=0){const t=s.channel(e),n=s.bits,i=t.min_array(),r=t.max_array(),o=i.length,a=n===8?new Int8Array(o*2):new Int16Array(o*2);for(let c=0;c<o;c++)a[c*2]=i[c],a[c*2+1]=r[c];return{data:a,bits:n,length:o,sampleRate:s.sample_rate}}async function Cb(s,e=0){const t=await La(s);return Zu(t,e)}async function Sb(s){const e=await La(s);return{sampleRate:e.sample_rate,channels:e.channels,duration:e.duration,samplesPerPixel:e.scale,length:e.length,bits:e.bits}}exports.AudioPosition=Zy;exports.AutomaticScrollCheckbox=Xy;exports.ContinuousPlayCheckbox=Hy;exports.DownloadAnnotationsButton=Ky;exports.EditableCheckbox=Uy;exports.ExportWavButton=Qy;exports.FastForwardButton=Py;exports.LinkEndpointsCheckbox=Yy;exports.MasterVolumeControl=jy;exports.PauseButton=Ny;exports.PlayButton=Oy;exports.RewindButton=Vy;exports.SelectionTimeInputs=Gy;exports.SkipBackwardButton=Wy;exports.SkipForwardButton=By;exports.StopButton=Fy;exports.TimeFormatSelect=Ly;exports.Tone=pu;exports.Waveform=ob;exports.WaveformPlaylistProvider=Ey;exports.ZoomInButton=$y;exports.ZoomOutButton=qy;exports.createEffectChain=Cy;exports.createEffectInstance=ei;exports.effectCategories=yy;exports.effectDefinitions=Si;exports.getEffectDefinition=ja;exports.getEffectsByCategory=vy;exports.getShortcutLabel=sy;exports.getWaveformDataMetadata=Sb;exports.loadPeaksFromWaveformData=Cb;exports.loadWaveformData=La;exports.useAnnotationDragHandlers=Qv;exports.useAnnotationKeyboardControls=iy;exports.useAudioTracks=Uv;exports.useClipDragHandlers=Kv;exports.useClipSplitting=ty;exports.useDragSensors=ey;exports.useDynamicEffects=Sy;exports.useExportWav=Wu;exports.useIntegratedRecording=_y;exports.useKeyboardShortcuts=sr;exports.useMasterAnalyser=Xv;exports.useMasterVolume=Vu;exports.usePlaybackAnimation=At;exports.usePlaybackShortcuts=ny;exports.usePlaylistControls=Qe;exports.usePlaylistData=wt;exports.usePlaylistState=os;exports.useTimeFormat=Nu;exports.useTrackDynamicEffects=Ty;exports.useWaveformPlaylist=My;exports.useZoomControls=Fu;exports.waveformDataToPeaks=Zu;
1369
+ `,nl=({clipStartSample:s,clipDurationSamples:e,...t})=>{const n=S.useRef(null),i=S.useRef(null),r=qa(),{waveHeight:o}=Gr(),{isPlaying:a,currentTimeRef:c,playbackStartTimeRef:l,audioStartPositionRef:u}=At(),{samplesPerPixel:h,sampleRate:p}=wt(),d=r?.waveProgressColor||"rgba(0, 0, 0, 0.1)";S.useEffect(()=>{const g=()=>{if(n.current){let y;if(a){const b=fe().currentTime-(l.current??0);y=(u.current??0)+b}else y=c.current??0;const x=y*p,w=s+e;let v=0;if(x<=s)v=0;else if(x>=w)v=t.length;else{const b=x-s;v=Math.floor(b/h)}n.current.style.width=`${v}px`}a&&(i.current=requestAnimationFrame(g))};return a?i.current=requestAnimationFrame(g):g(),()=>{i.current&&(cancelAnimationFrame(i.current),i.current=null)}},[a,p,h,s,e,t.length,c,l,u]),S.useEffect(()=>{if(!a&&n.current){const y=(c.current??0)*p,x=s+e;let w=0;if(y<=s)w=0;else if(y>=x)w=t.length;else{const v=y-s;w=Math.floor(v/h)}n.current.style.width=`${w}px`}});const f=r?.waveformDrawMode||"inverted";let _;f==="inverted"?_=t.isSelected&&r?r.selectedWaveFillColor:r?.waveFillColor||"white":_=t.isSelected&&r?r.selectedWaveOutlineColor:r?.waveOutlineColor||"grey";const m=tr(_);return E.jsxs(tb,{children:[E.jsx(sb,{$color:m,$height:o,$top:t.index*o,$width:t.length}),E.jsx(nb,{ref:n,$color:d,$height:o,$top:t.index*o}),E.jsx(ib,{children:E.jsx(L0,{...t,transparentBackground:!0})})]})},rb=60,ob=({renderTrackControls:s,renderTimestamp:e,renderPlayhead:t,annotationControls:n,annotationListConfig:i,annotationTextHeight:r,className:o,showClipHeaders:a=!1,interactiveClips:c=!1,showFades:l=!1,recordingState:u})=>{const h=qa(),{isPlaying:p,currentTimeRef:d,playbackStartTimeRef:f,audioStartPositionRef:_}=At(),{selectionStart:m,selectionEnd:g,annotations:y,activeAnnotationId:x,annotationsEditable:w,linkEndpoints:v,continuousPlay:b,selectedTrackId:k}=rs(),{setAnnotations:T,setActiveAnnotationId:R,setTrackMute:I,setTrackSolo:A,setTrackVolume:D,setTrackPan:O,setSelection:N,play:q,setScrollContainer:V,setSelectedTrackId:j,setCurrentTime:X}=Ue(),{audioBuffers:B,peaksDataArray:G,trackStates:H,tracks:te,duration:de,samplesPerPixel:ie,sampleRate:Q,waveHeight:_e,timeScaleHeight:Me,controls:z,playoutRef:Ke,barWidth:ut,barGap:Vt}=wt(),[U,ht]=S.useState(!1),$e=S.useRef(null),L=S.useCallback(ae=>{$e.current=ae,V(ae)},[V]);let J=B.length>0?de:rb;if(u?.isRecording){const me=(u.startSample+u.durationSamples)/Q;J=Math.max(J,me+10)}const ve=Math.floor(J*Q/ie),ye=async ae=>{console.log("Annotation clicked:",ae.id),R(ae.id);const me=b?void 0:ae.end-ae.start;await q(ae.start,me)},le=S.useCallback(ae=>{if(ae>=0&&ae<te.length){const me=te[ae];j(me.id)}},[te,j]),we=ae=>{const me=ae.currentTarget.getBoundingClientRect(),Ie=z.show?z.width:0,Ze=(ae.clientX-me.left-Ie)*ie/Q,Ce=ae.clientY-me.top;let jt=0,Lt=-1;for(let ft=0;ft<G.length;ft++){const It=G[ft],nt=(It.length>0?Math.max(...It.map(Os=>Os.peaks.data.length)):1)*_e+(a?22:0);if(Ce>=jt&&Ce<jt+nt){Lt=ft;break}jt+=nt}Lt!==-1&&le(Lt),ht(!0),X(Ze),N(Ze,Ze)},ze=ae=>{if(!U)return;const me=ae.currentTarget.getBoundingClientRect(),Ie=z.show?z.width:0,Ze=(ae.clientX-me.left-Ie)*ie/Q,Ge=Math.min(m,Ze),Ce=Math.max(m,Ze);N(Ge,Ce)},tt=ae=>{if(!U)return;ht(!1);const me=ae.currentTarget.getBoundingClientRect(),Ie=z.show?z.width:0,Ze=(ae.clientX-me.left-Ie)*ie/Q,Ge=Math.min(m,Ze),Ce=Math.max(m,Ze);Math.abs(Ce-Ge)<.1?(X(Ge),p&&Ke.current?(Ke.current.stop(),q(Ge)):Ke.current&&Ke.current.stop()):N(Ge,Ce)};return te.some(ae=>ae.clips.length>0)&&(B.length===0||G.length===0)?E.jsx("div",{className:o,children:"Loading waveform..."}):E.jsx(V0,{children:E.jsxs($a.Provider,{value:{samplesPerPixel:ie,sampleRate:Q,zoomLevels:[ie],waveHeight:_e,timeScaleHeight:Me,duration:J,controls:z,barWidth:ut,barGap:Vt},children:[E.jsx(Iu,{theme:h,backgroundColor:tr(h.waveOutlineColor),timescaleBackgroundColor:h.timescaleBackgroundColor,scrollContainerWidth:ve+(z.show?z.width:0),timescaleWidth:ve,tracksWidth:ve,controlsWidth:z.show?z.width:0,onTracksMouseDown:we,onTracksMouseMove:ze,onTracksMouseUp:tt,scrollContainerRef:L,timescale:Me>0?E.jsx(U0,{duration:J*1e3,marker:1e4,bigStep:5e3,secondStep:1e3,renderTimestamp:e}):void 0,children:E.jsxs(E.Fragment,{children:[G.map((ae,me)=>{const Ie=te[me];if(!Ie)return null;const st=H[me]||{name:`Track ${me+1}`,muted:!1,soloed:!1,volume:1,pan:0},Ze=s?s(me):E.jsxs(rv,{onClick:()=>le(me),children:[E.jsx(ov,{style:{justifyContent:"center"},children:st.name||`Track ${me+1}`}),E.jsxs(iv,{children:[E.jsx(Wc,{$variant:st.muted?"danger":"outline",onClick:()=>I(me,!st.muted),children:"Mute"}),E.jsx(Wc,{$variant:st.soloed?"info":"outline",onClick:()=>A(me,!st.soloed),children:"Solo"})]}),E.jsxs($c,{children:[E.jsx(av,{}),E.jsx(Bc,{min:"0",max:"1",step:"0.01",value:st.volume,onChange:Ce=>D(me,parseFloat(Ce.target.value))}),E.jsx(cv,{})]}),E.jsxs($c,{children:[E.jsx("span",{children:"L"}),E.jsx(Bc,{min:"-1",max:"1",step:"0.01",value:st.pan,onChange:Ce=>O(me,parseFloat(Ce.target.value))}),E.jsx("span",{children:"R"})]})]}),Ge=ae.length>0?Math.max(...ae.map(Ce=>Ce.peaks.data.length)):1;return E.jsx(Mu.Provider,{value:Ze,children:E.jsxs(nv,{numChannels:Ge,backgroundColor:tr(h.waveOutlineColor),offset:0,width:ve,hasClipHeaders:a,trackId:Ie.id,isSelected:Ie.id===k,children:[ae.map((Ce,jt)=>{const Lt=Ce.peaks,ft=Lt.length;return E.jsx(Vc,{clipId:Ce.clipId,trackIndex:me,clipIndex:jt,trackName:Ce.trackName,startSample:Ce.startSample,durationSamples:Ce.durationSamples,samplesPerPixel:ie,showHeader:a,disableHeaderDrag:!c,isSelected:Ie.id===k,trackId:Ie.id,fadeIn:Ce.fadeIn,fadeOut:Ce.fadeOut,sampleRate:Q,showFades:l,onMouseDown:It=>{It.target.closest('[role="button"][aria-roledescription="draggable"]')||le(me)},children:Lt.data.map((It,Ct)=>E.jsx(nl,{index:Ct,data:It,bits:Lt.bits,length:ft,isSelected:Ie.id===k,clipStartSample:Ce.startSample,clipDurationSamples:Ce.durationSamples},`${me}-${jt}-${Ct}`))},`${me}-${jt}`)}),u?.isRecording&&u.trackId===Ie.id&&u.peaks.length>0&&E.jsx(Vc,{clipId:"recording-preview",trackIndex:me,clipIndex:ae.length,trackName:"Recording...",startSample:u.startSample,durationSamples:u.durationSamples,samplesPerPixel:ie,showHeader:a,disableHeaderDrag:!0,isSelected:Ie.id===k,trackId:Ie.id,children:E.jsx(nl,{index:0,data:u.peaks,bits:16,length:Math.floor(u.peaks.length/2),isSelected:Ie.id===k,clipStartSample:u.startSample,clipDurationSamples:u.durationSamples},`${me}-recording-0`)},`${me}-recording`)]})},Ie.id)}),y.length>0&&E.jsx(Dv,{height:30,width:ve,children:y.map((ae,me)=>{const Ie=ae.start*Q/ie,st=ae.end*Q/ie;return E.jsx(Tv,{annotationId:ae.id,annotationIndex:me,startPosition:Ie,endPosition:st,label:ae.id,color:"#ff9800",isActive:ae.id===x,onClick:()=>ye(ae),editable:w},ae.id)})}),m!==g&&E.jsx(N0,{startPosition:Math.min(m,g)*Q/ie+(z.show?z.width:0),endPosition:Math.max(m,g)*Q/ie+(z.show?z.width:0),color:h.selectionColor}),(p||m===g)&&(t?t({position:(d.current??0)*Q/ie+(z.show?z.width:0),color:h.playheadColor,isPlaying:p,currentTimeRef:d,playbackStartTimeRef:f,audioStartPositionRef:_,samplesPerPixel:ie,sampleRate:Q,controlsOffset:z.show?z.width:0,getAudioContextTime:()=>fe().currentTime}):E.jsx(eb,{color:h.playheadColor,controlsOffset:z.show?z.width:0}))]})}),y.length>0&&E.jsx($v,{annotations:y,activeAnnotationId:x??void 0,shouldScrollToActive:!0,editable:w,controls:w?n:void 0,annotationListConfig:{linkEndpoints:v,continuousPlay:b},height:r,onAnnotationUpdate:ae=>{T(ae)}})]})})};function Us(s,e){this._waveformData=s,this._channelIndex=e}Us.prototype.min_sample=function(s){var e=(s*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._at(e)};Us.prototype.max_sample=function(s){var e=(s*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._at(e)};Us.prototype.set_min_sample=function(s,e){var t=(s*this._waveformData.channels+this._channelIndex)*2;return this._waveformData._set_at(t,e)};Us.prototype.set_max_sample=function(s,e){var t=(s*this._waveformData.channels+this._channelIndex)*2+1;return this._waveformData._set_at(t,e)};Us.prototype.min_array=function(){for(var s=this._waveformData.length,e=[],t=0;t<s;t++)e.push(this.min_sample(t));return e};Us.prototype.max_array=function(){for(var s=this._waveformData.length,e=[],t=0;t<s;t++)e.push(this.max_sample(t));return e};var ab=127,cb=-128,lb=32767,ub=-32768;function hb(s,e){var t=Math.floor(s/e),n=s-t*e;return n>0&&t++,t}function db(s){for(var e=s.scale,t=s.amplitude_scale,n=s.split_channels,i=s.length,r=s.sample_rate,o=s.channels.map(function(A){return new Float32Array(A)}),a=n?o.length:1,c=24,l=hb(i,e),u=s.bits===8?1:2,h=c+l*2*u*a,p=new ArrayBuffer(h),d=new DataView(p),f=0,_=c,m=new Array(a),g=new Array(a),y=0;y<a;y++)m[y]=1/0,g[y]=-1/0;var x=s.bits===8?cb:ub,w=s.bits===8?ab:lb;d.setInt32(0,2,!0),d.setUint32(4,s.bits===8,!0),d.setInt32(8,r,!0),d.setInt32(12,e,!0),d.setInt32(16,l,!0),d.setInt32(20,a,!0);for(var v=0;v<i;v++){var b=0;if(a===1){for(var k=0;k<o.length;++k)b+=o[k][v];b=Math.floor(w*b*t/o.length),b<m[0]&&(m[0]=b,m[0]<x&&(m[0]=x)),b>g[0]&&(g[0]=b,g[0]>w&&(g[0]=w))}else for(var T=0;T<a;++T)b=Math.floor(w*o[T][v]*t),b<m[T]&&(m[T]=b,m[T]<x&&(m[T]=x)),b>g[T]&&(g[T]=b,g[T]>w&&(g[T]=w));if(++f===e){for(var R=0;R<a;R++)s.bits===8?(d.setInt8(_++,m[R]),d.setInt8(_++,g[R])):(d.setInt16(_,m[R],!0),d.setInt16(_+2,g[R],!0),_+=4),m[R]=1/0,g[R]=-1/0;f=0}}if(f>0)for(var I=0;I<a;I++)s.bits===8?(d.setInt8(_++,m[I]),d.setInt8(_++,g[I])):(d.setInt16(_,m[I],!0),d.setInt16(_+2,g[I],!0));return p}function nr(s){"@babel/helpers - typeof";return nr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nr(s)}function pb(s){return s&&nr(s)==="object"&&"sample_rate"in s&&"samples_per_pixel"in s&&"bits"in s&&"length"in s&&"data"in s}function fb(s){var e=s&&nr(s)==="object"&&"byteLength"in s;if(e){var t=new DataView(s),n=t.getInt32(0,!0);if(n!==1&&n!==2)throw new TypeError("WaveformData.create(): This waveform data version not supported")}return e}function mb(s){var e=s.data,t=s.channels||1,n=24,i=s.bits===8?1:2,r=s.length*2*t;if(e.length!==r)throw new Error("WaveformData.create(): Length mismatch in JSON waveform data");var o=n+e.length*i,a=new ArrayBuffer(o),c=new DataView(a);c.setInt32(0,2,!0),c.setUint32(4,s.bits===8,!0),c.setInt32(8,s.sample_rate,!0),c.setInt32(12,s.samples_per_pixel,!0),c.setInt32(16,s.length,!0),c.setInt32(20,t,!0);var l=n;if(s.bits===8)for(var u=0;u<e.length;u++)c.setInt8(l++,e[u],!0);else for(var h=0;h<e.length;h++)c.setInt16(l,e[h],!0),l+=2;return a}function Qs(s){return s==null}function gb(s,e){var t=atob(s);return t}function _b(s,e,t){var n=gb(s),i=n.indexOf(`
1370
+ `,10)+1,r=n.substring(i)+"",o=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(o)}function vb(s,e,t){var n;return function(r){return n=n||_b(s),new Worker(n,r)}}var yb=vb("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");function Pt(s){if(pb(s)&&(s=mb(s)),fb(s)){this._data=new DataView(s),this._offset=this._version()===2?24:20,this._channels=[];for(var e=0;e<this.channels;e++)this._channels[e]=new Us(this,e)}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 bb(s){var e={scale:s.scale||jn.scale,bits:s.bits||jn.bits,amplitude_scale:s.amplitude_scale||jn.amplitude_scale,split_channels:s.split_channels||jn.split_channels,disable_worker:s.disable_worker||jn.disable_worker};return e}function wb(s){for(var e=[],t=0;t<s.numberOfChannels;++t)e.push(s.getChannelData(t).buffer);return e}function zu(s,e,t){var n=wb(s);if(e.disable_worker){var i=db({scale:e.scale,bits:e.bits,amplitude_scale:e.amplitude_scale,split_channels:e.split_channels,length:s.length,sample_rate:s.sampleRate,channels:n});t(void 0,new Pt(i),s)}else{var r=new yb;r.onmessage=function(o){t(void 0,new Pt(o.data),s)},r.postMessage({scale:e.scale,bits:e.bits,amplitude_scale:e.amplitude_scale,split_channels:e.split_channels,length:s.length,sample_rate:s.sampleRate,channels:n},n)}}function xb(s,e,t,n){function i(o){o||(o=new DOMException("EncodingError")),n(o),n=function(){}}var r=s.decodeAudioData(e,function(o){zu(o,t,n)},i);r&&r.catch(i)}Pt.create=function(e){return new Pt(e)};Pt.createFromAudio=function(s,e){var t=bb(s);if(s.audio_context&&s.array_buffer)return xb(s.audio_context,s.array_buffer,t,e);if(s.audio_buffer)return zu(s.audio_buffer,t,e);throw new TypeError("WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object")};function Xr(s){this._inputData=s.waveformData,this._output_samples_per_pixel=s.scale,this._scale=this._inputData.scale,this._input_buffer_size=this._inputData.length;var e=this._input_buffer_size*this._inputData.scale,t=Math.ceil(e/this._output_samples_per_pixel),n=24,i=this._inputData.bits===8?1:2,r=n+t*2*this._inputData.channels*i;this._output_data=new ArrayBuffer(r),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,t,!0),this.output_dataview.setInt32(20,this._inputData.channels,!0),this._outputWaveformData=new Pt(this._output_data),this._input_index=0,this._output_index=0;var o=this._inputData.channels;this._min=new Array(o),this._max=new Array(o);for(var a=0;a<o;++a)this._input_buffer_size>0?(this._min[a]=this._inputData.channel(a).min_sample(this._input_index),this._max[a]=this._inputData.channel(a).max_sample(this._input_index)):(this._min[a]=0,this._max[a]=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}Xr.prototype.sample_at_pixel=function(s){return Math.floor(s*this._output_samples_per_pixel)};Xr.prototype.next=function(){for(var s=0,e=1e3,t=this._inputData.channels,n;this._input_index<this._input_buffer_size&&s<e;){for(;Math.floor(this.sample_at_pixel(this._output_index)/this._scale)===this._input_index;){if(this._output_index>0)for(var i=0;i<t;++i)n=this._outputWaveformData.channel(i),n.set_min_sample(this._output_index-1,this._min[i]),n.set_max_sample(this._output_index-1,this._max[i]);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 r=0;r<t;++r)this._min[r]=this._max_value,this._max[r]=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<t;++o){n=this._inputData.channel(o);var a=n.min_sample(this._input_index);a<this._min[o]&&(this._min[o]=a),a=n.max_sample(this._input_index),a>this._max[o]&&(this._max[o]=a)}this._input_index++}s++}if(this._input_index<this._input_buffer_size)return!1;if(this._input_index!==this._last_input_index)for(var c=0;c<t;++c)n=this._outputWaveformData.channel(c),n.set_min_sample(this._output_index-1,this._min[c]),n.set_max_sample(this._output_index-1,this._max[c]);return!0};Xr.prototype.getOutputData=function(){return this._output_data};Pt.prototype={_getResampleOptions:function(e){var t={};if(t.scale=e.scale,t.width=e.width,!Qs(t.width)&&(typeof t.width!="number"||t.width<=0))throw new RangeError("WaveformData.resample(): width should be a positive integer value");if(!Qs(t.scale)&&(typeof t.scale!="number"||t.scale<=0))throw new RangeError("WaveformData.resample(): scale should be a positive integer value");if(!t.scale&&!t.width)throw new Error("WaveformData.resample(): Missing scale or width option");if(t.width&&(t.scale=Math.floor(this.duration*this.sample_rate/t.width)),t.scale<this.scale)throw new Error("WaveformData.resample(): Zoom level "+t.scale+" too low, minimum: "+this.scale);return t.abortSignal=e.abortSignal,t},resample:function(e){e=this._getResampleOptions(e),e.waveformData=this;for(var t=new Xr(e);!t.next(););return new Pt(t.getOutputData())},concat:function(){var e=this,t=Array.prototype.slice.call(arguments);t.forEach(function(i){if(e.channels!==i.channels||e.sample_rate!==i.sample_rate||e.bits!==i.bits||e.scale!==i.scale)throw new Error("WaveformData.concat(): Waveforms are incompatible")});var n=this._concatBuffers.apply(this,t);return Pt.create(n)},_concatBuffers:function(){for(var e=Array.prototype.slice.call(arguments),t=this._offset,n=t,i=0,r=[this].concat(e).map(function(g){return g._data.buffer}),o=0;o<r.length;o++){var a=r[o],c=new DataView(a).getInt32(16,!0);n+=a.byteLength-t,i+=c}for(var l=new ArrayBuffer(n),u=new DataView(r[0]),h=new DataView(l),p=0;p<t;p++)h.setUint8(p,u.getUint8(p));h.setInt32(16,i,!0);for(var d=0,f=new Uint8Array(l,t),_=0;_<r.length;_++){var m=r[_];f.set(new Uint8Array(m,t),d),d+=m.byteLength-t}return l},slice:function(e){var t=0,n=0;if(!Qs(e.startIndex)&&!Qs(e.endIndex)?(t=e.startIndex,n=e.endIndex):!Qs(e.startTime)&&!Qs(e.endTime)&&(t=this.at_time(e.startTime),n=this.at_time(e.endTime)),t<0)throw new RangeError("startIndex or startTime must not be negative");if(n<0)throw new RangeError("endIndex or endTime must not be negative");t>this.length&&(t=this.length),n>this.length&&(n=this.length),t>n&&(t=n);var i=n-t,r=24,o=this.bits===8?1:2,a=r+i*2*this.channels*o,c=new ArrayBuffer(a),l=new DataView(c);l.setInt32(0,2,!0),l.setUint32(4,this.bits===8,!0),l.setInt32(8,this.sample_rate,!0),l.setInt32(12,this.scale,!0),l.setInt32(16,i,!0),l.setInt32(20,this.channels,!0);for(var u=0;u<i*this.channels*2;u++){var h=this._at(t*this.channels*2+u);this.bits===8?l.setInt8(r+u,h):l.setInt16(r+u*2,h,!0)}return new Pt(c)},_version:function(){return this._data.getInt32(0,!0)},get length(){return this._data.getUint32(16,!0)},get bits(){var s=!!this._data.getUint32(4,!0);return s?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(e){if(e>=0&&e<this._channels.length)return this._channels[e];throw new RangeError("Invalid channel: "+e)},get sample_rate(){return this._data.getInt32(8,!0)},get scale(){return this._data.getInt32(12,!0)},_at:function(e){return this.bits===8?this._data.getInt8(this._offset+e):this._data.getInt16(this._offset+e*2,!0)},_set_at:function(e,t){return this.bits===8?this._data.setInt8(this._offset+e,t):this._data.setInt16(this._offset+e*2,t,!0)},at_time:function(e){return Math.floor(e*this.sample_rate/this.scale)},time:function(e){return e*this.scale/this.sample_rate},toJSON:function(){for(var e={version:2,channels:this.channels,sample_rate:this.sample_rate,samples_per_pixel:this.scale,bits:this.bits,length:this.length,data:[]},t=0;t<this.length;t++)for(var n=0;n<this.channels;n++)e.data.push(this.channel(n).min_sample(t)),e.data.push(this.channel(n).max_sample(t));return e},toArrayBuffer:function(){return this._data.buffer}};async function La(s){const e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch waveform data: ${e.statusText}`);if(s.endsWith(".dat")){const n=await e.arrayBuffer();return Pt.create(n)}else{const n=await e.json();return Pt.create(n)}}function Zu(s,e=0){const t=s.channel(e),n=s.bits,i=t.min_array(),r=t.max_array(),o=i.length,a=n===8?new Int8Array(o*2):new Int16Array(o*2);for(let c=0;c<o;c++)a[c*2]=i[c],a[c*2+1]=r[c];return{data:a,bits:n,length:o,sampleRate:s.sample_rate}}async function Cb(s,e=0){const t=await La(s);return Zu(t,e)}async function Sb(s){const e=await La(s);return{sampleRate:e.sample_rate,channels:e.channels,duration:e.duration,samplesPerPixel:e.scale,length:e.length,bits:e.bits}}exports.AudioPosition=Zy;exports.AutomaticScrollCheckbox=Xy;exports.ContinuousPlayCheckbox=Hy;exports.DownloadAnnotationsButton=Ky;exports.EditableCheckbox=Uy;exports.ExportWavButton=Qy;exports.FastForwardButton=Py;exports.LinkEndpointsCheckbox=Yy;exports.MasterVolumeControl=jy;exports.PauseButton=Ny;exports.PlayButton=Oy;exports.RewindButton=Vy;exports.SelectionTimeInputs=Gy;exports.SkipBackwardButton=Wy;exports.SkipForwardButton=By;exports.StopButton=Fy;exports.TimeFormatSelect=Ly;exports.Tone=pu;exports.Waveform=ob;exports.WaveformPlaylistProvider=Ey;exports.ZoomInButton=$y;exports.ZoomOutButton=qy;exports.createEffectChain=Cy;exports.createEffectInstance=ei;exports.effectCategories=yy;exports.effectDefinitions=Si;exports.getEffectDefinition=ja;exports.getEffectsByCategory=vy;exports.getShortcutLabel=sy;exports.getWaveformDataMetadata=Sb;exports.loadPeaksFromWaveformData=Cb;exports.loadWaveformData=La;exports.useAnnotationDragHandlers=Qv;exports.useAnnotationKeyboardControls=iy;exports.useAudioTracks=Uv;exports.useClipDragHandlers=Kv;exports.useClipSplitting=ty;exports.useDragSensors=ey;exports.useDynamicEffects=Sy;exports.useExportWav=Wu;exports.useIntegratedRecording=_y;exports.useKeyboardShortcuts=sr;exports.useMasterAnalyser=Xv;exports.useMasterVolume=Vu;exports.usePlaybackAnimation=At;exports.usePlaybackShortcuts=ny;exports.usePlaylistControls=Ue;exports.usePlaylistData=wt;exports.usePlaylistState=rs;exports.useTimeFormat=Nu;exports.useTrackDynamicEffects=Ty;exports.useWaveformPlaylist=My;exports.useZoomControls=Fu;exports.waveformDataToPeaks=Zu;
1371
1371
  //# sourceMappingURL=index.js.map