tone 15.4.0 → 15.4.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/build/Tone.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see Tone.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tone=e():t.Tone=e()}("undefined"!=typeof self?self:this,(()=>(()=>{var t={18:t=>{t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},113:t=>{t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=Array(e);s<e;s++)n[s]=t[s];return n},t.exports.__esModule=!0,t.exports.default=t.exports},327:(t,e,s)=>{var n=s(564).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},474:t=>{t.exports=function(t,e){var s=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=s){var n,i,o,r,a=[],c=!0,h=!1;try{if(o=(s=s.call(t)).next,0===e){if(Object(s)!==s)return;c=!1}else for(;!(c=(n=o.call(s)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){h=!0,i=t}finally{try{if(!c&&null!=s.return&&(r=s.return(),Object(r)!==r))return}finally{if(h)throw i}}return a}},t.exports.__esModule=!0,t.exports.default=t.exports},498:(t,e,s)=>{var n=s(564).default,i=s(327);t.exports=function(t){var e=i(t,"string");return"symbol"==n(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},564:t=>{function e(s){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(s)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},569:t=>{t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},744:(t,e,s)=>{var n=s(113);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?n(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},805:t=>{t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},821:(t,e,s)=>{var n=s(569),i=s(474),o=s(744),r=s(18);t.exports=function(t,e){return n(t)||i(t,e)||o(t,e)||r()},t.exports.__esModule=!0,t.exports.default=t.exports},871:function(t,e,s){!function(t,e,s,n){"use strict";var i=function(t,e,s){return{endTime:e,insertTime:s,type:"exponentialRampToValue",value:t}},o=function(t,e,s){return{endTime:e,insertTime:s,type:"linearRampToValue",value:t}},r=function(t,e){return{startTime:e,type:"setValue",value:t}},a=function(t,e,s){return{duration:s,startTime:e,type:"setValueCurve",values:t}},c=function(t,e,s){var n=s.startTime,i=s.target,o=s.timeConstant;return i+(e-i)*Math.exp((n-t)/o)},h=function(t){return"exponentialRampToValue"===t.type},l=function(t){return"linearRampToValue"===t.type},u=function(t){return h(t)||l(t)},p=function(t){return"setValue"===t.type},d=function(t){return"setValueCurve"===t.type},f=function(t,e,s,n){var i=t[e];return void 0===i?n:u(i)||p(i)?i.value:d(i)?i.values[i.values.length-1]:c(s,f(t,e-1,i.startTime,n),i)},_=function(t,e,s,n,i){return void 0===s?[n.insertTime,i]:u(s)?[s.endTime,s.value]:p(s)?[s.startTime,s.value]:d(s)?[s.startTime+s.duration,s.values[s.values.length-1]]:[s.startTime,f(t,e-1,s.startTime,i)]},m=function(t){return"cancelAndHold"===t.type},g=function(t){return"cancelScheduledValues"===t.type},v=function(t){return m(t)||g(t)?t.cancelTime:h(t)||l(t)?t.endTime:t.startTime},y=function(t,e,s,n){var i=n.endTime,o=n.value;return s===o?o:0<s&&0<o||s<0&&o<0?s*Math.pow(o/s,(t-e)/(i-e)):0},x=function(t,e,s,n){return s+(t-e)/(n.endTime-e)*(n.value-s)},w=function(t,e){var s=e.duration,n=e.startTime,i=e.values;return function(t,e){var s=Math.floor(e),n=Math.ceil(e);return s===n?t[s]:(1-(e-s))*t[s]+(1-(n-e))*t[n]}(i,(t-n)/s*(i.length-1))},b=function(t){return"setTarget"===t.type},T=function(){return n((function t(e){s(this,t),this._automationEvents=[],this._currenTime=0,this._defaultValue=e}),[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:"add",value:function(t){var e=v(t);if(m(t)||g(t)){var s=this._automationEvents.findIndex((function(s){return g(t)&&d(s)?s.startTime+s.duration>=e:v(s)>=e})),n=this._automationEvents[s];if(-1!==s&&(this._automationEvents=this._automationEvents.slice(0,s)),m(t)){var c=this._automationEvents[this._automationEvents.length-1];if(void 0!==n&&u(n)){if(void 0!==c&&b(c))throw new Error("The internal list is malformed.");var p=void 0===c?n.insertTime:d(c)?c.startTime+c.duration:v(c),f=void 0===c?this._defaultValue:d(c)?c.values[c.values.length-1]:c.value,_=h(n)?y(e,p,f,n):x(e,p,f,n),w=h(n)?i(_,e,this._currenTime):o(_,e,this._currenTime);this._automationEvents.push(w)}if(void 0!==c&&b(c)&&this._automationEvents.push(r(this.getValue(e),e)),void 0!==c&&d(c)&&c.startTime+c.duration>e){var T=e-c.startTime,S=(c.values.length-1)/c.duration,k=Math.max(2,1+Math.ceil(T*S)),A=T/(k-1)*S,C=c.values.slice(0,k);if(A<1)for(var O=1;O<k;O+=1){var D=A*O%1;C[O]=c.values[O-1]*(1-D)+c.values[O]*D}this._automationEvents[this._automationEvents.length-1]=a(C,c.startTime,T)}}}else{var M=this._automationEvents.findIndex((function(t){return v(t)>e})),E=-1===M?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[M-1];if(void 0!==E&&d(E)&&v(E)+E.duration>e)return!1;var R=h(t)?i(t.value,t.endTime,this._currenTime):l(t)?o(t.value,e,this._currenTime):t;if(-1===M)this._automationEvents.push(R);else{if(d(t)&&e+t.duration>v(this._automationEvents[M]))return!1;this._automationEvents.splice(M,0,R)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return v(e)>t}));if(e>1){var s=this._automationEvents.slice(e-1),n=s[0];b(n)&&s.unshift(r(f(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=s}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var s=this._automationEvents.findIndex((function(e){return v(e)>t})),n=this._automationEvents[s],i=(-1===s?this._automationEvents.length:s)-1,o=this._automationEvents[i];if(void 0!==o&&b(o)&&(void 0===n||!u(n)||n.insertTime>t))return c(t,f(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(void 0!==o&&p(o)&&(void 0===n||!u(n)))return o.value;if(void 0!==o&&d(o)&&(void 0===n||!u(n)||o.startTime+o.duration>t))return t<o.startTime+o.duration?w(t,o):o.values[o.values.length-1];if(void 0!==o&&u(o)&&(void 0===n||!u(n)))return o.value;if(void 0!==n&&h(n)){var r=_(this._automationEvents,i,o,n,this._defaultValue),a=e(r,2),m=a[0],g=a[1];return y(t,m,g,n)}if(void 0!==n&&l(n)){var T=_(this._automationEvents,i,o,n,this._defaultValue),S=e(T,2),k=S[0],A=S[1];return x(t,k,A,n)}return this._defaultValue}}])}();t.AutomationEventList=T,t.createCancelAndHoldAutomationEvent=function(t){return{cancelTime:t,type:"cancelAndHold"}},t.createCancelScheduledValuesAutomationEvent=function(t){return{cancelTime:t,type:"cancelScheduledValues"}},t.createExponentialRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"exponentialRampToValue",value:t}},t.createLinearRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"linearRampToValue",value:t}},t.createSetTargetAutomationEvent=function(t,e,s){return{startTime:e,target:t,timeConstant:s,type:"setTarget"}},t.createSetValueAutomationEvent=r,t.createSetValueCurveAutomationEvent=a}(e,s(821),s(805),s(989))},989:(t,e,s)=>{var n=s(498);function i(t,e){for(var s=0;s<e.length;s++){var i=e[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,n(i.key),i)}}t.exports=function(t,e,s){return e&&i(t.prototype,e),s&&i(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function s(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,s),o.exports}s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";s.r(n),s.d(n,{AMOscillator:()=>Za,AMSynth:()=>ic,Abs:()=>To,Add:()=>Fo,AmplitudeEnvelope:()=>rr,Analyser:()=>lo,AudioToGain:()=>Fr,AutoFilter:()=>Xr,AutoPanner:()=>Yr,AutoWah:()=>$r,BaseContext:()=>Mi,BiquadFilter:()=>Bo,BitCrusher:()=>Kr,Buffer:()=>qc,BufferSource:()=>Ic,Buffers:()=>Vc,Channel:()=>Ro,Chebyshev:()=>ea,Chorus:()=>ia,Clock:()=>Tr,Compressor:()=>Yo,Context:()=>Ii,Convolver:()=>lr,CrossFade:()=>Vo,DCMeter:()=>po,Delay:()=>Sr,Destination:()=>Sc,Distortion:()=>oa,Draw:()=>Dc,DuoSynth:()=>rc,EQ3:()=>ur,Emitter:()=>Di,Envelope:()=>ir,FFT:()=>fo,FMOscillator:()=>Ya,FMSynth:()=>ac,FatOscillator:()=>Xa,FeedbackCombFilter:()=>gr,FeedbackDelay:()=>aa,Filter:()=>Uo,Follower:()=>ko,Freeverb:()=>la,Frequency:()=>Ji,FrequencyClass:()=>Yi,FrequencyEnvelope:()=>hr,FrequencyShifter:()=>pa,Gain:()=>co,GainToAudio:()=>qo,Gate:()=>Jo,GrainPlayer:()=>mc,GreaterThan:()=>$o,GreaterThanZero:()=>Ho,IntervalTimeline:()=>qr,JCReverb:()=>ma,LFO:()=>Qr,Limiter:()=>Ko,Listener:()=>Cc,Loop:()=>Ia,LowpassCombFilter:()=>vr,Master:()=>kc,MembraneSynth:()=>cc,Merge:()=>Io,MetalSynth:()=>lc,Meter:()=>Ao,MidSideCompressor:()=>tr,MidSideMerge:()=>Lo,MidSideSplit:()=>zo,Midi:()=>Dr,MidiClass:()=>Or,Mono:()=>Wo,MonoSynth:()=>oc,MultibandCompressor:()=>er,MultibandSplit:()=>Go,Multiply:()=>Po,Negate:()=>No,Noise:()=>ba,NoiseSynth:()=>uc,Offline:()=>Ar,OfflineContext:()=>Li,OmniOscillator:()=>Ka,OnePoleFilter:()=>So,Oscillator:()=>Gr,PWMOscillator:()=>$a,PanVol:()=>Mo,Panner:()=>Oo,Panner3D:()=>Zo,Param:()=>so,Part:()=>Fa,Pattern:()=>Ga,Phaser:()=>ga,PingPongDelay:()=>ya,PitchShift:()=>xa,Player:()=>gc,Players:()=>vc,PluckSynth:()=>pc,PolySynth:()=>dc,Pow:()=>ar,PulseOscillator:()=>Ha,Recorder:()=>Xo,Reverb:()=>Aa,ReverseDelay:()=>Oa,Sampler:()=>fc,Scale:()=>cr,ScaleExp:()=>Hr,Sequence:()=>Qa,Signal:()=>go,Solo:()=>Eo,Split:()=>ho,StateTimeline:()=>yr,StereoWidener:()=>Ea,Subtract:()=>jo,SyncedSignal:()=>_c,Synth:()=>sc,Ticks:()=>Er,TicksClass:()=>Mr,Time:()=>Xi,TimeClass:()=>Zi,Timeline:()=>ki,ToneAudioBuffer:()=>ji,ToneAudioBuffers:()=>Cr,ToneAudioNode:()=>no,ToneBufferSource:()=>wa,ToneEvent:()=>Va,ToneOscillatorNode:()=>Ur,Transport:()=>bc,TransportTime:()=>to,TransportTimeClass:()=>Ki,Tremolo:()=>Ra,Unit:()=>e,UserMedia:()=>yc,Vibrato:()=>qa,Volume:()=>Do,WaveShaper:()=>bo,Waveform:()=>Co,Zero:()=>Pr,connect:()=>oo,connectSeries:()=>io,connectSignal:()=>yo,context:()=>Ec,dbToGain:()=>i,debug:()=>t,defaultArg:()=>di,disconnect:()=>ro,disconnectSignal:()=>xo,fanIn:()=>ao,ftom:()=>c,gainToDb:()=>o,getContext:()=>Bi,getDestination:()=>Ac,getDraw:()=>Mc,getListener:()=>Oc,getTransport:()=>Tc,immediate:()=>wc,intervalToFrequencyRatio:()=>r,isArray:()=>Hn,isBoolean:()=>Yn,isDefined:()=>Gn,isFunction:()=>Qn,isNote:()=>Jn,isNumber:()=>Zn,isObject:()=>Xn,isString:()=>$n,isUndef:()=>Un,loaded:()=>Rc,mtof:()=>l,now:()=>xc,optionsFromArguments:()=>pi,setContext:()=>Ui,start:()=>Gi,supported:()=>jn,version:()=>wi});var t={};s.r(t),s.d(t,{assert:()=>Kn,assertContextRunning:()=>ei,assertRange:()=>ti,assertUsedScheduleTime:()=>oi,enterScheduledCallback:()=>ii,log:()=>ci,setLogger:()=>ai,warn:()=>hi});var e={};function i(t){return Math.pow(10,t/20)}function o(t){return Math.log(t)/Math.LN10*20}function r(t){return Math.pow(2,t/12)}s.r(e);let a=440;function c(t){return Math.round(h(t))}function h(t){return 69+12*Math.log2(t/a)}function l(t){return a*Math.pow(2,(t-69)/12)}var u=s(871);const p=new WeakSet,d=new WeakMap,f=new WeakMap,_=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakMap,w=new WeakMap,b={construct:()=>b},T=/^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]*);?/,S=(t,e)=>{const s=[];let n=t.replace(/^[\s]+/,""),i=n.match(T);for(;null!==i;){const t=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());s.push(o),n=n.slice(i[0].length).replace(/^[\s]+/,""),i=n.match(T)}return[s.join(";"),n]},k=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},A=t=>{if(!(t=>{try{new new Proxy(t,b)}catch{return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.")},C=(t,e)=>{const s=t.get(e);if(void 0===s)throw new Error("A value with the given key could not be found.");return s},O=(t,e)=>{const s=Array.from(t).filter(e);if(s.length>1)throw Error("More than one element was found.");if(0===s.length)throw Error("No element was found.");const[n]=s;return t.delete(n),n},D=(t,e,s,n)=>{const i=C(t,e),o=O(i,(t=>t[0]===s&&t[1]===n));return 0===i.size&&t.delete(e),o},M=t=>C(v,t),E=t=>{if(p.has(t))throw new Error("The AudioNode is already stored.");p.add(t),M(t).forEach((t=>t(!0)))},R=t=>"port"in t,q=t=>{if(!p.has(t))throw new Error("The AudioNode is not stored.");p.delete(t),M(t).forEach((t=>t(!1)))},V=(t,e)=>{!R(t)&&e.every((t=>0===t.size))&&q(t)},I={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},F=(t,e)=>t.context===e,P=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},N=()=>new DOMException("","IndexSizeError"),j=t=>{var e;t.getChannelData=(e=t.getChannelData,s=>{try{return e.call(t,s)}catch(t){if(12===t.code)throw N();throw t}})},L={numberOfChannels:1},z=-34028234663852886e22,W=-z,B=t=>p.has(t),U={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},G=t=>C(d,t),Q=t=>C(_,t),Z=(t,e)=>{const{activeInputs:s}=G(t);s.forEach((s=>s.forEach((([s])=>{e.includes(t)||Z(s,[...e,t])}))));const n=(t=>"playbackRate"in t)(t)?[t.playbackRate]:R(t)?Array.from(t.parameters.values()):(t=>"frequency"in t&&"gain"in t)(t)?[t.Q,t.detune,t.frequency,t.gain]:(t=>"offset"in t)(t)?[t.offset]:(t=>!("frequency"in t)&&"gain"in t)(t)?[t.gain]:(t=>"detune"in t&&"frequency"in t&&!("gain"in t))(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of n){const s=Q(t);void 0!==s&&s.activeInputs.forEach((([t])=>Z(t,e)))}B(t)&&q(t)},X=t=>{Z(t.destination,[])},Y=t=>"context"in t,H=t=>Y(t[0]),$=(t,e,s,n)=>{for(const e of t)if(s(e)){if(n)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},J=(t,e,[s,n],i)=>{$(t,[e,s,n],(t=>t[0]===e&&t[1]===s),i)},K=(t,[e,s,n],i)=>{const o=t.get(e);void 0===o?t.set(e,new Set([[s,n]])):$(o,[s,n],(t=>t[0]===s),i)},tt=t=>"inputs"in t,et=(t,e,s,n)=>{if(tt(e)){const i=e.inputs[n];return t.connect(i,s,0),[i,s,0]}return t.connect(e,s,n),[e,s,n]},st=(t,e,s)=>{for(const n of t)if(n[0]===e&&n[1]===s)return t.delete(n),n;return null},nt=(t,e)=>{if(!M(t).delete(e))throw new Error("Missing the expected event listener.")},it=(t,e,s)=>{const n=C(t,e),i=O(n,(t=>t[0]===s));return 0===n.size&&t.delete(e),i},ot=(t,e,s,n)=>{tt(e)?t.disconnect(e.inputs[n],s,0):t.disconnect(e,s,n)},rt=t=>C(f,t),at=t=>C(m,t),ct=t=>y.has(t),ht=t=>!p.has(t),lt=(t,e)=>new Promise((s=>{if(null!==e)s(!0);else{const e=t.createScriptProcessor(256,1,1),n=t.createGain(),i=t.createBuffer(1,2,44100),o=i.getChannelData(0);o[0]=1,o[1]=1;const r=t.createBufferSource();r.buffer=i,r.loop=!0,r.connect(e).connect(t.destination),r.connect(n),r.disconnect(n),e.onaudioprocess=n=>{const i=n.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?s(!0):s(!1),r.stop(),e.onaudioprocess=null,r.disconnect(e),e.disconnect(t.destination)},r.start()}})),ut=(t,e)=>{const s=new Map;for(const e of t)for(const t of e){const e=s.get(t);s.set(t,void 0===e?1:e+1)}s.forEach(((t,s)=>e(s,t)))},pt=t=>"context"in t,dt=t=>{const e=new Map;t.connect=(t=>(s,n=0,i=0)=>{const o=pt(s)?t(s,n,i):t(s,n),r=e.get(s);return void 0===r?e.set(s,[{input:i,output:n}]):r.every((t=>t.input!==i||t.output!==n))&&r.push({input:i,output:n}),o})(t.connect.bind(t)),t.disconnect=(s=>(n,i,o)=>{if(s.apply(t),void 0===n)e.clear();else if("number"==typeof n)for(const[t,s]of e){const i=s.filter((t=>t.output!==n));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(n))if(void 0===i)e.delete(n);else{const t=e.get(n);if(void 0!==t){const s=t.filter((t=>t.output!==i&&(t.input!==o||void 0===o)));0===s.length?e.delete(n):e.set(n,s)}}for(const[s,n]of e)n.forEach((e=>{pt(s)?t.connect(s,e.output,e.input):t.connect(s,e.output)}))})(t.disconnect)},ft=(t,e,s,n,i)=>{const[o,r]=((t,e,s,n)=>{const{activeInputs:i,passiveInputs:o}=G(e),r=st(i[n],t,s);return null===r?[D(o,t,s,n)[2],!1]:[r[2],!0]})(t,s,n,i);if(null!==o&&(nt(t,o),!r||e||ct(t)||ot(rt(t),rt(s),n,i)),B(s)){const{activeInputs:t}=G(s);V(s,t)}},_t=(t,e,s,n)=>{const[i,o]=((t,e,s)=>{const{activeInputs:n,passiveInputs:i}=Q(e),o=st(n,t,s);return null===o?[it(i,t,s)[1],!1]:[o[2],!0]})(t,s,n);null!==i&&(nt(t,i),!o||e||ct(t)||rt(t).disconnect(at(s),n))};class mt{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach(((s,n)=>t.call(e,s,n,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const gt={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function vt(t,e,s,n,i){if("function"==typeof t.copyFromChannel)0===e[s].byteLength&&(e[s]=new Float32Array(128)),t.copyFromChannel(e[s],n,i);else{const o=t.getChannelData(n);if(0===e[s].byteLength)e[s]=o.slice(i,i+128);else{const t=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[s].set(t)}}}const yt=(t,e,s,n,i)=>{"function"==typeof t.copyToChannel?0!==e[s].byteLength&&t.copyToChannel(e[s],n,i):0!==e[s].byteLength&&t.getChannelData(n).set(e[s],i)},xt=(t,e)=>{const s=[];for(let n=0;n<t;n+=1){const t=[],i="number"==typeof e?e:e[n];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));s.push(t)}return s},wt=async(t,e,s,n,i,o,r)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,c=n.channelCount*n.numberOfInputs,h=i.reduce(((t,e)=>t+e),0),l=0===h?null:s.createBuffer(h,a,s.sampleRate);if(void 0===o)throw new Error("Missing the processor constructor.");const u=G(t),p=await((t,e)=>{const s=C(w,t),n=rt(e);return C(s,n)})(s,t),d=xt(n.numberOfInputs,n.channelCount),f=xt(n.numberOfOutputs,i),_=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let h=0;h<a;h+=128){if(n.numberOfInputs>0&&null!==e)for(let t=0;t<n.numberOfInputs;t+=1)for(let s=0;s<n.channelCount;s+=1)vt(e,d[t],s,s,h);void 0!==o.parameterDescriptors&&null!==e&&o.parameterDescriptors.forEach((({name:t},s)=>{vt(e,_,t,c+s,h)}));for(let t=0;t<n.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===f[t][e].byteLength&&(f[t][e]=new Float32Array(128));try{const t=d.map(((t,e)=>0===u.activeInputs[e].size?[]:t)),e=r(h/s.sampleRate,s.sampleRate,(()=>p.process(t,f,_)));if(null!==l)for(let t=0,e=0;t<n.numberOfOutputs;t+=1){for(let s=0;s<i[t];s+=1)yt(l,f[t],s,e+s,h);e+=i[t]}if(!e)break}catch(e){t.dispatchEvent(new ErrorEvent("processorerror",{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}));break}}return l},bt={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Tt={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},St={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},kt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},At={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Ct=t=>{const{port1:e,port2:s}=new MessageChannel;return new Promise((n=>{const i=()=>{s.onmessage=null,e.close(),s.close(),n()};s.onmessage=()=>i();try{e.postMessage(t,[t])}catch{}finally{i()}}))},Ot={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Dt=(t,e,s)=>{const n=e[s];if(void 0===n)throw t();return n},Mt={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Et={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Rt=()=>new DOMException("","InvalidStateError"),qt=()=>new DOMException("","InvalidAccessError"),Vt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},It=(t,e,s,n,i,o,r,a,c,h,l)=>{const u=h.length;let p=a;for(let a=0;a<u;a+=1){let u=s[0]*h[a];for(let e=1;e<i;e+=1){const n=p-e&c-1;u+=s[e]*o[n],u-=t[e]*r[n]}for(let t=i;t<n;t+=1)u+=s[t]*o[p-t&c-1];for(let s=i;s<e;s+=1)u-=t[s]*r[p-s&c-1];o[p]=h[a],r[p]=u,p=p+1&c-1,l[a]=u}return p},Ft={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Pt=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const s=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==s&&(s.catch((()=>{})),!0)}catch{}return!1},Nt=(t,e,s)=>{const n=e[s];void 0!==n&&n!==t[s]&&(t[s]=n)},jt=(t,e)=>{Nt(t,e,"channelCount"),Nt(t,e,"channelCountMode"),Nt(t,e,"channelInterpretation")},Lt=t=>"function"==typeof t.getFloatTimeDomainData,zt=(t,e,s)=>{const n=e[s];void 0!==n&&n!==t[s].value&&(t[s].value=n)},Wt=t=>{t.start=(e=>(s=0,n=0,i)=>{if("number"==typeof i&&i<0||n<0||s<0)throw new RangeError("The parameters can't be negative.");e.call(t,s,n,i)})(t.start)},Bt=t=>{var e;t.stop=(e=t.stop,(s=0)=>{if(s<0)throw new RangeError("The parameter can't be negative.");e.call(t,s)})},Ut=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),Gt=(t,e)=>{const s=t.createBiquadFilter();return jt(s,e),zt(s,e,"Q"),zt(s,e,"detune"),zt(s,e,"frequency"),zt(s,e,"gain"),Nt(s,e,"type"),s},Qt=(t,e)=>{const s=t.createChannelSplitter(e.numberOfOutputs);return jt(s,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Rt()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Rt()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Rt()}})})(s),s},Zt=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),Xt=(t,e)=>{const s=t.createDelay(e.maxDelayTime);return jt(s,e),zt(s,e,"delayTime"),s},Yt=(t,e)=>{const s=t.createGain();return jt(s,e),zt(s,e,"gain"),s};function Ht(t,e){const s=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/s,(t[1]*e[0]-t[0]*e[1])/s]}function $t(t,e){let s=[0,0];for(let o=t.length-1;o>=0;o-=1)i=e,s=[(n=s)[0]*i[0]-n[1]*i[1],n[0]*i[1]+n[1]*i[0]],s[0]+=t[o];var n,i;return s}const Jt=(t,e,s,n)=>t.createScriptProcessor(e,s,n),Kt=()=>new DOMException("","NotSupportedError"),te={numberOfChannels:1},ee={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},se={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},ne={disableNormalization:!1},ie={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},oe=()=>new DOMException("","UnknownError"),re={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},ae=(t,e,s)=>void 0===t.copyFromChannel?t.getChannelData(s)[0]:(t.copyFromChannel(e,s),e[0]),ce=t=>{if(null===t)return!1;const e=t.length;return e%2!=0?0!==t[Math.floor(e/2)]:t[e/2-1]+t[e/2]!==0},he=(t,e,s,n)=>{let i=t;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:o,set:r}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:s(o),set:n(r)})},le=(t,e,s)=>{try{t.setValueAtTime(e,s)}catch(n){if(9!==n.code)throw n;le(t,e,s+1e-7)}},ue=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},pe=t=>{const e=t.createBuffer(1,1,44100),s=t.createBufferSource();s.buffer=e,s.start(),s.stop();try{return s.stop(),!0}catch{return!1}},de=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},fe=()=>{try{new DOMException}catch{return!1}return!0},_e=()=>new Promise((t=>{const e=new ArrayBuffer(0),{port1:s,port2:n}=new MessageChannel;s.onmessage=({data:e})=>t(null!==e),n.postMessage(e,[e])})),me=(t,e)=>{const s=e.createGain();t.connect(s);const n=(e=>()=>{e.call(t,s),t.removeEventListener("ended",n)})(t.disconnect);t.addEventListener("ended",n),Zt(t,s),t.stop=(e=>{let n=!1;return(i=0)=>{if(n)try{e.call(t,i)}catch{s.gain.setValueAtTime(0,i)}else e.call(t,i),n=!0}})(t.stop)},ge=(t,e)=>s=>{const n={value:t};return Object.defineProperties(s,{currentTarget:n,target:n}),"function"==typeof e?e.call(t,s):e.handleEvent.call(t,s)},ve=(t=>(e,s,[n,i,o],r)=>{t(e[i],[s,n,o],(t=>t[0]===s&&t[1]===n),r)})($),ye=(t=>(e,s,[n,i,o],r)=>{const a=e.get(n);void 0===a?e.set(n,new Set([[i,s,o]])):t(a,[i,s,o],(t=>t[0]===i&&t[1]===s),r)})($),xe=(t=>(e,s,n,i)=>t(e[i],(t=>t[0]===s&&t[1]===n)))(O),we=new WeakMap,be=(t=>e=>{var s;return null!==(s=t.get(e))&&void 0!==s?s:0})(we),Te=(Se=new Map,ke=new WeakMap,(t,e)=>{const s=ke.get(t);if(void 0!==s)return s;const n=Se.get(t);if(void 0!==n)return n;try{const s=e();return s instanceof Promise?(Se.set(t,s),s.catch((()=>!1)).then((e=>(Se.delete(t),ke.set(t,e),e)))):(ke.set(t,s),s)}catch{return ke.set(t,!1),!1}});var Se,ke;const Ae="undefined"==typeof window?null:window,Ce=((t,e)=>(s,n)=>{const i=s.createAnalyser();if(jt(i,n),!(n.maxDecibels>n.minDecibels))throw e();return Nt(i,n,"fftSize"),Nt(i,n,"maxDecibels"),Nt(i,n,"minDecibels"),Nt(i,n,"smoothingTimeConstant"),t(Lt,(()=>Lt(i)))||(t=>{t.getFloatTimeDomainData=e=>{const s=new Uint8Array(e.length);t.getByteTimeDomainData(s);const n=Math.max(s.length,t.fftSize);for(let t=0;t<n;t+=1)e[t]=.0078125*(s[t]-128);return e}})(i),i})(Te,N),Oe=(t=>e=>{const s=t(e);if(null===s.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return s.renderer})(G),De=((t,e,s)=>async(n,i,o)=>{const r=t(n);await Promise.all(r.activeInputs.map(((t,r)=>Array.from(t).map((async([t,a])=>{const c=e(t),h=await c.render(t,i),l=n.context.destination;s(t)||n===l&&s(n)||h.connect(o,a,r)})))).reduce(((t,e)=>[...t,...e]),[]))})(G,Oe,ct),Me=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,fftSize:r.fftSize,maxDecibels:r.maxDecibels,minDecibels:r.minDecibels,smoothingTimeConstant:r.smoothingTimeConstant};r=t(o,e)}return n.set(o,r),await s(i,o,r),r})(i,o)}}})(Ce,rt,De),Ee=(Re=g,t=>{const e=Re.get(t);if(void 0===e)throw Rt();return e});var Re;const qe=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(Ae),Ve=(t=>e=>null!==t&&e instanceof t)(qe),Ie=new WeakMap,Fe=(t=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(e,s,n){if(null!==s){let i=this._listeners.get(s);void 0===i&&(i=t(this,s),"function"==typeof s&&this._listeners.set(s,i)),this._nativeEventTarget.addEventListener(e,i,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,s){const n=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===n?null:n,s)}})(ge),Pe=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(Ae),Ne=(t=>e=>null!==t&&e instanceof t)(Pe),je=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(Ae),Le=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(Ae),ze=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(Ae),We=((t,e,s,n,i,o,r,a,c,h,l,u,p,d,_,m)=>class extends h{constructor(e,n,i,o){super(i),this._context=e,this._nativeAudioNode=i;const r=l(e);u(r)&&!0!==s(lt,(()=>lt(r,m)))&&dt(i),f.set(this,i),v.set(this,new Set),"closed"!==e.state&&n&&E(this),t(this,o,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,s=0,a=0){if(s<0||s>=this._nativeAudioNode.numberOfOutputs)throw i();const h=l(this._context),u=_(h);if(p(t)||d(t))throw o();if(Y(t)){const i=rt(t);try{const e=et(this._nativeAudioNode,i,s,a),n=ht(this);(u||n)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!n&&ht(t)&&E(t)}catch(t){if(12===t.code)throw o();throw t}if(e(this,t,s,a,u)){const e=c([this],t);ut(e,n(u))}return t}const f=at(t);if("playbackRate"===f.name&&1024===f.maxValue)throw r();try{this._nativeAudioNode.connect(f,s),(u||ht(this))&&this._nativeAudioNode.disconnect(f,s)}catch(t){if(12===t.code)throw o();throw t}if(((t,e,s,n)=>{const{activeInputs:i,passiveInputs:o}=Q(e),{outputs:r}=G(t),a=M(t),c=r=>{const a=rt(t),c=at(e);if(r){const e=it(o,t,s);J(i,t,e,!1),n||ct(t)||a.connect(c,s)}else{const e=((t,e,s)=>O(t,(t=>t[0]===e&&t[1]===s)))(i,t,s);K(o,e,!1),n||ct(t)||a.disconnect(c,s)}};return!!$(r,[e,s],(t=>t[0]===e&&t[1]===s),!0)&&(a.add(c),B(t)?J(i,t,[s,c],!0):K(o,[t,s,c],!0),!0)})(this,t,s,u)){const e=c([this],t);ut(e,n(u))}}disconnect(t,e,s){let n;const r=l(this._context),h=_(r);if(void 0===t)n=((t,e)=>{const s=G(t),n=[];for(const i of s.outputs)H(i)?ft(t,e,...i):_t(t,e,...i),n.push(i[0]);return s.outputs.clear(),n})(this,h);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();n=((t,e,s)=>{const n=G(t),i=[];for(const o of n.outputs)o[1]===s&&(H(o)?ft(t,e,...o):_t(t,e,...o),i.push(o[0]),n.outputs.delete(o));return i})(this,h,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(Y(t)&&void 0!==s&&(s<0||s>=t.numberOfInputs))throw i();if(n=((t,e,s,n,i)=>{const o=G(t);return Array.from(o.outputs).filter((t=>!(t[0]!==s||void 0!==n&&t[1]!==n||void 0!==i&&t[2]!==i))).map((s=>(H(s)?ft(t,e,...s):_t(t,e,...s),o.outputs.delete(s),s[0])))})(this,h,t,e,s),0===n.length)throw o()}for(const t of n){const e=c([this],t);ut(e,a)}}})((Be=d,(t,e,s)=>{const n=[];for(let t=0;t<s.numberOfInputs;t+=1)n.push(new Set);Be.set(t,{activeInputs:n,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,s,n,i,o,r,a,c,h,l,u,p)=>{const d=new WeakMap;return(f,_,m,g,v)=>{const{activeInputs:y,passiveInputs:x}=o(_),{outputs:w}=o(f),b=a(f),T=o=>{const a=c(_),h=c(f);if(o){const e=D(x,f,m,g);t(y,f,e,!1),v||u(f)||s(h,a,m,g),p(_)&&E(_)}else{const t=n(y,f,m,g);e(x,g,t,!1),v||u(f)||i(h,a,m,g);const s=r(_);if(0===s)l(_)&&V(_,y);else{const t=d.get(_);void 0!==t&&clearTimeout(t),d.set(_,setTimeout((()=>{l(_)&&V(_,y)}),1e3*s))}}};return!!h(w,[_,m,g],(t=>t[0]===_&&t[1]===m&&t[2]===g),!0)&&(b.add(T),l(f)?t(y,f,[m,g,T],!0):e(x,g,[f,m,T],!0),!0)}})(ve,ye,et,xe,ot,G,be,M,rt,$,B,ct,ht),Te,((t,e,s,n,i,o)=>r=>(a,c)=>{const h=t.get(a);if(void 0===h){if(!r&&o(a)){const t=n(a),{outputs:o}=s(a);for(const s of o)if(H(s)){const i=n(s[0]);e(t,i,s[1],s[2])}else{const e=i(s[0]);t.disconnect(e,s[1])}}t.set(a,c)}else t.set(a,h+c)})(y,ot,G,rt,at,B),N,qt,Kt,((t,e,s,n,i,o,r,a)=>(c,h)=>{const l=e.get(c);if(void 0===l)throw new Error("Missing the expected cycle count.");const u=o(c.context),p=a(u);if(l===h){if(e.delete(c),!p&&r(c)){const e=n(c),{outputs:o}=s(c);for(const s of o)if(H(s)){const i=n(s[0]);t(e,i,s[1],s[2])}else{const t=i(s[0]);e.connect(t,s[1])}}}else e.set(c,l-h)})(et,y,G,rt,at,Ee,B,Ve),((t,e,s)=>function n(i,o){const r=Y(o)?o:s(t,o);if((t=>"delayTime"in t)(r))return[];if(i[0]===r)return[i];if(i.includes(r))return[];const{outputs:a}=e(r);return Array.from(a).map((t=>n([...i,r],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(Ie,G,C),Fe,Ee,Ne,je,Le,Ve,ze);var Be;const Ue=((t,e,s,n,i,o)=>class extends t{constructor(t,s){const r=i(t),a={...I,...s},c=n(r,a);super(t,!1,c,o(r)?e():null),this._nativeAnalyserNode=c}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,s()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,s()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(We,Me,N,Ce,Ee,Ve),Ge=new WeakSet,Qe=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(Ae),Ze=(Xe=new Uint32Array(1),t=>(Xe[0]=t,Xe[0]));var Xe;const Ye=((t,e)=>s=>{s.copyFromChannel=(n,i,o=0)=>{const r=t(o),a=t(i);if(a>=s.numberOfChannels)throw e();const c=s.length,h=s.getChannelData(a),l=n.length;for(let t=r<0?-r:0;t+r<c&&t<l;t+=1)n[t]=h[t+r]},s.copyToChannel=(n,i,o=0)=>{const r=t(o),a=t(i);if(a>=s.numberOfChannels)throw e();const c=s.length,h=s.getChannelData(a),l=n.length;for(let t=r<0?-r:0;t+r<c&&t<l;t+=1)h[t+r]=n[t]}})(Ze,N),He=(t=>e=>{e.copyFromChannel=(s=>(n,i,o=0)=>{const r=t(o),a=t(i);if(r<e.length)return s.call(e,n,a,r)})(e.copyFromChannel),e.copyToChannel=(s=>(n,i,o=0)=>{const r=t(o),a=t(i);if(r<e.length)return s.call(e,n,a,r)})(e.copyToChannel)})(Ze),$e=((t,e,s,n,i,o,r,a)=>{let c=null;return class h{constructor(h){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:u,sampleRate:p}={...L,...h};null===c&&(c=new i(1,1,44100));const d=null!==n&&e(o,o)?new n({length:l,numberOfChannels:u,sampleRate:p}):c.createBuffer(u,l,p);if(0===d.numberOfChannels)throw s();return"function"!=typeof d.copyFromChannel?(r(d),j(d)):e(P,(()=>P(d)))||a(d),t.add(d),d}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===h.prototype||t.has(e)}}})(Ge,Te,Kt,Qe,qe,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(Qe),Ye,He),Je=(t=>(e,s)=>{const n=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});s.connect(n).connect(e.destination);const i=()=>{s.removeEventListener("ended",i),s.disconnect(n),n.disconnect()};s.addEventListener("ended",i)})(Yt),Ke=((t,e,s)=>async(n,i,o)=>{const r=e(n);await Promise.all(Array.from(r.activeInputs).map((async([e,n])=>{const r=t(e),a=await r.render(e,i);s(e)||a.connect(o,n)})))})(Oe,Q,ct),ts=(t=>(e,s,n)=>t(s,e,n))(Ke),es=((t,e,s,n,i,o,r,a,c,h,l)=>(c,u)=>{const p=c.createBufferSource();return jt(p,u),zt(p,u,"playbackRate"),Nt(p,u,"buffer"),Nt(p,u,"loop"),Nt(p,u,"loopEnd"),Nt(p,u,"loopStart"),e(s,(()=>s(c)))||(t=>{t.start=(e=>{let s=!1;return(n=0,i=0,o)=>{if(s)throw Rt();e.call(t,n,i,o),s=!0}})(t.start)})(p),e(n,(()=>n(c)))||(t=>{t.start=(e=>(s=0,n=0,i)=>{const o=t.buffer,r=null===o?n:Math.min(o.duration,n);null!==o&&r>o.duration-.5/t.context.sampleRate?e.call(t,s,0,0):e.call(t,s,r,i)})(t.start)})(p),e(i,(()=>i(c)))||h(p,c),e(o,(()=>o(c)))||Wt(p),e(r,(()=>r(c)))||l(p,c),e(a,(()=>a(c)))||Bt(p),t(c,p),p})(Je,Te,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),s=t.createBuffer(1,1,44100);e.buffer=s;try{e.start(0,1)}catch{return!1}return!0}),(t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0}),ue,pe,de,0,(t=>(e,s)=>{const n=s.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=n),t(e,"buffer",(t=>()=>{const s=t.call(e);return s===n?null:s}),(t=>s=>t.call(e,null===s?n:s)))})(he),me),ss=((t,e)=>(s,n,i)=>(t(n).replay(i),e(n,s,i)))((t=>e=>{const s=t(e);if(null===s.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return s.renderer})(Q),Ke),ns=((t,e,s,n,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(c,h){const l=o.get(h);return void 0!==l?Promise.resolve(l):(async(c,h)=>{let l=s(c);const u=F(l,h);if(!u){const t={buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value};l=e(h,t),null!==r&&l.start(...r),null!==a&&l.stop(a)}return o.set(h,l),u?await t(h,c.playbackRate,l.playbackRate):await n(h,c.playbackRate,l.playbackRate),await i(c,h,l),l})(c,h)}}})(ts,es,rt,ss,De),is=((t,e,s,n,i,o,r,a,c,h,l,p,d)=>(n,f,_,m=null,g=null)=>{const v=_.value,y=new u.AutomationEventList(v),x=f?(t=>({replay(e){for(const s of t)if("exponentialRampToValue"===s.type){const{endTime:t,value:n}=s;e.exponentialRampToValueAtTime(n,t)}else if("linearRampToValue"===s.type){const{endTime:t,value:n}=s;e.linearRampToValueAtTime(n,t)}else if("setTarget"===s.type){const{startTime:t,target:n,timeConstant:i}=s;e.setTargetAtTime(n,t,i)}else if("setValue"===s.type){const{startTime:t,value:n}=s;e.setValueAtTime(n,t)}else{if("setValueCurve"!==s.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:n,values:i}=s;e.setValueCurveAtTime(i,n,t)}}}}))(y):null,w={get defaultValue(){return v},get maxValue(){return null===m?_.maxValue:m},get minValue(){return null===g?_.minValue:g},get value(){return _.value},set value(t){_.value=t,w.setValueAtTime(t,n.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof _.cancelAndHoldAtTime)null===x&&y.flush(n.context.currentTime),y.add(i(t)),_.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===x&&y.flush(n.context.currentTime),y.add(i(t));const s=Array.from(y).pop();_.cancelScheduledValues(t),e!==s&&void 0!==s&&("exponentialRampToValue"===s.type?_.exponentialRampToValueAtTime(s.value,s.endTime):"linearRampToValue"===s.type?_.linearRampToValueAtTime(s.value,s.endTime):"setValue"===s.type?_.setValueAtTime(s.value,s.startTime):"setValueCurve"===s.type&&_.setValueCurveAtTime(s.values,s.startTime,s.duration))}return w},cancelScheduledValues:t=>(null===x&&y.flush(n.context.currentTime),y.add(o(t)),_.cancelScheduledValues(t),w),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const s=n.context.currentTime;return null===x&&y.flush(s),0===Array.from(y).length&&(y.add(h(v,s)),_.setValueAtTime(v,s)),y.add(r(t,e)),_.exponentialRampToValueAtTime(t,e),w},linearRampToValueAtTime(t,e){const s=n.context.currentTime;return null===x&&y.flush(s),0===Array.from(y).length&&(y.add(h(v,s)),_.setValueAtTime(v,s)),y.add(a(t,e)),_.linearRampToValueAtTime(t,e),w},setTargetAtTime:(t,e,s)=>(null===x&&y.flush(n.context.currentTime),y.add(c(t,e,s)),_.setTargetAtTime(t,e,s),w),setValueAtTime:(t,e)=>(null===x&&y.flush(n.context.currentTime),y.add(h(t,e)),_.setValueAtTime(t,e),w),setValueCurveAtTime(t,e,s){const i=t instanceof Float32Array?t:new Float32Array(t);if(null!==p&&"webkitAudioContext"===p.name){const t=e+s,o=n.context.sampleRate,r=Math.ceil(e*o),a=Math.floor(t*o),c=a-r,h=new Float32Array(c);for(let t=0;t<c;t+=1){const n=(i.length-1)/s*((r+t)/o-e),a=Math.floor(n),c=Math.ceil(n);h[t]=a===c?i[a]:(1-(n-a))*i[a]+(1-(c-n))*i[c]}null===x&&y.flush(n.context.currentTime),y.add(l(h,e,s)),_.setValueCurveAtTime(h,e,s);const u=a/o;u<t&&d(w,h[h.length-1],u),d(w,i[i.length-1],t)}else null===x&&y.flush(n.context.currentTime),y.add(l(i,e,s)),_.setValueCurveAtTime(i,e,s);return w}};return s.set(w,_),e.set(w,n),t(w,x),w})((os=_,(t,e)=>{os.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),Ie,m,0,u.createCancelAndHoldAutomationEvent,u.createCancelScheduledValuesAutomationEvent,u.createExponentialRampToValueAutomationEvent,u.createLinearRampToValueAutomationEvent,u.createSetTargetAutomationEvent,u.createSetValueAutomationEvent,u.createSetValueCurveAutomationEvent,Pe,le);var os;const rs=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,n){const a=o(t),c={...U,...n},h=i(a,c),l=r(a),u=l?e():null;super(t,!1,h,u),this._audioBufferSourceNodeRenderer=u,this._isBufferNullified=!1,this._isBufferSet=null!==c.buffer,this._nativeAudioBufferSourceNode=h,this._onended=null,this._playbackRate=s(this,l,h.playbackRate,W,z)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const s=this._nativeAudioBufferSourceNode.onended;this._onended=null!==s&&s===e?t:s}get playbackRate(){return this._playbackRate}start(t=0,e=0,s){if(this._nativeAudioBufferSourceNode.start(t,e,s),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===s?[t,e]:[t,e,s]),"closed"!==this.context.state){E(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),B(this)&&q(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(We,ns,is,Rt,es,Ee,Ve,ge),as=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,e){const s=o(t),n=r(s),c=i(s,e,n);super(t,!1,c,n?(t=>{const e=new WeakMap;return{render(s,n){const i=e.get(n);return void 0!==i?Promise.resolve(i):(async(s,n)=>{const i=n.destination;return e.set(n,i),await t(s,n,i),i})(s,n)}}})(a):null),this._isNodeOfNativeOfflineAudioContext=n,this._nativeAudioDestinationNode=c}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw s();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(We,0,N,Rt,((t,e)=>(s,n,i)=>{const o=s.destination;if(o.channelCount!==n)try{o.channelCount=n}catch{}i&&"explicit"!==o.channelCountMode&&(o.channelCountMode="explicit"),0===o.maxChannelCount&&Object.defineProperty(o,"maxChannelCount",{value:n});const r=t(s,{channelCount:n,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return e(r,"channelCount",(t=>()=>t.call(r)),(t=>e=>{t.call(r,e);try{o.channelCount=e}catch(t){if(e>o.maxChannelCount)throw t}})),e(r,"channelCountMode",(t=>()=>t.call(r)),(t=>e=>{t.call(r,e),o.channelCountMode=e})),e(r,"channelInterpretation",(t=>()=>t.call(r)),(t=>e=>{t.call(r,e),o.channelInterpretation=e})),Object.defineProperty(r,"maxChannelCount",{get:()=>o.maxChannelCount}),r.connect(o),r})(Yt,he),Ee,Ve,De),cs=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={Q:c.Q.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,detune:c.detune.value,frequency:c.frequency.value,gain:c.gain.value,type:c.type};c=e(a,t)}return o.set(a,c),h?(await t(a,r.Q,c.Q),await t(a,r.detune,c.detune),await t(a,r.frequency,c.frequency),await t(a,r.gain,c.gain)):(await n(a,r.Q,c.Q),await n(a,r.detune,c.detune),await n(a,r.frequency,c.frequency),await n(a,r.gain,c.gain)),await i(r,a,c),c})(r,a)}}})(ts,Gt,rt,ss,De),hs=(t=>(e,s)=>t.set(e,s))(we),ls=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,n){const c=o(t),h={...bt,...n},l=i(c,h),u=r(c);super(t,!1,l,u?s():null),this._Q=e(this,u,l.Q,W,z),this._detune=e(this,u,l.detune,1200*Math.log2(W),-1200*Math.log2(W)),this._frequency=e(this,u,l.frequency,t.sampleRate/2,0),this._gain=e(this,u,l.gain,40*Math.log10(W),z),this._nativeBiquadFilterNode=l,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(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,s){try{this._nativeBiquadFilterNode.getFrequencyResponse(t,e,s)}catch(t){if(11===t.code)throw n();throw t}if(t.length!==e.length||e.length!==s.length)throw n()}})(We,is,cs,qt,Gt,Ee,Ve,hs),us=((t,e)=>(s,n,i)=>{const o=new Set;return s.connect=(i=>(r,a=0,c=0)=>{const h=0===o.size;if(e(r))return i.call(s,r,a,c),t(o,[r,a,c],(t=>t[0]===r&&t[1]===a&&t[2]===c),!0),h&&n(),r;i.call(s,r,a),t(o,[r,a],(t=>t[0]===r&&t[1]===a),!0),h&&n()})(s.connect),s.disconnect=(t=>(n,r,a)=>{const c=o.size>0;if(void 0===n)t.apply(s),o.clear();else if("number"==typeof n){t.call(s,n);for(const t of o)t[1]===n&&o.delete(t)}else{e(n)?t.call(s,n,r,a):t.call(s,n,r);for(const t of o)t[0]!==n||void 0!==r&&t[1]!==r||void 0!==a&&t[2]!==a||o.delete(t)}const h=0===o.size;c&&h&&i()})(s.disconnect),s})($,je),ps=((t,e)=>(s,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=s.createBufferSource();e(n,(()=>{const t=n.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(n,0,e)}),(()=>i.disconnect(n)))})(Rt,us),ds=((t,e)=>(s,n)=>{const i=s.createChannelMerger(n.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(s,i),jt(i,n),i})(Pe,ps),fs=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,numberOfInputs:r.numberOfInputs};r=t(o,e)}return n.set(o,r),await s(i,o,r),r})(i,o)}}})(ds,rt,De),_s=((t,e,s,n,i)=>class extends t{constructor(t,o){const r=n(t),a={...Tt,...o};super(t,!1,s(r,a),i(r)?e():null)}})(We,fs,ds,Ee,Ve),ms=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,numberOfOutputs:r.numberOfOutputs};r=t(o,e)}return n.set(o,r),await s(i,o,r),r})(i,o)}}})(Qt,rt,De),gs=((t,e,s,n,i)=>class extends t{constructor(t,o){const r=n(t),a=(t=>({...t,channelCount:t.numberOfOutputs}))({...St,...o});super(t,!1,s(r,a),i(r)?e():null)}})(We,ms,Qt,Ee,Ve),vs=((t,e,s,n)=>(i,{offset:o,...r})=>{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}),h=s(i,{...r,gain:o}),l=a.getChannelData(0);l[0]=1,l[1]=1,c.buffer=a,c.loop=!0;const u={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return c.onended},set onended(t){c.onended=t},addEventListener:(...t)=>c.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>c.dispatchEvent(t[0]),removeEventListener:(...t)=>c.removeEventListener(t[0],t[1],t[2]),start(t=0){c.start.call(c,t)},stop(t=0){c.stop.call(c,t)}};return t(i,c),n(Zt(u,h),(()=>c.connect(h)),(()=>c.disconnect(h)))})(Je,es,Yt,us),ys=((t,e,s,n,i)=>(o,r)=>{if(void 0===o.createConstantSource)return s(o,r);const a=o.createConstantSource();return jt(a,r),zt(a,r,"offset"),e(n,(()=>n(o)))||Wt(a),e(i,(()=>i(o)))||Bt(a),t(o,a),a})(Je,Te,vs,ue,de),xs=((t,e,s,n,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(c,h){const l=o.get(h);return void 0!==l?Promise.resolve(l):(async(c,h)=>{let l=s(c);const u=F(l,h);if(!u){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,offset:l.offset.value};l=e(h,t),null!==r&&l.start(r),null!==a&&l.stop(a)}return o.set(h,l),u?await t(h,c.offset,l.offset):await n(h,c.offset,l.offset),await i(c,h,l),l})(c,h)}}})(ts,ys,rt,ss,De),ws=((t,e,s,n,i,o,r)=>class extends t{constructor(t,r){const a=i(t),c={...kt,...r},h=n(a,c),l=o(a),u=l?s():null;super(t,!1,h,u),this._constantSourceNodeRenderer=u,this._nativeConstantSourceNode=h,this._offset=e(this,l,h.offset,W,z),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(t){const e="function"==typeof t?r(this,t):null;this._nativeConstantSourceNode.onended=e;const s=this._nativeConstantSourceNode.onended;this._onended=null!==s&&s===e?t:s}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){E(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),B(this)&&q(this)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})(We,is,xs,ys,Ee,Ve,ge),bs=((t,e)=>(s,n)=>{const i=s.createConvolver();if(jt(i,n),n.disableNormalization===i.normalize&&(i.normalize=!n.disableNormalization),Nt(i,n,"buffer"),n.channelCount>2)throw t();if(e(i,"channelCount",(t=>()=>t.call(i)),(e=>s=>{if(s>2)throw t();return e.call(i,s)})),"max"===n.channelCountMode)throw t();return e(i,"channelCountMode",(t=>()=>t.call(i)),(e=>s=>{if("max"===s)throw t();return e.call(i,s)})),i})(Kt,he),Ts=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={buffer:r.buffer,channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,disableNormalization:!r.normalize};r=t(o,e)}return n.set(o,r),tt(r)?await s(i,o,r.inputs[0]):await s(i,o,r),r})(i,o)}}})(bs,rt,De),Ss=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=n(t),c={...At,...r},h=s(a,c);super(t,!1,h,i(a)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=h,null!==c.buffer&&o(this,c.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(t){if(this._nativeConvolverNode.buffer=t,null===t&&null!==this._nativeConvolverNode.buffer){const t=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=t.createBuffer(1,1,t.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,null===this._nativeConvolverNode.buffer?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(t){this._nativeConvolverNode.normalize=t}})(We,Ts,bs,Ee,Ve,hs),ks=((t,e,s,n,i)=>o=>{const r=new WeakMap;return{render(a,c){const h=r.get(c);return void 0!==h?Promise.resolve(h):(async(a,c)=>{let h=s(a);const l=F(h,c);if(!l){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,delayTime:h.delayTime.value,maxDelayTime:o};h=e(c,t)}return r.set(c,h),l?await t(c,a.delayTime,h.delayTime):await n(c,a.delayTime,h.delayTime),await i(a,c,h),h})(a,c)}}})(ts,Xt,rt,ss,De),As=((t,e,s,n,i,o,r)=>class extends t{constructor(t,a){const c=i(t),h={...Ot,...a},l=n(c,h),u=o(c);super(t,!1,l,u?s(h.maxDelayTime):null),this._delayTime=e(this,u,l.delayTime),r(this,h.maxDelayTime)}get delayTime(){return this._delayTime}})(We,is,ks,Xt,Ee,Ve,hs),Cs=(t=>(e,s)=>{const n=e.createDynamicsCompressor();if(jt(n,s),s.channelCount>2)throw t();if("max"===s.channelCountMode)throw t();return zt(n,s,"attack"),zt(n,s,"knee"),zt(n,s,"ratio"),zt(n,s,"release"),zt(n,s,"threshold"),n})(Kt),Os=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={attack:c.attack.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,knee:c.knee.value,ratio:c.ratio.value,release:c.release.value,threshold:c.threshold.value};c=e(a,t)}return o.set(a,c),h?(await t(a,r.attack,c.attack),await t(a,r.knee,c.knee),await t(a,r.ratio,c.ratio),await t(a,r.release,c.release),await t(a,r.threshold,c.threshold)):(await n(a,r.attack,c.attack),await n(a,r.knee,c.knee),await n(a,r.ratio,c.ratio),await n(a,r.release,c.release),await n(a,r.threshold,c.threshold)),await i(r,a,c),c})(r,a)}}})(ts,Cs,rt,ss,De),Ds=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,i){const c=o(t),h={...Mt,...i},l=n(c,h),u=r(c);super(t,!1,l,u?s():null),this._attack=e(this,u,l.attack),this._knee=e(this,u,l.knee),this._nativeDynamicsCompressorNode=l,this._ratio=e(this,u,l.ratio),this._release=e(this,u,l.release),this._threshold=e(this,u,l.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(t){const e=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=t,t>2)throw this._nativeDynamicsCompressorNode.channelCount=e,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(t){const e=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=t,"max"===t)throw this._nativeDynamicsCompressorNode.channelCountMode=e,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return"number"==typeof this._nativeDynamicsCompressorNode.reduction.value?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}})(We,is,Os,Cs,Kt,Ee,Ve,hs),Ms=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(a,t)}return o.set(a,c),h?await t(a,r.gain,c.gain):await n(a,r.gain,c.gain),await i(r,a,c),c})(r,a)}}})(ts,Yt,rt,ss,De),Es=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=i(t),c={...Et,...r},h=n(a,c),l=o(a);super(t,!1,h,l?s():null),this._gain=e(this,l,h.gain,W,z)}get gain(){return this._gain}})(We,is,Ms,Yt,Ee,Ve),Rs=((t,e,s,n)=>(i,o,{channelCount:r,channelCountMode:a,channelInterpretation:c,feedback:h,feedforward:l})=>{const u=Ut(o,i.sampleRate),p=h instanceof Float64Array?h:new Float64Array(h),d=l instanceof Float64Array?l:new Float64Array(l),f=p.length,_=d.length,m=Math.min(f,_);if(0===f||f>20)throw n();if(0===p[0])throw e();if(0===_||_>20)throw n();if(0===d[0])throw e();if(1!==p[0]){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=s(i,u,r,r);g.channelCount=r,g.channelCountMode=a,g.channelInterpretation=c;const v=[],y=[],x=[];for(let t=0;t<r;t+=1){v.push(0);const t=new Float32Array(32),e=new Float32Array(32);t.fill(0),e.fill(0),y.push(t),x.push(e)}g.onaudioprocess=t=>{const e=t.inputBuffer,s=t.outputBuffer,n=e.numberOfChannels;for(let t=0;t<n;t+=1){const n=e.getChannelData(t),i=s.getChannelData(t);v[t]=It(p,f,d,_,m,y[t],x[t],v[t],32,n,i)}};const w=i.sampleRate/2;return Zt({get bufferSize(){return u},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)=>g.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>g.dispatchEvent(t[0]),getFrequencyResponse(e,s,n){if(e.length!==s.length||s.length!==n.length)throw t();const i=e.length;for(let t=0;t<i;t+=1){const i=-Math.PI*(e[t]/w),o=[Math.cos(i),Math.sin(i)],r=Ht($t(d,o),$t(p,o));s[t]=Math.sqrt(r[0]*r[0]+r[1]*r[1]),n[t]=Math.atan2(r[1],r[0])}},removeEventListener:(...t)=>g.removeEventListener(t[0],t[1],t[2])},g)})(qt,Rt,Jt,Kt),qs=((t,e,s,n)=>i=>t(Pt,(()=>Pt(i)))?Promise.resolve(t(n,n)).then((t=>{if(!t){const t=s(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const s=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{s.disconnect(),t(e.renderedBuffer)},s.connect(i.destination),i.startRendering()})))(Te,Yt,Jt,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const s=new e(1,1,44100),n=t(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{s.oncomplete=()=>{n.disconnect(),t(0!==s.currentTime)},s.startRendering()}))})(Yt,qe)),Vs=((t,e,s,n,i)=>(o,r)=>{const a=new WeakMap;let c=null;return{render(h,l){const u=a.get(l);return void 0!==u?Promise.resolve(u):(async(h,l)=>{let u=null,p=e(h);const d=F(p,l);if(void 0===l.createIIRFilter?u=t(l,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(p=l.createIIRFilter(r,o)),a.set(l,null===u?p:u),null!==u){if(null===c){if(null===s)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new s(h.context.destination.channelCount,h.context.length,l.sampleRate);c=(async()=>(await n(h,t,t.destination),((t,e,s,n)=>{const i=s instanceof Float64Array?s:new Float64Array(s),o=n instanceof Float64Array?n:new Float64Array(n),r=i.length,a=o.length,c=Math.min(r,a);if(1!==i[0]){for(let t=0;t<r;t+=1)o[t]/=i[0];for(let t=1;t<a;t+=1)i[t]/=i[0]}const h=new Float32Array(32),l=new Float32Array(32),u=e.createBuffer(t.numberOfChannels,t.length,t.sampleRate),p=t.numberOfChannels;for(let e=0;e<p;e+=1){const s=t.getChannelData(e),n=u.getChannelData(e);h.fill(0),l.fill(0),It(i,r,o,a,c,h,l,0,32,s,n)}return u})(await i(t),l,o,r)))()}const t=await c;return u.buffer=t,u.start(0),u}return await n(h,l,p),p})(h,l)}}})(es,rt,qe,De,qs),Is=(t=>(e,s,n)=>{if(void 0===e.createIIRFilter)return t(e,s,n);const i=e.createIIRFilter(n.feedforward,n.feedback);return jt(i,n),i})(Rs),Fs=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=n(t),c=i(a),h={...Vt,...r},l=e(a,c?null:t.baseLatency,h);super(t,!1,l,c?s(h.feedback,h.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(s,n,i)=>{if(s.length!==n.length||n.length!==i.length)throw qt();return e.call(t,s,n,i)})})(l),this._nativeIIRFilterNode=l,o(this,1)}getFrequencyResponse(t,e,s){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,s)}})(We,Is,Vs,Ee,Ve,hs),Ps=((t,e,s,n,i,o,r,a)=>(c,h)=>{const l=h.listener,{forwardX:u,forwardY:p,forwardZ:d,positionX:f,positionY:_,positionZ:m,upX:g,upY:v,upZ:y}=void 0===l.forwardX?(()=>{const u=new Float32Array(1),p=e(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),d=r(h);let f=!1,_=[0,0,-1,0,1,0],m=[0,0,0];const g=()=>{if(f)return;f=!0;const t=n(h,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[o(t,u,0),o(t,u,1),o(t,u,2),o(t,u,3),o(t,u,4),o(t,u,5)];e.some(((t,e)=>t!==_[e]))&&(l.setOrientation(...e),_=e);const s=[o(t,u,6),o(t,u,7),o(t,u,8)];s.some(((t,e)=>t!==m[e]))&&(l.setPosition(...s),m=s)},p.connect(t)},v=t=>e=>{e!==_[t]&&(_[t]=e,l.setOrientation(..._))},y=t=>e=>{e!==m[t]&&(m[t]=e,l.setPosition(...m))},x=(e,n,o)=>{const r=s(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:n});r.connect(p,0,e),r.start(),Object.defineProperty(r.offset,"defaultValue",{get:()=>n});const l=t({context:c},d,r.offset,W,z);var u,f,_,m,v,y,x;return a(l,"value",(t=>()=>t.call(l)),(t=>e=>{try{t.call(l,e)}catch(t){if(9!==t.code)throw t}g(),d&&o(e)})),l.cancelAndHoldAtTime=(u=l.cancelAndHoldAtTime,d?()=>{throw i()}:(...t)=>{const e=u.apply(l,t);return g(),e}),l.cancelScheduledValues=(f=l.cancelScheduledValues,d?()=>{throw i()}:(...t)=>{const e=f.apply(l,t);return g(),e}),l.exponentialRampToValueAtTime=(_=l.exponentialRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=_.apply(l,t);return g(),e}),l.linearRampToValueAtTime=(m=l.linearRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=m.apply(l,t);return g(),e}),l.setTargetAtTime=(v=l.setTargetAtTime,d?()=>{throw i()}:(...t)=>{const e=v.apply(l,t);return g(),e}),l.setValueAtTime=(y=l.setValueAtTime,d?()=>{throw i()}:(...t)=>{const e=y.apply(l,t);return g(),e}),l.setValueCurveAtTime=(x=l.setValueCurveAtTime,d?()=>{throw i()}:(...t)=>{const e=x.apply(l,t);return g(),e}),l};return{forwardX:x(0,0,v(0)),forwardY:x(1,0,v(1)),forwardZ:x(2,-1,v(2)),positionX:x(6,0,y(0)),positionY:x(7,0,y(1)),positionZ:x(8,0,y(2)),upX:x(3,0,v(3)),upY:x(4,1,v(4)),upZ:x(5,0,v(5))}})():l;return{get forwardX(){return u},get forwardY(){return p},get forwardZ(){return d},get positionX(){return f},get positionY(){return _},get positionZ(){return m},get upX(){return g},get upY(){return v},get upZ(){return y}}})(is,ds,ys,Jt,Kt,ae,Ve,he),Ns=new WeakMap,js=((t,e,s,n,i,o)=>class extends s{constructor(s,o){super(s),this._nativeContext=s,g.set(this,s),n(s)&&i.set(s,new Set),this._destination=new t(this,o),this._listener=e(this,s),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(t){const e="function"==typeof t?o(this,t):null;this._nativeContext.onstatechange=e;const s=this._nativeContext.onstatechange;this._onstatechange=null!==s&&s===e?t:s}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(as,Ps,Fe,Ve,Ns,ge),Ls=((t,e,s,n,i,o)=>(r,a)=>{const c=r.createOscillator();return jt(c,a),zt(c,a,"detune"),zt(c,a,"frequency"),void 0!==a.periodicWave?c.setPeriodicWave(a.periodicWave):Nt(c,a,"type"),e(s,(()=>s(r)))||Wt(c),e(n,(()=>n(r)))||o(c,r),e(i,(()=>i(r)))||Bt(c),t(r,c),c})(Je,Te,ue,pe,de,me),zs=((t,e,s,n,i)=>()=>{const o=new WeakMap;let r=null,a=null,c=null;return{set periodicWave(t){r=t},set start(t){a=t},set stop(t){c=t},render(h,l){const u=o.get(l);return void 0!==u?Promise.resolve(u):(async(h,l)=>{let u=s(h);const p=F(u,l);if(!p){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,periodicWave:null===r?void 0:r,type:u.type};u=e(l,t),null!==a&&u.start(a),null!==c&&u.stop(c)}return o.set(l,u),p?(await t(l,h.detune,u.detune),await t(l,h.frequency,u.frequency)):(await n(l,h.detune,u.detune),await n(l,h.frequency,u.frequency)),await i(h,l,u),u})(h,l)}}})(ts,Ls,rt,ss,De),Ws=((t,e,s,n,i,o,r)=>class extends t{constructor(t,r){const a=i(t),c={...ee,...r},h=s(a,c),l=o(a),u=l?n():null,p=t.sampleRate/2;super(t,!1,h,u),this._detune=e(this,l,h.detune,153600,-153600),this._frequency=e(this,l,h.frequency,p,-p),this._nativeOscillatorNode=h,this._onended=null,this._oscillatorNodeRenderer=u,null!==this._oscillatorNodeRenderer&&void 0!==c.periodicWave&&(this._oscillatorNodeRenderer.periodicWave=c.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(t){const e="function"==typeof t?r(this,t):null;this._nativeOscillatorNode.onended=e;const s=this._nativeOscillatorNode.onended;this._onended=null!==s&&s===e?t:s}get type(){return this._nativeOscillatorNode.type}set type(t){this._nativeOscillatorNode.type=t,null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.start=t),"closed"!==this.context.state){E(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),B(this)&&q(this)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})(We,is,Ls,zs,Ee,Ve,ge),Bs=(t=>(e,s)=>{const n=t(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(s),n.start(),()=>{n.stop(),n.disconnect(s)}})(es),Us=((t,e,s,n,i)=>(o,{curve:r,oversample:a,...c})=>{const h=o.createWaveShaper(),l=o.createWaveShaper();jt(h,c),jt(l,c);const u=s(o,{...c,gain:1}),p=s(o,{...c,gain:-1}),d=s(o,{...c,gain:1}),f=s(o,{...c,gain:-1});let _=null,m=!1,g=null;const v={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){u.channelCount=t,p.channelCount=t,h.channelCount=t,d.channelCount=t,l.channelCount=t,f.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){u.channelCountMode=t,p.channelCountMode=t,h.channelCountMode=t,d.channelCountMode=t,l.channelCountMode=t,f.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t,p.channelInterpretation=t,h.channelInterpretation=t,d.channelInterpretation=t,l.channelInterpretation=t,f.channelInterpretation=t},get context(){return h.context},get curve(){return g},set curve(s){if(null!==s&&s.length<2)throw e();if(null===s)h.curve=s,l.curve=s;else{const t=s.length,e=new Float32Array(t+2-t%2),n=new Float32Array(t+2-t%2);e[0]=s[0],n[0]=-s[t-1];const i=Math.ceil((t+1)/2),o=(t+1)/2-1;for(let r=1;r<i;r+=1){const a=r/i*o,c=Math.floor(a),h=Math.ceil(a);e[r]=c===h?s[c]:(1-(a-c))*s[c]+(1-(h-a))*s[h],n[r]=c===h?-s[t-1-c]:-(1-(a-c))*s[t-1-c]-(1-(h-a))*s[t-1-h]}e[i]=t%2==1?s[i-1]:(s[i-2]+s[i-1])/2,h.curve=e,l.curve=n}g=s,m&&(n(g)&&null===_?_=t(o,u):null!==_&&(_(),_=null))},get inputs(){return[u]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(t){h.oversample=t,l.oversample=t},addEventListener:(...t)=>u.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>u.dispatchEvent(t[0]),removeEventListener:(...t)=>u.removeEventListener(t[0],t[1],t[2])};return null!==r&&(v.curve=r instanceof Float32Array?r:new Float32Array(r)),a!==v.oversample&&(v.oversample=a),i(Zt(v,d),(()=>{u.connect(h).connect(d),u.connect(p).connect(l).connect(f).connect(d),m=!0,n(g)&&(_=t(o,u))}),(()=>{u.disconnect(h),h.disconnect(d),u.disconnect(p),p.disconnect(l),l.disconnect(f),f.disconnect(d),m=!1,null!==_&&(_(),_=null)}))})(Bs,Rt,Yt,ce,us),Gs=((t,e,s,n,i,o,r)=>(a,c)=>{const h=a.createWaveShaper();if(null!==o&&"webkitAudioContext"===o.name&&void 0===a.createGain().gain.automationRate)return s(a,c);jt(h,c);const l=null===c.curve||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(null!==l&&l.length<2)throw e();Nt(h,{curve:l},"curve"),Nt(h,c,"oversample");let u=null,p=!1;return r(h,"curve",(t=>()=>t.call(h)),(e=>s=>(e.call(h,s),p&&(n(s)&&null===u?u=t(a,h):n(s)||null===u||(u(),u=null)),s))),i(h,(()=>{p=!0,n(h.curve)&&(u=t(a,h))}),(()=>{p=!1,null!==u&&(u(),u=null)}))})(Bs,Rt,Us,ce,us,Pe,he),Qs=((t,e,s,n,i,o,r,a,c,h)=>(l,{coneInnerAngle:u,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:_,orientationX:m,orientationY:g,orientationZ:v,panningModel:y,positionX:x,positionY:w,positionZ:b,refDistance:T,rolloffFactor:S,...k})=>{const A=l.createPanner();if(k.channelCount>2)throw r();if("max"===k.channelCountMode)throw r();jt(A,k);const C={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},O=s(l,{...C,channelInterpretation:"speakers",numberOfInputs:6}),D=n(l,{...k,gain:1}),M=n(l,{...C,gain:1}),E=n(l,{...C,gain:0}),R=n(l,{...C,gain:0}),q=n(l,{...C,gain:0}),V=n(l,{...C,gain:0}),I=n(l,{...C,gain:0}),F=i(l,256,6,1),P=o(l,{...C,curve:new Float32Array([1,1]),oversample:"none"});let N=[m,g,v],j=[x,w,b];const L=new Float32Array(1);F.onaudioprocess=({inputBuffer:t})=>{const e=[c(t,L,0),c(t,L,1),c(t,L,2)];e.some(((t,e)=>t!==N[e]))&&(A.setOrientation(...e),N=e);const s=[c(t,L,3),c(t,L,4),c(t,L,5)];s.some(((t,e)=>t!==j[e]))&&(A.setPosition(...s),j=s)},Object.defineProperty(E.gain,"defaultValue",{get:()=>0}),Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(I.gain,"defaultValue",{get:()=>0});const z={get bufferSize(){},get channelCount(){return A.channelCount},set channelCount(t){if(t>2)throw r();D.channelCount=t,A.channelCount=t},get channelCountMode(){return A.channelCountMode},set channelCountMode(t){if("max"===t)throw r();D.channelCountMode=t,A.channelCountMode=t},get channelInterpretation(){return A.channelInterpretation},set channelInterpretation(t){D.channelInterpretation=t,A.channelInterpretation=t},get coneInnerAngle(){return A.coneInnerAngle},set coneInnerAngle(t){A.coneInnerAngle=t},get coneOuterAngle(){return A.coneOuterAngle},set coneOuterAngle(t){A.coneOuterAngle=t},get coneOuterGain(){return A.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();A.coneOuterGain=t},get context(){return A.context},get distanceModel(){return A.distanceModel},set distanceModel(t){A.distanceModel=t},get inputs(){return[D]},get maxDistance(){return A.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;A.maxDistance=t},get numberOfInputs(){return A.numberOfInputs},get numberOfOutputs(){return A.numberOfOutputs},get orientationX(){return M.gain},get orientationY(){return E.gain},get orientationZ(){return R.gain},get panningModel(){return A.panningModel},set panningModel(t){A.panningModel=t},get positionX(){return q.gain},get positionY(){return V.gain},get positionZ(){return I.gain},get refDistance(){return A.refDistance},set refDistance(t){if(t<0)throw new RangeError;A.refDistance=t},get rolloffFactor(){return A.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;A.rolloffFactor=t},addEventListener:(...t)=>D.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>D.dispatchEvent(t[0]),removeEventListener:(...t)=>D.removeEventListener(t[0],t[1],t[2])};return u!==z.coneInnerAngle&&(z.coneInnerAngle=u),p!==z.coneOuterAngle&&(z.coneOuterAngle=p),d!==z.coneOuterGain&&(z.coneOuterGain=d),f!==z.distanceModel&&(z.distanceModel=f),_!==z.maxDistance&&(z.maxDistance=_),m!==z.orientationX.value&&(z.orientationX.value=m),g!==z.orientationY.value&&(z.orientationY.value=g),v!==z.orientationZ.value&&(z.orientationZ.value=v),y!==z.panningModel&&(z.panningModel=y),x!==z.positionX.value&&(z.positionX.value=x),w!==z.positionY.value&&(z.positionY.value=w),b!==z.positionZ.value&&(z.positionZ.value=b),T!==z.refDistance&&(z.refDistance=T),S!==z.rolloffFactor&&(z.rolloffFactor=S),1===N[0]&&0===N[1]&&0===N[2]||A.setOrientation(...N),0===j[0]&&0===j[1]&&0===j[2]||A.setPosition(...j),h(Zt(z,A),(()=>{D.connect(A),t(D,P,0,0),P.connect(M).connect(O,0,0),P.connect(E).connect(O,0,1),P.connect(R).connect(O,0,2),P.connect(q).connect(O,0,3),P.connect(V).connect(O,0,4),P.connect(I).connect(O,0,5),O.connect(F).connect(l.destination)}),(()=>{D.disconnect(A),a(D,P,0,0),P.disconnect(M),M.disconnect(O),P.disconnect(E),E.disconnect(O),P.disconnect(R),R.disconnect(O),P.disconnect(q),q.disconnect(O),P.disconnect(V),V.disconnect(O),P.disconnect(I),I.disconnect(O),O.disconnect(F),F.disconnect(l.destination)}))})(et,Rt,ds,Yt,Jt,Gs,Kt,ot,ae,us),Zs=(t=>(e,s)=>{const n=e.createPanner();return void 0===n.orientationX?t(e,s):(jt(n,s),zt(n,s,"orientationX"),zt(n,s,"orientationY"),zt(n,s,"orientationZ"),zt(n,s,"positionX"),zt(n,s,"positionY"),zt(n,s,"positionZ"),Nt(n,s,"coneInnerAngle"),Nt(n,s,"coneOuterAngle"),Nt(n,s,"coneOuterGain"),Nt(n,s,"distanceModel"),Nt(n,s,"maxDistance"),Nt(n,s,"panningModel"),Nt(n,s,"refDistance"),Nt(n,s,"rolloffFactor"),n)})(Qs),Xs=((t,e,s,n,i,o,r,a,c,h)=>()=>{const l=new WeakMap;let u=null;return{render(p,d){const f=l.get(d);return void 0!==f?Promise.resolve(f):(async(p,d)=>{let f=null,_=o(p);const m={channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation},g={...m,coneInnerAngle:_.coneInnerAngle,coneOuterAngle:_.coneOuterAngle,coneOuterGain:_.coneOuterGain,distanceModel:_.distanceModel,maxDistance:_.maxDistance,panningModel:_.panningModel,refDistance:_.refDistance,rolloffFactor:_.rolloffFactor},v=F(_,d);if("bufferSize"in _)f=n(d,{...m,gain:1});else if(!v){const t={...g,orientationX:_.orientationX.value,orientationY:_.orientationY.value,orientationZ:_.orientationZ.value,positionX:_.positionX.value,positionY:_.positionY.value,positionZ:_.positionZ.value};_=i(d,t)}if(l.set(d,null===f?_:f),null!==f){if(null===u){if(null===r)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new r(6,p.context.length,d.sampleRate),n=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});n.connect(t.destination),u=(async()=>{const e=await Promise.all([p.orientationX,p.orientationY,p.orientationZ,p.positionX,p.positionY,p.positionZ].map((async(e,n)=>{const i=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===n?1:0});return await a(t,e,i.offset),i})));for(let t=0;t<6;t+=1)e[t].connect(n,0,t),e[t].start(0);return h(t)})()}const t=await u,o=n(d,{...m,gain:1});await c(p,d,o);const l=[];for(let e=0;e<t.numberOfChannels;e+=1)l.push(t.getChannelData(e));let _=[l[0][0],l[1][0],l[2][0]],v=[l[3][0],l[4][0],l[5][0]],y=n(d,{...m,gain:1}),x=i(d,{...g,orientationX:_[0],orientationY:_[1],orientationZ:_[2],positionX:v[0],positionY:v[1],positionZ:v[2]});o.connect(y).connect(x.inputs[0]),x.connect(f);for(let e=128;e<t.length;e+=128){const t=[l[0][e],l[1][e],l[2][e]],s=[l[3][e],l[4][e],l[5][e]];if(t.some(((t,e)=>t!==_[e]))||s.some(((t,e)=>t!==v[e]))){_=t,v=s;const r=e/d.sampleRate;y.gain.setValueAtTime(0,r),y=n(d,{...m,gain:0}),x=i(d,{...g,orientationX:_[0],orientationY:_[1],orientationZ:_[2],positionX:v[0],positionY:v[1],positionZ:v[2]}),y.gain.setValueAtTime(1,r),o.connect(y).connect(x.inputs[0]),x.connect(f)}}return f}return v?(await t(d,p.orientationX,_.orientationX),await t(d,p.orientationY,_.orientationY),await t(d,p.orientationZ,_.orientationZ),await t(d,p.positionX,_.positionX),await t(d,p.positionY,_.positionY),await t(d,p.positionZ,_.positionZ)):(await a(d,p.orientationX,_.orientationX),await a(d,p.orientationY,_.orientationY),await a(d,p.orientationZ,_.orientationZ),await a(d,p.positionX,_.positionX),await a(d,p.positionY,_.positionY),await a(d,p.positionZ,_.positionZ)),tt(_)?await c(p,d,_.inputs[0]):await c(p,d,_),_})(p,d)}}})(ts,ds,ys,Yt,Zs,rt,qe,ss,De,qs),Ys=((t,e,s,n,i,o,r)=>class extends t{constructor(t,a){const c=i(t),h={...se,...a},l=s(c,h),u=o(c);super(t,!1,l,u?n():null),this._nativePannerNode=l,this._orientationX=e(this,u,l.orientationX,W,z),this._orientationY=e(this,u,l.orientationY,W,z),this._orientationZ=e(this,u,l.orientationZ,W,z),this._positionX=e(this,u,l.positionX,W,z),this._positionY=e(this,u,l.positionY,W,z),this._positionZ=e(this,u,l.positionZ,W,z),r(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(t){this._nativePannerNode.coneInnerAngle=t}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(t){this._nativePannerNode.coneOuterAngle=t}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(t){this._nativePannerNode.coneOuterGain=t}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(t){this._nativePannerNode.distanceModel=t}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(t){this._nativePannerNode.maxDistance=t}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(t){this._nativePannerNode.panningModel=t}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(t){this._nativePannerNode.refDistance=t}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(t){this._nativePannerNode.rolloffFactor=t}})(We,is,Zs,Xs,Ee,Ve,hs),Hs=(t=>(e,{disableNormalization:s,imag:n,real:i})=>{const o=n instanceof Float32Array?n:new Float32Array(n),r=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(r,o,{disableNormalization:s});if(Array.from(n).length<2)throw t();return a})(N),$s=((t,e,s)=>class n{constructor(n,i){const o=e(n),r=(t=>{const{imag:e,real:s}=t;return void 0===e?void 0===s?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(s,(()=>0)),real:s}:void 0===s?{...t,imag:e,real:Array.from(e,(()=>0))}:{...t,imag:e,real:s}})({...ne,...i}),a=t(o,r);return s.add(a),a}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===n.prototype||s.has(t)}})(Hs,Ee,new WeakSet),Js=((t,e,s,n,i,o)=>{const r=16385,a=new Float32Array([1,1]),c=Math.PI/2,h={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l={...h,oversample:"none"},u=(t,o,u,p,d)=>{if(1===o)return((t,e,i,o)=>{const u=new Float32Array(r),p=new Float32Array(r);for(let t=0;t<r;t+=1){const e=t/16384*c;u[t]=Math.cos(e),p[t]=Math.sin(e)}const d=s(t,{...h,gain:0}),f=n(t,{...l,curve:u}),_=n(t,{...l,curve:a}),m=s(t,{...h,gain:0}),g=n(t,{...l,curve:p});return{connectGraph(){e.connect(d),e.connect(void 0===_.inputs?_:_.inputs[0]),e.connect(m),_.connect(i),i.connect(void 0===f.inputs?f:f.inputs[0]),i.connect(void 0===g.inputs?g:g.inputs[0]),f.connect(d.gain),g.connect(m.gain),d.connect(o,0,0),m.connect(o,0,1)},disconnectGraph(){e.disconnect(d),e.disconnect(void 0===_.inputs?_:_.inputs[0]),e.disconnect(m),_.disconnect(i),i.disconnect(void 0===f.inputs?f:f.inputs[0]),i.disconnect(void 0===g.inputs?g:g.inputs[0]),f.disconnect(d.gain),g.disconnect(m.gain),d.disconnect(o,0,0),m.disconnect(o,0,1)}}})(t,u,p,d);if(2===o)return((t,i,o,u)=>{const p=new Float32Array(r),d=new Float32Array(r),f=new Float32Array(r),_=new Float32Array(r),m=Math.floor(8192.5);for(let t=0;t<r;t+=1)if(t>m){const e=(t-m)/(16384-m)*c;p[t]=Math.cos(e),d[t]=Math.sin(e),f[t]=0,_[t]=1}else{const e=t/(16384-m)*c;p[t]=1,d[t]=0,f[t]=Math.cos(e),_[t]=Math.sin(e)}const g=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),v=s(t,{...h,gain:0}),y=n(t,{...l,curve:p}),x=s(t,{...h,gain:0}),w=n(t,{...l,curve:d}),b=n(t,{...l,curve:a}),T=s(t,{...h,gain:0}),S=n(t,{...l,curve:f}),k=s(t,{...h,gain:0}),A=n(t,{...l,curve:_});return{connectGraph(){i.connect(g),i.connect(void 0===b.inputs?b:b.inputs[0]),g.connect(v,0),g.connect(x,0),g.connect(T,1),g.connect(k,1),b.connect(o),o.connect(void 0===y.inputs?y:y.inputs[0]),o.connect(void 0===w.inputs?w:w.inputs[0]),o.connect(void 0===S.inputs?S:S.inputs[0]),o.connect(void 0===A.inputs?A:A.inputs[0]),y.connect(v.gain),w.connect(x.gain),S.connect(T.gain),A.connect(k.gain),v.connect(u,0,0),T.connect(u,0,0),x.connect(u,0,1),k.connect(u,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(void 0===b.inputs?b:b.inputs[0]),g.disconnect(v,0),g.disconnect(x,0),g.disconnect(T,1),g.disconnect(k,1),b.disconnect(o),o.disconnect(void 0===y.inputs?y:y.inputs[0]),o.disconnect(void 0===w.inputs?w:w.inputs[0]),o.disconnect(void 0===S.inputs?S:S.inputs[0]),o.disconnect(void 0===A.inputs?A:A.inputs[0]),y.disconnect(v.gain),w.disconnect(x.gain),S.disconnect(T.gain),A.disconnect(k.gain),v.disconnect(u,0,0),T.disconnect(u,0,0),x.disconnect(u,0,1),k.disconnect(u,0,1)}}})(t,u,p,d);throw i()};return(e,{channelCount:n,channelCountMode:r,pan:a,...c})=>{if("max"===r)throw i();const h=t(e,{...c,channelCount:1,channelCountMode:r,numberOfInputs:2}),l=s(e,{...c,channelCount:n,channelCountMode:r,gain:1}),p=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:d,disconnectGraph:f}=u(e,n,l,p,h);Object.defineProperty(p.gain,"defaultValue",{get:()=>0}),Object.defineProperty(p.gain,"maxValue",{get:()=>1}),Object.defineProperty(p.gain,"minValue",{get:()=>-1});const _={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){l.channelCount!==t&&(m&&f(),({connectGraph:d,disconnectGraph:f}=u(e,t,l,p,h)),m&&d()),l.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();l.channelCountMode=t},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(t){l.channelInterpretation=t},get context(){return l.context},get inputs(){return[l]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get pan(){return p.gain},addEventListener:(...t)=>l.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>l.dispatchEvent(t[0]),removeEventListener:(...t)=>l.removeEventListener(t[0],t[1],t[2])};let m=!1;return o(Zt(_,h),(()=>{d(),m=!0}),(()=>{f(),m=!1}))}})(ds,Qt,Yt,Gs,Kt,us),Ks=((t,e)=>(s,n)=>{const i=n.channelCountMode;if("clamped-max"===i)throw e();if(void 0===s.createStereoPanner)return t(s,n);const o=s.createStereoPanner();return jt(o,n),zt(o,n,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),o})(Js,Kt),tn=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(a,t)}return o.set(a,c),h?await t(a,r.pan,c.pan):await n(a,r.pan,c.pan),tt(c)?await i(r,a,c.inputs[0]):await i(r,a,c),c})(r,a)}}})(ts,Ks,rt,ss,De),en=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=i(t),c={...ie,...r},h=s(a,c),l=o(a);super(t,!1,h,l?n():null),this._pan=e(this,l,h.pan)}get pan(){return this._pan}})(We,is,Ks,tn,Ee,Ve),sn=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,curve:r.curve,oversample:r.oversample};r=t(o,e)}return n.set(o,r),tt(r)?await s(i,o,r.inputs[0]):await s(i,o,r),r})(i,o)}}})(Gs,rt,De),nn=((t,e,s,n,i,o,r)=>class extends t{constructor(t,e){const a=i(t),c={...re,...e},h=s(a,c);super(t,!0,h,o(a)?n():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=h,r(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(t){if(null===t)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(t.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=t}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(t){this._nativeWaveShaperNode.oversample=t}})(We,Rt,Gs,sn,Ee,Ve,hs),on=(t=>null!==t&&t.isSecureContext)(Ae),rn=(t=>(e,s,n)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*s)},currentTime:{configurable:!0,get:()=>e}});try{return n()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(Ae),an=new WeakMap,cn=((t,e)=>s=>{let n=t.get(s);if(void 0!==n)return n;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new e(1,1,44100),t.set(s,n),n})(an,qe),hn=on?((t,e,s,n,i,o,r,a,c,h,l,u,p)=>{let d=0;return(f,_,m={credentials:"omit"})=>{const g=l.get(f);if(void 0!==g&&g.has(_))return Promise.resolve();const v=h.get(f);if(void 0!==v){const t=v.get(_);if(void 0!==t)return t}const y=o(f),w=void 0===y.audioWorklet?i(_).then((([t,e])=>{const[n,i]=S(t,e);return s(`${n};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}\n})})(window,'_AWGS')`)})).then((()=>{const t=p._AWGS.pop();if(void 0===t)throw new SyntaxError;n(y.currentTime,y.sampleRate,(()=>t(class{},void 0,((t,s)=>{if(""===t.trim())throw e();const n=x.get(y);if(void 0!==n){if(n.has(t))throw e();A(s),k(s.parameterDescriptors),n.set(t,s)}else A(s),k(s.parameterDescriptors),x.set(y,new Map([[t,s]]))}),y.sampleRate,void 0,void 0)))})):Promise.all([i(_),Promise.resolve(t(u,u))]).then((([[t,e],s])=>{const n=d+1;d=n;const[i,o]=S(t,e),h=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${o}\n})(${s?"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{${s?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${s?"":"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${n}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),l=URL.createObjectURL(h);return y.audioWorklet.addModule(l,m).then((()=>{if(a(y))return y;const t=r(y);return t.audioWorklet.addModule(l,m).then((()=>t))})).then((t=>{if(null===c)throw new SyntaxError;try{new c(t,`__sac${n}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(l)))}));return void 0===v?h.set(f,new Map([[_,w]])):v.set(_,w),w.then((()=>{const t=l.get(f);void 0===t?l.set(f,new Set([_])):t.add(_)})).finally((()=>{const t=h.get(f);void 0!==t&&t.delete(_)})),w}})(Te,Kt,(t=>e=>new Promise(((s,n)=>{if(null===t)return void n(new SyntaxError);const i=t.document.head;if(null===i)n(new SyntaxError);else{const o=t.document.createElement("script"),r=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(r),c=t.onerror,h=()=>{t.onerror=c,URL.revokeObjectURL(a)};t.onerror=(e,s,i,o,r)=>s===a||s===t.location.href&&1===i&&1===o?(h(),n(r),!1):null!==c?c(e,s,i,o,r):void 0,o.onerror=()=>{h(),n(new SyntaxError)},o.onload=()=>{h(),s()},o.src=a,o.type="module",i.appendChild(o)}})))(Ae),rn,(async t=>{try{const e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw new DOMException("","AbortError")}),Ee,cn,Ve,ze,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const s=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(s);let o=!1,r=!1;try{await n.audioWorklet.addModule(i);const e=new t(n,"a",{numberOfOutputs:0}),s=n.createOscillator();e.port.onmessage=()=>o=!0,e.onprocessorerror=()=>r=!0,s.connect(e),s.start(0),await n.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return o&&!r})(ze,qe),Ae):void 0,ln=((t,e)=>s=>t(s)||e(s))(Ne,Ve),un=((t,e,s,n,i,o,r,a,c,h,l)=>(s,n)=>{const u=r(s)?s:o(s);if(i.has(n)){const t=new DOMException("","DataCloneError");return Promise.reject(t)}try{i.add(n)}catch{}return e(c,(()=>c(u)))?u.decodeAudioData(n).then((s=>(Ct(n).catch((()=>{})),e(a,(()=>a(s)))||l(s),t.add(s),s))):new Promise(((e,s)=>{const i=async()=>{try{await Ct(n)}catch{}},o=t=>{s(t),i()};try{u.decodeAudioData(n,(s=>{"function"!=typeof s.copyFromChannel&&(h(s),j(s)),t.add(s),i().then((()=>e(s)))}),(t=>{o(null===t?new DOMException("","EncodingError"):t)}))}catch(t){o(t)}}))})(Ge,Te,0,0,new WeakSet,Ee,ln,P,Pt,Ye,He),pn=((t,e,s,n,i,o,r,a,c,h,l,u,p,d,f,_,m,g,v,y)=>class extends f{constructor(e,s){super(e,s),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,s)=>t(this,e,s)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,n){return new s({length:e,numberOfChannels:t,sampleRate:n})}createBufferSource(){return new n(this)}createChannelMerger(t=6){return new o(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new r(this,{numberOfOutputs:t})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(t=1){return new l(this,{maxDelayTime:t})}createDynamicsCompressor(){return new u(this)}createGain(){return new p(this)}createIIRFilter(t,e){return new d(this,{feedback:e,feedforward:t})}createOscillator(){return new _(this)}createPanner(){return new m(this)}createPeriodicWave(t,e,s={disableNormalization:!1}){return new g(this,{...s,imag:e,real:t})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(t,e,s){return h(this._nativeContext,t).then((t=>("function"==typeof e&&e(t),t)),(t=>{throw"function"==typeof s&&s(t),t}))}})(hn,Ue,$e,rs,ls,_s,gs,ws,Ss,un,As,Ds,Es,Fs,js,Ws,Ys,$s,en,nn),dn=((t,e,s,n)=>class extends t{constructor(t,e){const i=s(t),o=((t,e)=>t.createMediaElementSource(e.mediaElement))(i,e);if(n(i))throw TypeError();super(t,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})(We,0,Ee,Ve),fn=((t,e,s,n)=>class extends t{constructor(t,e){const i=s(t);if(n(i))throw new TypeError;const o=((t,e)=>{const s=t.createMediaStreamDestination();return jt(s,e),1===s.numberOfOutputs&&Object.defineProperty(s,"numberOfOutputs",{get:()=>0}),s})(i,{...Ft,...e});super(t,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})(We,0,Ee,Ve),_n=((t,e,s,n)=>class extends t{constructor(t,e){const i=s(t),o=((t,{mediaStream:e})=>{const s=e.getAudioTracks();s.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const n=s.slice(0,1),i=t.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(i,"mediaStream",{value:e}),i})(i,e);if(n(i))throw new TypeError;super(t,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(We,0,Ee,Ve),mn=((t,e)=>(s,{mediaStreamTrack:n})=>{if("function"==typeof s.createMediaStreamTrackSource)return s.createMediaStreamTrackSource(n);const i=new MediaStream([n]),o=s.createMediaStreamSource(i);if("audio"!==n.kind)throw t();if(e(s))throw new TypeError;return o})(Rt,Ve),gn=((t,e,s)=>class extends t{constructor(t,n){const i=s(t);super(t,!0,e(i,n),null)}})(We,mn,Ee),vn=((t,e,s,n,i,o,r,a,c)=>class extends t{constructor(t={}){if(null===c)throw new Error("Missing the native AudioContext constructor.");let e;try{e=new c(t)}catch(t){if(12===t.code&&"sampleRate is not in range"===t.message)throw s();throw t}if(null===e)throw n();if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw s();super(e,2);const{latencyHint:i}=t,{sampleRate:o}=e;if(this._baseLatency="number"==typeof e.baseLatency?e.baseLatency:"balanced"===i?512/o:"interactive"===i||void 0===i?256/o:"playback"===i?1024/o:128*Math.max(2,Math.min(128,Math.round(i*o/128)))/o,this._nativeAudioContext=e,"webkitAudioContext"===c.name?(this._nativeGainNode=e.createGain(),this._nativeOscillatorNode=e.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(e.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,"running"===e.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),e.removeEventListener("statechange",t)};e.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then((()=>{throw e()})):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close().then((()=>{null!==this._nativeGainNode&&null!==this._nativeOscillatorNode&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),X(this)})))}createMediaElementSource(t){return new i(this,{mediaElement:t})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(t){return new r(this,{mediaStream:t})}createMediaStreamTrackSource(t){return new a(this,{mediaStreamTrack:t})}resume(){return"suspended"===this._state?new Promise(((t,e)=>{const s=()=>{this._nativeAudioContext.removeEventListener("statechange",s),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",s)})):this._nativeAudioContext.resume().catch((t=>{if(void 0===t||15===t.code)throw e();throw t}))}suspend(){return this._nativeAudioContext.suspend().catch((t=>{if(void 0===t)throw e();throw t}))}})(pn,Rt,Kt,oe,dn,fn,_n,gn,Pe),yn=(t=>e=>{const s=t.get(e);if(void 0===s)throw new Error("The context has no set of AudioWorkletNodes.");return s})(Ns),xn=(t=>(e,s)=>{t(e).add(s)})(yn),wn=(t=>(e,s,n=0,i=0)=>{const o=e[n];if(void 0===o)throw t();return pt(s)?o.connect(s,0,i):o.connect(s,0)})(N),bn=(t=>(e,s)=>{t(e).delete(s)})(yn),Tn=(t=>(e,s=void 0,n=void 0,i=0)=>void 0===s?e.forEach((t=>t.disconnect())):"number"==typeof s?Dt(t,e,s).disconnect():pt(s)?void 0===n?e.forEach((t=>t.disconnect(s))):void 0===i?Dt(t,e,n).disconnect(s,0):Dt(t,e,n).disconnect(s,0,i):void 0===n?e.forEach((t=>t.disconnect(s))):Dt(t,e,n).disconnect(s,0))(N),Sn=new WeakMap,kn=((t,e)=>s=>e(t,s))(Sn,C),An=((t,e,s,n,i,o,r,a,c,h,l,u,p)=>(d,f,_,m)=>{if(0===m.numberOfInputs&&0===m.numberOfOutputs)throw c();const g=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(g.some((t=>t<1)))throw c();if(g.length!==m.numberOfOutputs)throw e();if("explicit"!==m.channelCountMode)throw c();const v=m.channelCount*m.numberOfInputs,y=g.reduce(((t,e)=>t+e),0),x=void 0===_.parameterDescriptors?0:_.parameterDescriptors.length;if(v+x>6||y>6)throw c();const b=new MessageChannel,T=[],S=[];for(let t=0;t<m.numberOfInputs;t+=1)T.push(r(d,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),S.push(i(d,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const k=[];if(void 0!==_.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:s,name:n}of _.parameterDescriptors){const i=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==m.parameterData[n]?m.parameterData[n]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?W:e},minValue:{get:()=>void 0===s?z:s}}),k.push(i)}const A=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,v+x)}),C=Ut(f,d.sampleRate),O=a(d,C,v+x,Math.max(1,y)),D=i(d,{channelCount:Math.max(1,y),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,y)}),M=[];for(let t=0;t<m.numberOfOutputs;t+=1)M.push(n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[t]}));for(let t=0;t<m.numberOfInputs;t+=1){T[t].connect(S[t]);for(let e=0;e<m.channelCount;e+=1)S[t].connect(A,e,t*m.channelCount+e)}const E=new mt(void 0===_.parameterDescriptors?[]:_.parameterDescriptors.map((({name:t},e)=>{const s=k[e];return s.connect(A,0,v+e),s.start(0),[t,s.offset]})));A.connect(O);let R=m.channelInterpretation,q=null;const V=0===m.numberOfOutputs?[O]:M,I={get bufferSize(){return C},get channelCount(){return m.channelCount},set channelCount(t){throw s()},get channelCountMode(){return m.channelCountMode},set channelCountMode(t){throw s()},get channelInterpretation(){return R},set channelInterpretation(t){for(const e of T)e.channelInterpretation=t;R=t},get context(){return O.context},get inputs(){return T},get numberOfInputs(){return m.numberOfInputs},get numberOfOutputs(){return m.numberOfOutputs},get onprocessorerror(){return q},set onprocessorerror(t){"function"==typeof q&&I.removeEventListener("processorerror",q),q="function"==typeof t?t:null,"function"==typeof q&&I.addEventListener("processorerror",q)},get parameters(){return E},get port(){return b.port2},addEventListener:(...t)=>O.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,V),disconnect:h.bind(null,V),dispatchEvent:(...t)=>O.dispatchEvent(t[0]),removeEventListener:(...t)=>O.removeEventListener(t[0],t[1],t[2])},F=new Map;var P,N;b.port1.addEventListener=(P=b.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const s=F.get(t[1]);void 0!==s?t[1]=s:(t[1]=t=>{l(d.currentTime,d.sampleRate,(()=>e(t)))},F.set(e,t[1]))}}return P.call(b.port1,t[0],t[1],t[2])}),b.port1.removeEventListener=(N=b.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=F.get(t[1]);void 0!==e&&(F.delete(t[1]),t[1]=e)}return N.call(b.port1,t[0],t[1],t[2])});let j=null;Object.defineProperty(b.port1,"onmessage",{get:()=>j,set:t=>{"function"==typeof j&&b.port1.removeEventListener("message",j),j="function"==typeof t?t:null,"function"==typeof j&&(b.port1.addEventListener("message",j),b.port1.start())}}),_.prototype.port=b.port1;let L=null;const B=((t,e,s,n)=>{let i=w.get(t);void 0===i&&(i=new WeakMap,w.set(t,i));const o=(async(t,e)=>{const s=await(t=>new Promise(((e,s)=>{const{port1:n,port2:i}=new MessageChannel;n.onmessage=({data:t})=>{n.close(),i.close(),e(t)},n.onmessageerror=({data:t})=>{n.close(),i.close(),s(t)},i.postMessage(t)})))(e);return new t(s)})(s,n);return i.set(e,o),o})(d,I,_,m);B.then((t=>L=t));const U=xt(m.numberOfInputs,m.channelCount),G=xt(m.numberOfOutputs,g),Q=void 0===_.parameterDescriptors?[]:_.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let Z=!0;const X=()=>{m.numberOfOutputs>0&&O.disconnect(D);for(let t=0,e=0;t<m.numberOfOutputs;t+=1){const s=M[t];for(let n=0;n<g[t];n+=1)D.disconnect(s,e+n,n);e+=g[t]}},Y=new Map;O.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==L){const s=u(I);for(let n=0;n<C;n+=128){for(let e=0;e<m.numberOfInputs;e+=1)for(let s=0;s<m.channelCount;s+=1)vt(t,U[e],s,s,n);void 0!==_.parameterDescriptors&&_.parameterDescriptors.forEach((({name:e},s)=>{vt(t,Q,e,v+s,n)}));for(let t=0;t<m.numberOfInputs;t+=1)for(let e=0;e<g[t];e+=1)0===G[t][e].byteLength&&(G[t][e]=new Float32Array(128));try{const t=U.map(((t,e)=>{if(s[e].size>0)return Y.set(e,C/128),t;const n=Y.get(e);return void 0===n?[]:(t.every((t=>t.every((t=>0===t))))&&(1===n?Y.delete(e):Y.set(e,n-1)),t)})),i=l(d.currentTime+n/d.sampleRate,d.sampleRate,(()=>L.process(t,G,Q)));Z=i;for(let t=0,s=0;t<m.numberOfOutputs;t+=1){for(let i=0;i<g[t];i+=1)yt(e,G[t],i,s+i,n);s+=g[t]}}catch(t){Z=!1,I.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!Z){for(let t=0;t<m.numberOfInputs;t+=1){T[t].disconnect(S[t]);for(let e=0;e<m.channelCount;e+=1)S[n].disconnect(A,e,t*m.channelCount+e)}if(void 0!==_.parameterDescriptors){const t=_.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=k[e];t.disconnect(A,0,v+e),t.stop()}}A.disconnect(O),O.onaudioprocess=null,H?X():K();break}}}};let H=!1;const $=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),J=()=>O.connect($).connect(d.destination),K=()=>{O.disconnect($),$.disconnect()};return J(),p(I,(()=>{if(Z){K(),m.numberOfOutputs>0&&O.connect(D);for(let t=0,e=0;t<m.numberOfOutputs;t+=1){const s=M[t];for(let n=0;n<g[t];n+=1)D.connect(s,e+n,n);e+=g[t]}}H=!0}),(()=>{Z&&(J(),X()),H=!1}))})(wn,N,Rt,ds,Qt,ys,Yt,Jt,Kt,Tn,rn,kn,us),Cn=((t,e,s,n,i)=>(o,r,a,c,h,l)=>{if(null!==a)try{const e=new a(o,c,l),n=new Map;let r=null;if(Object.defineProperties(e,{channelCount:{get:()=>l.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>r,set:t=>{"function"==typeof r&&e.removeEventListener("processorerror",r),r="function"==typeof t?t:null,"function"==typeof r&&e.addEventListener("processorerror",r)}}}),e.addEventListener=(p=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const s=n.get(t[1]);void 0!==s?t[1]=s:(t[1]=s=>{"error"===s.type?(Object.defineProperties(s,{type:{value:"processorerror"}}),e(s)):e(new ErrorEvent(t[0],{...s}))},n.set(e,t[1]))}}return p.call(e,"error",t[1],t[2]),p.call(e,...t)}),e.removeEventListener=(u=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=n.get(t[1]);void 0!==e&&(n.delete(t[1]),t[1]=e)}return u.call(e,"error",t[1],t[2]),u.call(e,t[0],t[1],t[2])}),0!==l.numberOfOutputs){const t=s(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return e.connect(t).connect(o.destination),i(e,(()=>t.disconnect()),(()=>t.connect(o.destination)))}return e}catch(t){if(11===t.code)throw n();throw t}var u,p;if(void 0===h)throw n();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),e(o,r,h,l)})(Rt,An,Yt,Kt,us),On=((t,e,s,n,i,o,r,a,c,h,l,u,p,d,f,_)=>(m,g,v)=>{const y=new WeakMap;let x=null;return{render(w,b){a(b,w);const T=y.get(b);return void 0!==T?Promise.resolve(T):(async(a,w)=>{let b=l(a),T=null;const S=F(b,w),k=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(null===u){const t=k.reduce(((t,e)=>t+e),0),s=i(w,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),o=[];for(let t=0;t<a.numberOfOutputs;t+=1)o.push(n(w,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:k[t]}));const h=r(w,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});h.connect=e.bind(null,o),h.disconnect=c.bind(null,o),T=[s,o,h]}else S||(b=new u(w,m));if(y.set(w,null===T?b:T[2]),null!==T){if(null===x){if(void 0===v)throw new Error("Missing the processor constructor.");if(null===p)throw new Error("Missing the native OfflineAudioContext constructor.");const t=a.channelCount*a.numberOfInputs,e=void 0===v.parameterDescriptors?0:v.parameterDescriptors.length,s=t+e,c=async()=>{const c=new p(s,128*Math.ceil(a.context.length/128),w.sampleRate),h=[],l=[];for(let t=0;t<g.numberOfInputs;t+=1)h.push(r(c,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),l.push(i(c,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const u=await Promise.all(Array.from(a.parameters.values()).map((async t=>{const e=o(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await d(c,t,e.offset),e}))),m=n(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<g.numberOfInputs;t+=1){h[t].connect(l[t]);for(let e=0;e<g.channelCount;e+=1)l[t].connect(m,e,t*g.channelCount+e)}for(const[e,s]of u.entries())s.connect(m,0,t+e),s.start(0);return m.connect(c.destination),await Promise.all(h.map((t=>f(a,c,t)))),_(c)};x=wt(a,0===s?null:await c(),w,g,k,v,h)}const t=await x,e=s(w,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,l,u]=T;null!==t&&(e.buffer=t,e.start(0)),e.connect(c);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const s=l[t];for(let n=0;n<k[t];n+=1)c.connect(s,e+n,n);e+=k[t]}return u}if(S)for(const[e,s]of a.parameters.entries())await t(w,s,b.parameters.get(e));else for(const[t,e]of a.parameters.entries())await d(w,e,b.parameters.get(t));return await f(a,w,b),b})(w,b)}}})(ts,wn,es,ds,Qt,ys,Yt,bn,Tn,rn,rt,ze,qe,ss,De,qs),Dn=(t=>e=>t.get(e))(an),Mn=(t=>(e,s)=>{t.set(e,s)})(Sn),En=on?((t,e,s,n,i,o,r,a,c,h,l,u,p,d)=>class extends e{constructor(e,l,p){var d;const f=a(e),_=c(f),m=(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))}))({...gt,...p});(t=>{const{port1:e,port2:s}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),s.close()}})(m);const g=x.get(f),v=null==g?void 0:g.get(l),y=_||"closed"!==f.state?f:null!==(d=r(f))&&void 0!==d?d:f,w=i(y,_?null:e.baseLatency,h,l,v,m);super(e,!0,w,_?n(l,m,v):null);const b=[];w.parameters.forEach(((t,e)=>{const n=s(this,_,t);b.push([e,n])})),this._nativeAudioWorkletNode=w,this._onprocessorerror=null,this._parameters=new mt(b),_&&t(f,this);const{activeInputs:T}=o(this);u(w,T)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?d(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const s=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==s&&s===e?t:s}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(xn,We,is,On,Cn,G,Dn,Ee,Ve,ze,0,Mn,0,ge):void 0,Rn=((t,e)=>(s,n,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(s,n,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(Kt,qe),qn=((t,e,s,n,i,o,r,a)=>(c,h)=>s(c).render(c,h).then((()=>Promise.all(Array.from(n(h)).map((t=>s(t).render(t,h)))))).then((()=>i(h))).then((s=>("function"!=typeof s.copyFromChannel?(r(s),j(s)):e(o,(()=>o(s)))||a(s),t.add(s),s))))(Ge,Te,Oe,yn,qs,P,Ye,He),Vn=((t,e,s,n,i)=>class extends t{constructor(t,s,i){let o;if("number"==typeof t&&void 0!==s&&void 0!==i)o={length:s,numberOfChannels:t,sampleRate:i};else{if("object"!=typeof t)throw new Error("The given parameters are not valid.");o=t}const{length:r,numberOfChannels:a,sampleRate:c}={...te,...o},h=n(a,r,c);e(Pt,(()=>Pt(h)))||h.addEventListener("statechange",(()=>{let t=0;const e=s=>{"running"===this._state&&(t>0?(h.removeEventListener("statechange",e),s.stopImmediatePropagation(),this._waitForThePromiseToSettle(s)):t+=1)};return e})()),super(h,a),this._length=r,this._nativeOfflineAudioContext=h,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(s()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally((()=>{this._state=null,X(this)})))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout((()=>this._waitForThePromiseToSettle(t)))}})(pn,Te,Rt,Rn,qn),In=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(g,Ne),Fn=((t,e)=>s=>t.has(s)||e(s))(f,je),Pn=((t,e)=>s=>t.has(s)||e(s))(m,Le),Nn=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(g,Ve),jn=()=>(async(t,e,s,n,i,o,r,a,c,h,l,u,p,d,f,_)=>!!(t(e,e)&&t(s,s)&&t(i,i)&&t(o,o)&&t(a,a)&&t(c,c)&&t(h,h)&&t(l,l)&&t(u,u)&&t(p,p)&&t(d,d))&&(await Promise.all([t(n,n),t(r,r),t(f,f),t(_,_)])).every((t=>t)))(Te,(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createBuffer(1,1,44100);if(void 0===e.copyToChannel)return!0;const s=new Float32Array(2);try{e.copyFromChannel(s,0,0)}catch{return!1}return!0})(qe),(t=>()=>{if(null===t)return!1;if(void 0!==t.prototype&&void 0!==t.prototype.close)return!0;const e=new t,s=void 0!==e.close;try{e.close()}catch{}return s})(Pe),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);return new Promise((t=>{let s=!0;const n=n=>{s&&(s=!1,e.startRendering(),t(n instanceof TypeError))};let i;try{i=e.decodeAudioData(null,(()=>{}),n)}catch(t){n(t)}void 0!==i&&i.catch(n)}))})(qe),(t=>()=>{if(null===t)return!1;let e;try{e=new t({latencyHint:"balanced"})}catch{return!1}return e.close(),!0})(Pe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createGain(),s=e.connect(e)===e;return e.disconnect(e),s})(qe),((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const s=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),o=URL.createObjectURL(s);let r=!1;try{await i.audioWorklet.addModule(o);const e=new t(i,"a",{numberOfOutputs:0}),s=i.createOscillator();await new Promise((t=>{e.port.onmessage=()=>t(),e.port.postMessage(n.port2,[n.port2])})),e.port.onmessage=()=>r=!0,s.connect(e),s.start(0),await i.startRendering(),r=await new Promise((t=>{n.port1.onmessage=({data:e})=>t(1===e),n.port1.postMessage(0)}))}catch{}finally{n.port1.close(),URL.revokeObjectURL(o)}return r})(ze,qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createChannelMerger();if("max"===e.channelCountMode)return!0;try{e.channelCount=2}catch{return!0}return!1})(qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100);return void 0===e.createConstantSource||e.createConstantSource().offset.maxValue!==Number.POSITIVE_INFINITY})(qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100),s=e.createConvolver();s.buffer=e.createBuffer(1,1,e.sampleRate);try{s.buffer=e.createBuffer(1,1,e.sampleRate)}catch{return!1}return!0})(qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createConvolver();try{e.channelCount=1}catch{return!1}return!0})(qe),fe,(t=>()=>null!==t&&t.hasOwnProperty("isSecureContext"))(Ae),(t=>()=>{if(null===t)return!1;const e=new t;try{return e.createMediaStreamSource(new MediaStream),!1}catch(t){return!0}finally{e.close()}})(Pe),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);if(void 0===e.createStereoPanner)return Promise.resolve(!0);if(void 0===e.createConstantSource)return Promise.resolve(!0);const s=e.createConstantSource(),n=e.createStereoPanner();return s.channelCount=1,s.offset.value=1,n.channelCount=1,s.start(),s.connect(n).connect(e.destination),e.startRendering().then((t=>1!==t.getChannelData(0)[0]))})(qe),_e);function Ln(t){return Pn(t)}function zn(t){return Fn(t)}function Wn(t){return Nn(t)}function Bn(t){return In(t)}function Un(t){return void 0===t}function Gn(t){return void 0!==t}function Qn(t){return"function"==typeof t}function Zn(t){return"number"==typeof t}function Xn(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object}function Yn(t){return"boolean"==typeof t}function Hn(t){return Array.isArray(t)}function $n(t){return"string"==typeof t}function Jn(t){return $n(t)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(t)}function Kn(t,e){if(!t)throw new Error(e)}function ti(t,e,s=1/0){if(!(e<=t&&t<=s))throw new RangeError(`Value must be within [${e}, ${s}], got: ${t}`)}function ei(t){t.isOffline||"running"===t.state||hi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let si=!1,ni=!1;function ii(t){si=t}function oi(t){Un(t)&&si&&!ni&&(ni=!0,hi("Schedulable methods should include the provided time argument to ensure accurate timing. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}let ri=console;function ai(t){ri=t}function ci(...t){ri.log(...t)}function hi(...t){ri.warn(...t)}function li(t,e){return"value"===t||Ln(e)||zn(e)||function(t){return t instanceof $e}(e)}function ui(t,...e){if(!e.length)return t;const s=e.shift();if(Xn(t)&&Xn(s))for(const e in s)li(e,s[e])?t[e]=s[e]:Xn(s[e])?(t[e]||Object.assign(t,{[e]:{}}),ui(t[e],s[e])):Object.assign(t,{[e]:s[e]});return ui(t,...e)}function pi(t,e,s=[],n){const i={},o=Array.from(e);if(Xn(o[0])&&n&&!Reflect.has(o[0],n)&&(Object.keys(o[0]).some((e=>Reflect.has(t,e)))||(ui(i,{[n]:o[0]}),s.splice(s.indexOf(n),1),o.shift())),1===o.length&&Xn(o[0]))ui(i,o[0]);else for(let t=0;t<s.length;t++)Gn(o[t])&&(i[s[t]]=o[t]);return ui(t,i)}function di(t,e){return Un(t)?e:t}function fi(t,e){return e.forEach((e=>{Reflect.has(t,e)&&delete t[e]})),t}const _i=1e-6;function mi(t,e){return t>e+_i}function gi(t,e){return mi(t,e)||yi(t,e)}function vi(t,e){return t+_i<e}function yi(t,e){return Math.abs(t-e)<_i}function xi(t,e,s){return Math.max(Math.min(t,s),e)}const wi="15.4.0",bi="object"==typeof self?self:null,Ti=bi&&(bi.hasOwnProperty("AudioContext")||bi.hasOwnProperty("webkitAudioContext"));class Si{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||bi&&this.toString()===bi.TONE_DEBUG_CLASS)&&ci(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}Si.version=wi;class ki extends Si{constructor(){super(),this.name="Timeline",this._timeline=[];const t=pi(ki.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(Kn(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){const e=this._timeline[this.length-1];Kn(gi(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{const e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(t){const e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this}get(t,e="time"){const s=this._search(t,e);return-1!==s?this._timeline[s]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const s=this._search(t,e);return s+1<this._timeline.length?this._timeline[s+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const s=this._search(t);return s-1>=0?this._timeline[s-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(yi(this._timeline[e].time,t)){for(let s=e;s>=0&&yi(this._timeline[s].time,t);s--)e=s;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&gi(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(0===this._timeline.length)return-1;let s=0;const n=this._timeline.length;let i=n;if(n>0&&this._timeline[n-1][e]<=t)return n-1;for(;s<i;){let n=Math.floor(s+(i-s)/2);const o=this._timeline[n],r=this._timeline[n+1];if(yi(o[e],t)){for(let s=n;s<this._timeline.length&&yi(this._timeline[s][e],t);s++)n=s;return n}if(vi(o[e],t)&&mi(r[e],t))return n;mi(o[e],t)?i=n:s=n+1}return-1}_iterate(t,e=0,s=this._timeline.length-1){this._timeline.slice(e,s+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const s=this._search(t);return-1!==s&&this._iterate(e,0,s),this}forEachAfter(t,e){const s=this._search(t);return this._iterate(e,s+1),this}forEachBetween(t,e,s){let n=this._search(t),i=this._search(e);return-1!==n&&-1!==i?(this._timeline[n].time!==t&&(n+=1),this._timeline[i].time===e&&(i-=1),this._iterate(s,n,i)):-1===n&&this._iterate(s,0,i),this}forEachFrom(t,e){let s=this._search(t);for(;s>=0&&this._timeline[s].time>=t;)s--;return this._iterate(e,s+1),this}forEachAtTime(t,e){const s=this._search(t);if(-1!==s&&yi(this._timeline[s].time,t)){let n=s;for(let e=s;e>=0&&yi(this._timeline[e].time,t);e--)n=e;this._iterate((t=>{e(t)}),n,s)}return this}dispose(){return super.dispose(),this._timeline=[],this}}function Ai(t,e,s,n){var i,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o<3?i(r):o>3?i(e,s,r):i(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r}function Ci(t,e,s,n){return new(s||(s=Promise))((function(i,o){function r(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}c((n=n.apply(t,e||[])).next())}))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;class Oi{constructor(t,e,s,n){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(n||44100),.001),this.updateInterval=s,this._createClock()}_createWorker(){const t=new Blob([`\n\t\t\t// the initial timeout time\n\t\t\tlet timeoutTime = ${(1e3*this._updateInterval).toFixed(1)};\n\t\t\t// onmessage callback\n\t\t\tself.onmessage = function(msg){\n\t\t\t\ttimeoutTime = parseInt(msg.data);\n\t\t\t};\n\t\t\t// the tick function which posts a message\n\t\t\t// and schedules a new tick\n\t\t\tfunction tick(){\n\t\t\t\tsetTimeout(tick, timeoutTime);\n\t\t\t\tself.postMessage('tick');\n\t\t\t}\n\t\t\t// call tick initially\n\t\t\ttick();\n\t\t\t`],{type:"text/javascript"}),e=URL.createObjectURL(t),s=new Worker(e);s.onmessage=this._callback.bind(this),this._worker=s}_createTimeout(){this._timeout=setTimeout((()=>{this._createTimeout(),this._callback()}),1e3*this._updateInterval)}_createClock(){if("worker"===this._type)try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else"timeout"===this._type&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),"worker"===this._type&&(null===(e=this._worker)||void 0===e||e.postMessage(1e3*this._updateInterval))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}}class Di extends Si{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach((t=>{Un(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)})),this}once(t,e){const s=(...n)=>{e(...n),this.off(t,s)};return this.on(t,s),this}off(t,e){return t.split(/\W+/).forEach((t=>{if(Un(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(Un(e))this._events[t]=[];else{const s=this._events[t];for(let t=s.length-1;t>=0;t--)s[t]===e&&s.splice(t,1)}})),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const s=this._events[t].slice(0);for(let t=0,n=s.length;t<n;t++)s[t].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach((e=>{const s=Object.getOwnPropertyDescriptor(Di.prototype,e);Object.defineProperty(t.prototype,e,s)}))}dispose(){return super.dispose(),this._events=void 0,this}}class Mi extends Di{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}const Ei=[];function Ri(t){Ei.push(t)}const qi=[];function Vi(t){qi.push(t)}class Ii extends Mi{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new ki,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromises=new Set;const s=pi(Ii.getDefaults(),arguments,["context"]);s.context?(this._context=s.context,this._latencyHint=(null===(t=arguments[0])||void 0===t?void 0:t.latencyHint)||""):(this._context=function(t){return new vn(t)}(s.sampleRate?{latencyHint:s.latencyHint,sampleRate:s.sampleRate}:{latencyHint:s.latencyHint}),this._latencyHint=s.latencyHint),this._ticker=new Oi(this.emit.bind(this,"tick"),s.clockSource,s.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[(null===(e=arguments[0])||void 0===e?void 0:e.hasOwnProperty("updateInterval"))?"_lookAhead":"lookAhead"]=s.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){var t;return this._initialized||(t=this,Ei.forEach((e=>e(t))),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(t,e,s){return this._context.createBuffer(t,e,s)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,s){return this._context.createPeriodicWave(t,e,s)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return Kn(Bn(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return Kn(Bn(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return Kn(Bn(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}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(t){Kn(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Kn(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Kn(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Kn(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,s){return Kn(Gn(En),"AudioWorkletNode only works in a secure context (https or localhost)"),new(t instanceof(null==bi?void 0:bi.BaseAudioContext)?null==bi?void 0:bi.AudioWorkletNode:En)(t,e,s)}(this.rawContext,t,e)}addAudioWorkletModule(t){return Ci(this,void 0,void 0,(function*(){Kn(Gn(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)");const e=this.rawContext.audioWorklet.addModule(t);return this._workletPromises.add(e),e.finally((()=>this._workletPromises.delete(e))),e}))}workletsAreReady(){return Ci(this,void 0,void 0,(function*(){yield Promise.all(this._workletPromises)}))}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/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 Bn(this._context)?this._context.resume():Promise.resolve()}close(){return Ci(this,void 0,void 0,(function*(){var t;Bn(this._context)&&"closed"!==this.state&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&(t=this,qi.forEach((e=>e(t))))}))}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),s=e.getChannelData(0);for(let e=0;e<s.length;e++)s[e]=t;const n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants.set(t,n),n}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map((t=>this._constants[t].disconnect())),this.close(),this}_timeoutLoop(){const t=this.now();this._timeouts.forEachBefore(t,(t=>{try{t.callback()}finally{this._timeouts.remove(t)}}))}setTimeout(t,e){this._timeoutIds++;const s=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:s+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach((e=>{e.id===t&&this._timeouts.remove(e)})),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const s=++this._timeoutIds,n=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),n()},id:s,time:i+e})};return n(),s}}function Fi(t,e){Hn(e)?e.forEach((e=>Fi(t,e))):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function Pi(t,e){Hn(e)?e.forEach((e=>Pi(t,e))):Object.defineProperty(t,e,{writable:!0})}const Ni=()=>{};class ji extends Si{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Ni;const t=pi(ji.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,$n(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:Ni,onload:Ni,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Bi().sampleRate}set(t){return t instanceof ji?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return Ci(this,void 0,void 0,(function*(){const e=ji.load(t).then((t=>{this.set(t),this.onload(this)}));ji.downloads.push(e);try{yield e}finally{const t=ji.downloads.indexOf(e);ji.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=Hn(t)&&t[0].length>0,s=e?t.length:1,n=e?t[0].length:t.length,i=Bi(),o=i.createBuffer(s,n,i.sampleRate),r=e||1!==s?t:[t];for(let t=0;t<s;t++)o.copyToChannel(r[t],t);return this._buffer=o,this}toMono(t){if(Zn(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let s=0;s<e;s++){const e=this.toArray(s);for(let s=0;s<e.length;s++)t[s]+=e[s]}t=t.map((t=>t/e)),this.fromArray(t)}return this}toArray(t){if(Zn(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this.toArray(0);{const t=[];for(let e=0;e<this.numberOfChannels;e++)t[e]=this.getChannelData(e);return t}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){Kn(this.loaded,"Buffer is not loaded");const s=Math.floor(t*this.sampleRate),n=Math.floor(e*this.sampleRate);Kn(s<n,"The start time must be less than the end time");const i=n-s,o=Bi().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let t=0;t<this.numberOfChannels;t++)o.copyToChannel(this.getChannelData(t).subarray(s,n),t);return new ji(o)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).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(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return(new ji).fromArray(t)}static fromUrl(t){return Ci(this,void 0,void 0,(function*(){const e=new ji;return yield e.load(t)}))}static load(t){return Ci(this,void 0,void 0,(function*(){const e=""===ji.baseUrl||ji.baseUrl.endsWith("/")?ji.baseUrl:ji.baseUrl+"/",s=yield fetch(e+t);if(!s.ok)throw new Error(`could not load url: ${t}`);const n=yield s.arrayBuffer();return yield Bi().decodeAudioData(n)}))}static supportsType(t){const e=t.split("."),s=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+s)}static loaded(){return Ci(this,void 0,void 0,(function*(){for(yield Promise.resolve();ji.downloads.length;)yield ji.downloads[0]}))}}ji.baseUrl="",ji.downloads=[];class Li extends Ii{constructor(){var t,e,s;super({clockSource:"offline",context:Wn(arguments[0])?arguments[0]:(t=arguments[0],e=arguments[1]*arguments[2],s=arguments[2],new Vn(t,e,s)),lookAhead:0,updateInterval:Wn(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Wn(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return Ci(this,void 0,void 0,(function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const s=Math.floor(this.sampleRate/128);t&&e%s===0&&(yield new Promise((t=>setTimeout(t,1))))}}))}render(){return Ci(this,arguments,void 0,(function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new ji(e)}))}close(){return Promise.resolve()}}const zi=new class extends Mi{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,s){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,s){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return Ci(this,void 0,void 0,(function*(){return Promise.resolve()}))}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};let Wi=zi;function Bi(){return Wi===zi&&Ti&&Ui(new Ii),Wi}function Ui(t,e=!1){e&&Wi.dispose(),Wi=Bn(t)?new Ii(t):Wn(t)?new Li(t):t}function Gi(){return Wi.resume()}if(bi&&!bi.TONE_SILENCE_LOGGING){let t="v";"dev"===wi&&(t="");const e=` * Tone.js ${t}${wi} * `;console.log(`%c${e}`,"background: #000; color: #fff")}class Qi extends Si{constructor(t,e,s){super(),this.defaultUnits="s",this._val=e,this._units=s,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const s=parseInt(t,10),n="."===e?1.5:1;return 1===s?this._beatsToUnits(this._getTimeSignature())*n:this._beatsToUnits(4/s)*n},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(3*Math.floor(e)))},regexp:/^(\d+)t$/i},tr:{method:(t,e,s)=>{let n=0;return t&&"0"!==t&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n+=this._beatsToUnits(parseFloat(e))),s&&"0"!==s&&(n+=this._beatsToUnits(parseFloat(s)/4)),n},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof Qi&&this.fromType(this._val),Un(this._val))return this._noArg();if($n(this._val)&&Un(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(Xn(this._val)){let t=0;for(const e in this._val)if(Gn(this._val[e])){const s=this._val[e];t+=new this.constructor(this.context,e).valueOf()*s}return t}if(Gn(this._units)){const t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}return $n(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*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(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi()}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return 1e3*this.toSeconds()}}class Zi extends Qi{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{const e=new Zi(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const s=new this.constructor(this.context,t).valueOf(),n=this.valueOf();return n+(Math.round(n/s)*s-n)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const s=Math.pow(2,t);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let s=e[0],n=new Zi(this.context,e[0]).toSeconds();return e.forEach((e=>{const i=new Zi(this.context,e).toSeconds();Math.abs(i-t)<Math.abs(n-t)&&(s=e,n=i)})),s}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const s=Math.floor(e/this._getTimeSignature());let n=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=n.toString();return i.length>3&&(n=parseFloat(parseFloat(i).toFixed(3))),[s,e,n].join(":")}toTicks(){const t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return c(this.toFrequency())}_now(){return this.context.now()}}function Xi(t,e){return new Zi(Bi(),t,e)}class Yi extends Zi{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return a}static set A4(t){!function(t){a=t}(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return"midi"===this.defaultUnits?t:Yi.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){const s=Hi[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?s:Yi.mtof(s)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,s){let n=1;return t&&"0"!==t&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n*=this._beatsToUnits(parseFloat(e))),s&&"0"!==s&&(n*=this._beatsToUnits(parseFloat(s)/4)),n}}})}transpose(t){return new Yi(this.context,this.valueOf()*r(t))}harmonize(t){return t.map((t=>this.transpose(t)))}toMidi(){return c(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/Yi.A4);let s=Math.round(12*e)+57;const n=Math.floor(s/12);return n<0&&(s+=-12*n),$i[s%12]+n.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return l(t)}static ftom(t){return c(t)}}const Hi={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},$i=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function Ji(t,e){return new Yi(Bi(),t,e)}class Ki extends Zi{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}function to(t,e){return new Ki(Bi(),t,e)}class eo extends Si{constructor(){super();const t=pi(eo.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Bi()}}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(t){return oi(t),new Zi(this.context,t).toSeconds()}toFrequency(t){return new Yi(this.context,t).toFrequency()}toTicks(t){return new Ki(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach((s=>{Un(t[s])&&delete e[s]})),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach((e=>{if(Reflect.has(this,e)){const s=this[e];Gn(s)&&Gn(s.value)&&Gn(s.setValueAtTime)?t[e]=s.value:s instanceof eo?t[e]=s._getPartialProperties(t[e]):Hn(s)||Zn(s)||$n(s)||Yn(s)?t[e]=s:delete t[e]}})),t}set(t){return Object.keys(t).forEach((e=>{Reflect.has(this,e)&&Gn(this[e])&&(this[e]&&Gn(this[e].value)&&Gn(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof eo?this[e].set(t[e]):this[e]=t[e])})),this}}class so extends eo{constructor(){const t=pi(so.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,Kn(Gn(t.param)&&(Ln(t.param)||t.param instanceof so),"param must be an AudioParam");!Ln(t.param);)t.param=t.param._param;this._swappable=!!Gn(t.swappable)&&t.swappable,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new ki(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,Gn(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(eo.getDefaults(),{convert:!0,units:"number"})}get value(){const t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return Gn(this._minValue)?this._minValue:"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"===this.units?0:"audioRange"===this.units?-1:"decibels"===this.units?-1/0:this._param.minValue}get maxValue(){return Gn(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return Gn(this.maxValue)&&Gn(this.minValue)&&ti(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?i(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&"decibels"===this.units?o(t):t}setValueAtTime(t,e){const s=this.toSeconds(e),n=this._fromType(t);return Kn(isFinite(n)&&isFinite(s),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this.log(this.units,"setValueAtTime",t,s),this._events.add({time:s,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,s),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),s=this._events.getAfter(e),n=this._events.get(e);let i=this._initialValue;if(null===n)i=this._initialValue;else if("setTargetAtTime"!==n.type||null!==s&&"setValueAtTime"!==s.type)if(null===s)i=n.value;else if("linearRampToValueAtTime"===s.type||"exponentialRampToValueAtTime"===s.type){let t=n.value;if("setTargetAtTime"===n.type){const e=this._events.getBefore(n.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===s.type?this._linearInterpolate(n.time,t,s.time,s.value,e):this._exponentialInterpolate(n.time,t,s.time,s.value,e)}else i=n.value;else{const t=this._events.getBefore(n.time);let s;s=null===t?this._initialValue:t.value,"setTargetAtTime"===n.type&&(i=this._exponentialApproach(n.time,s,n.value,n.constant,e))}return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===this._fromType(e)&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const s=this._fromType(t),n=this.toSeconds(e);return Kn(isFinite(s)&&isFinite(n),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(s),this._events.add({time:n,type:"linearRampToValueAtTime",value:s}),this.log(this.units,"linearRampToValueAtTime",t,n),this._param.linearRampToValueAtTime(s,n),this}exponentialRampToValueAtTime(t,e){let s=this._fromType(t);s=yi(s,0)?this._minOutput:s,this._assertRange(s);const n=this.toSeconds(e);return Kn(isFinite(s)&&isFinite(n),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:n,type:"exponentialRampToValueAtTime",value:s}),this.log(this.units,"exponentialRampToValueAtTime",t,n),this._param.exponentialRampToValueAtTime(s,n),this}exponentialRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.exponentialRampToValueAtTime(t,s+this.toSeconds(e)),this}linearRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.linearRampToValueAtTime(t,s+this.toSeconds(e)),this}targetRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.exponentialApproachValueAtTime(t,s,e),this}exponentialApproachValueAtTime(t,e,s){e=this.toSeconds(e),s=this.toSeconds(s);const n=Math.log(s+1)/Math.log(200);return this.setTargetAtTime(t,e,n),this.cancelAndHoldAtTime(e+.9*s),this.linearRampToValueAtTime(t,e+s),this}setTargetAtTime(t,e,s){const n=this._fromType(t);Kn(isFinite(s)&&s>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(n),Kn(isFinite(n)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:s,time:i,type:"setTargetAtTime",value:n}),this.log(this.units,"setTargetAtTime",t,i,s),this._param.setTargetAtTime(n,i,s),this}setValueCurveAtTime(t,e,s,n=1){s=this.toSeconds(s),e=this.toSeconds(e);const i=this._fromType(t[0])*n;this.setValueAtTime(this._toType(i),e);const o=s/(t.length-1);for(let s=1;s<t.length;s++){const i=this._fromType(t[s])*n;this.linearRampToValueAtTime(this._toType(i),e+s*o)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return Kn(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){const e=this.toSeconds(t),s=this._fromType(this.getValueAtTime(e));Kn(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+s);const n=this._events.get(e),i=this._events.getAfter(e);return n&&yi(n.time,e)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),"linearRampToValueAtTime"===i.type?this.linearRampToValueAtTime(this._toType(s),e):"exponentialRampToValueAtTime"===i.type&&this.exponentialRampToValueAtTime(this._toType(s),e)),this._events.add({time:e,type:"setValueAtTime",value:s}),this._param.setValueAtTime(s,e),this}rampTo(t,e=.1,s){return"frequency"===this.units||"bpm"===this.units||"decibels"===this.units?this.exponentialRampTo(t,e,s):this.linearRampTo(t,e,s),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const s=this._events.get(e);if(s&&"setTargetAtTime"===s.type){const n=this._events.getAfter(s.time),i=n?n.time:e+2,o=(i-e)/10;for(let s=e;s<i;s+=o)t.linearRampToValueAtTime(this.getValueAtTime(s),s)}return this._events.forEachAfter(this.context.currentTime,(e=>{"cancelScheduledValues"===e.type?t.cancelScheduledValues(e.time):"setTargetAtTime"===e.type?t.setTargetAtTime(e.value,e.time,e.constant):t[e.type](e.value,e.time)})),this}setParam(t){Kn(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,s,n,i){return s+(e-s)*Math.exp(-(i-t)/n)}_linearInterpolate(t,e,s,n,i){return e+(i-t)/(s-t)*(n-e)}_exponentialInterpolate(t,e,s,n,i){return e*Math.pow(n/e,(i-t)/(s-t))}}class no extends eo{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return Gn(this.input)?Ln(this.input)||this.input instanceof so?1:this.input.numberOfInputs:0}get numberOfOutputs(){return Gn(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return Gn(t)&&(t instanceof no||zn(t))}_getInternalNodes(){const t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach((e=>{e.channelCount=t.channelCount,e.channelCountMode=t.channelCountMode,e.channelInterpretation=t.channelInterpretation}))}_getChannelProperties(){const t=this._getInternalNodes();Kn(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,s=0){return oo(this,t,e,s),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return hi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,s=0){return ro(this,t,e,s),this}chain(...t){return io(this,...t),this}fan(...t){return t.forEach((t=>this.connect(t))),this}dispose(){return super.dispose(),Gn(this.input)&&(this.input instanceof no?this.input.dispose():zn(this.input)&&this.input.disconnect()),Gn(this.output)&&(this.output instanceof no?this.output.dispose():zn(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function io(...t){const e=t.shift();t.reduce(((t,e)=>(t instanceof no?t.connect(e):zn(t)&&oo(t,e),e)),e)}function oo(t,e,s=0,n=0){for(Kn(Gn(t),"Cannot connect from undefined node"),Kn(Gn(e),"Cannot connect to undefined node"),(e instanceof no||zn(e))&&Kn(e.numberOfInputs>0,"Cannot connect to node with no inputs"),Kn(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof no||e instanceof so;)Gn(e.input)&&(e=e.input);for(;t instanceof no;)Gn(t.output)&&(t=t.output);Ln(e)?t.connect(e,s):t.connect(e,s,n)}function ro(t,e,s=0,n=0){if(Gn(e))for(;e instanceof no||e instanceof so;)e=e.input;for(;!zn(t);)Gn(t.output)&&(t=t.output);Ln(e)?t.disconnect(e,s):zn(e)?t.disconnect(e,s,n):t.disconnect()}function ao(...t){const e=t.pop();Gn(e)&&t.forEach((t=>oo(t,e)))}class co extends no{constructor(){const t=pi(co.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new so({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),Fi(this,"gain")}static getDefaults(){return Object.assign(no.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class ho extends no{constructor(){const t=pi(ho.getDefaults(),arguments,["channels"]);super(t),this.name="Split",this._splitter=this.input=this.output=this.context.createChannelSplitter(t.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign(no.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}}class lo extends no{constructor(){const t=pi(lo.getDefaults(),arguments,["type","size"]);super(t),this.name="Analyser",this._analyzers=[],this._buffers=[],this.input=this.output=this._gain=new co({context:this.context}),this._split=new ho({context:this.context,channels:t.channels}),this.input.connect(this._split),ti(t.channels,1);for(let e=0;e<t.channels;e++)this._analyzers[e]=this.context.createAnalyser(),this._split.connect(this._analyzers[e],e,0);this.size=t.size,this.type=t.type,this.smoothing=t.smoothing}static getDefaults(){return Object.assign(no.getDefaults(),{size:1024,smoothing:.8,type:"fft",channels:1})}getValue(){return this._analyzers.forEach(((t,e)=>{const s=this._buffers[e];"fft"===this._type?t.getFloatFrequencyData(s):"waveform"===this._type&&t.getFloatTimeDomainData(s)})),1===this.channels?this._buffers[0]:this._buffers}get size(){return this._analyzers[0].frequencyBinCount}set size(t){this._analyzers.forEach(((e,s)=>{e.fftSize=2*t,this._buffers[s]=new Float32Array(t)}))}get channels(){return this._analyzers.length}get type(){return this._type}set type(t){Kn("waveform"===t||"fft"===t,`Analyser: invalid type: ${t}`),this._type=t}get smoothing(){return this._analyzers[0].smoothingTimeConstant}set smoothing(t){this._analyzers.forEach((e=>e.smoothingTimeConstant=t))}dispose(){return super.dispose(),this._analyzers.forEach((t=>t.disconnect())),this._split.dispose(),this._gain.dispose(),this}}class uo extends no{constructor(){super(pi(uo.getDefaults(),arguments)),this.name="MeterBase",this.input=this.output=this._analyser=new lo({context:this.context,size:256,type:"waveform"})}dispose(){return super.dispose(),this._analyser.dispose(),this}}class po extends uo{constructor(){super(pi(po.getDefaults(),arguments)),this.name="DCMeter",this._analyser.type="waveform",this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}}class fo extends uo{constructor(){const t=pi(fo.getDefaults(),arguments,["size"]);super(t),this.name="FFT",this.normalRange=t.normalRange,this._analyser.type="fft",this.size=t.size}static getDefaults(){return Object.assign(no.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map((t=>this.normalRange?i(t):t))}get size(){return this._analyser.size}set size(t){this._analyser.size=t}get smoothing(){return this._analyser.smoothing}set smoothing(t){this._analyser.smoothing=t}getFrequencyOfIndex(t){return Kn(0<=t&&t<this.size,`index must be greater than or equal to 0 and less than ${this.size}`),t*this.context.sampleRate/(2*this.size)}}class _o extends no{constructor(t){super(t),this.onended=Ni,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new co({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const e=this.toSeconds(t);return-1!==this._startTime&&e>=this._startTime&&(-1===this._stopTime||e<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(no.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Ni})}_startGain(t,e=1){Kn(-1===this._startTime,"Source cannot be started more than once");const s=this.toSeconds(this._fadeIn);return this._startTime=t+s,this._startTime=Math.max(this._startTime,this.context.currentTime),s>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+s):this._gainNode.gain.exponentialApproachValueAtTime(e,t,s)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Kn(-1!==this._startTime,"'start' must be called before 'stop'"),this.cancelStop();const e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?"linear"===this._curve?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout((()=>{const t="exponential"===this._curve?2*e:0;this._stopSource(this.now()+t),this._onended()}),this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==Ni&&(this.onended(this),this.onended=Ni,!this.context.isOffline)){const t=()=>this.dispose();"undefined"!=typeof requestIdleCallback?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Kn(-1!==this._startTime,"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=Ni,this}}class mo extends _o{constructor(){var t;const e=pi(mo.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._contextStarted=t=>{"running"===t&&(this._source=this.context.createConstantSource(),oo(this._source,this._gainNode),this.offset.setParam(this._source.offset),"started"===this.state&&this._source.start(0))};const s=!this.context.isOffline&&"running"!==this.context.state;s?this.context.on("statechange",this._contextStarted):(this._source=this.context.createConstantSource(),oo(this._source,this._gainNode)),this.offset=new so({context:this.context,convert:e.convert,param:s?this.context.createGain().gain:null===(t=this._source)||void 0===t?void 0:t.offset,swappable:s,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(_o.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){var e;const s=this.toSeconds(t);return this.log("start",s),this._startGain(s),null===(e=this._source)||void 0===e||e.start(s),this}_stopSource(t){var e;"stopped"!==this.state&&(null===(e=this._source)||void 0===e||e.stop(t))}dispose(){var t;return super.dispose(),"started"===this.state&&this.stop(),null===(t=this._source)||void 0===t||t.disconnect(),this.offset.dispose(),this.context.off("statechange",this._contextStarted),this}}class go extends no{constructor(){const t=pi(go.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new mo({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(no.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,s=0){return yo(this,t,e,s),this}disconnect(t,e,s){return xo(this,t,e,s),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,s){return this._param.exponentialRampTo(t,e,s),this}linearRampTo(t,e,s){return this._param.linearRampTo(t,e,s),this}targetRampTo(t,e,s){return this._param.targetRampTo(t,e,s),this}exponentialApproachValueAtTime(t,e,s){return this._param.exponentialApproachValueAtTime(t,e,s),this}setTargetAtTime(t,e,s){return this._param.setTargetAtTime(t,e,s),this}setValueCurveAtTime(t,e,s,n){return this._param.setValueCurveAtTime(t,e,s,n),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,s){return this._param.rampTo(t,e,s),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}const vo=new WeakMap;function yo(t,e,s,n){var i;if(e instanceof so||Ln(e)||e instanceof go&&e.override){const o=e.value;e.cancelScheduledValues(0),e.setValueAtTime(0,0),(e instanceof go||e instanceof so)&&(e.overridden=!0),vo.has(t)||vo.set(t,[]),null===(i=vo.get(t))||void 0===i||i.push({destination:e,outputNum:s||0,inputNum:n||0,previousValue:o})}oo(t,e,s,n)}function xo(t,e,s,n){if((e instanceof so||Ln(e)||e instanceof go&&e.override||void 0===e)&&vo.has(t)){let i=vo.get(t);if(e&&(i=i.filter((t=>t.destination===e&&(Un(s)||t.outputNum===s)&&(Un(n)||t.inputNum===n)))),!i.length)throw new Error("Not connected to destination node");i.forEach((t=>{(t.destination instanceof go||t.destination instanceof so)&&(t.destination.overridden=!1),t.destination.setValueAtTime(t.previousValue,0)})),vo.set(t,vo.get(t).filter((t=>!i.includes(t))))}ro(t,e,s,n)}class wo extends no{constructor(){super(pi(wo.getDefaults(),arguments,["context"]))}connect(t,e=0,s=0){return yo(this,t,e,s),this}disconnect(t,e=0,s=0){return xo(this,t,e,s),this}}class bo extends wo{constructor(){const t=pi(bo.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Hn(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Qn(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(go.getDefaults(),{length:1024})}setMap(t,e=1024){const s=new Float32Array(e);for(let n=0,i=e;n<i;n++){const e=n/(i-1)*2-1;s[n]=t(e,n)}return this.curve=s,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){Kn(["none","2x","4x"].some((e=>e.includes(t))),"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class To extends wo{constructor(){super(...arguments),this.name="Abs",this._abs=new bo({context:this.context,mapping:t=>Math.abs(t)<.001?0:Math.abs(t)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}}class So extends no{constructor(){const t=pi(So.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OnePoleFilter",this._frequency=t.frequency,this._type=t.type,this.input=new co({context:this.context}),this.output=new co({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign(no.getDefaults(),{frequency:880,type:"lowpass"})}_createFilter(){const t=this._filter,e=this.toFrequency(this._frequency),s=1/(2*Math.PI*e);if("lowpass"===this._type){const t=1/(s*this.context.sampleRate),e=t-1;this._filter=this.context.createIIRFilter([t,0],[1,e])}else{const t=1/(s*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,t])}this.input.chain(this._filter,this.output),t&&this.context.setTimeout((()=>{this.disposed||(this.input.disconnect(t),t.disconnect())}),this.blockTime)}get frequency(){return this._frequency}set frequency(t){this._frequency=t,this._createFilter()}get type(){return this._type}set type(t){this._type=t,this._createFilter()}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let s=0;s<t;s++){const n=19980*Math.pow(s/t,2)+20;e[s]=n}const s=new Float32Array(t),n=new Float32Array(t);return this._filter.getFrequencyResponse(e,s,n),s}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this._filter.disconnect(),this}}class ko extends no{constructor(){const t=pi(ko.getDefaults(),arguments,["smoothing"]);super(t),this.name="Follower",this._abs=this.input=new To({context:this.context}),this._lowpass=this.output=new So({context:this.context,frequency:1/this.toSeconds(t.smoothing),type:"lowpass"}),this._abs.connect(this._lowpass),this._smoothing=t.smoothing}static getDefaults(){return Object.assign(no.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}}class Ao extends uo{constructor(){const t=pi(Ao.getDefaults(),arguments,["smoothing"]);super(t),this.name="Meter",this.input=this.output=this._analyser=new lo({context:this.context,size:256,type:"waveform",channels:t.channelCount}),this.smoothing=t.smoothing,this.normalRange=t.normalRange,this._rms=new Array(t.channelCount),this._rms.fill(0)}static getDefaults(){return Object.assign(uo.getDefaults(),{smoothing:.8,normalRange:!1,channelCount:1})}getLevel(){return hi("'getLevel' has been changed to 'getValue'"),this.getValue()}getValue(){const t=this._analyser.getValue(),e=(1===this.channels?[t]:t).map(((t,e)=>{const s=t.reduce(((t,e)=>t+e*e),0),n=Math.sqrt(s/t.length);return this._rms[e]=Math.max(n,this._rms[e]*this.smoothing),this.normalRange?this._rms[e]:o(this._rms[e])}));return 1===this.channels?e[0]:e}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}}class Co extends uo{constructor(){const t=pi(Co.getDefaults(),arguments,["size"]);super(t),this.name="Waveform",this._analyser.type="waveform",this.size=t.size}static getDefaults(){return Object.assign(uo.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(t){this._analyser.size=t}}class Oo extends no{constructor(){const t=pi(Oo.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new so({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",Fi(this,"pan")}static getDefaults(){return Object.assign(no.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}class Do extends no{constructor(){const t=pi(Do.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new co({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,Fi(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class Mo extends no{constructor(){const t=pi(Mo.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new Oo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,Fi(this,["pan","volume"])}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class Eo extends no{constructor(){const t=pi(Eo.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new co({context:this.context}),Eo._allSolos.has(this.context)||Eo._allSolos.set(this.context,new Set),Eo._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(no.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),Eo._allSolos.get(this.context).forEach((t=>t._updateSolo()))}get muted(){return 0===this.input.gain.value}_addSolo(){Eo._soloed.has(this.context)||Eo._soloed.set(this.context,new Set),Eo._soloed.get(this.context).add(this)}_removeSolo(){Eo._soloed.has(this.context)&&Eo._soloed.get(this.context).delete(this)}_isSoloed(){return Eo._soloed.has(this.context)&&Eo._soloed.get(this.context).has(this)}_noSolos(){return!Eo._soloed.has(this.context)||Eo._soloed.has(this.context)&&0===Eo._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),Eo._allSolos.get(this.context).delete(this),this._removeSolo(),this}}Eo._allSolos=new Map,Eo._soloed=new Map;class Ro extends no{constructor(){const t=pi(Ro.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new Eo({solo:t.solo,context:this.context}),this._panVol=this.output=new Mo({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),Fi(this,["pan","volume"])}static getDefaults(){return Object.assign(no.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return Ro.buses.has(t)||Ro.buses.set(t,new co({context:this.context})),Ro.buses.get(t)}send(t,e=0){const s=this._getBus(t),n=new co({context:this.context,units:"decibels",gain:e});return this.connect(n),n.connect(s),n}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}Ro.buses=new Map;class qo extends wo{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new bo({context:this.context,mapping:t=>2*Math.abs(t)-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Vo extends no{constructor(){const t=pi(Vo.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new qo({context:this.context}),this.a=new co({context:this.context,gain:0}),this.b=new co({context:this.context,gain:0}),this.output=new co({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new go({context:this.context,units:"normalRange",value:t.fade}),Fi(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",oo(this._split,this.a.gain,0),oo(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(no.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 Io extends no{constructor(){const t=pi(Io.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(no.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}class Fo extends go{constructor(){super(pi(Fo.getDefaults(),arguments,["value"])),this.override=!1,this.name="Add",this._sum=new co({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,io(this._constantSource,this._sum)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class Po extends go{constructor(){const t=pi(Po.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new co({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class No extends wo{constructor(){super(...arguments),this.name="Negate",this._multiply=new Po({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}}class jo extends go{constructor(){super(pi(jo.getDefaults(),arguments,["value"])),this.override=!1,this.name="Subtract",this._sum=new co({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new No({context:this.context}),this.subtrahend=this._param,io(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}}class Lo extends no{constructor(){super(pi(Lo.getDefaults(),arguments)),this.name="MidSideMerge",this.mid=new co({context:this.context}),this.side=new co({context:this.context}),this._left=new Fo({context:this.context}),this._leftMult=new Po({context:this.context,value:Math.SQRT1_2}),this._right=new jo({context:this.context}),this._rightMult=new Po({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Io({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 zo extends no{constructor(){super(pi(zo.getDefaults(),arguments)),this.name="MidSideSplit",this._split=this.input=new ho({channels:2,context:this.context}),this._midAdd=new Fo({context:this.context}),this.mid=new Po({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new jo({context:this.context}),this.side=new Po({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 Wo extends no{constructor(){super(pi(Wo.getDefaults(),arguments)),this.name="Mono",this.input=new co({context:this.context}),this._merge=this.output=new Io({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 Bo extends no{constructor(){const t=pi(Bo.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new so({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new so({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new so({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new so({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(no.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Kn(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let s=0;s<t;s++){const n=19980*Math.pow(s/t,2)+20;e[s]=n}const s=new Float32Array(t),n=new Float32Array(t),i=this.context.createBiquadFilter();return i.type=this.type,i.Q.value=this.Q.value,i.frequency.value=this.frequency.value,i.gain.value=this.gain.value,i.getFrequencyResponse(e,s,n),s}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}class Uo extends no{constructor(){const t=pi(Uo.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this._filters=[],this._filters=[],this.Q=new go({context:this.context,units:"positive",value:t.Q}),this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this.detune=new go({context:this.context,units:"cents",value:t.detune}),this.gain=new go({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,Fi(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(no.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Kn(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),`Invalid filter type: ${t}`),this._type=t,this._filters.forEach((e=>e.type=t))}get rolloff(){return this._rolloff}set rolloff(t){const e=Zn(t)?t:parseInt(t,10),s=[-12,-24,-48,-96];let n=s.indexOf(e);Kn(-1!==n,`rolloff can only be ${s.join(", ")}`),n+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach((t=>t.disconnect())),this._filters=new Array(n);for(let t=0;t<n;t++){const e=new Bo({context:this.context});e.type=this._type,this.frequency.connect(e.frequency),this.detune.connect(e.detune),this.Q.connect(e.Q),this.gain.connect(e.gain),this._filters[t]=e}this._internalChannels=this._filters,io(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){const e=new Bo({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),s=new Float32Array(t).map((()=>1));return this._filters.forEach((()=>{e.getFrequencyResponse(t).forEach(((t,e)=>s[e]*=t))})),e.dispose(),s}dispose(){return super.dispose(),this._filters.forEach((t=>{t.dispose()})),Pi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class Go extends no{constructor(){const t=pi(Go.getDefaults(),arguments,["lowFrequency","highFrequency"]);super(t),this.name="MultibandSplit",this.input=new co({context:this.context}),this.output=void 0,this.low=new Uo({context:this.context,frequency:0,type:"lowpass"}),this._lowMidFilter=new Uo({context:this.context,frequency:0,type:"highpass"}),this.mid=new Uo({context:this.context,frequency:0,type:"lowpass"}),this.high=new Uo({context:this.context,frequency:0,type:"highpass"}),this._internalChannels=[this.low,this.mid,this.high],this.lowFrequency=new go({context:this.context,units:"frequency",value:t.lowFrequency}),this.highFrequency=new go({context:this.context,units:"frequency",value:t.highFrequency}),this.Q=new go({context:this.context,units:"positive",value:t.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),Fi(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(no.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),Pi(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 Qo extends no{constructor(){super(...arguments),this.name="Listener",this.positionX=new so({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new so({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new so({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new so({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new so({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new so({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new so({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new so({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new so({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(no.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}}Ri((t=>{t.listener=new Qo({context:t})})),Vi((t=>{t.listener.dispose()}));class Zo extends no{constructor(){const t=pi(Zo.getDefaults(),arguments,["positionX","positionY","positionZ"]);super(t),this.name="Panner3D",this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=t.panningModel,this.maxDistance=t.maxDistance,this.distanceModel=t.distanceModel,this.coneOuterGain=t.coneOuterGain,this.coneOuterAngle=t.coneOuterAngle,this.coneInnerAngle=t.coneInnerAngle,this.refDistance=t.refDistance,this.rolloffFactor=t.rolloffFactor,this.positionX=new so({context:this.context,param:this._panner.positionX,value:t.positionX}),this.positionY=new so({context:this.context,param:this._panner.positionY,value:t.positionY}),this.positionZ=new so({context:this.context,param:this._panner.positionZ,value:t.positionZ}),this.orientationX=new so({context:this.context,param:this._panner.orientationX,value:t.orientationX}),this.orientationY=new so({context:this.context,param:this._panner.orientationY,value:t.orientationY}),this.orientationZ=new so({context:this.context,param:this._panner.orientationZ,value:t.orientationZ})}static getDefaults(){return Object.assign(no.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(t,e,s){return this.positionX.value=t,this.positionY.value=e,this.positionZ.value=s,this}setOrientation(t,e,s){return this.orientationX.value=t,this.orientationY.value=e,this.orientationZ.value=s,this}get panningModel(){return this._panner.panningModel}set panningModel(t){this._panner.panningModel=t}get refDistance(){return this._panner.refDistance}set refDistance(t){this._panner.refDistance=t}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(t){this._panner.rolloffFactor=t}get distanceModel(){return this._panner.distanceModel}set distanceModel(t){this._panner.distanceModel=t}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(t){this._panner.coneInnerAngle=t}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(t){this._panner.coneOuterAngle=t}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(t){this._panner.coneOuterGain=t}get maxDistance(){return this._panner.maxDistance}set maxDistance(t){this._panner.maxDistance=t}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 Xo extends no{constructor(){const t=pi(Xo.getDefaults(),arguments);super(t),this.name="Recorder",this.input=new co({context:this.context}),Kn(Xo.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:t.mimeType})}static getDefaults(){return no.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return null!==bi&&Reflect.has(bi,"MediaRecorder")}get state(){return"inactive"===this._recorder.state?"stopped":"paused"===this._recorder.state?"paused":"started"}start(){return Ci(this,void 0,void 0,(function*(){Kn("started"!==this.state,"Recorder is already started");const t=new Promise((t=>{const e=()=>{this._recorder.removeEventListener("start",e,!1),t()};this._recorder.addEventListener("start",e,!1)}));return"stopped"===this.state?this._recorder.start():this._recorder.resume(),yield t}))}stop(){return Ci(this,void 0,void 0,(function*(){Kn("stopped"!==this.state,"Recorder is not started");const t=new Promise((t=>{const e=s=>{this._recorder.removeEventListener("dataavailable",e,!1),t(s.data)};this._recorder.addEventListener("dataavailable",e,!1)}));return this._recorder.stop(),yield t}))}pause(){return Kn("started"===this.state,"Recorder must be started"),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}}class Yo extends no{constructor(){const t=pi(Yo.getDefaults(),arguments,["threshold","ratio"]);super(t),this.name="Compressor",this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor,this.threshold=new so({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:"decibels",value:t.threshold}),this.attack=new so({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:"time",value:t.attack}),this.release=new so({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:"time",value:t.release}),this.knee=new so({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:"decibels",value:t.knee}),this.ratio=new so({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:"positive",value:t.ratio}),Fi(this,["knee","release","attack","ratio","threshold"])}static getDefaults(){return Object.assign(no.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 Ho extends wo{constructor(){super(pi(Ho.getDefaults(),arguments)),this.name="GreaterThanZero",this._thresh=this.output=new bo({context:this.context,length:127,mapping:t=>t<=0?0:1}),this._scale=this.input=new Po({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}}class $o extends go{constructor(){const t=pi($o.getDefaults(),arguments,["value"]);super(t),this.name="GreaterThan",this.override=!1,this._subtract=this.input=new jo({context:this.context,value:t.value}),this._gtz=this.output=new Ho({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,Fi(this,"comparator"),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}}class Jo extends no{constructor(){const t=pi(Jo.getDefaults(),arguments,["threshold","smoothing"]);super(t),this.name="Gate",this._follower=new ko({context:this.context,smoothing:t.smoothing}),this._gt=new $o({context:this.context,value:i(t.threshold)}),this.input=new co({context:this.context}),this._gate=this.output=new co({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign(no.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return o(this._gt.value)}set threshold(t){this._gt.value=i(t)}get smoothing(){return this._follower.smoothing}set smoothing(t){this._follower.smoothing=t}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}}class Ko extends no{constructor(){const t=pi(Ko.getDefaults(),arguments,["threshold"]);super(t),this.name="Limiter",this._compressor=this.input=this.output=new Yo({context:this.context,ratio:20,attack:.003,release:.01,threshold:t.threshold}),this.threshold=this._compressor.threshold,Fi(this,"threshold")}static getDefaults(){return Object.assign(no.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}}class tr extends no{constructor(){const t=pi(tr.getDefaults(),arguments);super(t),this.name="MidSideCompressor",this._midSideSplit=this.input=new zo({context:this.context}),this._midSideMerge=this.output=new Lo({context:this.context}),this.mid=new Yo(Object.assign(t.mid,{context:this.context})),this.side=new Yo(Object.assign(t.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),Fi(this,["mid","side"])}static getDefaults(){return Object.assign(no.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 er extends no{constructor(){const t=pi(er.getDefaults(),arguments);super(t),this.name="MultibandCompressor",this._splitter=this.input=new Go({context:this.context,lowFrequency:t.lowFrequency,highFrequency:t.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new co({context:this.context}),this.low=new Yo(Object.assign(t.low,{context:this.context})),this.mid=new Yo(Object.assign(t.mid,{context:this.context})),this.high=new Yo(Object.assign(t.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),Fi(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(no.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}}function sr(t,e=1/0){const s=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return s.get(this)},set:function(n){ti(n,t,e),s.set(this,n)}})}}function nr(t,e=1/0){const s=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return s.get(this)},set:function(n){ti(this.toSeconds(n),t,e),s.set(this,n)}})}}class ir extends no{constructor(){const t=pi(ir.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new go({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(no.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if($n(t))return t;{let s;for(s in or)if(or[s][e]===t)return s;return t}}_setCurve(t,e,s){if($n(s)&&Reflect.has(or,s)){const n=or[s];Xn(n)?"_decayCurve"!==t&&(this[t]=n[e]):this[t]=n}else{if(!Hn(s)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+s);this[t]=s}}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let s=this.toSeconds(this.attack);const n=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0&&(s=(1-i)/(1/s)),s<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if("linear"===this._attackCurve)this._sig.linearRampTo(e,s,t);else if("exponential"===this._attackCurve)this._sig.targetRampTo(e,s,t);else{this._sig.cancelAndHoldAtTime(t);let n=this._attackCurve;for(let t=1;t<n.length;t++)if(n[t-1]<=i&&i<=n[t]){n=this._attackCurve.slice(t),n[0]=i;break}this._sig.setValueCurveAtTime(n,t,s,e)}if(n&&this.sustain<1){const i=e*this.sustain,o=t+s;this.log("decay",o),"linear"===this._decayCurve?this._sig.linearRampToValueAtTime(i,n+o):this._sig.exponentialApproachValueAtTime(i,o,n)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const s=this.toSeconds(this.release);s<this.sampleTime?this._sig.setValueAtTime(0,t):"linear"===this._releaseCurve?this._sig.linearRampTo(0,s,t):"exponential"===this._releaseCurve?this._sig.targetRampTo(0,s,t):(Kn(Hn(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,s,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,s=1){return e=this.toSeconds(e),this.triggerAttack(e,s),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,s=0){return yo(this,t,e,s),this}disconnect(t,e=0,s=0){return xo(this,t,e,s),this}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){const e=t/this.context.sampleRate,s=new Li(1,e,this.context.sampleRate),n=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=n+this.toSeconds(this.release),o=.1*i,r=i+o,a=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/r,decay:e*this.toSeconds(this.decay)/r,release:e*this.toSeconds(this.release)/r,context:s}));return a._sig.toDestination(),a.triggerAttackRelease(e*(n+o)/r,0),(yield s.render()).getChannelData(0)}))}dispose(){return super.dispose(),this._sig.dispose(),this}}Ai([nr(0)],ir.prototype,"attack",void 0),Ai([nr(0)],ir.prototype,"decay",void 0),Ai([sr(0,1)],ir.prototype,"sustain",void 0),Ai([nr(0)],ir.prototype,"release",void 0);const or=(()=>{const t=128;let e,s;const n=[];for(e=0;e<t;e++)n[e]=Math.sin(e/127*(Math.PI/2));const i=[];for(e=0;e<127;e++){s=e/127;const t=Math.sin(s*(2*Math.PI)*6.4-Math.PI/2)+1;i[e]=t/10+.83*s}i[127]=1;const o=[];for(e=0;e<t;e++)o[e]=Math.ceil(e/127*5)/5;const r=[];for(e=0;e<t;e++)s=e/127,r[e]=.5*(1-Math.cos(Math.PI*s));const a=[];for(e=0;e<t;e++){s=e/127;const t=4*Math.pow(s,3)+.2,n=Math.cos(t*Math.PI*2*s);a[e]=Math.abs(n*(1-s))}function c(t){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=1-t[s];return e}return{bounce:{In:c(a),Out:a},cosine:{In:n,Out:(h=n,h.slice(0).reverse())},exponential:"exponential",linear:"linear",ripple:{In:i,Out:c(i)},sine:{In:r,Out:c(r)},step:{In:o,Out:c(o)}};var h})();class rr extends ir{constructor(){super(pi(rr.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new co({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 ar extends wo{constructor(){const t=pi(ar.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new bo({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(wo.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class cr extends wo{constructor(){const t=pi(cr.getDefaults(),arguments,["min","max"]);super(t),this.name="Scale",this._mult=this.input=new Po({context:this.context,value:t.max-t.min}),this._add=this.output=new Fo({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(wo.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(t){this._min=t,this._setRange()}get max(){return this._max}set max(t){this._max=t,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 hr extends ir{constructor(){const t=pi(hr.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="FrequencyEnvelope",this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new ar({context:this.context,value:t.exponent}),this._scale=this.output=new cr({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(ir.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){const e=this.toFrequency(t);ti(e,0),this._baseFrequency=e,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._scale.max=this._baseFrequency*Math.pow(2,t)}get exponent(){return this._exponent.value}set exponent(t){this._exponent.value=t}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class lr extends no{constructor(){const t=pi(lr.getDefaults(),arguments,["url","onload"]);super(t),this.name="Convolver",this._convolver=this.context.createConvolver(),this._buffer=new ji(t.url,(e=>{this.buffer=e,t.onload()})),this.input=new co({context:this.context}),this.output=new co({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=t.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign(no.getDefaults(),{normalize:!0,onload:Ni})}load(t){return Ci(this,void 0,void 0,(function*(){this.buffer=yield this._buffer.load(t)}))}get buffer(){return this._buffer.length?this._buffer:null}set buffer(t){t&&this._buffer.set(t),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));const e=this._buffer.get();this._convolver.buffer=e||null}get normalize(){return this._convolver.normalize}set normalize(t){this._convolver.normalize=t}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}}class ur extends no{constructor(){const t=pi(ur.getDefaults(),arguments,["low","mid","high"]);super(t),this.name="EQ3",this.output=new co({context:this.context}),this._internalChannels=[],this.input=this._multibandSplit=new Go({context:this.context,highFrequency:t.highFrequency,lowFrequency:t.lowFrequency}),this._lowGain=new co({context:this.context,gain:t.low,units:"decibels"}),this._midGain=new co({context:this.context,gain:t.mid,units:"decibels"}),this._highGain=new co({context:this.context,gain:t.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),Fi(this,["low","mid","high","lowFrequency","highFrequency"]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign(no.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),Pi(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}}const pr=new Set;function dr(t){pr.add(t)}function fr(t,e){const s=`registerProcessor("${t}", ${e})`;pr.add(s)}class _r extends no{constructor(t){super(t),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=Ni;const e=URL.createObjectURL(new Blob([Array.from(pr).join("\n")],{type:"text/javascript"})),s=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain;let n=_r._workletPromises.get(this.context);t.workletOptions&&(this.workletOptions=Object.assign({},this.workletOptions,t.workletOptions)),void 0===n&&(n=this.context.addAudioWorkletModule(e),_r._workletPromises.set(this.context,n)),n.then((()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(s,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}}_r._workletPromises=new WeakMap,dr('\n\t/**\n\t * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}. \n\t */\n\tclass ToneAudioWorkletProcessor extends AudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\t\n\t\t\tsuper(options);\n\t\t\t/**\n\t\t\t * If the processor was disposed or not. Keep alive until its disposed.\n\t\t\t */\n\t\t\tthis.disposed = false;\n\t\t \t/** \n\t\t\t * The number of samples in the processing block\n\t\t\t */\n\t\t\tthis.blockSize = 128;\n\t\t\t/**\n\t\t\t * the sample rate\n\t\t\t */\n\t\t\tthis.sampleRate = sampleRate;\n\n\t\t\tthis.port.onmessage = (event) => {\n\t\t\t\t// when it receives a dispose \n\t\t\t\tif (event.data === "dispose") {\n\t\t\t\t\tthis.disposed = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n'),dr("\n\t/**\n\t * Abstract class for a single input/output processor. \n\t * has a 'generate' function which processes one sample at a time\n\t */\n\tclass SingleIOProcessor extends ToneAudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(Object.assign(options, {\n\t\t\t\tnumberOfInputs: 1,\n\t\t\t\tnumberOfOutputs: 1\n\t\t\t}));\n\t\t\t/**\n\t\t\t * Holds the name of the parameter and a single value of that\n\t\t\t * parameter at the current sample\n\t\t\t * @type { [name: string]: number }\n\t\t\t */\n\t\t\tthis.params = {}\n\t\t}\n\n\t\t/**\n\t\t * Generate an output sample from the input sample and parameters\n\t\t * @abstract\n\t\t * @param input number\n\t\t * @param channel number\n\t\t * @param parameters { [name: string]: number }\n\t\t * @returns number\n\t\t */\n\t\tgenerate(){}\n\n\t\t/**\n\t\t * Update the private params object with the \n\t\t * values of the parameters at the given index\n\t\t * @param parameters { [name: string]: Float32Array },\n\t\t * @param index number\n\t\t */\n\t\tupdateParams(parameters, index) {\n\t\t\tfor (const paramName in parameters) {\n\t\t\t\tconst param = parameters[paramName];\n\t\t\t\tif (param.length > 1) {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][index];\n\t\t\t\t} else {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][0];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Process a single frame of the audio\n\t\t * @param inputs Float32Array[][]\n\t\t * @param outputs Float32Array[][]\n\t\t */\n\t\tprocess(inputs, outputs, parameters) {\n\t\t\tconst input = inputs[0];\n\t\t\tconst output = outputs[0];\n\t\t\t// get the parameter values\n\t\t\tconst channelCount = Math.max(input && input.length || 0, output.length);\n\t\t\tfor (let sample = 0; sample < this.blockSize; sample++) {\n\t\t\t\tthis.updateParams(parameters, sample);\n\t\t\t\tfor (let channel = 0; channel < channelCount; channel++) {\n\t\t\t\t\tconst inputSample = input && input.length ? input[channel][sample] : 0;\n\t\t\t\t\toutput[channel][sample] = this.generate(inputSample, channel, this.params);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn !this.disposed;\n\t\t}\n\t};\n"),dr("\n\t/**\n\t * A multichannel buffer for use within an AudioWorkletProcessor as a delay line\n\t */\n\tclass DelayLine {\n\n\t\tconstructor(size, channels) {\n\t\t\tthis.buffer = [];\n\t\t\tthis.writeHead = []\n\t\t\tthis.size = size;\n\n\t\t\t// create the empty channels\n\t\t\tfor (let i = 0; i < channels; i++) {\n\t\t\t\tthis.buffer[i] = new Float32Array(this.size);\n\t\t\t\tthis.writeHead[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Push a value onto the end\n\t\t * @param channel number\n\t\t * @param value number\n\t\t */\n\t\tpush(channel, value) {\n\t\t\tthis.writeHead[channel] += 1;\n\t\t\tif (this.writeHead[channel] >= this.size) {\n\t\t\t\tthis.writeHead[channel] = 0;\n\t\t\t}\n\t\t\tthis.buffer[channel][this.writeHead[channel]] = value;\n\t\t}\n\n\t\t/**\n\t\t * Get the recorded value of the channel given the delay\n\t\t * @param channel number\n\t\t * @param delay number delay samples\n\t\t */\n\t\tget(channel, delay) {\n\t\t\tlet readHead = this.writeHead[channel] - Math.floor(delay);\n\t\t\tif (readHead < 0) {\n\t\t\t\treadHead += this.size;\n\t\t\t}\n\t\t\treturn this.buffer[channel][readHead];\n\t\t}\n\n\t\t/**\n\t\t * Get the reverse recorded value of the channel given the delay\n\t\t * @param channel number\n\t\t * @param delay number delay samples\n\t\t */\n\t\tgetReverse(channel, delay) {\n\t\t\tif (!this.size || !delay) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tconst readHead = delay * 2 - this.writeHead[channel] - 1;\n\n\t\t\t// Gain function to reduce clicking when read is too close to write\n\t\t\tlet readWriteDifference = this.writeHead[channel] - readHead;\n\t\t\tif (readWriteDifference < 0) {\n\t\t\t\treadWriteDifference += this.size\n\t\t\t}\n\t\t\tconst delayPct = readWriteDifference / this.size;\n\t\t\tconst gainFunction = 4 * delayPct * (1 - delayPct);\n\n\t\t\treturn this.buffer[channel][readHead] * gainFunction;\n\t\t}\n\t}\n");const mr="feedback-comb-filter";fr(mr,'\n\tclass FeedbackCombFilterWorklet extends SingleIOProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(options);\n\t\t\tthis.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);\n\t\t}\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: "delayTime",\n\t\t\t\tdefaultValue: 0.1,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 1,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}, {\n\t\t\t\tname: "feedback",\n\t\t\t\tdefaultValue: 0.5,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 0.9999,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, channel, parameters) {\n\t\t\tconst delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);\n\t\t\tthis.delayLine.push(channel, input + delayedSample * parameters.feedback);\n\t\t\treturn delayedSample;\n\t\t}\n\t}\n');class gr extends _r{constructor(){const t=pi(gr.getDefaults(),arguments,["delayTime","resonance"]);super(t),this.name="FeedbackCombFilter",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.delayTime=new so({context:this.context,value:t.delayTime,units:"time",minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new so({context:this.context,value:t.resonance,units:"normalRange",param:this._dummyParam,swappable:!0}),Fi(this,["resonance","delayTime"])}_audioWorkletName(){return mr}static getDefaults(){return Object.assign(no.getDefaults(),{delayTime:.1,resonance:.5})}onReady(t){io(this.input,t,this.output);const e=t.parameters.get("delayTime");this.delayTime.setParam(e);const s=t.parameters.get("feedback");this.resonance.setParam(s)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}}class vr extends no{constructor(){const t=pi(vr.getDefaults(),arguments,["delayTime","resonance","dampening"]);super(t),this.name="LowpassCombFilter",this._combFilter=this.output=new gr({context:this.context,delayTime:t.delayTime,resonance:t.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new So({context:this.context,frequency:t.dampening,type:"lowpass"}),this._lowpass.connect(this._combFilter)}static getDefaults(){return Object.assign(no.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})}get dampening(){return this._lowpass.frequency}set dampening(t){this._lowpass.frequency=t}dispose(){return super.dispose(),this._combFilter.dispose(),this._lowpass.dispose(),this}}class yr extends ki{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){const e=this.get(t);return null!==e?e.state:this._initial}setStateAtTime(t,e,s){return ti(e,0),this.add(Object.assign({},s,{state:t,time:e})),this}getLastState(t,e){for(let s=this._search(e);s>=0;s--){const e=this._timeline[s];if(e.state===t)return e}}getNextState(t,e){const s=this._search(e);if(-1!==s)for(let e=s;e<this._timeline.length;e++){const s=this._timeline[e];if(s.state===t)return s}}}class xr extends so{constructor(){const t=pi(xr.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new ki(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(so.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,s){e=this.toSeconds(e),this.setRampPoint(e);const n=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max(1/s,1));for(let t=0;t<=o;t++){const o=s*t+e,r=this._exponentialApproach(i.time,i.value,n,s,o);this.linearRampToValueAtTime(this._toType(r),o)}return this}setValueAtTime(t,e){const s=this.toSeconds(e);super.setValueAtTime(t,e);const n=this._events.get(s),i=this._events.previousEvent(n),o=this._getTicksUntilEvent(i,s);return n.ticks=Math.max(o,0),this}linearRampToValueAtTime(t,e){const s=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const n=this._events.get(s),i=this._events.previousEvent(n),o=this._getTicksUntilEvent(i,s);return n.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const s=this._fromType(t),n=this._events.get(e),i=Math.round(Math.max(10*(e-n.time),1)),o=(e-n.time)/i;for(let t=0;t<=i;t++){const i=o*t+n.time,r=this._exponentialInterpolate(n.time,n.value,e,s,i);this.linearRampToValueAtTime(this._toType(r),i)}return this}_getTicksUntilEvent(t,e){if(null===t)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Un(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const s=this._fromType(this.getValueAtTime(t.time));let n=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(n=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(s+n)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),s=this._events.get(e);return Math.max(this._getTicksUntilEvent(s,e),0)}getDurationOfTicks(t,e){const s=this.toSeconds(e),n=this.getTicksAtTime(e);return this.getTimeOfTick(n+t)-s}getTimeOfTick(t){const e=this._events.get(t,"ticks"),s=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&s&&"linearRampToValueAtTime"===s.type&&e.value!==s.value){const n=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(s.time))-n)/(s.time-e.time),o=Math.sqrt(Math.pow(n,2)-2*i*(e.ticks-t)),r=(-n+o)/i;return(r>0?r:(-n-o)/i)+e.time}return e?0===e.value?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){const s=this.toSeconds(e),n=this.toSeconds(t),i=this.getTicksAtTime(s);return this.getTicksAtTime(s+n)-i}_fromType(t){return"bpm"===this.units&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return"bpm"===this.units&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class wr extends go{constructor(){const t=pi(wr.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new xr({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(go.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}}class br extends eo{constructor(){const t=pi(br.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new yr,this._tickOffset=new ki,this._ticksAtTime=new ki,this._secondsAtTime=new ki,this.frequency=new wr({context:this.context,units:t.units,value:t.frequency}),Fi(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},eo.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){const s=this.toSeconds(t);return"started"!==this._state.getValueAtTime(s)&&(this._state.setStateAtTime("started",s),Gn(e)&&this.setTicksAtTime(e,s),this._ticksAtTime.cancel(s),this._secondsAtTime.cancel(s)),this}stop(t){const e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){const t=this._state.get(e);t&&t.time>0&&(this._tickOffset.cancel(t.time),this._state.cancel(t.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){const e=this.toSeconds(t),s=this._state.getLastState("stopped",e),n=this._ticksAtTime.get(e),i={state:"paused",time:e};this._state.add(i);let o=n||s,r=n?n.ticks:0,a=null;return this._state.forEachBetween(o.time,e+this.sampleTime,(t=>{let e=o.time;const s=this._tickOffset.get(t.time);s&&s.time>=o.time&&(r=s.ticks,e=s.time),"started"===o.state&&"started"!==t.state&&(r+=this.frequency.getTicksAtTime(t.time)-this.frequency.getTicksAtTime(e),t.time!==i.time&&(a={state:t.state,time:t.time,ticks:r})),o=t})),this._state.remove(i),a&&this._ticksAtTime.add(a),r}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),s=this.frequency.timeToTicks(t,e);this.setTicksAtTime(s,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),s={state:"paused",time:t};this._state.add(s);const n=this._secondsAtTime.get(t);let i=n||e,o=n?n.seconds:0,r=null;return this._state.forEachBetween(i.time,t+this.sampleTime,(t=>{let e=i.time;const n=this._tickOffset.get(t.time);n&&n.time>=i.time&&(o=n.seconds,e=n.time),"started"===i.state&&"started"!==t.state&&(o+=t.time-e,t.time!==s.time&&(r={state:t.state,time:t.time,seconds:o})),i=t})),this._state.remove(s),r&&this._secondsAtTime.add(r),o}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){const s=this._tickOffset.get(e),n=this._state.get(e),i=Math.max(s.time,n.time),o=this.frequency.getTicksAtTime(i)+t-s.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(t,e,s){let n=this._state.get(t);this._state.forEachBetween(t,e,(e=>{n&&"started"===n.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(n.time,t),e.time-this.sampleTime,s),n=e}));let i=null;if(n&&"started"===n.state){const o=Math.max(n.time,t),r=this.frequency.getTicksAtTime(o),a=r-this.frequency.getTicksAtTime(n.time);let c=Math.ceil(a)-a;c=yi(c,1)?0:c;let h=this.frequency.getTimeOfTick(r+c);for(;h<e;){try{s(h,Math.round(this.getTicksAtTime(h)))}catch(t){i=t;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}}class Tr extends eo{constructor(){const t=pi(Tr.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=Ni,this._lastUpdate=0,this._state=new yr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new br({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,Fi(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(eo.getDefaults(),{callback:Ni,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){ei(this.context);const s=this.toSeconds(t);return this.log("start",s),"started"!==this._state.getValueAtTime(s)&&(this._state.setStateAtTime("started",s),this._tickSource.start(s,e),s<this._lastUpdate&&this.emit("start",s,e)),this}stop(t){const e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){const s=this.toSeconds(e),n=this.getTicksAtTime(s);return this._tickSource.getTimeOfTick(n+t,s)}_loop(){const t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,(t=>{switch(t.state){case"started":const e=this._tickSource.getTicksAtTime(t.time);this.emit("start",t.time,e);break;case"stopped":0!==t.time&&this.emit("stop",t.time);break;case"paused":this.emit("pause",t.time)}})),this._tickSource.forEachTickBetween(t,e,((t,e)=>{this.callback(t,e)})))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Di.mixin(Tr);class Sr extends no{constructor(){const t=pi(Sr.getDefaults(),arguments,["delayTime","maxDelay"]);super(t),this.name="Delay";const e=this.toSeconds(t.maxDelay);this._maxDelay=Math.max(e,this.toSeconds(t.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(e),this.delayTime=new so({context:this.context,param:this._delayNode.delayTime,units:"time",value:t.delayTime,minValue:0,maxValue:this.maxDelay}),Fi(this,"delayTime")}static getDefaults(){return Object.assign(no.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}}class kr extends no{constructor(){const t=pi(kr.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Do({context:this.context}),this.output=new co({context:this.context}),this.volume=this.input.volume,io(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),io(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}function Ar(t,e){return Ci(this,arguments,void 0,(function*(t,e,s=2,n=Bi().sampleRate){const i=Bi(),o=new Li(s,e,n);Ui(o),yield t(o);const r=o.render();Ui(i);const a=yield r;return new ji(a)}))}Ri((t=>{t.destination=new kr({context:t})})),Vi((t=>{t.destination.dispose()}));class Cr extends Si{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=pi(Cr.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach((e=>{this._loadingCount++;const s=t.urls[e];this.add(e,s,this._bufferLoaded.bind(this,t.onload),t.onerror)}))}static getDefaults(){return{baseUrl:"",onerror:Ni,onload:Ni,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Kn(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,0===this._loadingCount&&t&&t()}get loaded(){return Array.from(this._buffers).every((([t,e])=>e.loaded))}add(t,e,s=Ni,n=Ni){return $n(e)?(this.baseUrl&&"data:audio/"===e.trim().substring(0,11).toLowerCase()&&(this.baseUrl=""),this._buffers.set(t.toString(),new ji(this.baseUrl+e,s,n))):this._buffers.set(t.toString(),new ji(e,s,n)),this}dispose(){return super.dispose(),this._buffers.forEach((t=>t.dispose())),this._buffers.clear(),this}}class Or extends Yi{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return c(super._frequencyToUnits(t))}_ticksToUnits(t){return c(super._ticksToUnits(t))}_beatsToUnits(t){return c(super._beatsToUnits(t))}_secondsToUnits(t){return c(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return l(this.toMidi())}transpose(t){return new Or(this.context,this.toMidi()+t)}}function Dr(t,e){return new Or(Bi(),t,e)}class Mr extends Ki{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}function Er(t,e){return new Mr(Bi(),t,e)}class Rr extends eo{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new ki,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){const t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,(e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)})),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}Ri((t=>{t.draw=new Rr({context:t})})),Vi((t=>{t.draw.dispose()}));class qr extends Si{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Kn(Gn(t.time),"Events must have a time property"),Kn(Gn(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Vr(t.time,t.time+t.duration,t);for(null===this._root?this._root=e:this._root.insert(e),this._length++;null!==e;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(null!==this._root){const e=[];this._root.search(t.time,e);for(const s of e)if(s.event===t){this._removeNode(s),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,(t=>this.remove(t))),this}_setRoot(t){this._root=t,null!==this._root&&(this._root.parent=null)}_replaceNodeInParent(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{let e,s=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,s=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,s=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,s=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,s=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),s&&this._rebalance(s)}t.dispose()}_rotateLeft(t){const e=t.parent,s=t.isLeftChild(),n=t.right;n&&(t.right=n.left,n.left=t),null!==e?s?e.left=n:e.right=n:this._setRoot(n)}_rotateRight(t){const e=t.parent,s=t.isLeftChild(),n=t.left;n&&(t.left=n.right,n.right=t),null!==e?s?e.left=n:e.right=n:this._setRoot(n)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(null!==this._root){const e=[];if(this._root.search(t,e),e.length>0){let t=e[0];for(let s=1;s<e.length;s++)e[s].low>t.low&&(t=e[s]);return t.event}}return null}forEach(t){if(null!==this._root){const e=[];this._root.traverse((t=>e.push(t))),e.forEach((e=>{e.event&&t(e.event)}))}return this}forEachAtTime(t,e){if(null!==this._root){const s=[];this._root.search(t,s),s.forEach((t=>{t.event&&e(t.event)}))}return this}forEachFrom(t,e){if(null!==this._root){const s=[];this._root.searchAfter(t,s),s.forEach((t=>{t.event&&e(t.event)}))}return this}dispose(){return super.dispose(),null!==this._root&&this._root.traverse((t=>t.dispose())),this._root=null,this}}class Vr{constructor(t,e,s){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=s,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)}traverse(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)}updateHeight(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t}isLeftChild(){return null!==this.parent&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}class Ir extends no{constructor(t){super(t),this.name="Effect",this._dryWet=new Vo({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new co({context:this.context}),this.effectReturn=new co({context:this.context}),this.input=new co({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],Fi(this,"wet")}static getDefaults(){return Object.assign(no.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}}class Fr extends wo{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new bo({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Pr extends wo{constructor(){super(pi(Pr.getDefaults(),arguments)),this.name="Zero",this._gain=new co({context:this.context}),this.output=this._gain,this.input=void 0,oo(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),ro(this.context.getConstant(0),this._gain),this}}class Nr extends Si{constructor(t){super(),this.name="TimelineValue",this._timeline=new ki({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){const e=this._timeline.get(t);return e?e.value:this._initialValue}}class jr{constructor(t,e){this.id=jr._eventId++,this._remainderTime=0;const s=Object.assign(jr.getDefaults(),e);this.transport=t,this.callback=s.callback,this._once=s.once,this.time=Math.floor(s.time),this._remainderTime=s.time-this.time}static getDefaults(){return{callback:Ni,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){const e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}}jr._eventId=0;class Lr extends jr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const s=Object.assign(Lr.getDefaults(),e);this.duration=s.duration,this._interval=s.interval,this._nextTick=s.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({},jr.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(),super.invoke(t)}_createEvent(){return vi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Mr(this.context,this._nextTick).toSeconds()):-1}_createEvents(){vi(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 Mr(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;const e=this.transport.getTicksAtTime(t);mi(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-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 zr extends eo{constructor(){const t=pi(zr.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Nr(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new ki,this._repeatedEvents=new qr,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new Tr({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),Fi(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(eo.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(2*this._swingTicks)!=0){const s=e%(2*this._swingTicks)/(2*this._swingTicks),n=Math.sin(s*Math.PI)*this._swingAmount;t+=new Mr(this.context,2*this._swingTicks/3).toSeconds()*n}ii(!0),this._timeline.forEachAtTime(e,(e=>e.invoke(t))),ii(!1)}schedule(t,e){const s=new jr(this,{callback:t,time:new Ki(this.context,e).toTicks()});return this._addEvent(s,this._timeline)}scheduleRepeat(t,e,s,n=1/0){const i=new Lr(this,{callback:t,duration:new Zi(this.context,n).toTicks(),interval:new Zi(this.context,e).toTicks(),time:new Ki(this.context,s).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const s=new jr(this,{callback:t,once:!0,time:new Ki(this.context,e).toTicks()});return this._addEvent(s,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,(t=>this.clear(t.id))),this._repeatedEvents.forEachFrom(e,(t=>this.clear(t.id))),this}_bindClockEvents(){this._clock.on("start",((t,e)=>{e=new Mr(this.context,e).toSeconds(),this.emit("start",t,e)})),this._clock.on("stop",(t=>{this.emit("stop",t)})),this._clock.on("pause",(t=>{this.emit("pause",t)}))}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){let s;return this.context.resume(),Gn(e)&&(s=this.toTicks(e)),this._clock.start(t,s),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Hn(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Zi(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Zi(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Mr(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){const t=this.now(),e=this._clock.getTicksAtTime(t);return new Mr(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),s=this._clock.frequency.timeToTicks(t,e);this.ticks=s}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(t){if(oi(),t=Math.floor(t),this._clock.ticks===t)return;const e=this.now();if("started"===this.state){const s=this._clock.getTicksAtTime(e),n=e+this._clock.frequency.getDurationOfTicks(Math.ceil(s)-s,e);this.emit("stop",n),this._clock.setTicksAtTime(t,n),this.emit("start",n,this._clock.getSecondsAtTime(n))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}setTicksAtTime(t,e){return this._clock.setTicksAtTime(t,e),this}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}setSecondsAtTime(t,e){return this.setTicksAtTime(this.toTicks(t),e),this}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),"started"!==this.state)return 0;{const e=this.now(),s=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(s,e)}}syncSignal(t,e){const s=this.now();let n=this.bpm,i=1/(60/n.getValueAtTime(s)/this.PPQ),o=[];if("time"===t.units){const t=1/64/i,e=new co(t),s=new ar(-1),r=new co(t);n.chain(e,s,r),n=r,i=1/i,o=[e,s,r]}e||(e=0!==t.getValueAtTime(s)?t.getValueAtTime(s)/i:0);const r=new co(e);return n.connect(r),r.connect(t._param),o.push(r),this._syncedSignals.push({initial:t.value,nodes:o,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const s=this._syncedSignals[e];s.signal===t&&(s.nodes.forEach((t=>t.dispose())),s.signal.value=s.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Pi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Di.mixin(zr),Ri((t=>{t.transport=new zr({context:t})})),Vi((t=>{t.transport.dispose()}));class Wr extends no{constructor(t){super(t),this.input=void 0,this._state=new yr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Ni,this._syncedStop=Ni,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Do({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,onstop:Ni,volume:0})}get state(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,s){let n=Un(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(n=this._clampToCurrentTime(n),this._synced||"started"!==this._state.getValueAtTime(n))if(this._state.setStateAtTime("started",n),this._synced){const t=this._state.get(n);t&&(t.offset=this.toSeconds(di(e,0)),t.duration=s?this.toSeconds(s):void 0);const i=this.context.transport.schedule((t=>{this._start(t,e,s)}),n);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>n&&this._syncedStart(this.now(),this.context.transport.seconds)}else ei(this.context),this._start(n,e,s);else Kn(mi(n,this._state.get(n).time),"Start time must be strictly greater than previous start time"),this._state.cancel(n),this._state.setStateAtTime("started",n),this.log("restart",n),this.restart(n,e,s);return this}stop(t){let e=Un(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||Gn(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){const t=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(t)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,s){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,s)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(mi(e,0)){const s=this._state.get(e);if(s&&"started"===s.state&&s.time!==e){const n=e-this.toSeconds(s.time);let i;s.duration&&(i=this.toSeconds(s.duration)-n),this._start(t,this.toSeconds(s.offset)+n,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));"started"===this._state.getValueAtTime(e)&&this._stop(t)},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((t=>this.context.transport.clear(t))),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=Ni,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}function Br(t,e){return Ci(this,void 0,void 0,(function*(){const s=e/t.context.sampleRate,n=new Li(1,s,t.context.sampleRate);return new t.constructor(Object.assign(t.get(),{frequency:2/s,detune:0,context:n})).toDestination().start(0),(yield n.render()).getChannelData(0)}))}class Ur extends _o{constructor(){const t=pi(Ur.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],oo(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new so({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new so({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),Fi(this,["frequency","detune"])}static getDefaults(){return Object.assign(_o.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),"started"===this.state&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class Gr extends Wr{constructor(){const t=pi(Gr.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),Fi(this,"frequency"),this.detune=new go({context:this.context,units:"cents",value:t.detune}),Fi(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&"custom"!==t.type&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(Wr.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),s=new Ur({context:this.context,onended:()=>{this._cleanUpConnections(s),this.onstop(this)}});this._oscillator=s,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(e)}_cleanUpConnections(t){this.context.isOffline||(this.frequency.disconnect(t.frequency),this.detune.disconnect(t.detune),t.disconnect())}_stop(t){const e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){const e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if("custom"===this._type)return Gr._periodicWaveCache.find((t=>{return t.phase===this._phase&&(e=t.partials,s=this._partials,e.length===s.length&&e.every(((t,e)=>s[e]===t)));var e,s}));{const t=Gr._periodicWaveCache.find((t=>t.type===this._type&&t.phase===this._phase));return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;const e=-1!==["sine","square","sawtooth","triangle"].indexOf(t);if(0===this._phase&&e)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=t);else{const e=this._getCachedPeriodicWave();if(Gn(e)){const{partials:t,wave:s}=e;this._wave=s,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[e,s]=this._getRealImaginary(t,this._phase),n=this.context.createPeriodicWave(e,s);this._wave=n,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),Gr._periodicWaveCache.push({imag:s,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:e,type:this._type,wave:this._wave}),Gr._periodicWaveCache.length>100&&Gr._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&"custom"!==this._type&&"custom"!==t?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){ti(t,0);let e=this._type;const s=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(s&&(e=s[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach(((t,s)=>e[s]=t)),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let s=2048;const n=new Float32Array(s),i=new Float32Array(s);let o=1;if("custom"===t){if(o=this._partials.length+1,this._partialCount=this._partials.length,s=o,0===this._partials.length)return[n,i]}else{const e=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);e?(o=parseInt(e[2],10)+1,this._partialCount=parseInt(e[2],10),t=e[1],o=Math.max(o,2),s=o):this._partialCount=0,this._partials=[]}for(let r=1;r<s;++r){const s=2/(r*Math.PI);let a;switch(t){case"sine":a=r<=o?1:0,this._partials[r-1]=a;break;case"square":a=1&r?2*s:0,this._partials[r-1]=a;break;case"sawtooth":a=s*(1&r?1:-1),this._partials[r-1]=a;break;case"triangle":a=1&r?s*s*2*(r-1>>1&1?-1:1):0,this._partials[r-1]=a;break;case"custom":a=this._partials[r-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}0!==a?(n[r]=-a*Math.sin(e*r),i[r]=a*Math.cos(e*r)):(n[r]=0,i[r]=0)}return[n,i]}_inverseFFT(t,e,s){let n=0;const i=t.length;for(let o=0;o<i;o++)n+=t[o]*Math.cos(o*s)+e[o]*Math.sin(o*s);return n}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let s=0;const n=2*Math.PI;for(let i=0;i<32;i++)s=Math.max(this._inverseFFT(t,e,i/32*n),s);return xi(-this._inverseFFT(t,e,this._phase)/s,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),null!==this._oscillator&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}Gr._periodicWaveCache=[];class Qr extends no{constructor(){const t=pi(Qr.getDefaults(),arguments,["frequency","min","max"]);super(t),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=so.prototype._fromType,this._toType=so.prototype._toType,this._is=so.prototype._is,this._clampValue=so.prototype._clampValue,this._oscillator=new Gr(t),this.frequency=this._oscillator.frequency,this._amplitudeGain=new co({context:this.context,gain:t.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new go({context:this.context,units:"audioRange",value:0}),this._zeros=new Pr({context:this.context}),this._a2g=new Fr({context:this.context}),this._scaler=this.output=new cr({context:this.context,max:t.max,min:t.min}),this.units=t.units,this.min=t.min,this.max=t.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),Fi(this,["amplitude","frequency"]),this.phase=t.phase}static getDefaults(){return Object.assign(Gr.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,type:"sine",units:"number"})}start(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this}stop(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),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(t){t=this._fromType(t),this._scaler.min=t}get max(){return this._toType(this._scaler.max)}set max(t){t=this._fromType(t),this._scaler.max=t}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(t){this._oscillator.partials=t,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t,this._setStoppedValue()}get units(){return this._units}set units(t){const e=this.min,s=this.max;this._units=t,this.min=e,this.max=s}get state(){return this._oscillator.state}connect(t,e,s){return(t instanceof so||t instanceof go)&&(this.convert=t.convert,this.units=t.units),yo(this,t,e,s),this}disconnect(t,e=0,s=0){return xo(this,t,e,s),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}}class Zr extends Ir{constructor(t){super(t),this.name="LFOEffect",this._lfo=new Qr({context:this.context,frequency:t.frequency,amplitude:t.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=t.type,Fi(this,["frequency","depth"])}static getDefaults(){return Object.assign(Ir.getDefaults(),{frequency:1,type:"sine",depth:1})}start(t){return this._lfo.start(t),this}stop(t){return this._lfo.stop(t),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Xr extends Zr{constructor(){const t=pi(Xr.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);super(t),this.name="AutoFilter",this.filter=new Uo(Object.assign(t.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=t.octaves,this.baseFrequency=t.baseFrequency}static getDefaults(){return Object.assign(Zr.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._lfo.max=this._lfo.min*Math.pow(2,t)}dispose(){return super.dispose(),this.filter.dispose(),this}}class Yr extends Zr{constructor(){const t=pi(Yr.getDefaults(),arguments,["frequency"]);super(t),this.name="AutoPanner",this._panner=new Oo({context:this.context,channelCount:t.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(Zr.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}}class Hr extends cr{constructor(){const t=pi(Hr.getDefaults(),arguments,["min","max","exponent"]);super(t),this.name="ScaleExp",this.input=this._exp=new ar({context:this.context,value:t.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(cr.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(t){this._exp.value=t}dispose(){return super.dispose(),this._exp.dispose(),this}}class $r extends Ir{constructor(){const t=pi($r.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);super(t),this.name="AutoWah",this._follower=new ko({context:this.context,smoothing:t.follower}),this._sweepRange=new Hr({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this._inputBoost=new co({context:this.context}),this._bandpass=new Uo({context:this.context,rolloff:-48,frequency:0,Q:t.Q}),this._peaking=new Uo({context:this.context,type:"peaking"}),this._peaking.gain.value=t.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=t.sensitivity,Fi(this,["gain","Q"])}static getDefaults(){return Object.assign(Ir.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(t){this._follower.smoothing=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),this._setSweepRange()}get sensitivity(){return o(1/this._inputBoost.gain.value)}set sensitivity(t){this._inputBoost.gain.value=1/i(t)}_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 Jr="bit-crusher";fr(Jr,"\n\tclass BitCrusherWorklet extends SingleIOProcessor {\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: \"bits\",\n\t\t\t\tdefaultValue: 12,\n\t\t\t\tminValue: 1,\n\t\t\t\tmaxValue: 16,\n\t\t\t\tautomationRate: 'k-rate'\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, _channel, parameters) {\n\t\t\tconst step = Math.pow(0.5, parameters.bits - 1);\n\t\t\tconst val = step * Math.floor(input / step + 0.5);\n\t\t\treturn val;\n\t\t}\n\t}\n");class Kr extends Ir{constructor(){const t=pi(Kr.getDefaults(),arguments,["bits"]);super(t),this.name="BitCrusher",this._bitCrusherWorklet=new ta({context:this.context,bits:t.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(Ir.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}}class ta extends _r{constructor(){const t=pi(ta.getDefaults(),arguments);super(t),this.name="BitCrusherWorklet",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.bits=new so({context:this.context,value:t.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(_r.getDefaults(),{bits:12})}_audioWorkletName(){return Jr}onReady(t){io(this.input,t,this.output);const e=t.parameters.get("bits");this.bits.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class ea extends Ir{constructor(){const t=pi(ea.getDefaults(),arguments,["order"]);super(t),this.name="Chebyshev",this._shaper=new bo({context:this.context,length:4096}),this._order=t.order,this.connectEffect(this._shaper),this.order=t.order,this.oversample=t.oversample}static getDefaults(){return Object.assign(Ir.getDefaults(),{order:1,oversample:"none"})}_getCoefficient(t,e,s){return s.has(e)||(0===e?s.set(e,0):1===e?s.set(e,t):s.set(e,2*t*this._getCoefficient(t,e-1,s)-this._getCoefficient(t,e-2,s))),s.get(e)}get order(){return this._order}set order(t){Kn(Number.isInteger(t),"'order' must be an integer"),this._order=t,this._shaper.setMap((e=>this._getCoefficient(e,t,new Map)))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class sa extends no{constructor(t){super(t),this.name="StereoEffect",this.input=new co({context:this.context}),this.input.channelCount=2,this.input.channelCountMode="explicit",this._dryWet=this.output=new Vo({context:this.context,fade:t.wet}),this.wet=this._dryWet.fade,this._split=new ho({context:this.context,channels:2}),this._merge=new Io({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),Fi(this,["wet"])}connectEffectLeft(...t){this._split.connect(t[0],0,0),io(...t),oo(t[t.length-1],this._merge,0,0)}connectEffectRight(...t){this._split.connect(t[0],1,0),io(...t),oo(t[t.length-1],this._merge,0,1)}static getDefaults(){return Object.assign(no.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}}class na extends sa{constructor(t){super(t),this.feedback=new go({context:this.context,value:t.feedback,units:"normalRange"}),this._feedbackL=new co({context:this.context}),this._feedbackR=new co({context:this.context}),this._feedbackSplit=new ho({context:this.context,channels:2}),this._feedbackMerge=new Io({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),Fi(this,["feedback"])}static getDefaults(){return Object.assign(sa.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}}class ia extends na{constructor(){const t=pi(ia.getDefaults(),arguments,["frequency","delayTime","depth"]);super(t),this.name="Chorus",this._depth=t.depth,this._delayTime=t.delayTime/1e3,this._lfoL=new Qr({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new Qr({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Sr({context:this.context}),this._delayNodeR=new Sr({context:this.context}),this.frequency=this._lfoL.frequency,Fi(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=t.type,this.spread=t.spread}static getDefaults(){return Object.assign(na.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(t){this._depth=t;const e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}get delayTime(){return 1e3*this._delayTime}set delayTime(t){this._delayTime=t/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),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 oa extends Ir{constructor(){const t=pi(oa.getDefaults(),arguments,["distortion"]);super(t),this.name="Distortion",this._shaper=new bo({context:this.context,length:4096}),this._distortion=t.distortion,this.connectEffect(this._shaper),this.distortion=t.distortion,this.oversample=t.oversample}static getDefaults(){return Object.assign(Ir.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(t){this._distortion=t;const e=100*t,s=Math.PI/180;this._shaper.setMap((t=>Math.abs(t)<.001?0:(3+e)*t*20*s/(Math.PI+e*Math.abs(t))))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class ra extends Ir{constructor(t){super(t),this.name="FeedbackEffect",this._feedbackGain=new co({context:this.context,gain:t.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,Fi(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(Ir.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class aa extends ra{constructor(){const t=pi(aa.getDefaults(),arguments,["delayTime","feedback"]);super(t),this.name="FeedbackDelay",this._delayNode=new Sr({context:this.context,delayTime:t.delayTime,maxDelay:t.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),Fi(this,"delayTime")}static getDefaults(){return Object.assign(ra.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}const ca=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],ha=[225,556,441,341];class la extends sa{constructor(){const t=pi(la.getDefaults(),arguments,["roomSize","dampening"]);super(t),this.name="Freeverb",this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[],this.roomSize=new go({context:this.context,value:t.roomSize,units:"normalRange"}),this._allpassFiltersL=ha.map((t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e})),this._allpassFiltersR=ha.map((t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e})),this._combFilters=ca.map(((e,s)=>{const n=new vr({context:this.context,dampening:t.dampening,delayTime:e});return s<ca.length/2?this.connectEffectLeft(n,...this._allpassFiltersL):this.connectEffectRight(n,...this._allpassFiltersR),this.roomSize.connect(n.resonance),n})),Fi(this,["roomSize"])}static getDefaults(){return Object.assign(sa.getDefaults(),{roomSize:.7,dampening:3e3})}get dampening(){return this._combFilters[0].dampening}set dampening(t){this._combFilters.forEach((e=>e.dampening=t))}dispose(){return super.dispose(),this._allpassFiltersL.forEach((t=>t.disconnect())),this._allpassFiltersR.forEach((t=>t.disconnect())),this._combFilters.forEach((t=>t.dispose())),this.roomSize.dispose(),this}}class ua extends no{constructor(t){super(t),this.name="PhaseShiftAllpass",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.offset90=new co({context:this.context}),this._bank0=this._createAllPassFilterBank([.6923878,.9360654322959,.988229522686,.9987488452737]),this._bank1=this._createAllPassFilterBank([.4021921162426,.856171088242,.9722909545651,.9952884791278]),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),io(this.input,...this._bank0,this._oneSampleDelay,this.output),io(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(t){return t.map((t=>{const e=[[t*t,0,-1],[1,0,-t*t]];return this.context.createIIRFilter(e[0],e[1])}))}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach((t=>t.disconnect())),this._bank1.forEach((t=>t.disconnect())),this._oneSampleDelay.disconnect(),this}}class pa extends Ir{constructor(){const t=pi(pa.getDefaults(),arguments,["frequency"]);super(t),this.name="FrequencyShifter",this.frequency=new go({context:this.context,units:"frequency",value:t.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new Ur({context:this.context,type:"sine"}),this._cosine=new Gr({context:this.context,phase:-90,type:"sine"}),this._sineMultiply=new Po({context:this.context}),this._cosineMultiply=new Po({context:this.context}),this._negate=new No({context:this.context}),this._add=new Fo({context:this.context}),this._phaseShifter=new ua({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 e=this.immediate();this._sine.start(e),this._cosine.start(e)}static getDefaults(){return Object.assign(Ir.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 da=[.06748,.06404,.08212,.09004],fa=[.773,.802,.753,.733],_a=[347,113,37];class ma extends sa{constructor(){const t=pi(ma.getDefaults(),arguments,["roomSize"]);super(t),this.name="JCReverb",this._allpassFilters=[],this._feedbackCombFilters=[],this.roomSize=new go({context:this.context,value:t.roomSize,units:"normalRange"}),this._scaleRoomSize=new cr({context:this.context,min:-.733,max:.197}),this._allpassFilters=_a.map((t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e})),this._feedbackCombFilters=da.map(((t,e)=>{const s=new gr({context:this.context,delayTime:t});return this._scaleRoomSize.connect(s.resonance),s.resonance.value=fa[e],e<da.length/2?this.connectEffectLeft(...this._allpassFilters,s):this.connectEffectRight(...this._allpassFilters,s),s})),this.roomSize.connect(this._scaleRoomSize),Fi(this,["roomSize"])}static getDefaults(){return Object.assign(sa.getDefaults(),{roomSize:.5})}dispose(){return super.dispose(),this._allpassFilters.forEach((t=>t.disconnect())),this._feedbackCombFilters.forEach((t=>t.dispose())),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}}class ga extends sa{constructor(){const t=pi(ga.getDefaults(),arguments,["frequency","octaves","baseFrequency"]);super(t),this.name="Phaser",this._lfoL=new Qr({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new Qr({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this.Q=new go({context:this.context,value:t.Q,units:"positive"}),this._filtersL=this._makeFilters(t.stages,this._lfoL),this._filtersR=this._makeFilters(t.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=t.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=t.baseFrequency,this.octaves=t.octaves,this._lfoL.start(),this._lfoR.start(),Fi(this,["frequency","Q"])}static getDefaults(){return Object.assign(sa.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(t,e){const s=[];for(let n=0;n<t;n++){const t=this.context.createBiquadFilter();t.type="allpass",this.Q.connect(t.Q),e.connect(t.frequency),s.push(t)}return s}get octaves(){return this._octaves}set octaves(t){this._octaves=t;const e=this._baseFrequency*Math.pow(2,t);this._lfoL.max=e,this._lfoR.max=e}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),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((t=>t.disconnect())),this._filtersR.forEach((t=>t.disconnect())),this.frequency.dispose(),this}}class va extends na{constructor(t){super(t),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),Fi(this,["feedback"])}}class ya extends va{constructor(){const t=pi(ya.getDefaults(),arguments,["delayTime","feedback"]);super(t),this.name="PingPongDelay",this._leftDelay=new Sr({context:this.context,maxDelay:t.maxDelay}),this._rightDelay=new Sr({context:this.context,maxDelay:t.maxDelay}),this._rightPreDelay=new Sr({context:this.context,maxDelay:t.maxDelay}),this.delayTime=new go({context:this.context,units:"time",value:t.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),Fi(this,["delayTime"])}static getDefaults(){return Object.assign(va.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}}class xa extends ra{constructor(){const t=pi(xa.getDefaults(),arguments,["pitch"]);super(t),this.name="PitchShift",this._frequency=new go({context:this.context}),this._delayA=new Sr({maxDelay:1,context:this.context}),this._lfoA=new Qr({context:this.context,min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new Sr({maxDelay:1,context:this.context}),this._lfoB=new Qr({context:this.context,min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new Vo({context:this.context}),this._crossFadeLFO=new Qr({context:this.context,min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Sr({delayTime:t.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,Fi(this,"delayTime"),this._pitch=t.pitch,this._windowSize=t.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 e=this.now();this._lfoA.start(e),this._lfoB.start(e),this._crossFadeLFO.start(e),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(ra.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(t){this._pitch=t;let e=0;t<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,e=r(t-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,e=r(t)-1),this._frequency.value=e*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(t){this._windowSize=this.toSeconds(t),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 wa extends _o{constructor(){const t=pi(wa.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,oo(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new so({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new ji(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(_o.getDefaults(),{url:new ji,loop:!1,loopEnd:0,loopStart:0,onload:Ni,onerror:Ni,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,s,n=1){Kn(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,n),e=this.loop?di(e,this.loopStart):di(e,0);let o=Math.max(this.toSeconds(e),0);if(this.loop){const t=this.toSeconds(this.loopEnd)||this.buffer.duration,e=this.toSeconds(this.loopStart),s=t-e;gi(o,t)&&(o=(o-e)%s+e),yi(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,vi(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,o)),Gn(s)){let t=this.toSeconds(s);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class ba extends Wr{constructor(){const t=pi(ba.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Wr.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Kn(t in ka,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,"started"===this.state)){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){const e=ka[this._type];this._source=new wa({url:e,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(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Ta=220500,Sa={brown:null,pink:null,white:null},ka={get brown(){if(!Sa.brown){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Ta);t[e]=s;let n=0;for(let t=0;t<Ta;t++){const e=2*Math.random()-1;s[t]=(n+.02*e)/1.02,n=s[t],s[t]*=3.5}}Sa.brown=(new ji).fromArray(t)}return Sa.brown},get pink(){if(!Sa.pink){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Ta);let n,i,o,r,a,c,h;t[e]=s,n=i=o=r=a=c=h=0;for(let t=0;t<Ta;t++){const e=2*Math.random()-1;n=.99886*n+.0555179*e,i=.99332*i+.0750759*e,o=.969*o+.153852*e,r=.8665*r+.3104856*e,a=.55*a+.5329522*e,c=-.7616*c-.016898*e,s[t]=n+i+o+r+a+c+h+.5362*e,s[t]*=.11,h=.115926*e}}Sa.pink=(new ji).fromArray(t)}return Sa.pink},get white(){if(!Sa.white){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Ta);t[e]=s;for(let t=0;t<Ta;t++)s[t]=2*Math.random()-1}Sa.white=(new ji).fromArray(t)}return Sa.white}};class Aa extends Ir{constructor(){const t=pi(Aa.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const e=this.toSeconds(t.decay);ti(e,.001),this._decay=e;const s=this.toSeconds(t.preDelay);ti(s,0),this._preDelay=s,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Ir.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){ti(t=this.toSeconds(t),.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){ti(t=this.toSeconds(t),0),this._preDelay=t,this.generate()}generate(){return Ci(this,void 0,void 0,(function*(){const t=this.ready,e=new Li(2,this._decay+this._preDelay,this.context.sampleRate),s=new ba({context:e}),n=new ba({context:e}),i=new Io({context:e});s.connect(i,0,0),n.connect(i,0,1);const o=new co({context:e}).toDestination();i.connect(o),s.start(0),n.start(0),o.gain.setValueAtTime(0,0),o.gain.setValueAtTime(1,this._preDelay),o.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const r=e.render();return this.ready=r.then(Ni),yield t,this._convolver.buffer=(yield r).get(),this}))}dispose(){return super.dispose(),this._convolver.disconnect(),this}}const Ca="reverse-delay";fr(Ca,'\n\tclass ReverseDelayWorklet extends SingleIOProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(options);\n\t\t\tthis.delayTime = Math.floor(this.sampleRate * options.processorOptions.delayTime);\n\t\t\tconst channels = options.channelCount || 2;\n\t\t\tthis.delayLine = new DelayLine(this.delayTime * 2, channels);\n\t\t}\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: "feedback",\n\t\t\t\tdefaultValue: 0.5,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 0.9999,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, channel, parameters) {\n\t\t\tconst reversedSample = this.delayLine.getReverse(channel, this.delayTime);\n\t\t\tconst delayedSample = this.delayLine.get(channel, this.delayTime);\n\n\t\t\t// Push the forward sample back on the line\n\t\t\tthis.delayLine.push(channel, input + delayedSample * parameters.feedback);\n\n\t\t\t// Play the reversed sample\n\t\t\treturn reversedSample;\n\t\t}\n\t}\n');class Oa extends Ir{constructor(){const t=pi(Oa.getDefaults(),arguments,["delayTime","feedback"]);super(t),this.name="ReverseDelay",this._reverseDelayWorklet=this._connectWorklet(t.delayTime,t.feedback)}_connectWorklet(t,e){const s=new Da({context:this.context,delayTime:this.toSeconds(t),feedback:e});return this.connectEffect(s),s}get delayTime(){return this._reverseDelayWorklet.delayTime}set delayTime(t){const e=this._reverseDelayWorklet;this._reverseDelayWorklet=this._connectWorklet(t,this.feedback),e.output.gain.linearRampTo(0,this.toSeconds(this.delayTime)),this.context.setTimeout((()=>e.dispose()),this.toSeconds(this.delayTime))}get feedback(){return this._reverseDelayWorklet.feedback.value}set feedback(t){this._reverseDelayWorklet.set({feedback:t})}static getDefaults(){return Object.assign(Ir.getDefaults(),{wet:.5,delayTime:1,feedback:.5})}dispose(){return super.dispose(),this._reverseDelayWorklet.dispose(),this}}class Da extends _r{constructor(){const t=pi(Da.getDefaults(),arguments,["delayTime","feedback"]);super(Object.assign(Object.assign({},t),{workletOptions:{processorOptions:{delayTime:t.delayTime}}})),this.name="ReverseDelayWorklet",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.delayTime=t.delayTime,this.feedback=new so({context:this.context,value:t.feedback,units:"normalRange",param:this._dummyParam,swappable:!0,minValue:0,maxValue:.9999})}static getDefaults(){return Object.assign(_r.getDefaults(),{delayTime:1,feedback:.5})}_audioWorkletName(){return Ca}onReady(t){io(this.input,t,this.output);const e=t.parameters.get("feedback");this.feedback.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.feedback.dispose(),this}}class Ma extends Ir{constructor(t){super(t),this.name="MidSideEffect",this._midSideMerge=new Lo({context:this.context}),this._midSideSplit=new zo({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(...t){this._midSend.chain(...t,this._midReturn)}connectEffectSide(...t){this._sideSend.chain(...t,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 Ea extends Ma{constructor(){const t=pi(Ea.getDefaults(),arguments,["width"]);super(t),this.name="StereoWidener",this.width=new go({context:this.context,value:t.width,units:"normalRange"}),Fi(this,["width"]),this._twoTimesWidthMid=new Po({context:this.context,value:2}),this._twoTimesWidthSide=new Po({context:this.context,value:2}),this._midMult=new Po({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new jo({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),oo(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new Po({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(Ma.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 Ra extends sa{constructor(){const t=pi(Ra.getDefaults(),arguments,["frequency","depth"]);super(t),this.name="Tremolo",this._lfoL=new Qr({context:this.context,type:t.type,min:1,max:0}),this._lfoR=new Qr({context:this.context,type:t.type,min:1,max:0}),this._amplitudeL=new co({context:this.context}),this._amplitudeR=new co({context:this.context}),this.frequency=new go({context:this.context,value:t.frequency,units:"frequency"}),this.depth=new go({context:this.context,value:t.depth,units:"normalRange"}),Fi(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=t.spread}static getDefaults(){return Object.assign(sa.getDefaults(),{frequency:10,type:"sine",depth:.5,spread:180})}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),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(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/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 qa extends Ir{constructor(){const t=pi(qa.getDefaults(),arguments,["frequency","depth"]);super(t),this.name="Vibrato",this._delayNode=new Sr({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new Qr({context:this.context,type:t.type,min:0,max:t.maxDelay,frequency:t.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=t.depth,Fi(this,["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(Ir.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:"sine"})}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Va extends eo{constructor(){const t=pi(Va.getDefaults(),arguments,["callback","value"]);super(t),this.name="ToneEvent",this._state=new yr("stopped"),this._startOffset=0,this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(eo.getDefaults(),{callback:Ni,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(t=-1){this._state.forEachFrom(t,(t=>{let e;if("started"===t.state){-1!==t.id&&this.context.transport.clear(t.id);const s=t.time+Math.round(this.startOffset/this._playbackRate);if(!0===this._loop||Zn(this._loop)&&this._loop>1){e=1/0,Zn(this._loop)&&(e=this._loop*this._getLoopDuration());const n=this._state.getAfter(s);null!==n&&(e=Math.min(e,n.time-s)),e!==1/0&&(e=new Mr(this.context,e));const i=new Mr(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new Mr(this.context,s),e)}else t.id=this.context.transport.schedule(this._tick.bind(this),new Mr(this.context,s))}}))}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t}get probability(){return this._probability}set probability(t){this._probability=t}get humanize(){return this._humanize}set humanize(t){this._humanize=t}start(t){const e=this.toTicks(t);return"stopped"===this._state.getValueAtTime(e)&&(this._state.add({id:-1,state:"started",time:e}),this._rescheduleEvents(e)),this}stop(t){this.cancel(t);const e=this.toTicks(t);if("started"===this._state.getValueAtTime(e)){this._state.setStateAtTime("stopped",e,{id:-1});const t=this._state.getBefore(e);let s=e;null!==t&&(s=t.time),this._rescheduleEvents(s)}return this}cancel(t){t=di(t,-1/0);const e=this.toTicks(t);return this._state.forEachFrom(e,(t=>{this.context.transport.clear(t.id)})),this._state.cancel(e),this}_tick(t){const e=this.context.transport.getTicksAtTime(t);if(!this.mute&&"started"===this._state.getValueAtTime(e)){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let e=.02;Yn(this.humanize)||(e=this.toSeconds(this.humanize)),t+=(2*Math.random()-1)*e}this.callback(t,this.value)}}_getLoopDuration(){return(this._loopEnd-this._loopStart)/this._playbackRate}get loop(){return this._loop}set loop(t){this._loop=t,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._rescheduleEvents()}get loopEnd(){return new Mr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}get loopStart(){return new Mr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){const s=this._getLoopDuration();return(t-e.time)%s/s}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class Ia extends eo{constructor(){const t=pi(Ia.getDefaults(),arguments,["callback","interval"]);super(t),this.name="Loop",this._event=new Va({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:t.interval,playbackRate:t.playbackRate,probability:t.probability,humanize:t.humanize}),this.callback=t.callback,this.iterations=t.iterations}static getDefaults(){return Object.assign(eo.getDefaults(),{interval:"4n",callback:Ni,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(t){return this._event.start(t),this}stop(t){return this._event.stop(t),this}cancel(t){return this._event.cancel(t),this}_tick(t){this.callback(t)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(t){this._event.loopEnd=t}get playbackRate(){return this._event.playbackRate}set playbackRate(t){this._event.playbackRate=t}get humanize(){return this._event.humanize}set humanize(t){this._event.humanize=t}get probability(){return this._event.probability}set probability(t){this._event.probability=t}get mute(){return this._event.mute}set mute(t){this._event.mute=t}get iterations(){return!0===this._event.loop?1/0:this._event.loop}set iterations(t){this._event.loop=t===1/0||t}dispose(){return super.dispose(),this._event.dispose(),this}}class Fa extends Va{constructor(){const t=pi(Fa.getDefaults(),arguments,["callback","events"]);super(t),this.name="Part",this._state=new yr("stopped"),this._events=new Set,this._state.increasing=!0,t.events.forEach((t=>{Hn(t)?this.add(t[0],t[1]):this.add(t)}))}static getDefaults(){return Object.assign(Va.getDefaults(),{events:[]})}start(t,e){const s=this.toTicks(t);if("started"!==this._state.getValueAtTime(s)){e=di(e,this._loop?this._loopStart:0),e=this._loop?di(e,this._loopStart):di(e,0);const t=this.toTicks(e);this._state.add({id:-1,offset:t,state:"started",time:s}),this._forEach((e=>{this._startNote(e,s,t)}))}return this}_startNote(t,e,s){e-=s,this._loop?t.startOffset>=this._loopStart&&t.startOffset<this._loopEnd?(t.startOffset<s&&(e+=this._getLoopDuration()),t.start(new Mr(this.context,e))):t.startOffset<this._loopStart&&t.startOffset>=s&&(t.loop=!1,t.start(new Mr(this.context,e))):t.startOffset>=s&&t.start(new Mr(this.context,e))}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t,this._forEach((t=>{t.startOffset+=this._startOffset}))}stop(t){const e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach((e=>{e.stop(t)})),this}at(t,e){const s=new Ki(this.context,t).toTicks(),n=new Mr(this.context,1).toSeconds(),i=this._events.values();let o=i.next();for(;!o.done;){const t=o.value;if(Math.abs(s-t.startOffset)<n)return Gn(e)&&(t.value=e),t;o=i.next()}return Gn(e)?(this.add(t,e),this.at(t)):null}add(t,e){t instanceof Object&&Reflect.has(t,"time")&&(t=(e=t).time);const s=this.toTicks(t);let n;return e instanceof Va?(n=e,n.callback=this._tick.bind(this)):n=new Va({callback:this._tick.bind(this),context:this.context,value:e}),n.startOffset=s,n.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(n),this._restartEvent(n),this}_restartEvent(t){this._state.forEach((e=>{"started"===e.state?this._startNote(t,e.time,e.offset):t.stop(new Mr(this.context,e.time))}))}remove(t,e){return Xn(t)&&t.hasOwnProperty("time")&&(t=(e=t).time),t=this.toTicks(t),this._events.forEach((s=>{s.startOffset===t&&(Un(e)||Gn(e)&&s.value===e)&&(this._events.delete(s),s.dispose())})),this}clear(){return this._forEach((t=>t.dispose())),this._events.clear(),this}cancel(t){return this._forEach((e=>e.cancel(t))),this._state.cancel(this.toTicks(t)),this}_forEach(t){return this._events&&this._events.forEach((e=>{e instanceof Fa?e._forEach(t):t(e)})),this}_setAll(t,e){this._forEach((s=>{s[t]=e}))}_tick(t,e){this.mute||this.callback(t,e)}_testLoopBoundaries(t){this._loop&&(t.startOffset<this._loopStart||t.startOffset>=this._loopEnd)?t.cancel(0):"stopped"===t.state&&this._restartEvent(t)}get probability(){return this._probability}set probability(t){this._probability=t,this._setAll("probability",t)}get humanize(){return this._humanize}set humanize(t){this._humanize=t,this._setAll("humanize",t)}get loop(){return this._loop}set loop(t){this._loop=t,this._forEach((e=>{e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.loop=t,this._testLoopBoundaries(e)}))}get loopEnd(){return new Mr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach((e=>{e.loopEnd=t,this._testLoopBoundaries(e)}))}get loopStart(){return new Mr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach((t=>{t.loopStart=this.loopStart,this._testLoopBoundaries(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._setAll("playbackRate",t)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}function*Pa(t){let e=0;for(;e<t;)e=xi(e,0,t-1),yield e,e++}function*Na(t){let e=t-1;for(;e>=0;)e=xi(e,0,t-1),yield e,e--}function*ja(t,e){for(;;)yield*e(t)}function*La(t,e){let s=e?0:t-1;for(;;)s=xi(s,0,t-1),yield s,e?(s++,s>=t-1&&(e=!1)):(s--,s<=0&&(e=!0))}function*za(t){let e=0,s=0;for(;e<t;)e=xi(e,0,t-1),yield e,s++,e+=s%2?2:-1}function*Wa(t){let e=t-1,s=0;for(;e>=0;)e=xi(e,0,t-1),yield e,s++,e+=s%2?-2:1}function*Ba(t){const e=[];for(let s=0;s<t;s++)e.push(s);for(;e.length>0;){const s=xi(e.splice(Math.floor(e.length*Math.random()),1)[0],0,t-1);yield s}}function*Ua(t,e="up"){switch(Kn(t>=1,"The number of values must be at least one"),e){case"up":yield*ja(t,Pa);case"down":yield*ja(t,Na);case"upDown":yield*La(t,!0);case"downUp":yield*La(t,!1);case"alternateUp":yield*ja(t,za);case"alternateDown":yield*ja(t,Wa);case"random":yield*function*(t){for(;;){const e=Math.floor(Math.random()*t);yield e}}(t);case"randomOnce":yield*ja(t,Ba);case"randomWalk":yield*function*(t){let e=Math.floor(Math.random()*t);for(;;)0===e?e++:e===t-1||Math.random()<.5?e--:e++,yield e}(t)}}class Ga extends Ia{constructor(){const t=pi(Ga.getDefaults(),arguments,["callback","values","pattern"]);super(t),this.name="Pattern",this.callback=t.callback,this._values=t.values,this._pattern=Ua(t.values.length,t.pattern),this._type=t.pattern}static getDefaults(){return Object.assign(Ia.getDefaults(),{pattern:"up",values:[],callback:Ni})}_tick(t){const e=this._pattern.next();this._index=e.value,this._value=this._values[e.value],this.callback(t,this._value)}get values(){return this._values}set values(t){this._values=t,this.pattern=this._type}get value(){return this._value}get index(){return this._index}get pattern(){return this._type}set pattern(t){this._type=t,this._pattern=Ua(this._values.length,this._type)}}class Qa extends Va{constructor(){const t=pi(Qa.getDefaults(),arguments,["callback","events","subdivision"]);super(t),this.name="Sequence",this._part=new Fa({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[],this._subdivision=this.toTicks(t.subdivision),this.events=t.events,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.playbackRate=t.playbackRate,this.probability=t.probability,this.humanize=t.humanize,this.mute=t.mute,this.playbackRate=t.playbackRate}static getDefaults(){return Object.assign(fi(Va.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})}_seqCallback(t,e){null===e||this.mute||this.callback(t,e)}get events(){return this._events}set events(t){this.clear(),this._eventsArray=t,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(t,e){return this._part.start(t,e?this._indexTime(e):e),this}stop(t){return this._part.stop(t),this}get subdivision(){return new Mr(this.context,this._subdivision).toSeconds()}_createSequence(t){return new Proxy(t,{get:(t,e)=>t[e],set:(t,e,s)=>($n(e)&&isFinite(parseInt(e,10))&&Hn(s)?t[e]=this._createSequence(s):t[e]=s,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(t,e,s){t.forEach(((t,n)=>{const i=n*e+s;if(Hn(t))this._rescheduleSequence(t,e/t.length,i);else{const e=new Mr(this.context,i,"i").toSeconds();this._part.add(e,t)}}))}_indexTime(t){return new Mr(this.context,t*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(t){this._part.loop=t}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this._part.loopStart=this._indexTime(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this._part.loopEnd=0===t?this._indexTime(this._eventsArray.length):this._indexTime(t)}get startOffset(){return this._part.startOffset}set startOffset(t){this._part.startOffset=t}get playbackRate(){return this._part.playbackRate}set playbackRate(t){this._part.playbackRate=t}get probability(){return this._part.probability}set probability(t){this._part.probability=t}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(t){this._part.humanize=t}get length(){return this._part.length}}class Za extends Wr{constructor(){const t=pi(Za.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new Fr({context:this.context}),this._modulationNode=new co({context:this.context}),this._carrier=new Gr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Gr({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Po({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),Fi(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Gr.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}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 Xa extends Wr{constructor(){const t=pi(Xa.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this.detune=new go({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,Fi(this,["frequency","detune"])}static getDefaults(){return Object.assign(Gr.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach((e=>e.start(t)))}_stop(t){t=this.toSeconds(t),this._forEach((e=>e.stop(t)))}_restart(t){this._forEach((e=>e.restart(t)))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach((e=>e.type=t))}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,s=t/(this._oscillators.length-1);this._forEach(((t,n)=>t.detune.value=e+s*n))}}get count(){return this._oscillators.length}set count(t){if(ti(t,1),this._oscillators.length!==t){this._forEach((t=>t.dispose())),this._oscillators=[];for(let e=0;e<t;e++){const s=new Gr({context:this.context,volume:-6-1.1*t,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:0===e?()=>this.onstop(this):Ni});"custom"===this.type&&(s.partials=this._partials),this.frequency.connect(s.frequency),this.detune.connect(s.detune),s.detune.overridden=!1,s.connect(this.output),this._oscillators[e]=s}this.spread=this._spread,"started"===this.state&&this._forEach((t=>t.start()))}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach(((t,e)=>t.phase=this._phase+e/this.count*360))}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach((e=>e.baseType=t)),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach((e=>e.partials=t)))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach((e=>e.partialCount=t)),this._type=this._oscillators[0].type}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach((t=>t.dispose())),this}}class Ya extends Wr{constructor(){const t=pi(Ya.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new co({context:this.context,gain:0}),this._carrier=new Gr({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Gr({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Po({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Po({context:this.context,units:"positive",value:t.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),Fi(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Gr.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class Ha extends Wr{constructor(){const t=pi(Ha.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new co({context:this.context,gain:0}),this._thresh=new bo({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new go({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Gr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.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),Fi(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Wr.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class $a extends Wr{constructor(){const t=pi($a.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Po({context:this.context,value:2}),this._pulse=new Ha({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Gr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),Fi(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Wr.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Ja={am:Za,fat:Xa,fm:Ya,oscillator:Gr,pulse:Ha,pwm:$a};class Ka extends Wr{constructor(){const t=pi(Ka.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this.detune=new go({context:this.context,units:"cents",value:t.detune}),Fi(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Gr.getDefaults(),Ya.getDefaults(),Za.getDefaults(),Xa.getDefaults(),Ha.getDefaults(),$a.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some((t=>this._sourceType===t))&&(t=this._sourceType),t+this._oscillator.type}set type(t){"fm"===t.substr(0,2)?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):"pwm"===t?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):"pulse"===t?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;const e=Ja[t],s=this.now();if(this._oscillator){const t=this._oscillator;t.stop(s),this.context.setTimeout((()=>t.dispose()),this.blockTime)}this._oscillator=new e({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),"started"===this.state&&this._oscillator.start(s)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";"pwm"!==this._oscillator.type&&"pulse"!==this._oscillator.type&&(e=this._oscillator.type),"fm"===t?this.type="fm"+e:"am"===t?this.type="am"+e:"fat"===t?this.type="fat"+e:"oscillator"===t?this.type=e:"pulse"===t?this.type="pulse":"pwm"===t&&(this.type="pwm")}_getOscType(t,e){return t instanceof Ja[e]}get baseType(){return this._oscillator.baseType}set baseType(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||"pulse"===t||"pwm"===t||(this._oscillator.baseType=t)}get width(){return this._getOscType(this._oscillator,"pulse")?this._oscillator.width:void 0}get count(){return this._getOscType(this._oscillator,"fat")?this._oscillator.count:void 0}set count(t){this._getOscType(this._oscillator,"fat")&&Zn(t)&&(this._oscillator.count=t)}get spread(){return this._getOscType(this._oscillator,"fat")?this._oscillator.spread:void 0}set spread(t){this._getOscType(this._oscillator,"fat")&&Zn(t)&&(this._oscillator.spread=t)}get modulationType(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.modulationType:void 0}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&$n(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){return this._getOscType(this._oscillator,"fm")?this._oscillator.modulationIndex:void 0}get harmonicity(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.harmonicity:void 0}get modulationFrequency(){return this._getOscType(this._oscillator,"pwm")?this._oscillator.modulationFrequency:void 0}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class tc extends no{constructor(){const t=pi(tc.getDefaults(),arguments);super(t),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 Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume")}static getDefaults(){return Object.assign(no.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 t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){const s=this["_original_"+t]=this[t];this[t]=(...t)=>{const n=t[e],i=this.context.transport.schedule((n=>{t[e]=n,s.apply(this,t)}),n);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach((t=>this.context.transport.clear(t))),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(t,e,s,n){const i=this.toSeconds(s),o=this.toSeconds(e);return this.triggerAttack(t,i,n),this.triggerRelease(i+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class ec extends tc{constructor(){const t=pi(ec.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(tc.getDefaults(),{detune:0,onsilence:Ni,portamento:0})}triggerAttack(t,e,s=1){this.log("triggerAttack",t,e,s);const n=this.toSeconds(e);return this._triggerEnvelopeAttack(n,s),this.setNote(t,n),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const s=this.toSeconds(e),n=t instanceof Yi?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(s)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(n,t,s)}else this.frequency.setValueAtTime(n,s);return this}}Ai([nr(0)],ec.prototype,"portamento",void 0);class sc extends ec{constructor(){const t=pi(sc.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new Ka(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new rr(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),Fi(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ec.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(fi(Ka.getDefaults(),[...Object.keys(Wr.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),s=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+s)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class nc extends ec{constructor(){const t=pi(nc.getDefaults(),arguments);super(t),this.name="ModulationSynth",this._carrier=new sc({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new sc({context:this.context,oscillator:t.modulation,envelope:t.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 go({context:this.context,units:"frequency"}),this.detune=new go({context:this.context,value:t.detune,units:"cents"}),this.harmonicity=new Po({context:this.context,value:t.harmonicity,minValue:0}),this._modulationNode=new co({context:this.context,gain:0}),Fi(this,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])}static getDefaults(){return Object.assign(ec.getDefaults(),{harmonicity:3,oscillator:Object.assign(fi(Ka.getDefaults(),[...Object.keys(Wr.getDefaults()),"frequency","detune"]),{type:"sine"}),envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(fi(Ka.getDefaults(),[...Object.keys(Wr.getDefaults()),"frequency","detune"]),{type:"square"}),modulationEnvelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(t,e){this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}}class ic extends nc{constructor(){super(pi(ic.getDefaults(),arguments)),this.name="AMSynth",this._modulationScale=new Fr({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 oc extends ec{constructor(){const t=pi(oc.getDefaults(),arguments);super(t),this.name="MonoSynth",this.oscillator=new Ka(Object.assign(t.oscillator,{context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new Uo(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new hr(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new rr(Object.assign(t.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),Fi(this,["oscillator","frequency","detune","filter","filterEnvelope","envelope"])}static getDefaults(){return Object.assign(ec.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(fi(Uo.getDefaults(),Object.keys(no.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(fi(hr.getDefaults(),Object.keys(no.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(fi(Ka.getDefaults(),Object.keys(Wr.getDefaults())),{type:"sawtooth"})})}_triggerEnvelopeAttack(t,e=1){if(this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),s=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+s)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}}class rc extends ec{constructor(){const t=pi(rc.getDefaults(),arguments);super(t),this.name="DuoSynth",this.voice0=new oc(Object.assign(t.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new oc(Object.assign(t.voice1,{context:this.context})),this.harmonicity=new Po({context:this.context,units:"positive",value:t.harmonicity}),this._vibrato=new Qr({frequency:t.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new co({context:this.context,units:"normalRange",gain:t.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new go({context:this.context,units:"frequency",value:440}),this.detune=new go({context:this.context,units:"cents",value:t.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),Fi(this,["voice0","voice1","frequency","vibratoAmount","vibratoRate"])}getLevelAtTime(t){return t=this.toSeconds(t),this.voice0.envelope.getValueAtTime(t)+this.voice1.envelope.getValueAtTime(t)}static getDefaults(){return ui(ec.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:ui(fi(oc.getDefaults(),Object.keys(ec.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:ui(fi(oc.getDefaults(),Object.keys(ec.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(t,e){this.voice0._triggerEnvelopeAttack(t,e),this.voice1._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this.voice0._triggerEnvelopeRelease(t),this.voice1._triggerEnvelopeRelease(t),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 ac extends nc{constructor(){const t=pi(ac.getDefaults(),arguments);super(t),this.name="FMSynth",this.modulationIndex=new Po({context:this.context,value:t.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(nc.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}}class cc extends sc{constructor(){const t=pi(cc.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Fi(this,["oscillator","envelope"])}static getDefaults(){return ui(ec.getDefaults(),sc.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:8,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const s=this.toSeconds(e),n=this.toFrequency(t instanceof Yi?t.toFrequency():t),i=n*Math.pow(2,this.octaves);return this.oscillator.frequency.setValueAtTime(i,s),this.oscillator.frequency.exponentialRampToValueAtTime(n,s+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}Ai([sr(.5,8)],cc.prototype,"octaves",void 0),Ai([nr(0,.5)],cc.prototype,"pitchDecay",void 0);const hc=[1,1.483,1.932,2.546,2.63,3.897];class lc extends ec{constructor(){const t=pi(lc.getDefaults(),arguments);super(t),this.name="MetalSynth",this._oscillators=[],this._freqMultipliers=[],this.detune=new go({context:this.context,units:"cents",value:t.detune}),this.frequency=new go({context:this.context,units:"frequency"}),this._amplitude=new co({context:this.context,gain:0}).connect(this.output),this._highpass=new Uo({Q:0,context:this.context,type:"highpass"}).connect(this._amplitude);for(let e=0;e<hc.length;e++){const s=new Ya({context:this.context,harmonicity:t.harmonicity,modulationIndex:t.modulationIndex,modulationType:"square",onstop:0===e?()=>this.onsilence(this):Ni,type:"square"});s.connect(this._highpass),this._oscillators[e]=s;const n=new Po({context:this.context,value:hc[e]});this._freqMultipliers[e]=n,this.frequency.chain(n,s.frequency),this.detune.connect(s.detune)}this._filterFreqScaler=new cr({context:this.context,max:7e3,min:this.toFrequency(t.resonance)}),this.envelope=new ir({attack:t.envelope.attack,attackCurve:"linear",context:this.context,decay:t.envelope.decay,release:t.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=t.octaves,this.octaves=t.octaves}static getDefaults(){return ui(ec.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(t,e=1){return this.envelope.triggerAttack(t,e),this._oscillators.forEach((e=>e.start(t))),0===this.envelope.sustain&&this._oscillators.forEach((e=>{e.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))})),this}_triggerEnvelopeRelease(t){return this.envelope.triggerRelease(t),this._oscillators.forEach((e=>e.stop(t+this.toSeconds(this.envelope.release)))),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(t){this._oscillators.forEach((e=>e.modulationIndex.value=t))}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(t){this._oscillators.forEach((e=>e.harmonicity.value=t))}get resonance(){return this._filterFreqScaler.min}set resonance(t){this._filterFreqScaler.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}dispose(){return super.dispose(),this._oscillators.forEach((t=>t.dispose())),this._freqMultipliers.forEach((t=>t.dispose())),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}}class uc extends tc{constructor(){const t=pi(uc.getDefaults(),arguments);super(t),this.name="NoiseSynth",this.noise=new ba(Object.assign({context:this.context},t.noise)),this.envelope=new rr(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(tc.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(fi(ba.getDefaults(),Object.keys(Wr.getDefaults())),{type:"white"})})}triggerAttack(t,e=1){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.noise.start(t),0===this.envelope.sustain&&this.noise.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.noise.stop(t+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0)),this}triggerAttackRelease(t,e,s=1){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,s),this.triggerRelease(e+t),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}class pc extends tc{constructor(){const t=pi(pc.getDefaults(),arguments);super(t),this.name="PluckSynth",this._noise=new ba({context:this.context,type:"pink"}),this.attackNoise=t.attackNoise,this._lfcf=new vr({context:this.context,dampening:t.dampening,resonance:t.resonance}),this.resonance=t.resonance,this.release=t.release,this._noise.connect(this._lfcf),this._lfcf.connect(this.output)}static getDefaults(){return ui(tc.getDefaults(),{attackNoise:1,dampening:4e3,resonance:.7,release:1})}get dampening(){return this._lfcf.dampening}set dampening(t){this._lfcf.dampening=t}triggerAttack(t,e){const s=this.toFrequency(t);e=this.toSeconds(e);const n=1/s;return this._lfcf.delayTime.setValueAtTime(n,e),this._noise.start(e),this._noise.stop(e+n*this.attackNoise),this._lfcf.resonance.cancelScheduledValues(e),this._lfcf.resonance.setValueAtTime(this.resonance,e),this}triggerRelease(t){return this._lfcf.resonance.linearRampTo(0,this.release,t),this}dispose(){return super.dispose(),this._noise.dispose(),this._lfcf.dispose(),this}}class dc extends tc{constructor(){const t=pi(dc.getDefaults(),arguments,["voice","options"]);super(t),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=t=>this.releaseAll(t),Kn(!Zn(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");const e=t.voice.getDefaults();this.options=Object.assign(e,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();const s=this._voices.indexOf(this._dummyVoice);this._voices.splice(s,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(tc.getDefaults(),{maxPolyphony:32,options:{},voice:sc})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);const e=this._activeVoices.findIndex((e=>e.voice===t));this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){const t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return Kn(t instanceof ec,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}hi("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(.95*this._averageActiveVoices,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){const t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,s){t.forEach((t=>{const n=new Or(this.context,t).toMidi(),i=this._getNextAvailableVoice();i&&(i.triggerAttack(t,e,s),this._activeVoices.push({midi:n,voice:i,released:!1}),this.log("triggerAttack",t,e))}))}_triggerRelease(t,e){t.forEach((t=>{const s=new Or(this.context,t).toMidi(),n=this._activeVoices.find((({midi:t,released:e})=>t===s&&!e));n&&(n.voice.triggerRelease(e),n.released=!0,this.log("triggerRelease",t,e))}))}_scheduleEvent(t,e,s,n){Kn(!this.disposed,"Synth was already disposed"),s<=this.now()?"attack"===t?this._triggerAttack(e,s,n):this._triggerRelease(e,s):this.context.setTimeout((()=>{this.disposed||this._scheduleEvent(t,e,s,n)}),s-this.now())}triggerAttack(t,e,s){Array.isArray(t)||(t=[t]);const n=this.toSeconds(e);return this._scheduleEvent("attack",t,n,s),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);const s=this.toSeconds(e);return this._scheduleEvent("release",t,s),this}triggerAttackRelease(t,e,s,n){const i=this.toSeconds(s);if(this.triggerAttack(t,i,n),Hn(e)){Kn(Hn(t),"If the duration is an array, the notes must also be an array");for(let s=0;s<t.length;s++){const n=e[Math.min(s,e.length-1)],o=this.toSeconds(n);Kn(o>0,"The duration must be greater than 0"),this.triggerRelease(t[s],i+o)}}else{const s=this.toSeconds(e);Kn(s>0,"The duration must be greater than 0"),this.triggerRelease(t,i+s)}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(t){const e=fi(t,["onsilence","context"]);return this.options=ui(this.options,e),this._voices.forEach((t=>t.set(e))),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){const e=this.toSeconds(t);return this._activeVoices.forEach((({voice:t})=>{t.triggerRelease(e)})),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach((t=>t.dispose())),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}}class fc extends tc{constructor(){const t=pi(fc.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map,this._providedMidiNotes=[];const e={};Object.keys(t.urls).forEach((s=>{const n=parseInt(s,10);if(Kn(Jn(s)||Zn(n)&&isFinite(n),`url key is neither a note or midi pitch: ${s}`),Jn(s)){const n=new Yi(this.context,s).toMidi();e[n]=t.urls[s]}else Zn(n)&&isFinite(n)&&(e[n]=t.urls[n])})),this._buffers=new Cr({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(tc.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Ni,onerror:Ni,release:.1,urls:{},loop:!1,loopEnd:0,loopStart:0})}_findClosest(t){let e=0;for(;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,s=1){this.log("triggerAttack",t,e,s),Array.isArray(t)||(t=[t]);const n=di(this._loopStart,0);return t.forEach((t=>{const i=h(new Yi(this.context,t).toFrequency()),o=Math.round(i),a=i-o,c=this._findClosest(o),l=o-c,u=this._buffers.get(l),p=r(c+a),d=this._loop?void 0:u.duration/p,f=new wa({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,loop:this._loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:p}).connect(this.output);f.start(e,n,d,s),Hn(this._activeSources.get(o))||this._activeSources.set(o,[]),this._activeSources.get(o).push(f),f.onended=()=>{if(this._activeSources&&this._activeSources.has(o)){const t=this._activeSources.get(o),e=t.indexOf(f);-1!==e&&t.splice(e,1)}}})),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach((t=>{const s=new Yi(this.context,t).toMidi();if(this._activeSources.has(s)&&this._activeSources.get(s).length){const t=this._activeSources.get(s);e=this.toSeconds(e),t.forEach((t=>{t.stop(e)})),this._activeSources.set(s,[])}})),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach((t=>{for(;t.length;)t.shift().stop(e)})),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,s,n=1){const i=this.toSeconds(s);return this.triggerAttack(t,i,n),Hn(e)?(Kn(Hn(t),"notes must be an array when duration is array"),t.forEach(((t,s)=>{const n=e[Math.min(s,e.length-1)];this.triggerRelease(t,i+this.toSeconds(n))}))):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,s){if(Kn(Jn(t)||isFinite(t),`note must be a pitch or midi: ${t}`),Jn(t)){const n=new Yi(this.context,t).toMidi();this._buffers.add(n,e,s)}else this._buffers.add(t,e,s);return this}get loaded(){return this._buffers.loaded}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this._providedMidiNotes.forEach((e=>{const s=this._buffers.get(e);s.loaded&&ti(this.toSeconds(t),0,s.duration)})),this._activeSources.forEach((e=>{e.forEach((e=>{e.loopStart=t}))}))}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this._providedMidiNotes.forEach((e=>{const s=this._buffers.get(e);s.loaded&&ti(this.toSeconds(t),0,s.duration)})),this._activeSources.forEach((e=>{e.forEach((e=>{e.loopEnd=t}))}))}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this._activeSources.forEach((e=>{e.forEach((e=>{e.loop=t}))})))}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach((t=>{t.forEach((t=>t.dispose()))})),this._activeSources.clear(),this}}Ai([nr(0)],fc.prototype,"attack",void 0),Ai([nr(0)],fc.prototype,"release",void 0);class _c extends go{constructor(){const t=pi(go.getDefaults(),arguments,["value","units"]);super(t),this.name="SyncedSignal",this.override=!1,this._lastVal=t.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 mo({context:this.context,offset:t.value,units:t.units}).start(0),this.setValueAtTime(t.value,0)}_onTick(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==e&&(this._lastVal=e,this._constantSource.offset.setValueAtTime(e,t))}_anchorValue(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal=e,this._constantSource.offset.cancelAndHoldAtTime(t),this._constantSource.offset.setValueAtTime(e,t)}getValueAtTime(t){const e=new Ki(this.context,t).toSeconds();return super.getValueAtTime(e)}setValueAtTime(t,e){const s=new Ki(this.context,e).toSeconds();return super.setValueAtTime(t,s),this}linearRampToValueAtTime(t,e){const s=new Ki(this.context,e).toSeconds();return super.linearRampToValueAtTime(t,s),this}exponentialRampToValueAtTime(t,e){const s=new Ki(this.context,e).toSeconds();return super.exponentialRampToValueAtTime(t,s),this}setTargetAtTime(t,e,s){const n=new Ki(this.context,e).toSeconds();return super.setTargetAtTime(t,n,s),this}cancelScheduledValues(t){const e=new Ki(this.context,t).toSeconds();return super.cancelScheduledValues(e),this}setValueCurveAtTime(t,e,s,n){const i=new Ki(this.context,e).toSeconds();return s=this.toSeconds(s),super.setValueCurveAtTime(t,i,s,n),this}cancelAndHoldAtTime(t){const e=new Ki(this.context,t).toSeconds();return super.cancelAndHoldAtTime(e),this}setRampPoint(t){const e=new Ki(this.context,t).toSeconds();return super.setRampPoint(e),this}exponentialRampTo(t,e,s){const n=new Ki(this.context,s).toSeconds();return super.exponentialRampTo(t,e,n),this}linearRampTo(t,e,s){const n=new Ki(this.context,s).toSeconds();return super.linearRampTo(t,e,n),this}targetRampTo(t,e,s){const n=new Ki(this.context,s).toSeconds();return super.targetRampTo(t,e,n),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 mc extends Wr{constructor(){const t=pi(mc.getDefaults(),arguments,["url","onload"]);super(t),this.name="GrainPlayer",this._loopStart=0,this._loopEnd=0,this._activeSources=[],this.buffer=new ji({onload:t.onload,onerror:t.onerror,reverse:t.reverse,url:t.url}),this._clock=new Tr({context:this.context,callback:this._tick.bind(this),frequency:1/t.grainSize}),this._playbackRate=t.playbackRate,this._grainSize=t.grainSize,this._overlap=t.overlap,this.detune=t.detune,this.overlap=t.overlap,this.loop=t.loop,this.playbackRate=t.playbackRate,this.grainSize=t.grainSize,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.reverse=t.reverse,this._clock.on("stop",this._onstop.bind(this))}static getDefaults(){return Object.assign(Wr.getDefaults(),{onload:Ni,onerror:Ni,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(t,e,s){e=di(e,0),e=this.toSeconds(e),t=this.toSeconds(t);const n=1/this._clock.frequency.getValueAtTime(t);this._clock.start(t,e/n),s&&this.stop(t+this.toSeconds(s))}restart(t,e,s){return super.restart(t,e,s),this}_restart(t,e,s){this._stop(t),this._start(t,e,s)}_stop(t){this._clock.stop(t)}_onstop(t){this._activeSources.forEach((e=>{e.fadeOut=0,e.stop(t)})),this.onstop(this)}_tick(t){const e=this._clock.getTicksAtTime(t),s=e*this._grainSize;if(this.log("offset",s),!this.loop&&s>this.buffer.duration)return void this.stop(t);const n=s<this._overlap?0:this._overlap,i=new wa({context:this.context,url:this.buffer,fadeIn:n,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:r(this.detune/100)}).connect(this.output);i.start(t,this._grainSize*e),i.stop(t+this._grainSize/this.playbackRate),this._activeSources.push(i),i.onended=()=>{const t=this._activeSources.indexOf(i);-1!==t&&this._activeSources.splice(t,1)}}get playbackRate(){return this._playbackRate}set playbackRate(t){ti(t,.001),this._playbackRate=t,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(t){this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._loopStart=this.toSeconds(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._loopEnd=this.toSeconds(t)}get reverse(){return this.buffer.reverse}set reverse(t){this.buffer.reverse=t}get grainSize(){return this._grainSize}set grainSize(t){this._grainSize=this.toSeconds(t),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(t){const e=this.toSeconds(t);ti(e,0),this._overlap=e}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach((t=>t.dispose())),this}}class gc extends Wr{constructor(){const t=pi(gc.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._constantSource=new mo({context:this.context,units:"hertz",offset:0}),this._progressTracker=new xr({context:this.context,units:"hertz",value:0,param:this._constantSource.offset}),this._progressOffset=new ki(1/0),this._buffer=new ji({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Wr.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Ni,onerror:Ni,playbackRate:1,reverse:!1})}load(t){return Ci(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_getProgressAtTime(t){if("stopped"===this._state.getValueAtTime(t))return 0;const e=this._state.getLastState("started",t);let s=0;this._progressOffset.forEachBetween(e.time,t,(t=>{s+=t.seek}));const n=this._progressTracker.getTicksAtTime(t)+s;if(this._loop){const t=0===this.loopEnd?this.buffer.duration:this.toSeconds(this.loopEnd),e=this.toSeconds(this.loopStart);return n%(t-e)+e}return n}get progress(){const t=this.now();return this._getProgressAtTime(t)}_onload(t=Ni){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),0!==this._activeSources.size||this._synced||"started"!==this._state.getValueAtTime(this.now())||(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,s){return super.start(t,e,s),this}_start(t,e,s){e=this._loop?di(e,this._loopStart):di(e,0);const n=this.toSeconds(e),i=s;s=di(s,Math.max(this._buffer.duration-n,0));let o=this.toSeconds(s);o/=this._playbackRate,t=this.toSeconds(t);const r=new wa({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(t+o),this._state.setStateAtTime("stopped",t+o,{implicitEnd:!0})),this._activeSources.add(r);const a=n-this._getProgressAtTime(t);this._progressOffset.add({time:t,seek:a}),this._progressTracker.setValueAtTime(this._playbackRate,t),this._loop&&Un(i)?r.start(t,n):r.start(t,n,o-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach((t=>t.stop(e))),this._progressTracker.setValueAtTime(0,e)}restart(t,e,s){return super.restart(t,e,s),this}_restart(t,e,s){var n;null===(n=[...this._activeSources].pop())||void 0===n||n.stop(t),this._start(t,e,s)}seek(t,e){const s=this.toSeconds(e);if("started"===this._state.getValueAtTime(s)){const e=this.toSeconds(t);this._stop(s),this._state.cancel(s),this._start(s,e)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach((e=>{e.loopStart=t}))}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach((e=>{e.loopEnd=t}))}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach((e=>{e.loop=t})),t)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;const e=this.now();this._progressTracker.setValueAtTime(t,e);const s=this._state.getNextState("stopped",e);if(s&&s.implicitEnd){this._state.cancel(s.time),this._activeSources.forEach((t=>t.cancelStop()));const n=this._getProgressAtTime(e),i=this._buffer.duration-n,o=e+i/t;this._state.setStateAtTime("stopped",o,{implicitEnd:!0})}this._activeSources.forEach((s=>{s.playbackRate.setValueAtTime(t,e)}))}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach((t=>t.dispose())),this._activeSources.clear(),this._buffer.dispose(),this._constantSource.dispose(),this._progressTracker.dispose(),this._progressOffset.dispose(),this}}Ai([nr(0)],gc.prototype,"fadeIn",void 0),Ai([nr(0)],gc.prototype,"fadeOut",void 0);class vc extends no{constructor(){const t=pi(vc.getDefaults(),arguments,["urls","onload"],"urls");super(t),this.name="Players",this.input=void 0,this._players=new Map,this._volume=this.output=new Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume"),this._buffers=new Cr({urls:t.urls,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.mute=t.mute,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Wr.getDefaults(),{baseUrl:"",fadeIn:0,fadeOut:0,mute:!1,onload:Ni,onerror:Ni,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._players.forEach((e=>{e.fadeIn=t}))}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._players.forEach((e=>{e.fadeOut=t}))}get state(){return Array.from(this._players).some((([t,e])=>"started"===e.state))?"started":"stopped"}has(t){return this._buffers.has(t)}player(t){if(Kn(this.has(t),`No Player with the name ${t} exists on this object`),!this._players.has(t)){const e=new gc({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(t)}).connect(this.output);this._players.set(t,e)}return this._players.get(t)}get loaded(){return this._buffers.loaded}add(t,e,s){return Kn(!this._buffers.has(t),"A buffer with that name already exists on this object"),this._buffers.add(t,e,s),this}stopAll(t){return this._players.forEach((e=>e.stop(t))),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach((t=>t.dispose())),this._buffers.dispose(),this}}class yc extends no{constructor(){const t=pi(yc.getDefaults(),arguments,["volume"]);super(t),this.name="UserMedia",this._volume=this.output=new Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume"),this.mute=t.mute}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,volume:0})}open(t){return Ci(this,void 0,void 0,(function*(){Kn(yc.supported,"UserMedia is not supported"),"started"===this.state&&this.close();const e=yield yc.enumerateDevices();Zn(t)?this._device=e[t]:(this._device=e.find((e=>e.label===t||e.deviceId===t)),!this._device&&e.length>0&&(this._device=e[0]),Kn(Gn(this._device),`No matching device ${t}`));const s={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(s.audio.deviceId=this._device.deviceId);const n=yield navigator.mediaDevices.getUserMedia(s);if(!this._stream){this._stream=n;const t=this.context.createMediaStreamSource(n);oo(t,this.output),this._mediaStream=t}return this}))}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach((t=>{t.stop()})),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return Ci(this,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((t=>"audioinput"===t.kind))}))}get state(){return this._stream&&this._stream.active?"started":"stopped"}get deviceId(){return this._device?this._device.deviceId:void 0}get groupId(){return this._device?this._device.groupId:void 0}get label(){return this._device?this._device.label:void 0}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return Gn(navigator.mediaDevices)&&Gn(navigator.mediaDevices.getUserMedia)}}function xc(){return Bi().now()}function wc(){return Bi().immediate()}const bc=Bi().transport;function Tc(){return Bi().transport}const Sc=Bi().destination,kc=Bi().destination;function Ac(){return Bi().destination}const Cc=Bi().listener;function Oc(){return Bi().listener}const Dc=Bi().draw;function Mc(){return Bi().draw}const Ec=Bi();function Rc(){return ji.loaded()}const qc=ji,Vc=Cr,Ic=wa})(),n})()));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tone=e():t.Tone=e()}("undefined"!=typeof self?self:this,(()=>(()=>{var t={18:t=>{t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},113:t=>{t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=Array(e);s<e;s++)n[s]=t[s];return n},t.exports.__esModule=!0,t.exports.default=t.exports},327:(t,e,s)=>{var n=s(564).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},474:t=>{t.exports=function(t,e){var s=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=s){var n,i,o,r,a=[],c=!0,h=!1;try{if(o=(s=s.call(t)).next,0===e){if(Object(s)!==s)return;c=!1}else for(;!(c=(n=o.call(s)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){h=!0,i=t}finally{try{if(!c&&null!=s.return&&(r=s.return(),Object(r)!==r))return}finally{if(h)throw i}}return a}},t.exports.__esModule=!0,t.exports.default=t.exports},498:(t,e,s)=>{var n=s(564).default,i=s(327);t.exports=function(t){var e=i(t,"string");return"symbol"==n(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},564:t=>{function e(s){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(s)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},569:t=>{t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},744:(t,e,s)=>{var n=s(113);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?n(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},805:t=>{t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},821:(t,e,s)=>{var n=s(569),i=s(474),o=s(744),r=s(18);t.exports=function(t,e){return n(t)||i(t,e)||o(t,e)||r()},t.exports.__esModule=!0,t.exports.default=t.exports},871:function(t,e,s){!function(t,e,s,n){"use strict";var i=function(t,e,s){return{endTime:e,insertTime:s,type:"exponentialRampToValue",value:t}},o=function(t,e,s){return{endTime:e,insertTime:s,type:"linearRampToValue",value:t}},r=function(t,e){return{startTime:e,type:"setValue",value:t}},a=function(t,e,s){return{duration:s,startTime:e,type:"setValueCurve",values:t}},c=function(t,e,s){var n=s.startTime,i=s.target,o=s.timeConstant;return i+(e-i)*Math.exp((n-t)/o)},h=function(t){return"exponentialRampToValue"===t.type},l=function(t){return"linearRampToValue"===t.type},u=function(t){return h(t)||l(t)},p=function(t){return"setValue"===t.type},d=function(t){return"setValueCurve"===t.type},f=function(t,e,s,n){var i=t[e];return void 0===i?n:u(i)||p(i)?i.value:d(i)?i.values[i.values.length-1]:c(s,f(t,e-1,i.startTime,n),i)},_=function(t,e,s,n,i){return void 0===s?[n.insertTime,i]:u(s)?[s.endTime,s.value]:p(s)?[s.startTime,s.value]:d(s)?[s.startTime+s.duration,s.values[s.values.length-1]]:[s.startTime,f(t,e-1,s.startTime,i)]},m=function(t){return"cancelAndHold"===t.type},g=function(t){return"cancelScheduledValues"===t.type},v=function(t){return m(t)||g(t)?t.cancelTime:h(t)||l(t)?t.endTime:t.startTime},y=function(t,e,s,n){var i=n.endTime,o=n.value;return s===o?o:0<s&&0<o||s<0&&o<0?s*Math.pow(o/s,(t-e)/(i-e)):0},x=function(t,e,s,n){return s+(t-e)/(n.endTime-e)*(n.value-s)},w=function(t,e){var s=e.duration,n=e.startTime,i=e.values;return function(t,e){var s=Math.floor(e),n=Math.ceil(e);return s===n?t[s]:(1-(e-s))*t[s]+(1-(n-e))*t[n]}(i,(t-n)/s*(i.length-1))},b=function(t){return"setTarget"===t.type},T=function(){return n((function t(e){s(this,t),this._automationEvents=[],this._currenTime=0,this._defaultValue=e}),[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:"add",value:function(t){var e=v(t);if(m(t)||g(t)){var s=this._automationEvents.findIndex((function(s){return g(t)&&d(s)?s.startTime+s.duration>=e:v(s)>=e})),n=this._automationEvents[s];if(-1!==s&&(this._automationEvents=this._automationEvents.slice(0,s)),m(t)){var c=this._automationEvents[this._automationEvents.length-1];if(void 0!==n&&u(n)){if(void 0!==c&&b(c))throw new Error("The internal list is malformed.");var p=void 0===c?n.insertTime:d(c)?c.startTime+c.duration:v(c),f=void 0===c?this._defaultValue:d(c)?c.values[c.values.length-1]:c.value,_=h(n)?y(e,p,f,n):x(e,p,f,n),w=h(n)?i(_,e,this._currenTime):o(_,e,this._currenTime);this._automationEvents.push(w)}if(void 0!==c&&b(c)&&this._automationEvents.push(r(this.getValue(e),e)),void 0!==c&&d(c)&&c.startTime+c.duration>e){var T=e-c.startTime,S=(c.values.length-1)/c.duration,k=Math.max(2,1+Math.ceil(T*S)),A=T/(k-1)*S,C=c.values.slice(0,k);if(A<1)for(var O=1;O<k;O+=1){var D=A*O%1;C[O]=c.values[O-1]*(1-D)+c.values[O]*D}this._automationEvents[this._automationEvents.length-1]=a(C,c.startTime,T)}}}else{var M=this._automationEvents.findIndex((function(t){return v(t)>e})),E=-1===M?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[M-1];if(void 0!==E&&d(E)&&v(E)+E.duration>e)return!1;var R=h(t)?i(t.value,t.endTime,this._currenTime):l(t)?o(t.value,e,this._currenTime):t;if(-1===M)this._automationEvents.push(R);else{if(d(t)&&e+t.duration>v(this._automationEvents[M]))return!1;this._automationEvents.splice(M,0,R)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return v(e)>t}));if(e>1){var s=this._automationEvents.slice(e-1),n=s[0];b(n)&&s.unshift(r(f(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=s}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var s=this._automationEvents.findIndex((function(e){return v(e)>t})),n=this._automationEvents[s],i=(-1===s?this._automationEvents.length:s)-1,o=this._automationEvents[i];if(void 0!==o&&b(o)&&(void 0===n||!u(n)||n.insertTime>t))return c(t,f(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(void 0!==o&&p(o)&&(void 0===n||!u(n)))return o.value;if(void 0!==o&&d(o)&&(void 0===n||!u(n)||o.startTime+o.duration>t))return t<o.startTime+o.duration?w(t,o):o.values[o.values.length-1];if(void 0!==o&&u(o)&&(void 0===n||!u(n)))return o.value;if(void 0!==n&&h(n)){var r=_(this._automationEvents,i,o,n,this._defaultValue),a=e(r,2),m=a[0],g=a[1];return y(t,m,g,n)}if(void 0!==n&&l(n)){var T=_(this._automationEvents,i,o,n,this._defaultValue),S=e(T,2),k=S[0],A=S[1];return x(t,k,A,n)}return this._defaultValue}}])}();t.AutomationEventList=T,t.createCancelAndHoldAutomationEvent=function(t){return{cancelTime:t,type:"cancelAndHold"}},t.createCancelScheduledValuesAutomationEvent=function(t){return{cancelTime:t,type:"cancelScheduledValues"}},t.createExponentialRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"exponentialRampToValue",value:t}},t.createLinearRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"linearRampToValue",value:t}},t.createSetTargetAutomationEvent=function(t,e,s){return{startTime:e,target:t,timeConstant:s,type:"setTarget"}},t.createSetValueAutomationEvent=r,t.createSetValueCurveAutomationEvent=a}(e,s(821),s(805),s(989))},989:(t,e,s)=>{var n=s(498);function i(t,e){for(var s=0;s<e.length;s++){var i=e[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,n(i.key),i)}}t.exports=function(t,e,s){return e&&i(t.prototype,e),s&&i(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function s(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,s),o.exports}s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";s.r(n),s.d(n,{AMOscillator:()=>Za,AMSynth:()=>ic,Abs:()=>To,Add:()=>Fo,AmplitudeEnvelope:()=>rr,Analyser:()=>lo,AudioToGain:()=>Fr,AutoFilter:()=>Xr,AutoPanner:()=>Yr,AutoWah:()=>$r,BaseContext:()=>Mi,BiquadFilter:()=>Bo,BitCrusher:()=>Kr,Buffer:()=>qc,BufferSource:()=>Ic,Buffers:()=>Vc,Channel:()=>Ro,Chebyshev:()=>ea,Chorus:()=>ia,Clock:()=>Tr,Compressor:()=>Yo,Context:()=>Ii,Convolver:()=>lr,CrossFade:()=>Vo,DCMeter:()=>po,Delay:()=>Sr,Destination:()=>Sc,Distortion:()=>oa,Draw:()=>Dc,DuoSynth:()=>rc,EQ3:()=>ur,Emitter:()=>Di,Envelope:()=>ir,FFT:()=>fo,FMOscillator:()=>Ya,FMSynth:()=>ac,FatOscillator:()=>Xa,FeedbackCombFilter:()=>gr,FeedbackDelay:()=>aa,Filter:()=>Uo,Follower:()=>ko,Freeverb:()=>la,Frequency:()=>Ji,FrequencyClass:()=>Yi,FrequencyEnvelope:()=>hr,FrequencyShifter:()=>pa,Gain:()=>co,GainToAudio:()=>qo,Gate:()=>Jo,GrainPlayer:()=>mc,GreaterThan:()=>$o,GreaterThanZero:()=>Ho,IntervalTimeline:()=>qr,JCReverb:()=>ma,LFO:()=>Qr,Limiter:()=>Ko,Listener:()=>Cc,Loop:()=>Ia,LowpassCombFilter:()=>vr,Master:()=>kc,MembraneSynth:()=>cc,Merge:()=>Io,MetalSynth:()=>lc,Meter:()=>Ao,MidSideCompressor:()=>tr,MidSideMerge:()=>Lo,MidSideSplit:()=>zo,Midi:()=>Dr,MidiClass:()=>Or,Mono:()=>Wo,MonoSynth:()=>oc,MultibandCompressor:()=>er,MultibandSplit:()=>Go,Multiply:()=>Po,Negate:()=>No,Noise:()=>ba,NoiseSynth:()=>uc,Offline:()=>Ar,OfflineContext:()=>Li,OmniOscillator:()=>Ka,OnePoleFilter:()=>So,Oscillator:()=>Gr,PWMOscillator:()=>$a,PanVol:()=>Mo,Panner:()=>Oo,Panner3D:()=>Zo,Param:()=>so,Part:()=>Fa,Pattern:()=>Ga,Phaser:()=>ga,PingPongDelay:()=>ya,PitchShift:()=>xa,Player:()=>gc,Players:()=>vc,PluckSynth:()=>pc,PolySynth:()=>dc,Pow:()=>ar,PulseOscillator:()=>Ha,Recorder:()=>Xo,Reverb:()=>Aa,ReverseDelay:()=>Oa,Sampler:()=>fc,Scale:()=>cr,ScaleExp:()=>Hr,Sequence:()=>Qa,Signal:()=>go,Solo:()=>Eo,Split:()=>ho,StateTimeline:()=>yr,StereoWidener:()=>Ea,Subtract:()=>jo,SyncedSignal:()=>_c,Synth:()=>sc,Ticks:()=>Er,TicksClass:()=>Mr,Time:()=>Xi,TimeClass:()=>Zi,Timeline:()=>ki,ToneAudioBuffer:()=>ji,ToneAudioBuffers:()=>Cr,ToneAudioNode:()=>no,ToneBufferSource:()=>wa,ToneEvent:()=>Va,ToneOscillatorNode:()=>Ur,Transport:()=>bc,TransportTime:()=>to,TransportTimeClass:()=>Ki,Tremolo:()=>Ra,Unit:()=>e,UserMedia:()=>yc,Vibrato:()=>qa,Volume:()=>Do,WaveShaper:()=>bo,Waveform:()=>Co,Zero:()=>Pr,connect:()=>oo,connectSeries:()=>io,connectSignal:()=>yo,context:()=>Ec,dbToGain:()=>i,debug:()=>t,defaultArg:()=>di,disconnect:()=>ro,disconnectSignal:()=>xo,fanIn:()=>ao,ftom:()=>c,gainToDb:()=>o,getContext:()=>Bi,getDestination:()=>Ac,getDraw:()=>Mc,getListener:()=>Oc,getTransport:()=>Tc,immediate:()=>wc,intervalToFrequencyRatio:()=>r,isArray:()=>Hn,isBoolean:()=>Yn,isDefined:()=>Gn,isFunction:()=>Qn,isNote:()=>Jn,isNumber:()=>Zn,isObject:()=>Xn,isString:()=>$n,isUndef:()=>Un,loaded:()=>Rc,mtof:()=>l,now:()=>xc,optionsFromArguments:()=>pi,setContext:()=>Ui,start:()=>Gi,supported:()=>jn,version:()=>wi});var t={};s.r(t),s.d(t,{assert:()=>Kn,assertContextRunning:()=>ei,assertRange:()=>ti,assertUsedScheduleTime:()=>oi,enterScheduledCallback:()=>ii,log:()=>ci,setLogger:()=>ai,warn:()=>hi});var e={};function i(t){return Math.pow(10,t/20)}function o(t){return Math.log(t)/Math.LN10*20}function r(t){return Math.pow(2,t/12)}s.r(e);let a=440;function c(t){return Math.round(h(t))}function h(t){return 69+12*Math.log2(t/a)}function l(t){return a*Math.pow(2,(t-69)/12)}var u=s(871);const p=new WeakSet,d=new WeakMap,f=new WeakMap,_=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakMap,w=new WeakMap,b={construct:()=>b},T=/^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]*);?/,S=(t,e)=>{const s=[];let n=t.replace(/^[\s]+/,""),i=n.match(T);for(;null!==i;){const t=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());s.push(o),n=n.slice(i[0].length).replace(/^[\s]+/,""),i=n.match(T)}return[s.join(";"),n]},k=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},A=t=>{if(!(t=>{try{new new Proxy(t,b)}catch{return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.")},C=(t,e)=>{const s=t.get(e);if(void 0===s)throw new Error("A value with the given key could not be found.");return s},O=(t,e)=>{const s=Array.from(t).filter(e);if(s.length>1)throw Error("More than one element was found.");if(0===s.length)throw Error("No element was found.");const[n]=s;return t.delete(n),n},D=(t,e,s,n)=>{const i=C(t,e),o=O(i,(t=>t[0]===s&&t[1]===n));return 0===i.size&&t.delete(e),o},M=t=>C(v,t),E=t=>{if(p.has(t))throw new Error("The AudioNode is already stored.");p.add(t),M(t).forEach((t=>t(!0)))},R=t=>"port"in t,q=t=>{if(!p.has(t))throw new Error("The AudioNode is not stored.");p.delete(t),M(t).forEach((t=>t(!1)))},V=(t,e)=>{!R(t)&&e.every((t=>0===t.size))&&q(t)},I={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},F=(t,e)=>t.context===e,P=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},N=()=>new DOMException("","IndexSizeError"),j=t=>{var e;t.getChannelData=(e=t.getChannelData,s=>{try{return e.call(t,s)}catch(t){if(12===t.code)throw N();throw t}})},L={numberOfChannels:1},z=-34028234663852886e22,W=-z,B=t=>p.has(t),U={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},G=t=>C(d,t),Q=t=>C(_,t),Z=(t,e)=>{const{activeInputs:s}=G(t);s.forEach((s=>s.forEach((([s])=>{e.includes(t)||Z(s,[...e,t])}))));const n=(t=>"playbackRate"in t)(t)?[t.playbackRate]:R(t)?Array.from(t.parameters.values()):(t=>"frequency"in t&&"gain"in t)(t)?[t.Q,t.detune,t.frequency,t.gain]:(t=>"offset"in t)(t)?[t.offset]:(t=>!("frequency"in t)&&"gain"in t)(t)?[t.gain]:(t=>"detune"in t&&"frequency"in t&&!("gain"in t))(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of n){const s=Q(t);void 0!==s&&s.activeInputs.forEach((([t])=>Z(t,e)))}B(t)&&q(t)},X=t=>{Z(t.destination,[])},Y=t=>"context"in t,H=t=>Y(t[0]),$=(t,e,s,n)=>{for(const e of t)if(s(e)){if(n)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},J=(t,e,[s,n],i)=>{$(t,[e,s,n],(t=>t[0]===e&&t[1]===s),i)},K=(t,[e,s,n],i)=>{const o=t.get(e);void 0===o?t.set(e,new Set([[s,n]])):$(o,[s,n],(t=>t[0]===s),i)},tt=t=>"inputs"in t,et=(t,e,s,n)=>{if(tt(e)){const i=e.inputs[n];return t.connect(i,s,0),[i,s,0]}return t.connect(e,s,n),[e,s,n]},st=(t,e,s)=>{for(const n of t)if(n[0]===e&&n[1]===s)return t.delete(n),n;return null},nt=(t,e)=>{if(!M(t).delete(e))throw new Error("Missing the expected event listener.")},it=(t,e,s)=>{const n=C(t,e),i=O(n,(t=>t[0]===s));return 0===n.size&&t.delete(e),i},ot=(t,e,s,n)=>{tt(e)?t.disconnect(e.inputs[n],s,0):t.disconnect(e,s,n)},rt=t=>C(f,t),at=t=>C(m,t),ct=t=>y.has(t),ht=t=>!p.has(t),lt=(t,e)=>new Promise((s=>{if(null!==e)s(!0);else{const e=t.createScriptProcessor(256,1,1),n=t.createGain(),i=t.createBuffer(1,2,44100),o=i.getChannelData(0);o[0]=1,o[1]=1;const r=t.createBufferSource();r.buffer=i,r.loop=!0,r.connect(e).connect(t.destination),r.connect(n),r.disconnect(n),e.onaudioprocess=n=>{const i=n.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?s(!0):s(!1),r.stop(),e.onaudioprocess=null,r.disconnect(e),e.disconnect(t.destination)},r.start()}})),ut=(t,e)=>{const s=new Map;for(const e of t)for(const t of e){const e=s.get(t);s.set(t,void 0===e?1:e+1)}s.forEach(((t,s)=>e(s,t)))},pt=t=>"context"in t,dt=t=>{const e=new Map;t.connect=(t=>(s,n=0,i=0)=>{const o=pt(s)?t(s,n,i):t(s,n),r=e.get(s);return void 0===r?e.set(s,[{input:i,output:n}]):r.every((t=>t.input!==i||t.output!==n))&&r.push({input:i,output:n}),o})(t.connect.bind(t)),t.disconnect=(s=>(n,i,o)=>{if(s.apply(t),void 0===n)e.clear();else if("number"==typeof n)for(const[t,s]of e){const i=s.filter((t=>t.output!==n));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(n))if(void 0===i)e.delete(n);else{const t=e.get(n);if(void 0!==t){const s=t.filter((t=>t.output!==i&&(t.input!==o||void 0===o)));0===s.length?e.delete(n):e.set(n,s)}}for(const[s,n]of e)n.forEach((e=>{pt(s)?t.connect(s,e.output,e.input):t.connect(s,e.output)}))})(t.disconnect)},ft=(t,e,s,n,i)=>{const[o,r]=((t,e,s,n)=>{const{activeInputs:i,passiveInputs:o}=G(e),r=st(i[n],t,s);return null===r?[D(o,t,s,n)[2],!1]:[r[2],!0]})(t,s,n,i);if(null!==o&&(nt(t,o),!r||e||ct(t)||ot(rt(t),rt(s),n,i)),B(s)){const{activeInputs:t}=G(s);V(s,t)}},_t=(t,e,s,n)=>{const[i,o]=((t,e,s)=>{const{activeInputs:n,passiveInputs:i}=Q(e),o=st(n,t,s);return null===o?[it(i,t,s)[1],!1]:[o[2],!0]})(t,s,n);null!==i&&(nt(t,i),!o||e||ct(t)||rt(t).disconnect(at(s),n))};class mt{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach(((s,n)=>t.call(e,s,n,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const gt={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function vt(t,e,s,n,i){if("function"==typeof t.copyFromChannel)0===e[s].byteLength&&(e[s]=new Float32Array(128)),t.copyFromChannel(e[s],n,i);else{const o=t.getChannelData(n);if(0===e[s].byteLength)e[s]=o.slice(i,i+128);else{const t=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[s].set(t)}}}const yt=(t,e,s,n,i)=>{"function"==typeof t.copyToChannel?0!==e[s].byteLength&&t.copyToChannel(e[s],n,i):0!==e[s].byteLength&&t.getChannelData(n).set(e[s],i)},xt=(t,e)=>{const s=[];for(let n=0;n<t;n+=1){const t=[],i="number"==typeof e?e:e[n];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));s.push(t)}return s},wt=async(t,e,s,n,i,o,r)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,c=n.channelCount*n.numberOfInputs,h=i.reduce(((t,e)=>t+e),0),l=0===h?null:s.createBuffer(h,a,s.sampleRate);if(void 0===o)throw new Error("Missing the processor constructor.");const u=G(t),p=await((t,e)=>{const s=C(w,t),n=rt(e);return C(s,n)})(s,t),d=xt(n.numberOfInputs,n.channelCount),f=xt(n.numberOfOutputs,i),_=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let h=0;h<a;h+=128){if(n.numberOfInputs>0&&null!==e)for(let t=0;t<n.numberOfInputs;t+=1)for(let s=0;s<n.channelCount;s+=1)vt(e,d[t],s,s,h);void 0!==o.parameterDescriptors&&null!==e&&o.parameterDescriptors.forEach((({name:t},s)=>{vt(e,_,t,c+s,h)}));for(let t=0;t<n.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===f[t][e].byteLength&&(f[t][e]=new Float32Array(128));try{const t=d.map(((t,e)=>0===u.activeInputs[e].size?[]:t)),e=r(h/s.sampleRate,s.sampleRate,(()=>p.process(t,f,_)));if(null!==l)for(let t=0,e=0;t<n.numberOfOutputs;t+=1){for(let s=0;s<i[t];s+=1)yt(l,f[t],s,e+s,h);e+=i[t]}if(!e)break}catch(e){t.dispatchEvent(new ErrorEvent("processorerror",{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}));break}}return l},bt={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Tt={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},St={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},kt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},At={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Ct=t=>{const{port1:e,port2:s}=new MessageChannel;return new Promise((n=>{const i=()=>{s.onmessage=null,e.close(),s.close(),n()};s.onmessage=()=>i();try{e.postMessage(t,[t])}catch{}finally{i()}}))},Ot={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Dt=(t,e,s)=>{const n=e[s];if(void 0===n)throw t();return n},Mt={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Et={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Rt=()=>new DOMException("","InvalidStateError"),qt=()=>new DOMException("","InvalidAccessError"),Vt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},It=(t,e,s,n,i,o,r,a,c,h,l)=>{const u=h.length;let p=a;for(let a=0;a<u;a+=1){let u=s[0]*h[a];for(let e=1;e<i;e+=1){const n=p-e&c-1;u+=s[e]*o[n],u-=t[e]*r[n]}for(let t=i;t<n;t+=1)u+=s[t]*o[p-t&c-1];for(let s=i;s<e;s+=1)u-=t[s]*r[p-s&c-1];o[p]=h[a],r[p]=u,p=p+1&c-1,l[a]=u}return p},Ft={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Pt=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const s=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==s&&(s.catch((()=>{})),!0)}catch{}return!1},Nt=(t,e,s)=>{const n=e[s];void 0!==n&&n!==t[s]&&(t[s]=n)},jt=(t,e)=>{Nt(t,e,"channelCount"),Nt(t,e,"channelCountMode"),Nt(t,e,"channelInterpretation")},Lt=t=>"function"==typeof t.getFloatTimeDomainData,zt=(t,e,s)=>{const n=e[s];void 0!==n&&n!==t[s].value&&(t[s].value=n)},Wt=t=>{t.start=(e=>(s=0,n=0,i)=>{if("number"==typeof i&&i<0||n<0||s<0)throw new RangeError("The parameters can't be negative.");e.call(t,s,n,i)})(t.start)},Bt=t=>{var e;t.stop=(e=t.stop,(s=0)=>{if(s<0)throw new RangeError("The parameter can't be negative.");e.call(t,s)})},Ut=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),Gt=(t,e)=>{const s=t.createBiquadFilter();return jt(s,e),zt(s,e,"Q"),zt(s,e,"detune"),zt(s,e,"frequency"),zt(s,e,"gain"),Nt(s,e,"type"),s},Qt=(t,e)=>{const s=t.createChannelSplitter(e.numberOfOutputs);return jt(s,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Rt()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Rt()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Rt()}})})(s),s},Zt=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),Xt=(t,e)=>{const s=t.createDelay(e.maxDelayTime);return jt(s,e),zt(s,e,"delayTime"),s},Yt=(t,e)=>{const s=t.createGain();return jt(s,e),zt(s,e,"gain"),s};function Ht(t,e){const s=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/s,(t[1]*e[0]-t[0]*e[1])/s]}function $t(t,e){let s=[0,0];for(let o=t.length-1;o>=0;o-=1)i=e,s=[(n=s)[0]*i[0]-n[1]*i[1],n[0]*i[1]+n[1]*i[0]],s[0]+=t[o];var n,i;return s}const Jt=(t,e,s,n)=>t.createScriptProcessor(e,s,n),Kt=()=>new DOMException("","NotSupportedError"),te={numberOfChannels:1},ee={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},se={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},ne={disableNormalization:!1},ie={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},oe=()=>new DOMException("","UnknownError"),re={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},ae=(t,e,s)=>void 0===t.copyFromChannel?t.getChannelData(s)[0]:(t.copyFromChannel(e,s),e[0]),ce=t=>{if(null===t)return!1;const e=t.length;return e%2!=0?0!==t[Math.floor(e/2)]:t[e/2-1]+t[e/2]!==0},he=(t,e,s,n)=>{let i=t;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:o,set:r}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:s(o),set:n(r)})},le=(t,e,s)=>{try{t.setValueAtTime(e,s)}catch(n){if(9!==n.code)throw n;le(t,e,s+1e-7)}},ue=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},pe=t=>{const e=t.createBuffer(1,1,44100),s=t.createBufferSource();s.buffer=e,s.start(),s.stop();try{return s.stop(),!0}catch{return!1}},de=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},fe=()=>{try{new DOMException}catch{return!1}return!0},_e=()=>new Promise((t=>{const e=new ArrayBuffer(0),{port1:s,port2:n}=new MessageChannel;s.onmessage=({data:e})=>t(null!==e),n.postMessage(e,[e])})),me=(t,e)=>{const s=e.createGain();t.connect(s);const n=(e=>()=>{e.call(t,s),t.removeEventListener("ended",n)})(t.disconnect);t.addEventListener("ended",n),Zt(t,s),t.stop=(e=>{let n=!1;return(i=0)=>{if(n)try{e.call(t,i)}catch{s.gain.setValueAtTime(0,i)}else e.call(t,i),n=!0}})(t.stop)},ge=(t,e)=>s=>{const n={value:t};return Object.defineProperties(s,{currentTarget:n,target:n}),"function"==typeof e?e.call(t,s):e.handleEvent.call(t,s)},ve=(t=>(e,s,[n,i,o],r)=>{t(e[i],[s,n,o],(t=>t[0]===s&&t[1]===n),r)})($),ye=(t=>(e,s,[n,i,o],r)=>{const a=e.get(n);void 0===a?e.set(n,new Set([[i,s,o]])):t(a,[i,s,o],(t=>t[0]===i&&t[1]===s),r)})($),xe=(t=>(e,s,n,i)=>t(e[i],(t=>t[0]===s&&t[1]===n)))(O),we=new WeakMap,be=(t=>e=>{var s;return null!==(s=t.get(e))&&void 0!==s?s:0})(we),Te=(Se=new Map,ke=new WeakMap,(t,e)=>{const s=ke.get(t);if(void 0!==s)return s;const n=Se.get(t);if(void 0!==n)return n;try{const s=e();return s instanceof Promise?(Se.set(t,s),s.catch((()=>!1)).then((e=>(Se.delete(t),ke.set(t,e),e)))):(ke.set(t,s),s)}catch{return ke.set(t,!1),!1}});var Se,ke;const Ae="undefined"==typeof window?null:window,Ce=((t,e)=>(s,n)=>{const i=s.createAnalyser();if(jt(i,n),!(n.maxDecibels>n.minDecibels))throw e();return Nt(i,n,"fftSize"),Nt(i,n,"maxDecibels"),Nt(i,n,"minDecibels"),Nt(i,n,"smoothingTimeConstant"),t(Lt,(()=>Lt(i)))||(t=>{t.getFloatTimeDomainData=e=>{const s=new Uint8Array(e.length);t.getByteTimeDomainData(s);const n=Math.max(s.length,t.fftSize);for(let t=0;t<n;t+=1)e[t]=.0078125*(s[t]-128);return e}})(i),i})(Te,N),Oe=(t=>e=>{const s=t(e);if(null===s.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return s.renderer})(G),De=((t,e,s)=>async(n,i,o)=>{const r=t(n);await Promise.all(r.activeInputs.map(((t,r)=>Array.from(t).map((async([t,a])=>{const c=e(t),h=await c.render(t,i),l=n.context.destination;s(t)||n===l&&s(n)||h.connect(o,a,r)})))).reduce(((t,e)=>[...t,...e]),[]))})(G,Oe,ct),Me=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,fftSize:r.fftSize,maxDecibels:r.maxDecibels,minDecibels:r.minDecibels,smoothingTimeConstant:r.smoothingTimeConstant};r=t(o,e)}return n.set(o,r),await s(i,o,r),r})(i,o)}}})(Ce,rt,De),Ee=(Re=g,t=>{const e=Re.get(t);if(void 0===e)throw Rt();return e});var Re;const qe=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(Ae),Ve=(t=>e=>null!==t&&e instanceof t)(qe),Ie=new WeakMap,Fe=(t=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(e,s,n){if(null!==s){let i=this._listeners.get(s);void 0===i&&(i=t(this,s),"function"==typeof s&&this._listeners.set(s,i)),this._nativeEventTarget.addEventListener(e,i,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,s){const n=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===n?null:n,s)}})(ge),Pe=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(Ae),Ne=(t=>e=>null!==t&&e instanceof t)(Pe),je=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(Ae),Le=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(Ae),ze=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(Ae),We=((t,e,s,n,i,o,r,a,c,h,l,u,p,d,_,m)=>class extends h{constructor(e,n,i,o){super(i),this._context=e,this._nativeAudioNode=i;const r=l(e);u(r)&&!0!==s(lt,(()=>lt(r,m)))&&dt(i),f.set(this,i),v.set(this,new Set),"closed"!==e.state&&n&&E(this),t(this,o,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,s=0,a=0){if(s<0||s>=this._nativeAudioNode.numberOfOutputs)throw i();const h=l(this._context),u=_(h);if(p(t)||d(t))throw o();if(Y(t)){const i=rt(t);try{const e=et(this._nativeAudioNode,i,s,a),n=ht(this);(u||n)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!n&&ht(t)&&E(t)}catch(t){if(12===t.code)throw o();throw t}if(e(this,t,s,a,u)){const e=c([this],t);ut(e,n(u))}return t}const f=at(t);if("playbackRate"===f.name&&1024===f.maxValue)throw r();try{this._nativeAudioNode.connect(f,s),(u||ht(this))&&this._nativeAudioNode.disconnect(f,s)}catch(t){if(12===t.code)throw o();throw t}if(((t,e,s,n)=>{const{activeInputs:i,passiveInputs:o}=Q(e),{outputs:r}=G(t),a=M(t),c=r=>{const a=rt(t),c=at(e);if(r){const e=it(o,t,s);J(i,t,e,!1),n||ct(t)||a.connect(c,s)}else{const e=((t,e,s)=>O(t,(t=>t[0]===e&&t[1]===s)))(i,t,s);K(o,e,!1),n||ct(t)||a.disconnect(c,s)}};return!!$(r,[e,s],(t=>t[0]===e&&t[1]===s),!0)&&(a.add(c),B(t)?J(i,t,[s,c],!0):K(o,[t,s,c],!0),!0)})(this,t,s,u)){const e=c([this],t);ut(e,n(u))}}disconnect(t,e,s){let n;const r=l(this._context),h=_(r);if(void 0===t)n=((t,e)=>{const s=G(t),n=[];for(const i of s.outputs)H(i)?ft(t,e,...i):_t(t,e,...i),n.push(i[0]);return s.outputs.clear(),n})(this,h);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();n=((t,e,s)=>{const n=G(t),i=[];for(const o of n.outputs)o[1]===s&&(H(o)?ft(t,e,...o):_t(t,e,...o),i.push(o[0]),n.outputs.delete(o));return i})(this,h,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(Y(t)&&void 0!==s&&(s<0||s>=t.numberOfInputs))throw i();if(n=((t,e,s,n,i)=>{const o=G(t);return Array.from(o.outputs).filter((t=>!(t[0]!==s||void 0!==n&&t[1]!==n||void 0!==i&&t[2]!==i))).map((s=>(H(s)?ft(t,e,...s):_t(t,e,...s),o.outputs.delete(s),s[0])))})(this,h,t,e,s),0===n.length)throw o()}for(const t of n){const e=c([this],t);ut(e,a)}}})((Be=d,(t,e,s)=>{const n=[];for(let t=0;t<s.numberOfInputs;t+=1)n.push(new Set);Be.set(t,{activeInputs:n,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,s,n,i,o,r,a,c,h,l,u,p)=>{const d=new WeakMap;return(f,_,m,g,v)=>{const{activeInputs:y,passiveInputs:x}=o(_),{outputs:w}=o(f),b=a(f),T=o=>{const a=c(_),h=c(f);if(o){const e=D(x,f,m,g);t(y,f,e,!1),v||u(f)||s(h,a,m,g),p(_)&&E(_)}else{const t=n(y,f,m,g);e(x,g,t,!1),v||u(f)||i(h,a,m,g);const s=r(_);if(0===s)l(_)&&V(_,y);else{const t=d.get(_);void 0!==t&&clearTimeout(t),d.set(_,setTimeout((()=>{l(_)&&V(_,y)}),1e3*s))}}};return!!h(w,[_,m,g],(t=>t[0]===_&&t[1]===m&&t[2]===g),!0)&&(b.add(T),l(f)?t(y,f,[m,g,T],!0):e(x,g,[f,m,T],!0),!0)}})(ve,ye,et,xe,ot,G,be,M,rt,$,B,ct,ht),Te,((t,e,s,n,i,o)=>r=>(a,c)=>{const h=t.get(a);if(void 0===h){if(!r&&o(a)){const t=n(a),{outputs:o}=s(a);for(const s of o)if(H(s)){const i=n(s[0]);e(t,i,s[1],s[2])}else{const e=i(s[0]);t.disconnect(e,s[1])}}t.set(a,c)}else t.set(a,h+c)})(y,ot,G,rt,at,B),N,qt,Kt,((t,e,s,n,i,o,r,a)=>(c,h)=>{const l=e.get(c);if(void 0===l)throw new Error("Missing the expected cycle count.");const u=o(c.context),p=a(u);if(l===h){if(e.delete(c),!p&&r(c)){const e=n(c),{outputs:o}=s(c);for(const s of o)if(H(s)){const i=n(s[0]);t(e,i,s[1],s[2])}else{const t=i(s[0]);e.connect(t,s[1])}}}else e.set(c,l-h)})(et,y,G,rt,at,Ee,B,Ve),((t,e,s)=>function n(i,o){const r=Y(o)?o:s(t,o);if((t=>"delayTime"in t)(r))return[];if(i[0]===r)return[i];if(i.includes(r))return[];const{outputs:a}=e(r);return Array.from(a).map((t=>n([...i,r],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(Ie,G,C),Fe,Ee,Ne,je,Le,Ve,ze);var Be;const Ue=((t,e,s,n,i,o)=>class extends t{constructor(t,s){const r=i(t),a={...I,...s},c=n(r,a);super(t,!1,c,o(r)?e():null),this._nativeAnalyserNode=c}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,s()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,s()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(We,Me,N,Ce,Ee,Ve),Ge=new WeakSet,Qe=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(Ae),Ze=(Xe=new Uint32Array(1),t=>(Xe[0]=t,Xe[0]));var Xe;const Ye=((t,e)=>s=>{s.copyFromChannel=(n,i,o=0)=>{const r=t(o),a=t(i);if(a>=s.numberOfChannels)throw e();const c=s.length,h=s.getChannelData(a),l=n.length;for(let t=r<0?-r:0;t+r<c&&t<l;t+=1)n[t]=h[t+r]},s.copyToChannel=(n,i,o=0)=>{const r=t(o),a=t(i);if(a>=s.numberOfChannels)throw e();const c=s.length,h=s.getChannelData(a),l=n.length;for(let t=r<0?-r:0;t+r<c&&t<l;t+=1)h[t+r]=n[t]}})(Ze,N),He=(t=>e=>{e.copyFromChannel=(s=>(n,i,o=0)=>{const r=t(o),a=t(i);if(r<e.length)return s.call(e,n,a,r)})(e.copyFromChannel),e.copyToChannel=(s=>(n,i,o=0)=>{const r=t(o),a=t(i);if(r<e.length)return s.call(e,n,a,r)})(e.copyToChannel)})(Ze),$e=((t,e,s,n,i,o,r,a)=>{let c=null;return class h{constructor(h){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:u,sampleRate:p}={...L,...h};null===c&&(c=new i(1,1,44100));const d=null!==n&&e(o,o)?new n({length:l,numberOfChannels:u,sampleRate:p}):c.createBuffer(u,l,p);if(0===d.numberOfChannels)throw s();return"function"!=typeof d.copyFromChannel?(r(d),j(d)):e(P,(()=>P(d)))||a(d),t.add(d),d}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===h.prototype||t.has(e)}}})(Ge,Te,Kt,Qe,qe,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(Qe),Ye,He),Je=(t=>(e,s)=>{const n=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});s.connect(n).connect(e.destination);const i=()=>{s.removeEventListener("ended",i),s.disconnect(n),n.disconnect()};s.addEventListener("ended",i)})(Yt),Ke=((t,e,s)=>async(n,i,o)=>{const r=e(n);await Promise.all(Array.from(r.activeInputs).map((async([e,n])=>{const r=t(e),a=await r.render(e,i);s(e)||a.connect(o,n)})))})(Oe,Q,ct),ts=(t=>(e,s,n)=>t(s,e,n))(Ke),es=((t,e,s,n,i,o,r,a,c,h,l)=>(c,u)=>{const p=c.createBufferSource();return jt(p,u),zt(p,u,"playbackRate"),Nt(p,u,"buffer"),Nt(p,u,"loop"),Nt(p,u,"loopEnd"),Nt(p,u,"loopStart"),e(s,(()=>s(c)))||(t=>{t.start=(e=>{let s=!1;return(n=0,i=0,o)=>{if(s)throw Rt();e.call(t,n,i,o),s=!0}})(t.start)})(p),e(n,(()=>n(c)))||(t=>{t.start=(e=>(s=0,n=0,i)=>{const o=t.buffer,r=null===o?n:Math.min(o.duration,n);null!==o&&r>o.duration-.5/t.context.sampleRate?e.call(t,s,0,0):e.call(t,s,r,i)})(t.start)})(p),e(i,(()=>i(c)))||h(p,c),e(o,(()=>o(c)))||Wt(p),e(r,(()=>r(c)))||l(p,c),e(a,(()=>a(c)))||Bt(p),t(c,p),p})(Je,Te,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),s=t.createBuffer(1,1,44100);e.buffer=s;try{e.start(0,1)}catch{return!1}return!0}),(t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0}),ue,pe,de,0,(t=>(e,s)=>{const n=s.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=n),t(e,"buffer",(t=>()=>{const s=t.call(e);return s===n?null:s}),(t=>s=>t.call(e,null===s?n:s)))})(he),me),ss=((t,e)=>(s,n,i)=>(t(n).replay(i),e(n,s,i)))((t=>e=>{const s=t(e);if(null===s.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return s.renderer})(Q),Ke),ns=((t,e,s,n,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(c,h){const l=o.get(h);return void 0!==l?Promise.resolve(l):(async(c,h)=>{let l=s(c);const u=F(l,h);if(!u){const t={buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value};l=e(h,t),null!==r&&l.start(...r),null!==a&&l.stop(a)}return o.set(h,l),u?await t(h,c.playbackRate,l.playbackRate):await n(h,c.playbackRate,l.playbackRate),await i(c,h,l),l})(c,h)}}})(ts,es,rt,ss,De),is=((t,e,s,n,i,o,r,a,c,h,l,p,d)=>(n,f,_,m=null,g=null)=>{const v=_.value,y=new u.AutomationEventList(v),x=f?(t=>({replay(e){for(const s of t)if("exponentialRampToValue"===s.type){const{endTime:t,value:n}=s;e.exponentialRampToValueAtTime(n,t)}else if("linearRampToValue"===s.type){const{endTime:t,value:n}=s;e.linearRampToValueAtTime(n,t)}else if("setTarget"===s.type){const{startTime:t,target:n,timeConstant:i}=s;e.setTargetAtTime(n,t,i)}else if("setValue"===s.type){const{startTime:t,value:n}=s;e.setValueAtTime(n,t)}else{if("setValueCurve"!==s.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:n,values:i}=s;e.setValueCurveAtTime(i,n,t)}}}}))(y):null,w={get defaultValue(){return v},get maxValue(){return null===m?_.maxValue:m},get minValue(){return null===g?_.minValue:g},get value(){return _.value},set value(t){_.value=t,w.setValueAtTime(t,n.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof _.cancelAndHoldAtTime)null===x&&y.flush(n.context.currentTime),y.add(i(t)),_.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===x&&y.flush(n.context.currentTime),y.add(i(t));const s=Array.from(y).pop();_.cancelScheduledValues(t),e!==s&&void 0!==s&&("exponentialRampToValue"===s.type?_.exponentialRampToValueAtTime(s.value,s.endTime):"linearRampToValue"===s.type?_.linearRampToValueAtTime(s.value,s.endTime):"setValue"===s.type?_.setValueAtTime(s.value,s.startTime):"setValueCurve"===s.type&&_.setValueCurveAtTime(s.values,s.startTime,s.duration))}return w},cancelScheduledValues:t=>(null===x&&y.flush(n.context.currentTime),y.add(o(t)),_.cancelScheduledValues(t),w),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const s=n.context.currentTime;return null===x&&y.flush(s),0===Array.from(y).length&&(y.add(h(v,s)),_.setValueAtTime(v,s)),y.add(r(t,e)),_.exponentialRampToValueAtTime(t,e),w},linearRampToValueAtTime(t,e){const s=n.context.currentTime;return null===x&&y.flush(s),0===Array.from(y).length&&(y.add(h(v,s)),_.setValueAtTime(v,s)),y.add(a(t,e)),_.linearRampToValueAtTime(t,e),w},setTargetAtTime:(t,e,s)=>(null===x&&y.flush(n.context.currentTime),y.add(c(t,e,s)),_.setTargetAtTime(t,e,s),w),setValueAtTime:(t,e)=>(null===x&&y.flush(n.context.currentTime),y.add(h(t,e)),_.setValueAtTime(t,e),w),setValueCurveAtTime(t,e,s){const i=t instanceof Float32Array?t:new Float32Array(t);if(null!==p&&"webkitAudioContext"===p.name){const t=e+s,o=n.context.sampleRate,r=Math.ceil(e*o),a=Math.floor(t*o),c=a-r,h=new Float32Array(c);for(let t=0;t<c;t+=1){const n=(i.length-1)/s*((r+t)/o-e),a=Math.floor(n),c=Math.ceil(n);h[t]=a===c?i[a]:(1-(n-a))*i[a]+(1-(c-n))*i[c]}null===x&&y.flush(n.context.currentTime),y.add(l(h,e,s)),_.setValueCurveAtTime(h,e,s);const u=a/o;u<t&&d(w,h[h.length-1],u),d(w,i[i.length-1],t)}else null===x&&y.flush(n.context.currentTime),y.add(l(i,e,s)),_.setValueCurveAtTime(i,e,s);return w}};return s.set(w,_),e.set(w,n),t(w,x),w})((os=_,(t,e)=>{os.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),Ie,m,0,u.createCancelAndHoldAutomationEvent,u.createCancelScheduledValuesAutomationEvent,u.createExponentialRampToValueAutomationEvent,u.createLinearRampToValueAutomationEvent,u.createSetTargetAutomationEvent,u.createSetValueAutomationEvent,u.createSetValueCurveAutomationEvent,Pe,le);var os;const rs=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,n){const a=o(t),c={...U,...n},h=i(a,c),l=r(a),u=l?e():null;super(t,!1,h,u),this._audioBufferSourceNodeRenderer=u,this._isBufferNullified=!1,this._isBufferSet=null!==c.buffer,this._nativeAudioBufferSourceNode=h,this._onended=null,this._playbackRate=s(this,l,h.playbackRate,W,z)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const s=this._nativeAudioBufferSourceNode.onended;this._onended=null!==s&&s===e?t:s}get playbackRate(){return this._playbackRate}start(t=0,e=0,s){if(this._nativeAudioBufferSourceNode.start(t,e,s),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===s?[t,e]:[t,e,s]),"closed"!==this.context.state){E(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),B(this)&&q(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(We,ns,is,Rt,es,Ee,Ve,ge),as=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,e){const s=o(t),n=r(s),c=i(s,e,n);super(t,!1,c,n?(t=>{const e=new WeakMap;return{render(s,n){const i=e.get(n);return void 0!==i?Promise.resolve(i):(async(s,n)=>{const i=n.destination;return e.set(n,i),await t(s,n,i),i})(s,n)}}})(a):null),this._isNodeOfNativeOfflineAudioContext=n,this._nativeAudioDestinationNode=c}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw s();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(We,0,N,Rt,((t,e)=>(s,n,i)=>{const o=s.destination;if(o.channelCount!==n)try{o.channelCount=n}catch{}i&&"explicit"!==o.channelCountMode&&(o.channelCountMode="explicit"),0===o.maxChannelCount&&Object.defineProperty(o,"maxChannelCount",{value:n});const r=t(s,{channelCount:n,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return e(r,"channelCount",(t=>()=>t.call(r)),(t=>e=>{t.call(r,e);try{o.channelCount=e}catch(t){if(e>o.maxChannelCount)throw t}})),e(r,"channelCountMode",(t=>()=>t.call(r)),(t=>e=>{t.call(r,e),o.channelCountMode=e})),e(r,"channelInterpretation",(t=>()=>t.call(r)),(t=>e=>{t.call(r,e),o.channelInterpretation=e})),Object.defineProperty(r,"maxChannelCount",{get:()=>o.maxChannelCount}),r.connect(o),r})(Yt,he),Ee,Ve,De),cs=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={Q:c.Q.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,detune:c.detune.value,frequency:c.frequency.value,gain:c.gain.value,type:c.type};c=e(a,t)}return o.set(a,c),h?(await t(a,r.Q,c.Q),await t(a,r.detune,c.detune),await t(a,r.frequency,c.frequency),await t(a,r.gain,c.gain)):(await n(a,r.Q,c.Q),await n(a,r.detune,c.detune),await n(a,r.frequency,c.frequency),await n(a,r.gain,c.gain)),await i(r,a,c),c})(r,a)}}})(ts,Gt,rt,ss,De),hs=(t=>(e,s)=>t.set(e,s))(we),ls=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,n){const c=o(t),h={...bt,...n},l=i(c,h),u=r(c);super(t,!1,l,u?s():null),this._Q=e(this,u,l.Q,W,z),this._detune=e(this,u,l.detune,1200*Math.log2(W),-1200*Math.log2(W)),this._frequency=e(this,u,l.frequency,t.sampleRate/2,0),this._gain=e(this,u,l.gain,40*Math.log10(W),z),this._nativeBiquadFilterNode=l,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(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,s){try{this._nativeBiquadFilterNode.getFrequencyResponse(t,e,s)}catch(t){if(11===t.code)throw n();throw t}if(t.length!==e.length||e.length!==s.length)throw n()}})(We,is,cs,qt,Gt,Ee,Ve,hs),us=((t,e)=>(s,n,i)=>{const o=new Set;return s.connect=(i=>(r,a=0,c=0)=>{const h=0===o.size;if(e(r))return i.call(s,r,a,c),t(o,[r,a,c],(t=>t[0]===r&&t[1]===a&&t[2]===c),!0),h&&n(),r;i.call(s,r,a),t(o,[r,a],(t=>t[0]===r&&t[1]===a),!0),h&&n()})(s.connect),s.disconnect=(t=>(n,r,a)=>{const c=o.size>0;if(void 0===n)t.apply(s),o.clear();else if("number"==typeof n){t.call(s,n);for(const t of o)t[1]===n&&o.delete(t)}else{e(n)?t.call(s,n,r,a):t.call(s,n,r);for(const t of o)t[0]!==n||void 0!==r&&t[1]!==r||void 0!==a&&t[2]!==a||o.delete(t)}const h=0===o.size;c&&h&&i()})(s.disconnect),s})($,je),ps=((t,e)=>(s,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=s.createBufferSource();e(n,(()=>{const t=n.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(n,0,e)}),(()=>i.disconnect(n)))})(Rt,us),ds=((t,e)=>(s,n)=>{const i=s.createChannelMerger(n.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(s,i),jt(i,n),i})(Pe,ps),fs=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,numberOfInputs:r.numberOfInputs};r=t(o,e)}return n.set(o,r),await s(i,o,r),r})(i,o)}}})(ds,rt,De),_s=((t,e,s,n,i)=>class extends t{constructor(t,o){const r=n(t),a={...Tt,...o};super(t,!1,s(r,a),i(r)?e():null)}})(We,fs,ds,Ee,Ve),ms=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,numberOfOutputs:r.numberOfOutputs};r=t(o,e)}return n.set(o,r),await s(i,o,r),r})(i,o)}}})(Qt,rt,De),gs=((t,e,s,n,i)=>class extends t{constructor(t,o){const r=n(t),a=(t=>({...t,channelCount:t.numberOfOutputs}))({...St,...o});super(t,!1,s(r,a),i(r)?e():null)}})(We,ms,Qt,Ee,Ve),vs=((t,e,s,n)=>(i,{offset:o,...r})=>{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}),h=s(i,{...r,gain:o}),l=a.getChannelData(0);l[0]=1,l[1]=1,c.buffer=a,c.loop=!0;const u={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return c.onended},set onended(t){c.onended=t},addEventListener:(...t)=>c.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>c.dispatchEvent(t[0]),removeEventListener:(...t)=>c.removeEventListener(t[0],t[1],t[2]),start(t=0){c.start.call(c,t)},stop(t=0){c.stop.call(c,t)}};return t(i,c),n(Zt(u,h),(()=>c.connect(h)),(()=>c.disconnect(h)))})(Je,es,Yt,us),ys=((t,e,s,n,i)=>(o,r)=>{if(void 0===o.createConstantSource)return s(o,r);const a=o.createConstantSource();return jt(a,r),zt(a,r,"offset"),e(n,(()=>n(o)))||Wt(a),e(i,(()=>i(o)))||Bt(a),t(o,a),a})(Je,Te,vs,ue,de),xs=((t,e,s,n,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(c,h){const l=o.get(h);return void 0!==l?Promise.resolve(l):(async(c,h)=>{let l=s(c);const u=F(l,h);if(!u){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,offset:l.offset.value};l=e(h,t),null!==r&&l.start(r),null!==a&&l.stop(a)}return o.set(h,l),u?await t(h,c.offset,l.offset):await n(h,c.offset,l.offset),await i(c,h,l),l})(c,h)}}})(ts,ys,rt,ss,De),ws=((t,e,s,n,i,o,r)=>class extends t{constructor(t,r){const a=i(t),c={...kt,...r},h=n(a,c),l=o(a),u=l?s():null;super(t,!1,h,u),this._constantSourceNodeRenderer=u,this._nativeConstantSourceNode=h,this._offset=e(this,l,h.offset,W,z),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(t){const e="function"==typeof t?r(this,t):null;this._nativeConstantSourceNode.onended=e;const s=this._nativeConstantSourceNode.onended;this._onended=null!==s&&s===e?t:s}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){E(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),B(this)&&q(this)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})(We,is,xs,ys,Ee,Ve,ge),bs=((t,e)=>(s,n)=>{const i=s.createConvolver();if(jt(i,n),n.disableNormalization===i.normalize&&(i.normalize=!n.disableNormalization),Nt(i,n,"buffer"),n.channelCount>2)throw t();if(e(i,"channelCount",(t=>()=>t.call(i)),(e=>s=>{if(s>2)throw t();return e.call(i,s)})),"max"===n.channelCountMode)throw t();return e(i,"channelCountMode",(t=>()=>t.call(i)),(e=>s=>{if("max"===s)throw t();return e.call(i,s)})),i})(Kt,he),Ts=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={buffer:r.buffer,channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,disableNormalization:!r.normalize};r=t(o,e)}return n.set(o,r),tt(r)?await s(i,o,r.inputs[0]):await s(i,o,r),r})(i,o)}}})(bs,rt,De),Ss=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=n(t),c={...At,...r},h=s(a,c);super(t,!1,h,i(a)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=h,null!==c.buffer&&o(this,c.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(t){if(this._nativeConvolverNode.buffer=t,null===t&&null!==this._nativeConvolverNode.buffer){const t=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=t.createBuffer(1,1,t.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,null===this._nativeConvolverNode.buffer?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(t){this._nativeConvolverNode.normalize=t}})(We,Ts,bs,Ee,Ve,hs),ks=((t,e,s,n,i)=>o=>{const r=new WeakMap;return{render(a,c){const h=r.get(c);return void 0!==h?Promise.resolve(h):(async(a,c)=>{let h=s(a);const l=F(h,c);if(!l){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,delayTime:h.delayTime.value,maxDelayTime:o};h=e(c,t)}return r.set(c,h),l?await t(c,a.delayTime,h.delayTime):await n(c,a.delayTime,h.delayTime),await i(a,c,h),h})(a,c)}}})(ts,Xt,rt,ss,De),As=((t,e,s,n,i,o,r)=>class extends t{constructor(t,a){const c=i(t),h={...Ot,...a},l=n(c,h),u=o(c);super(t,!1,l,u?s(h.maxDelayTime):null),this._delayTime=e(this,u,l.delayTime),r(this,h.maxDelayTime)}get delayTime(){return this._delayTime}})(We,is,ks,Xt,Ee,Ve,hs),Cs=(t=>(e,s)=>{const n=e.createDynamicsCompressor();if(jt(n,s),s.channelCount>2)throw t();if("max"===s.channelCountMode)throw t();return zt(n,s,"attack"),zt(n,s,"knee"),zt(n,s,"ratio"),zt(n,s,"release"),zt(n,s,"threshold"),n})(Kt),Os=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={attack:c.attack.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,knee:c.knee.value,ratio:c.ratio.value,release:c.release.value,threshold:c.threshold.value};c=e(a,t)}return o.set(a,c),h?(await t(a,r.attack,c.attack),await t(a,r.knee,c.knee),await t(a,r.ratio,c.ratio),await t(a,r.release,c.release),await t(a,r.threshold,c.threshold)):(await n(a,r.attack,c.attack),await n(a,r.knee,c.knee),await n(a,r.ratio,c.ratio),await n(a,r.release,c.release),await n(a,r.threshold,c.threshold)),await i(r,a,c),c})(r,a)}}})(ts,Cs,rt,ss,De),Ds=((t,e,s,n,i,o,r,a)=>class extends t{constructor(t,i){const c=o(t),h={...Mt,...i},l=n(c,h),u=r(c);super(t,!1,l,u?s():null),this._attack=e(this,u,l.attack),this._knee=e(this,u,l.knee),this._nativeDynamicsCompressorNode=l,this._ratio=e(this,u,l.ratio),this._release=e(this,u,l.release),this._threshold=e(this,u,l.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(t){const e=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=t,t>2)throw this._nativeDynamicsCompressorNode.channelCount=e,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(t){const e=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=t,"max"===t)throw this._nativeDynamicsCompressorNode.channelCountMode=e,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return"number"==typeof this._nativeDynamicsCompressorNode.reduction.value?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}})(We,is,Os,Cs,Kt,Ee,Ve,hs),Ms=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(a,t)}return o.set(a,c),h?await t(a,r.gain,c.gain):await n(a,r.gain,c.gain),await i(r,a,c),c})(r,a)}}})(ts,Yt,rt,ss,De),Es=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=i(t),c={...Et,...r},h=n(a,c),l=o(a);super(t,!1,h,l?s():null),this._gain=e(this,l,h.gain,W,z)}get gain(){return this._gain}})(We,is,Ms,Yt,Ee,Ve),Rs=((t,e,s,n)=>(i,o,{channelCount:r,channelCountMode:a,channelInterpretation:c,feedback:h,feedforward:l})=>{const u=Ut(o,i.sampleRate),p=h instanceof Float64Array?h:new Float64Array(h),d=l instanceof Float64Array?l:new Float64Array(l),f=p.length,_=d.length,m=Math.min(f,_);if(0===f||f>20)throw n();if(0===p[0])throw e();if(0===_||_>20)throw n();if(0===d[0])throw e();if(1!==p[0]){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=s(i,u,r,r);g.channelCount=r,g.channelCountMode=a,g.channelInterpretation=c;const v=[],y=[],x=[];for(let t=0;t<r;t+=1){v.push(0);const t=new Float32Array(32),e=new Float32Array(32);t.fill(0),e.fill(0),y.push(t),x.push(e)}g.onaudioprocess=t=>{const e=t.inputBuffer,s=t.outputBuffer,n=e.numberOfChannels;for(let t=0;t<n;t+=1){const n=e.getChannelData(t),i=s.getChannelData(t);v[t]=It(p,f,d,_,m,y[t],x[t],v[t],32,n,i)}};const w=i.sampleRate/2;return Zt({get bufferSize(){return u},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)=>g.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>g.dispatchEvent(t[0]),getFrequencyResponse(e,s,n){if(e.length!==s.length||s.length!==n.length)throw t();const i=e.length;for(let t=0;t<i;t+=1){const i=-Math.PI*(e[t]/w),o=[Math.cos(i),Math.sin(i)],r=Ht($t(d,o),$t(p,o));s[t]=Math.sqrt(r[0]*r[0]+r[1]*r[1]),n[t]=Math.atan2(r[1],r[0])}},removeEventListener:(...t)=>g.removeEventListener(t[0],t[1],t[2])},g)})(qt,Rt,Jt,Kt),qs=((t,e,s,n)=>i=>t(Pt,(()=>Pt(i)))?Promise.resolve(t(n,n)).then((t=>{if(!t){const t=s(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const s=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{s.disconnect(),t(e.renderedBuffer)},s.connect(i.destination),i.startRendering()})))(Te,Yt,Jt,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const s=new e(1,1,44100),n=t(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{s.oncomplete=()=>{n.disconnect(),t(0!==s.currentTime)},s.startRendering()}))})(Yt,qe)),Vs=((t,e,s,n,i)=>(o,r)=>{const a=new WeakMap;let c=null;return{render(h,l){const u=a.get(l);return void 0!==u?Promise.resolve(u):(async(h,l)=>{let u=null,p=e(h);const d=F(p,l);if(void 0===l.createIIRFilter?u=t(l,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(p=l.createIIRFilter(r,o)),a.set(l,null===u?p:u),null!==u){if(null===c){if(null===s)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new s(h.context.destination.channelCount,h.context.length,l.sampleRate);c=(async()=>(await n(h,t,t.destination),((t,e,s,n)=>{const i=s instanceof Float64Array?s:new Float64Array(s),o=n instanceof Float64Array?n:new Float64Array(n),r=i.length,a=o.length,c=Math.min(r,a);if(1!==i[0]){for(let t=0;t<r;t+=1)o[t]/=i[0];for(let t=1;t<a;t+=1)i[t]/=i[0]}const h=new Float32Array(32),l=new Float32Array(32),u=e.createBuffer(t.numberOfChannels,t.length,t.sampleRate),p=t.numberOfChannels;for(let e=0;e<p;e+=1){const s=t.getChannelData(e),n=u.getChannelData(e);h.fill(0),l.fill(0),It(i,r,o,a,c,h,l,0,32,s,n)}return u})(await i(t),l,o,r)))()}const t=await c;return u.buffer=t,u.start(0),u}return await n(h,l,p),p})(h,l)}}})(es,rt,qe,De,qs),Is=(t=>(e,s,n)=>{if(void 0===e.createIIRFilter)return t(e,s,n);const i=e.createIIRFilter(n.feedforward,n.feedback);return jt(i,n),i})(Rs),Fs=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=n(t),c=i(a),h={...Vt,...r},l=e(a,c?null:t.baseLatency,h);super(t,!1,l,c?s(h.feedback,h.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(s,n,i)=>{if(s.length!==n.length||n.length!==i.length)throw qt();return e.call(t,s,n,i)})})(l),this._nativeIIRFilterNode=l,o(this,1)}getFrequencyResponse(t,e,s){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,s)}})(We,Is,Vs,Ee,Ve,hs),Ps=((t,e,s,n,i,o,r,a)=>(c,h)=>{const l=h.listener,{forwardX:u,forwardY:p,forwardZ:d,positionX:f,positionY:_,positionZ:m,upX:g,upY:v,upZ:y}=void 0===l.forwardX?(()=>{const u=new Float32Array(1),p=e(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),d=r(h);let f=!1,_=[0,0,-1,0,1,0],m=[0,0,0];const g=()=>{if(f)return;f=!0;const t=n(h,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[o(t,u,0),o(t,u,1),o(t,u,2),o(t,u,3),o(t,u,4),o(t,u,5)];e.some(((t,e)=>t!==_[e]))&&(l.setOrientation(...e),_=e);const s=[o(t,u,6),o(t,u,7),o(t,u,8)];s.some(((t,e)=>t!==m[e]))&&(l.setPosition(...s),m=s)},p.connect(t)},v=t=>e=>{e!==_[t]&&(_[t]=e,l.setOrientation(..._))},y=t=>e=>{e!==m[t]&&(m[t]=e,l.setPosition(...m))},x=(e,n,o)=>{const r=s(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:n});r.connect(p,0,e),r.start(),Object.defineProperty(r.offset,"defaultValue",{get:()=>n});const l=t({context:c},d,r.offset,W,z);var u,f,_,m,v,y,x;return a(l,"value",(t=>()=>t.call(l)),(t=>e=>{try{t.call(l,e)}catch(t){if(9!==t.code)throw t}g(),d&&o(e)})),l.cancelAndHoldAtTime=(u=l.cancelAndHoldAtTime,d?()=>{throw i()}:(...t)=>{const e=u.apply(l,t);return g(),e}),l.cancelScheduledValues=(f=l.cancelScheduledValues,d?()=>{throw i()}:(...t)=>{const e=f.apply(l,t);return g(),e}),l.exponentialRampToValueAtTime=(_=l.exponentialRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=_.apply(l,t);return g(),e}),l.linearRampToValueAtTime=(m=l.linearRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=m.apply(l,t);return g(),e}),l.setTargetAtTime=(v=l.setTargetAtTime,d?()=>{throw i()}:(...t)=>{const e=v.apply(l,t);return g(),e}),l.setValueAtTime=(y=l.setValueAtTime,d?()=>{throw i()}:(...t)=>{const e=y.apply(l,t);return g(),e}),l.setValueCurveAtTime=(x=l.setValueCurveAtTime,d?()=>{throw i()}:(...t)=>{const e=x.apply(l,t);return g(),e}),l};return{forwardX:x(0,0,v(0)),forwardY:x(1,0,v(1)),forwardZ:x(2,-1,v(2)),positionX:x(6,0,y(0)),positionY:x(7,0,y(1)),positionZ:x(8,0,y(2)),upX:x(3,0,v(3)),upY:x(4,1,v(4)),upZ:x(5,0,v(5))}})():l;return{get forwardX(){return u},get forwardY(){return p},get forwardZ(){return d},get positionX(){return f},get positionY(){return _},get positionZ(){return m},get upX(){return g},get upY(){return v},get upZ(){return y}}})(is,ds,ys,Jt,Kt,ae,Ve,he),Ns=new WeakMap,js=((t,e,s,n,i,o)=>class extends s{constructor(s,o){super(s),this._nativeContext=s,g.set(this,s),n(s)&&i.set(s,new Set),this._destination=new t(this,o),this._listener=e(this,s),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(t){const e="function"==typeof t?o(this,t):null;this._nativeContext.onstatechange=e;const s=this._nativeContext.onstatechange;this._onstatechange=null!==s&&s===e?t:s}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(as,Ps,Fe,Ve,Ns,ge),Ls=((t,e,s,n,i,o)=>(r,a)=>{const c=r.createOscillator();return jt(c,a),zt(c,a,"detune"),zt(c,a,"frequency"),void 0!==a.periodicWave?c.setPeriodicWave(a.periodicWave):Nt(c,a,"type"),e(s,(()=>s(r)))||Wt(c),e(n,(()=>n(r)))||o(c,r),e(i,(()=>i(r)))||Bt(c),t(r,c),c})(Je,Te,ue,pe,de,me),zs=((t,e,s,n,i)=>()=>{const o=new WeakMap;let r=null,a=null,c=null;return{set periodicWave(t){r=t},set start(t){a=t},set stop(t){c=t},render(h,l){const u=o.get(l);return void 0!==u?Promise.resolve(u):(async(h,l)=>{let u=s(h);const p=F(u,l);if(!p){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,periodicWave:null===r?void 0:r,type:u.type};u=e(l,t),null!==a&&u.start(a),null!==c&&u.stop(c)}return o.set(l,u),p?(await t(l,h.detune,u.detune),await t(l,h.frequency,u.frequency)):(await n(l,h.detune,u.detune),await n(l,h.frequency,u.frequency)),await i(h,l,u),u})(h,l)}}})(ts,Ls,rt,ss,De),Ws=((t,e,s,n,i,o,r)=>class extends t{constructor(t,r){const a=i(t),c={...ee,...r},h=s(a,c),l=o(a),u=l?n():null,p=t.sampleRate/2;super(t,!1,h,u),this._detune=e(this,l,h.detune,153600,-153600),this._frequency=e(this,l,h.frequency,p,-p),this._nativeOscillatorNode=h,this._onended=null,this._oscillatorNodeRenderer=u,null!==this._oscillatorNodeRenderer&&void 0!==c.periodicWave&&(this._oscillatorNodeRenderer.periodicWave=c.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(t){const e="function"==typeof t?r(this,t):null;this._nativeOscillatorNode.onended=e;const s=this._nativeOscillatorNode.onended;this._onended=null!==s&&s===e?t:s}get type(){return this._nativeOscillatorNode.type}set type(t){this._nativeOscillatorNode.type=t,null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.start=t),"closed"!==this.context.state){E(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),B(this)&&q(this)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})(We,is,Ls,zs,Ee,Ve,ge),Bs=(t=>(e,s)=>{const n=t(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(s),n.start(),()=>{n.stop(),n.disconnect(s)}})(es),Us=((t,e,s,n,i)=>(o,{curve:r,oversample:a,...c})=>{const h=o.createWaveShaper(),l=o.createWaveShaper();jt(h,c),jt(l,c);const u=s(o,{...c,gain:1}),p=s(o,{...c,gain:-1}),d=s(o,{...c,gain:1}),f=s(o,{...c,gain:-1});let _=null,m=!1,g=null;const v={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){u.channelCount=t,p.channelCount=t,h.channelCount=t,d.channelCount=t,l.channelCount=t,f.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){u.channelCountMode=t,p.channelCountMode=t,h.channelCountMode=t,d.channelCountMode=t,l.channelCountMode=t,f.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t,p.channelInterpretation=t,h.channelInterpretation=t,d.channelInterpretation=t,l.channelInterpretation=t,f.channelInterpretation=t},get context(){return h.context},get curve(){return g},set curve(s){if(null!==s&&s.length<2)throw e();if(null===s)h.curve=s,l.curve=s;else{const t=s.length,e=new Float32Array(t+2-t%2),n=new Float32Array(t+2-t%2);e[0]=s[0],n[0]=-s[t-1];const i=Math.ceil((t+1)/2),o=(t+1)/2-1;for(let r=1;r<i;r+=1){const a=r/i*o,c=Math.floor(a),h=Math.ceil(a);e[r]=c===h?s[c]:(1-(a-c))*s[c]+(1-(h-a))*s[h],n[r]=c===h?-s[t-1-c]:-(1-(a-c))*s[t-1-c]-(1-(h-a))*s[t-1-h]}e[i]=t%2==1?s[i-1]:(s[i-2]+s[i-1])/2,h.curve=e,l.curve=n}g=s,m&&(n(g)&&null===_?_=t(o,u):null!==_&&(_(),_=null))},get inputs(){return[u]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(t){h.oversample=t,l.oversample=t},addEventListener:(...t)=>u.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>u.dispatchEvent(t[0]),removeEventListener:(...t)=>u.removeEventListener(t[0],t[1],t[2])};return null!==r&&(v.curve=r instanceof Float32Array?r:new Float32Array(r)),a!==v.oversample&&(v.oversample=a),i(Zt(v,d),(()=>{u.connect(h).connect(d),u.connect(p).connect(l).connect(f).connect(d),m=!0,n(g)&&(_=t(o,u))}),(()=>{u.disconnect(h),h.disconnect(d),u.disconnect(p),p.disconnect(l),l.disconnect(f),f.disconnect(d),m=!1,null!==_&&(_(),_=null)}))})(Bs,Rt,Yt,ce,us),Gs=((t,e,s,n,i,o,r)=>(a,c)=>{const h=a.createWaveShaper();if(null!==o&&"webkitAudioContext"===o.name&&void 0===a.createGain().gain.automationRate)return s(a,c);jt(h,c);const l=null===c.curve||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(null!==l&&l.length<2)throw e();Nt(h,{curve:l},"curve"),Nt(h,c,"oversample");let u=null,p=!1;return r(h,"curve",(t=>()=>t.call(h)),(e=>s=>(e.call(h,s),p&&(n(s)&&null===u?u=t(a,h):n(s)||null===u||(u(),u=null)),s))),i(h,(()=>{p=!0,n(h.curve)&&(u=t(a,h))}),(()=>{p=!1,null!==u&&(u(),u=null)}))})(Bs,Rt,Us,ce,us,Pe,he),Qs=((t,e,s,n,i,o,r,a,c,h)=>(l,{coneInnerAngle:u,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:_,orientationX:m,orientationY:g,orientationZ:v,panningModel:y,positionX:x,positionY:w,positionZ:b,refDistance:T,rolloffFactor:S,...k})=>{const A=l.createPanner();if(k.channelCount>2)throw r();if("max"===k.channelCountMode)throw r();jt(A,k);const C={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},O=s(l,{...C,channelInterpretation:"speakers",numberOfInputs:6}),D=n(l,{...k,gain:1}),M=n(l,{...C,gain:1}),E=n(l,{...C,gain:0}),R=n(l,{...C,gain:0}),q=n(l,{...C,gain:0}),V=n(l,{...C,gain:0}),I=n(l,{...C,gain:0}),F=i(l,256,6,1),P=o(l,{...C,curve:new Float32Array([1,1]),oversample:"none"});let N=[m,g,v],j=[x,w,b];const L=new Float32Array(1);F.onaudioprocess=({inputBuffer:t})=>{const e=[c(t,L,0),c(t,L,1),c(t,L,2)];e.some(((t,e)=>t!==N[e]))&&(A.setOrientation(...e),N=e);const s=[c(t,L,3),c(t,L,4),c(t,L,5)];s.some(((t,e)=>t!==j[e]))&&(A.setPosition(...s),j=s)},Object.defineProperty(E.gain,"defaultValue",{get:()=>0}),Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(I.gain,"defaultValue",{get:()=>0});const z={get bufferSize(){},get channelCount(){return A.channelCount},set channelCount(t){if(t>2)throw r();D.channelCount=t,A.channelCount=t},get channelCountMode(){return A.channelCountMode},set channelCountMode(t){if("max"===t)throw r();D.channelCountMode=t,A.channelCountMode=t},get channelInterpretation(){return A.channelInterpretation},set channelInterpretation(t){D.channelInterpretation=t,A.channelInterpretation=t},get coneInnerAngle(){return A.coneInnerAngle},set coneInnerAngle(t){A.coneInnerAngle=t},get coneOuterAngle(){return A.coneOuterAngle},set coneOuterAngle(t){A.coneOuterAngle=t},get coneOuterGain(){return A.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();A.coneOuterGain=t},get context(){return A.context},get distanceModel(){return A.distanceModel},set distanceModel(t){A.distanceModel=t},get inputs(){return[D]},get maxDistance(){return A.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;A.maxDistance=t},get numberOfInputs(){return A.numberOfInputs},get numberOfOutputs(){return A.numberOfOutputs},get orientationX(){return M.gain},get orientationY(){return E.gain},get orientationZ(){return R.gain},get panningModel(){return A.panningModel},set panningModel(t){A.panningModel=t},get positionX(){return q.gain},get positionY(){return V.gain},get positionZ(){return I.gain},get refDistance(){return A.refDistance},set refDistance(t){if(t<0)throw new RangeError;A.refDistance=t},get rolloffFactor(){return A.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;A.rolloffFactor=t},addEventListener:(...t)=>D.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>D.dispatchEvent(t[0]),removeEventListener:(...t)=>D.removeEventListener(t[0],t[1],t[2])};return u!==z.coneInnerAngle&&(z.coneInnerAngle=u),p!==z.coneOuterAngle&&(z.coneOuterAngle=p),d!==z.coneOuterGain&&(z.coneOuterGain=d),f!==z.distanceModel&&(z.distanceModel=f),_!==z.maxDistance&&(z.maxDistance=_),m!==z.orientationX.value&&(z.orientationX.value=m),g!==z.orientationY.value&&(z.orientationY.value=g),v!==z.orientationZ.value&&(z.orientationZ.value=v),y!==z.panningModel&&(z.panningModel=y),x!==z.positionX.value&&(z.positionX.value=x),w!==z.positionY.value&&(z.positionY.value=w),b!==z.positionZ.value&&(z.positionZ.value=b),T!==z.refDistance&&(z.refDistance=T),S!==z.rolloffFactor&&(z.rolloffFactor=S),1===N[0]&&0===N[1]&&0===N[2]||A.setOrientation(...N),0===j[0]&&0===j[1]&&0===j[2]||A.setPosition(...j),h(Zt(z,A),(()=>{D.connect(A),t(D,P,0,0),P.connect(M).connect(O,0,0),P.connect(E).connect(O,0,1),P.connect(R).connect(O,0,2),P.connect(q).connect(O,0,3),P.connect(V).connect(O,0,4),P.connect(I).connect(O,0,5),O.connect(F).connect(l.destination)}),(()=>{D.disconnect(A),a(D,P,0,0),P.disconnect(M),M.disconnect(O),P.disconnect(E),E.disconnect(O),P.disconnect(R),R.disconnect(O),P.disconnect(q),q.disconnect(O),P.disconnect(V),V.disconnect(O),P.disconnect(I),I.disconnect(O),O.disconnect(F),F.disconnect(l.destination)}))})(et,Rt,ds,Yt,Jt,Gs,Kt,ot,ae,us),Zs=(t=>(e,s)=>{const n=e.createPanner();return void 0===n.orientationX?t(e,s):(jt(n,s),zt(n,s,"orientationX"),zt(n,s,"orientationY"),zt(n,s,"orientationZ"),zt(n,s,"positionX"),zt(n,s,"positionY"),zt(n,s,"positionZ"),Nt(n,s,"coneInnerAngle"),Nt(n,s,"coneOuterAngle"),Nt(n,s,"coneOuterGain"),Nt(n,s,"distanceModel"),Nt(n,s,"maxDistance"),Nt(n,s,"panningModel"),Nt(n,s,"refDistance"),Nt(n,s,"rolloffFactor"),n)})(Qs),Xs=((t,e,s,n,i,o,r,a,c,h)=>()=>{const l=new WeakMap;let u=null;return{render(p,d){const f=l.get(d);return void 0!==f?Promise.resolve(f):(async(p,d)=>{let f=null,_=o(p);const m={channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation},g={...m,coneInnerAngle:_.coneInnerAngle,coneOuterAngle:_.coneOuterAngle,coneOuterGain:_.coneOuterGain,distanceModel:_.distanceModel,maxDistance:_.maxDistance,panningModel:_.panningModel,refDistance:_.refDistance,rolloffFactor:_.rolloffFactor},v=F(_,d);if("bufferSize"in _)f=n(d,{...m,gain:1});else if(!v){const t={...g,orientationX:_.orientationX.value,orientationY:_.orientationY.value,orientationZ:_.orientationZ.value,positionX:_.positionX.value,positionY:_.positionY.value,positionZ:_.positionZ.value};_=i(d,t)}if(l.set(d,null===f?_:f),null!==f){if(null===u){if(null===r)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new r(6,p.context.length,d.sampleRate),n=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});n.connect(t.destination),u=(async()=>{const e=await Promise.all([p.orientationX,p.orientationY,p.orientationZ,p.positionX,p.positionY,p.positionZ].map((async(e,n)=>{const i=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===n?1:0});return await a(t,e,i.offset),i})));for(let t=0;t<6;t+=1)e[t].connect(n,0,t),e[t].start(0);return h(t)})()}const t=await u,o=n(d,{...m,gain:1});await c(p,d,o);const l=[];for(let e=0;e<t.numberOfChannels;e+=1)l.push(t.getChannelData(e));let _=[l[0][0],l[1][0],l[2][0]],v=[l[3][0],l[4][0],l[5][0]],y=n(d,{...m,gain:1}),x=i(d,{...g,orientationX:_[0],orientationY:_[1],orientationZ:_[2],positionX:v[0],positionY:v[1],positionZ:v[2]});o.connect(y).connect(x.inputs[0]),x.connect(f);for(let e=128;e<t.length;e+=128){const t=[l[0][e],l[1][e],l[2][e]],s=[l[3][e],l[4][e],l[5][e]];if(t.some(((t,e)=>t!==_[e]))||s.some(((t,e)=>t!==v[e]))){_=t,v=s;const r=e/d.sampleRate;y.gain.setValueAtTime(0,r),y=n(d,{...m,gain:0}),x=i(d,{...g,orientationX:_[0],orientationY:_[1],orientationZ:_[2],positionX:v[0],positionY:v[1],positionZ:v[2]}),y.gain.setValueAtTime(1,r),o.connect(y).connect(x.inputs[0]),x.connect(f)}}return f}return v?(await t(d,p.orientationX,_.orientationX),await t(d,p.orientationY,_.orientationY),await t(d,p.orientationZ,_.orientationZ),await t(d,p.positionX,_.positionX),await t(d,p.positionY,_.positionY),await t(d,p.positionZ,_.positionZ)):(await a(d,p.orientationX,_.orientationX),await a(d,p.orientationY,_.orientationY),await a(d,p.orientationZ,_.orientationZ),await a(d,p.positionX,_.positionX),await a(d,p.positionY,_.positionY),await a(d,p.positionZ,_.positionZ)),tt(_)?await c(p,d,_.inputs[0]):await c(p,d,_),_})(p,d)}}})(ts,ds,ys,Yt,Zs,rt,qe,ss,De,qs),Ys=((t,e,s,n,i,o,r)=>class extends t{constructor(t,a){const c=i(t),h={...se,...a},l=s(c,h),u=o(c);super(t,!1,l,u?n():null),this._nativePannerNode=l,this._orientationX=e(this,u,l.orientationX,W,z),this._orientationY=e(this,u,l.orientationY,W,z),this._orientationZ=e(this,u,l.orientationZ,W,z),this._positionX=e(this,u,l.positionX,W,z),this._positionY=e(this,u,l.positionY,W,z),this._positionZ=e(this,u,l.positionZ,W,z),r(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(t){this._nativePannerNode.coneInnerAngle=t}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(t){this._nativePannerNode.coneOuterAngle=t}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(t){this._nativePannerNode.coneOuterGain=t}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(t){this._nativePannerNode.distanceModel=t}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(t){this._nativePannerNode.maxDistance=t}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(t){this._nativePannerNode.panningModel=t}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(t){this._nativePannerNode.refDistance=t}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(t){this._nativePannerNode.rolloffFactor=t}})(We,is,Zs,Xs,Ee,Ve,hs),Hs=(t=>(e,{disableNormalization:s,imag:n,real:i})=>{const o=n instanceof Float32Array?n:new Float32Array(n),r=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(r,o,{disableNormalization:s});if(Array.from(n).length<2)throw t();return a})(N),$s=((t,e,s)=>class n{constructor(n,i){const o=e(n),r=(t=>{const{imag:e,real:s}=t;return void 0===e?void 0===s?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(s,(()=>0)),real:s}:void 0===s?{...t,imag:e,real:Array.from(e,(()=>0))}:{...t,imag:e,real:s}})({...ne,...i}),a=t(o,r);return s.add(a),a}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===n.prototype||s.has(t)}})(Hs,Ee,new WeakSet),Js=((t,e,s,n,i,o)=>{const r=16385,a=new Float32Array([1,1]),c=Math.PI/2,h={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l={...h,oversample:"none"},u=(t,o,u,p,d)=>{if(1===o)return((t,e,i,o)=>{const u=new Float32Array(r),p=new Float32Array(r);for(let t=0;t<r;t+=1){const e=t/16384*c;u[t]=Math.cos(e),p[t]=Math.sin(e)}const d=s(t,{...h,gain:0}),f=n(t,{...l,curve:u}),_=n(t,{...l,curve:a}),m=s(t,{...h,gain:0}),g=n(t,{...l,curve:p});return{connectGraph(){e.connect(d),e.connect(void 0===_.inputs?_:_.inputs[0]),e.connect(m),_.connect(i),i.connect(void 0===f.inputs?f:f.inputs[0]),i.connect(void 0===g.inputs?g:g.inputs[0]),f.connect(d.gain),g.connect(m.gain),d.connect(o,0,0),m.connect(o,0,1)},disconnectGraph(){e.disconnect(d),e.disconnect(void 0===_.inputs?_:_.inputs[0]),e.disconnect(m),_.disconnect(i),i.disconnect(void 0===f.inputs?f:f.inputs[0]),i.disconnect(void 0===g.inputs?g:g.inputs[0]),f.disconnect(d.gain),g.disconnect(m.gain),d.disconnect(o,0,0),m.disconnect(o,0,1)}}})(t,u,p,d);if(2===o)return((t,i,o,u)=>{const p=new Float32Array(r),d=new Float32Array(r),f=new Float32Array(r),_=new Float32Array(r),m=Math.floor(8192.5);for(let t=0;t<r;t+=1)if(t>m){const e=(t-m)/(16384-m)*c;p[t]=Math.cos(e),d[t]=Math.sin(e),f[t]=0,_[t]=1}else{const e=t/(16384-m)*c;p[t]=1,d[t]=0,f[t]=Math.cos(e),_[t]=Math.sin(e)}const g=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),v=s(t,{...h,gain:0}),y=n(t,{...l,curve:p}),x=s(t,{...h,gain:0}),w=n(t,{...l,curve:d}),b=n(t,{...l,curve:a}),T=s(t,{...h,gain:0}),S=n(t,{...l,curve:f}),k=s(t,{...h,gain:0}),A=n(t,{...l,curve:_});return{connectGraph(){i.connect(g),i.connect(void 0===b.inputs?b:b.inputs[0]),g.connect(v,0),g.connect(x,0),g.connect(T,1),g.connect(k,1),b.connect(o),o.connect(void 0===y.inputs?y:y.inputs[0]),o.connect(void 0===w.inputs?w:w.inputs[0]),o.connect(void 0===S.inputs?S:S.inputs[0]),o.connect(void 0===A.inputs?A:A.inputs[0]),y.connect(v.gain),w.connect(x.gain),S.connect(T.gain),A.connect(k.gain),v.connect(u,0,0),T.connect(u,0,0),x.connect(u,0,1),k.connect(u,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(void 0===b.inputs?b:b.inputs[0]),g.disconnect(v,0),g.disconnect(x,0),g.disconnect(T,1),g.disconnect(k,1),b.disconnect(o),o.disconnect(void 0===y.inputs?y:y.inputs[0]),o.disconnect(void 0===w.inputs?w:w.inputs[0]),o.disconnect(void 0===S.inputs?S:S.inputs[0]),o.disconnect(void 0===A.inputs?A:A.inputs[0]),y.disconnect(v.gain),w.disconnect(x.gain),S.disconnect(T.gain),A.disconnect(k.gain),v.disconnect(u,0,0),T.disconnect(u,0,0),x.disconnect(u,0,1),k.disconnect(u,0,1)}}})(t,u,p,d);throw i()};return(e,{channelCount:n,channelCountMode:r,pan:a,...c})=>{if("max"===r)throw i();const h=t(e,{...c,channelCount:1,channelCountMode:r,numberOfInputs:2}),l=s(e,{...c,channelCount:n,channelCountMode:r,gain:1}),p=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:d,disconnectGraph:f}=u(e,n,l,p,h);Object.defineProperty(p.gain,"defaultValue",{get:()=>0}),Object.defineProperty(p.gain,"maxValue",{get:()=>1}),Object.defineProperty(p.gain,"minValue",{get:()=>-1});const _={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){l.channelCount!==t&&(m&&f(),({connectGraph:d,disconnectGraph:f}=u(e,t,l,p,h)),m&&d()),l.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();l.channelCountMode=t},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(t){l.channelInterpretation=t},get context(){return l.context},get inputs(){return[l]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get pan(){return p.gain},addEventListener:(...t)=>l.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>l.dispatchEvent(t[0]),removeEventListener:(...t)=>l.removeEventListener(t[0],t[1],t[2])};let m=!1;return o(Zt(_,h),(()=>{d(),m=!0}),(()=>{f(),m=!1}))}})(ds,Qt,Yt,Gs,Kt,us),Ks=((t,e)=>(s,n)=>{const i=n.channelCountMode;if("clamped-max"===i)throw e();if(void 0===s.createStereoPanner)return t(s,n);const o=s.createStereoPanner();return jt(o,n),zt(o,n,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),o})(Js,Kt),tn=((t,e,s,n,i)=>()=>{const o=new WeakMap;return{render(r,a){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a)=>{let c=s(r);const h=F(c,a);if(!h){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(a,t)}return o.set(a,c),h?await t(a,r.pan,c.pan):await n(a,r.pan,c.pan),tt(c)?await i(r,a,c.inputs[0]):await i(r,a,c),c})(r,a)}}})(ts,Ks,rt,ss,De),en=((t,e,s,n,i,o)=>class extends t{constructor(t,r){const a=i(t),c={...ie,...r},h=s(a,c),l=o(a);super(t,!1,h,l?n():null),this._pan=e(this,l,h.pan)}get pan(){return this._pan}})(We,is,Ks,tn,Ee,Ve),sn=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,o){const r=n.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!F(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,curve:r.curve,oversample:r.oversample};r=t(o,e)}return n.set(o,r),tt(r)?await s(i,o,r.inputs[0]):await s(i,o,r),r})(i,o)}}})(Gs,rt,De),nn=((t,e,s,n,i,o,r)=>class extends t{constructor(t,e){const a=i(t),c={...re,...e},h=s(a,c);super(t,!0,h,o(a)?n():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=h,r(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(t){if(null===t)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(t.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=t}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(t){this._nativeWaveShaperNode.oversample=t}})(We,Rt,Gs,sn,Ee,Ve,hs),on=(t=>null!==t&&t.isSecureContext)(Ae),rn=(t=>(e,s,n)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*s)},currentTime:{configurable:!0,get:()=>e}});try{return n()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(Ae),an=new WeakMap,cn=((t,e)=>s=>{let n=t.get(s);if(void 0!==n)return n;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new e(1,1,44100),t.set(s,n),n})(an,qe),hn=on?((t,e,s,n,i,o,r,a,c,h,l,u,p)=>{let d=0;return(f,_,m={credentials:"omit"})=>{const g=l.get(f);if(void 0!==g&&g.has(_))return Promise.resolve();const v=h.get(f);if(void 0!==v){const t=v.get(_);if(void 0!==t)return t}const y=o(f),w=void 0===y.audioWorklet?i(_).then((([t,e])=>{const[n,i]=S(t,e);return s(`${n};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}\n})})(window,'_AWGS')`)})).then((()=>{const t=p._AWGS.pop();if(void 0===t)throw new SyntaxError;n(y.currentTime,y.sampleRate,(()=>t(class{},void 0,((t,s)=>{if(""===t.trim())throw e();const n=x.get(y);if(void 0!==n){if(n.has(t))throw e();A(s),k(s.parameterDescriptors),n.set(t,s)}else A(s),k(s.parameterDescriptors),x.set(y,new Map([[t,s]]))}),y.sampleRate,void 0,void 0)))})):Promise.all([i(_),Promise.resolve(t(u,u))]).then((([[t,e],s])=>{const n=d+1;d=n;const[i,o]=S(t,e),h=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${o}\n})(${s?"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{${s?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${s?"":"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${n}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),l=URL.createObjectURL(h);return y.audioWorklet.addModule(l,m).then((()=>{if(a(y))return y;const t=r(y);return t.audioWorklet.addModule(l,m).then((()=>t))})).then((t=>{if(null===c)throw new SyntaxError;try{new c(t,`__sac${n}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(l)))}));return void 0===v?h.set(f,new Map([[_,w]])):v.set(_,w),w.then((()=>{const t=l.get(f);void 0===t?l.set(f,new Set([_])):t.add(_)})).finally((()=>{const t=h.get(f);void 0!==t&&t.delete(_)})),w}})(Te,Kt,(t=>e=>new Promise(((s,n)=>{if(null===t)return void n(new SyntaxError);const i=t.document.head;if(null===i)n(new SyntaxError);else{const o=t.document.createElement("script"),r=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(r),c=t.onerror,h=()=>{t.onerror=c,URL.revokeObjectURL(a)};t.onerror=(e,s,i,o,r)=>s===a||s===t.location.href&&1===i&&1===o?(h(),n(r),!1):null!==c?c(e,s,i,o,r):void 0,o.onerror=()=>{h(),n(new SyntaxError)},o.onload=()=>{h(),s()},o.src=a,o.type="module",i.appendChild(o)}})))(Ae),rn,(async t=>{try{const e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw new DOMException("","AbortError")}),Ee,cn,Ve,ze,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const s=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(s);let o=!1,r=!1;try{await n.audioWorklet.addModule(i);const e=new t(n,"a",{numberOfOutputs:0}),s=n.createOscillator();e.port.onmessage=()=>o=!0,e.onprocessorerror=()=>r=!0,s.connect(e),s.start(0),await n.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return o&&!r})(ze,qe),Ae):void 0,ln=((t,e)=>s=>t(s)||e(s))(Ne,Ve),un=((t,e,s,n,i,o,r,a,c,h,l)=>(s,n)=>{const u=r(s)?s:o(s);if(i.has(n)){const t=new DOMException("","DataCloneError");return Promise.reject(t)}try{i.add(n)}catch{}return e(c,(()=>c(u)))?u.decodeAudioData(n).then((s=>(Ct(n).catch((()=>{})),e(a,(()=>a(s)))||l(s),t.add(s),s))):new Promise(((e,s)=>{const i=async()=>{try{await Ct(n)}catch{}},o=t=>{s(t),i()};try{u.decodeAudioData(n,(s=>{"function"!=typeof s.copyFromChannel&&(h(s),j(s)),t.add(s),i().then((()=>e(s)))}),(t=>{o(null===t?new DOMException("","EncodingError"):t)}))}catch(t){o(t)}}))})(Ge,Te,0,0,new WeakSet,Ee,ln,P,Pt,Ye,He),pn=((t,e,s,n,i,o,r,a,c,h,l,u,p,d,f,_,m,g,v,y)=>class extends f{constructor(e,s){super(e,s),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,s)=>t(this,e,s)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,n){return new s({length:e,numberOfChannels:t,sampleRate:n})}createBufferSource(){return new n(this)}createChannelMerger(t=6){return new o(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new r(this,{numberOfOutputs:t})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(t=1){return new l(this,{maxDelayTime:t})}createDynamicsCompressor(){return new u(this)}createGain(){return new p(this)}createIIRFilter(t,e){return new d(this,{feedback:e,feedforward:t})}createOscillator(){return new _(this)}createPanner(){return new m(this)}createPeriodicWave(t,e,s={disableNormalization:!1}){return new g(this,{...s,imag:e,real:t})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(t,e,s){return h(this._nativeContext,t).then((t=>("function"==typeof e&&e(t),t)),(t=>{throw"function"==typeof s&&s(t),t}))}})(hn,Ue,$e,rs,ls,_s,gs,ws,Ss,un,As,Ds,Es,Fs,js,Ws,Ys,$s,en,nn),dn=((t,e,s,n)=>class extends t{constructor(t,e){const i=s(t),o=((t,e)=>t.createMediaElementSource(e.mediaElement))(i,e);if(n(i))throw TypeError();super(t,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})(We,0,Ee,Ve),fn=((t,e,s,n)=>class extends t{constructor(t,e){const i=s(t);if(n(i))throw new TypeError;const o=((t,e)=>{const s=t.createMediaStreamDestination();return jt(s,e),1===s.numberOfOutputs&&Object.defineProperty(s,"numberOfOutputs",{get:()=>0}),s})(i,{...Ft,...e});super(t,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})(We,0,Ee,Ve),_n=((t,e,s,n)=>class extends t{constructor(t,e){const i=s(t),o=((t,{mediaStream:e})=>{const s=e.getAudioTracks();s.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const n=s.slice(0,1),i=t.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(i,"mediaStream",{value:e}),i})(i,e);if(n(i))throw new TypeError;super(t,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(We,0,Ee,Ve),mn=((t,e)=>(s,{mediaStreamTrack:n})=>{if("function"==typeof s.createMediaStreamTrackSource)return s.createMediaStreamTrackSource(n);const i=new MediaStream([n]),o=s.createMediaStreamSource(i);if("audio"!==n.kind)throw t();if(e(s))throw new TypeError;return o})(Rt,Ve),gn=((t,e,s)=>class extends t{constructor(t,n){const i=s(t);super(t,!0,e(i,n),null)}})(We,mn,Ee),vn=((t,e,s,n,i,o,r,a,c)=>class extends t{constructor(t={}){if(null===c)throw new Error("Missing the native AudioContext constructor.");let e;try{e=new c(t)}catch(t){if(12===t.code&&"sampleRate is not in range"===t.message)throw s();throw t}if(null===e)throw n();if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw s();super(e,2);const{latencyHint:i}=t,{sampleRate:o}=e;if(this._baseLatency="number"==typeof e.baseLatency?e.baseLatency:"balanced"===i?512/o:"interactive"===i||void 0===i?256/o:"playback"===i?1024/o:128*Math.max(2,Math.min(128,Math.round(i*o/128)))/o,this._nativeAudioContext=e,"webkitAudioContext"===c.name?(this._nativeGainNode=e.createGain(),this._nativeOscillatorNode=e.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(e.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,"running"===e.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),e.removeEventListener("statechange",t)};e.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then((()=>{throw e()})):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close().then((()=>{null!==this._nativeGainNode&&null!==this._nativeOscillatorNode&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),X(this)})))}createMediaElementSource(t){return new i(this,{mediaElement:t})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(t){return new r(this,{mediaStream:t})}createMediaStreamTrackSource(t){return new a(this,{mediaStreamTrack:t})}resume(){return"suspended"===this._state?new Promise(((t,e)=>{const s=()=>{this._nativeAudioContext.removeEventListener("statechange",s),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",s)})):this._nativeAudioContext.resume().catch((t=>{if(void 0===t||15===t.code)throw e();throw t}))}suspend(){return this._nativeAudioContext.suspend().catch((t=>{if(void 0===t)throw e();throw t}))}})(pn,Rt,Kt,oe,dn,fn,_n,gn,Pe),yn=(t=>e=>{const s=t.get(e);if(void 0===s)throw new Error("The context has no set of AudioWorkletNodes.");return s})(Ns),xn=(t=>(e,s)=>{t(e).add(s)})(yn),wn=(t=>(e,s,n=0,i=0)=>{const o=e[n];if(void 0===o)throw t();return pt(s)?o.connect(s,0,i):o.connect(s,0)})(N),bn=(t=>(e,s)=>{t(e).delete(s)})(yn),Tn=(t=>(e,s=void 0,n=void 0,i=0)=>void 0===s?e.forEach((t=>t.disconnect())):"number"==typeof s?Dt(t,e,s).disconnect():pt(s)?void 0===n?e.forEach((t=>t.disconnect(s))):void 0===i?Dt(t,e,n).disconnect(s,0):Dt(t,e,n).disconnect(s,0,i):void 0===n?e.forEach((t=>t.disconnect(s))):Dt(t,e,n).disconnect(s,0))(N),Sn=new WeakMap,kn=((t,e)=>s=>e(t,s))(Sn,C),An=((t,e,s,n,i,o,r,a,c,h,l,u,p)=>(d,f,_,m)=>{if(0===m.numberOfInputs&&0===m.numberOfOutputs)throw c();const g=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(g.some((t=>t<1)))throw c();if(g.length!==m.numberOfOutputs)throw e();if("explicit"!==m.channelCountMode)throw c();const v=m.channelCount*m.numberOfInputs,y=g.reduce(((t,e)=>t+e),0),x=void 0===_.parameterDescriptors?0:_.parameterDescriptors.length;if(v+x>6||y>6)throw c();const b=new MessageChannel,T=[],S=[];for(let t=0;t<m.numberOfInputs;t+=1)T.push(r(d,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),S.push(i(d,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const k=[];if(void 0!==_.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:s,name:n}of _.parameterDescriptors){const i=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==m.parameterData[n]?m.parameterData[n]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?W:e},minValue:{get:()=>void 0===s?z:s}}),k.push(i)}const A=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,v+x)}),C=Ut(f,d.sampleRate),O=a(d,C,v+x,Math.max(1,y)),D=i(d,{channelCount:Math.max(1,y),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,y)}),M=[];for(let t=0;t<m.numberOfOutputs;t+=1)M.push(n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[t]}));for(let t=0;t<m.numberOfInputs;t+=1){T[t].connect(S[t]);for(let e=0;e<m.channelCount;e+=1)S[t].connect(A,e,t*m.channelCount+e)}const E=new mt(void 0===_.parameterDescriptors?[]:_.parameterDescriptors.map((({name:t},e)=>{const s=k[e];return s.connect(A,0,v+e),s.start(0),[t,s.offset]})));A.connect(O);let R=m.channelInterpretation,q=null;const V=0===m.numberOfOutputs?[O]:M,I={get bufferSize(){return C},get channelCount(){return m.channelCount},set channelCount(t){throw s()},get channelCountMode(){return m.channelCountMode},set channelCountMode(t){throw s()},get channelInterpretation(){return R},set channelInterpretation(t){for(const e of T)e.channelInterpretation=t;R=t},get context(){return O.context},get inputs(){return T},get numberOfInputs(){return m.numberOfInputs},get numberOfOutputs(){return m.numberOfOutputs},get onprocessorerror(){return q},set onprocessorerror(t){"function"==typeof q&&I.removeEventListener("processorerror",q),q="function"==typeof t?t:null,"function"==typeof q&&I.addEventListener("processorerror",q)},get parameters(){return E},get port(){return b.port2},addEventListener:(...t)=>O.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,V),disconnect:h.bind(null,V),dispatchEvent:(...t)=>O.dispatchEvent(t[0]),removeEventListener:(...t)=>O.removeEventListener(t[0],t[1],t[2])},F=new Map;var P,N;b.port1.addEventListener=(P=b.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const s=F.get(t[1]);void 0!==s?t[1]=s:(t[1]=t=>{l(d.currentTime,d.sampleRate,(()=>e(t)))},F.set(e,t[1]))}}return P.call(b.port1,t[0],t[1],t[2])}),b.port1.removeEventListener=(N=b.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=F.get(t[1]);void 0!==e&&(F.delete(t[1]),t[1]=e)}return N.call(b.port1,t[0],t[1],t[2])});let j=null;Object.defineProperty(b.port1,"onmessage",{get:()=>j,set:t=>{"function"==typeof j&&b.port1.removeEventListener("message",j),j="function"==typeof t?t:null,"function"==typeof j&&(b.port1.addEventListener("message",j),b.port1.start())}}),_.prototype.port=b.port1;let L=null;const B=((t,e,s,n)=>{let i=w.get(t);void 0===i&&(i=new WeakMap,w.set(t,i));const o=(async(t,e)=>{const s=await(t=>new Promise(((e,s)=>{const{port1:n,port2:i}=new MessageChannel;n.onmessage=({data:t})=>{n.close(),i.close(),e(t)},n.onmessageerror=({data:t})=>{n.close(),i.close(),s(t)},i.postMessage(t)})))(e);return new t(s)})(s,n);return i.set(e,o),o})(d,I,_,m);B.then((t=>L=t));const U=xt(m.numberOfInputs,m.channelCount),G=xt(m.numberOfOutputs,g),Q=void 0===_.parameterDescriptors?[]:_.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let Z=!0;const X=()=>{m.numberOfOutputs>0&&O.disconnect(D);for(let t=0,e=0;t<m.numberOfOutputs;t+=1){const s=M[t];for(let n=0;n<g[t];n+=1)D.disconnect(s,e+n,n);e+=g[t]}},Y=new Map;O.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==L){const s=u(I);for(let n=0;n<C;n+=128){for(let e=0;e<m.numberOfInputs;e+=1)for(let s=0;s<m.channelCount;s+=1)vt(t,U[e],s,s,n);void 0!==_.parameterDescriptors&&_.parameterDescriptors.forEach((({name:e},s)=>{vt(t,Q,e,v+s,n)}));for(let t=0;t<m.numberOfInputs;t+=1)for(let e=0;e<g[t];e+=1)0===G[t][e].byteLength&&(G[t][e]=new Float32Array(128));try{const t=U.map(((t,e)=>{if(s[e].size>0)return Y.set(e,C/128),t;const n=Y.get(e);return void 0===n?[]:(t.every((t=>t.every((t=>0===t))))&&(1===n?Y.delete(e):Y.set(e,n-1)),t)})),i=l(d.currentTime+n/d.sampleRate,d.sampleRate,(()=>L.process(t,G,Q)));Z=i;for(let t=0,s=0;t<m.numberOfOutputs;t+=1){for(let i=0;i<g[t];i+=1)yt(e,G[t],i,s+i,n);s+=g[t]}}catch(t){Z=!1,I.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!Z){for(let t=0;t<m.numberOfInputs;t+=1){T[t].disconnect(S[t]);for(let e=0;e<m.channelCount;e+=1)S[n].disconnect(A,e,t*m.channelCount+e)}if(void 0!==_.parameterDescriptors){const t=_.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=k[e];t.disconnect(A,0,v+e),t.stop()}}A.disconnect(O),O.onaudioprocess=null,H?X():K();break}}}};let H=!1;const $=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),J=()=>O.connect($).connect(d.destination),K=()=>{O.disconnect($),$.disconnect()};return J(),p(I,(()=>{if(Z){K(),m.numberOfOutputs>0&&O.connect(D);for(let t=0,e=0;t<m.numberOfOutputs;t+=1){const s=M[t];for(let n=0;n<g[t];n+=1)D.connect(s,e+n,n);e+=g[t]}}H=!0}),(()=>{Z&&(J(),X()),H=!1}))})(wn,N,Rt,ds,Qt,ys,Yt,Jt,Kt,Tn,rn,kn,us),Cn=((t,e,s,n,i)=>(o,r,a,c,h,l)=>{if(null!==a)try{const e=new a(o,c,l),n=new Map;let r=null;if(Object.defineProperties(e,{channelCount:{get:()=>l.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>r,set:t=>{"function"==typeof r&&e.removeEventListener("processorerror",r),r="function"==typeof t?t:null,"function"==typeof r&&e.addEventListener("processorerror",r)}}}),e.addEventListener=(p=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const s=n.get(t[1]);void 0!==s?t[1]=s:(t[1]=s=>{"error"===s.type?(Object.defineProperties(s,{type:{value:"processorerror"}}),e(s)):e(new ErrorEvent(t[0],{...s}))},n.set(e,t[1]))}}return p.call(e,"error",t[1],t[2]),p.call(e,...t)}),e.removeEventListener=(u=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=n.get(t[1]);void 0!==e&&(n.delete(t[1]),t[1]=e)}return u.call(e,"error",t[1],t[2]),u.call(e,t[0],t[1],t[2])}),0!==l.numberOfOutputs){const t=s(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return e.connect(t).connect(o.destination),i(e,(()=>t.disconnect()),(()=>t.connect(o.destination)))}return e}catch(t){if(11===t.code)throw n();throw t}var u,p;if(void 0===h)throw n();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),e(o,r,h,l)})(Rt,An,Yt,Kt,us),On=((t,e,s,n,i,o,r,a,c,h,l,u,p,d,f,_)=>(m,g,v)=>{const y=new WeakMap;let x=null;return{render(w,b){a(b,w);const T=y.get(b);return void 0!==T?Promise.resolve(T):(async(a,w)=>{let b=l(a),T=null;const S=F(b,w),k=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(null===u){const t=k.reduce(((t,e)=>t+e),0),s=i(w,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),o=[];for(let t=0;t<a.numberOfOutputs;t+=1)o.push(n(w,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:k[t]}));const h=r(w,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});h.connect=e.bind(null,o),h.disconnect=c.bind(null,o),T=[s,o,h]}else S||(b=new u(w,m));if(y.set(w,null===T?b:T[2]),null!==T){if(null===x){if(void 0===v)throw new Error("Missing the processor constructor.");if(null===p)throw new Error("Missing the native OfflineAudioContext constructor.");const t=a.channelCount*a.numberOfInputs,e=void 0===v.parameterDescriptors?0:v.parameterDescriptors.length,s=t+e,c=async()=>{const c=new p(s,128*Math.ceil(a.context.length/128),w.sampleRate),h=[],l=[];for(let t=0;t<g.numberOfInputs;t+=1)h.push(r(c,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),l.push(i(c,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const u=await Promise.all(Array.from(a.parameters.values()).map((async t=>{const e=o(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await d(c,t,e.offset),e}))),m=n(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<g.numberOfInputs;t+=1){h[t].connect(l[t]);for(let e=0;e<g.channelCount;e+=1)l[t].connect(m,e,t*g.channelCount+e)}for(const[e,s]of u.entries())s.connect(m,0,t+e),s.start(0);return m.connect(c.destination),await Promise.all(h.map((t=>f(a,c,t)))),_(c)};x=wt(a,0===s?null:await c(),w,g,k,v,h)}const t=await x,e=s(w,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,l,u]=T;null!==t&&(e.buffer=t,e.start(0)),e.connect(c);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const s=l[t];for(let n=0;n<k[t];n+=1)c.connect(s,e+n,n);e+=k[t]}return u}if(S)for(const[e,s]of a.parameters.entries())await t(w,s,b.parameters.get(e));else for(const[t,e]of a.parameters.entries())await d(w,e,b.parameters.get(t));return await f(a,w,b),b})(w,b)}}})(ts,wn,es,ds,Qt,ys,Yt,bn,Tn,rn,rt,ze,qe,ss,De,qs),Dn=(t=>e=>t.get(e))(an),Mn=(t=>(e,s)=>{t.set(e,s)})(Sn),En=on?((t,e,s,n,i,o,r,a,c,h,l,u,p,d)=>class extends e{constructor(e,l,p){var d;const f=a(e),_=c(f),m=(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))}))({...gt,...p});(t=>{const{port1:e,port2:s}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),s.close()}})(m);const g=x.get(f),v=null==g?void 0:g.get(l),y=_||"closed"!==f.state?f:null!==(d=r(f))&&void 0!==d?d:f,w=i(y,_?null:e.baseLatency,h,l,v,m);super(e,!0,w,_?n(l,m,v):null);const b=[];w.parameters.forEach(((t,e)=>{const n=s(this,_,t);b.push([e,n])})),this._nativeAudioWorkletNode=w,this._onprocessorerror=null,this._parameters=new mt(b),_&&t(f,this);const{activeInputs:T}=o(this);u(w,T)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?d(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const s=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==s&&s===e?t:s}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(xn,We,is,On,Cn,G,Dn,Ee,Ve,ze,0,Mn,0,ge):void 0,Rn=((t,e)=>(s,n,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(s,n,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(Kt,qe),qn=((t,e,s,n,i,o,r,a)=>(c,h)=>s(c).render(c,h).then((()=>Promise.all(Array.from(n(h)).map((t=>s(t).render(t,h)))))).then((()=>i(h))).then((s=>("function"!=typeof s.copyFromChannel?(r(s),j(s)):e(o,(()=>o(s)))||a(s),t.add(s),s))))(Ge,Te,Oe,yn,qs,P,Ye,He),Vn=((t,e,s,n,i)=>class extends t{constructor(t,s,i){let o;if("number"==typeof t&&void 0!==s&&void 0!==i)o={length:s,numberOfChannels:t,sampleRate:i};else{if("object"!=typeof t)throw new Error("The given parameters are not valid.");o=t}const{length:r,numberOfChannels:a,sampleRate:c}={...te,...o},h=n(a,r,c);e(Pt,(()=>Pt(h)))||h.addEventListener("statechange",(()=>{let t=0;const e=s=>{"running"===this._state&&(t>0?(h.removeEventListener("statechange",e),s.stopImmediatePropagation(),this._waitForThePromiseToSettle(s)):t+=1)};return e})()),super(h,a),this._length=r,this._nativeOfflineAudioContext=h,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(s()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally((()=>{this._state=null,X(this)})))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout((()=>this._waitForThePromiseToSettle(t)))}})(pn,Te,Rt,Rn,qn),In=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(g,Ne),Fn=((t,e)=>s=>t.has(s)||e(s))(f,je),Pn=((t,e)=>s=>t.has(s)||e(s))(m,Le),Nn=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(g,Ve),jn=()=>(async(t,e,s,n,i,o,r,a,c,h,l,u,p,d,f,_)=>!!(t(e,e)&&t(s,s)&&t(i,i)&&t(o,o)&&t(a,a)&&t(c,c)&&t(h,h)&&t(l,l)&&t(u,u)&&t(p,p)&&t(d,d))&&(await Promise.all([t(n,n),t(r,r),t(f,f),t(_,_)])).every((t=>t)))(Te,(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createBuffer(1,1,44100);if(void 0===e.copyToChannel)return!0;const s=new Float32Array(2);try{e.copyFromChannel(s,0,0)}catch{return!1}return!0})(qe),(t=>()=>{if(null===t)return!1;if(void 0!==t.prototype&&void 0!==t.prototype.close)return!0;const e=new t,s=void 0!==e.close;try{e.close()}catch{}return s})(Pe),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);return new Promise((t=>{let s=!0;const n=n=>{s&&(s=!1,e.startRendering(),t(n instanceof TypeError))};let i;try{i=e.decodeAudioData(null,(()=>{}),n)}catch(t){n(t)}void 0!==i&&i.catch(n)}))})(qe),(t=>()=>{if(null===t)return!1;let e;try{e=new t({latencyHint:"balanced"})}catch{return!1}return e.close(),!0})(Pe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createGain(),s=e.connect(e)===e;return e.disconnect(e),s})(qe),((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const s=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),o=URL.createObjectURL(s);let r=!1;try{await i.audioWorklet.addModule(o);const e=new t(i,"a",{numberOfOutputs:0}),s=i.createOscillator();await new Promise((t=>{e.port.onmessage=()=>t(),e.port.postMessage(n.port2,[n.port2])})),e.port.onmessage=()=>r=!0,s.connect(e),s.start(0),await i.startRendering(),r=await new Promise((t=>{n.port1.onmessage=({data:e})=>t(1===e),n.port1.postMessage(0)}))}catch{}finally{n.port1.close(),URL.revokeObjectURL(o)}return r})(ze,qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createChannelMerger();if("max"===e.channelCountMode)return!0;try{e.channelCount=2}catch{return!0}return!1})(qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100);return void 0===e.createConstantSource||e.createConstantSource().offset.maxValue!==Number.POSITIVE_INFINITY})(qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100),s=e.createConvolver();s.buffer=e.createBuffer(1,1,e.sampleRate);try{s.buffer=e.createBuffer(1,1,e.sampleRate)}catch{return!1}return!0})(qe),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createConvolver();try{e.channelCount=1}catch{return!1}return!0})(qe),fe,(t=>()=>null!==t&&t.hasOwnProperty("isSecureContext"))(Ae),(t=>()=>{if(null===t)return!1;const e=new t;try{return e.createMediaStreamSource(new MediaStream),!1}catch(t){return!0}finally{e.close()}})(Pe),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);if(void 0===e.createStereoPanner)return Promise.resolve(!0);if(void 0===e.createConstantSource)return Promise.resolve(!0);const s=e.createConstantSource(),n=e.createStereoPanner();return s.channelCount=1,s.offset.value=1,n.channelCount=1,s.start(),s.connect(n).connect(e.destination),e.startRendering().then((t=>1!==t.getChannelData(0)[0]))})(qe),_e);function Ln(t){return Pn(t)}function zn(t){return Fn(t)}function Wn(t){return Nn(t)}function Bn(t){return In(t)}function Un(t){return void 0===t}function Gn(t){return void 0!==t}function Qn(t){return"function"==typeof t}function Zn(t){return"number"==typeof t}function Xn(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object}function Yn(t){return"boolean"==typeof t}function Hn(t){return Array.isArray(t)}function $n(t){return"string"==typeof t}function Jn(t){return $n(t)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(t)}function Kn(t,e){if(!t)throw new Error(e)}function ti(t,e,s=1/0){if(!(e<=t&&t<=s))throw new RangeError(`Value must be within [${e}, ${s}], got: ${t}`)}function ei(t){t.isOffline||"running"===t.state||hi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let si=!1,ni=!1;function ii(t){si=t}function oi(t){Un(t)&&si&&!ni&&(ni=!0,hi("Schedulable methods should include the provided time argument to ensure accurate timing. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}let ri=console;function ai(t){ri=t}function ci(...t){ri.log(...t)}function hi(...t){ri.warn(...t)}function li(t,e){return"value"===t||Ln(e)||zn(e)||function(t){return t instanceof $e}(e)}function ui(t,...e){if(!e.length)return t;const s=e.shift();if(Xn(t)&&Xn(s))for(const e in s)li(e,s[e])?t[e]=s[e]:Xn(s[e])?(t[e]||Object.assign(t,{[e]:{}}),ui(t[e],s[e])):Object.assign(t,{[e]:s[e]});return ui(t,...e)}function pi(t,e,s=[],n){const i={},o=Array.from(e);if(Xn(o[0])&&n&&!Reflect.has(o[0],n)&&(Object.keys(o[0]).some((e=>Reflect.has(t,e)))||(ui(i,{[n]:o[0]}),s.splice(s.indexOf(n),1),o.shift())),1===o.length&&Xn(o[0]))ui(i,o[0]);else for(let t=0;t<s.length;t++)Gn(o[t])&&(i[s[t]]=o[t]);return ui(t,i)}function di(t,e){return Un(t)?e:t}function fi(t,e){return e.forEach((e=>{Reflect.has(t,e)&&delete t[e]})),t}const _i=1e-6;function mi(t,e){return t>e+_i}function gi(t,e){return mi(t,e)||yi(t,e)}function vi(t,e){return t+_i<e}function yi(t,e){return Math.abs(t-e)<_i}function xi(t,e,s){return Math.max(Math.min(t,s),e)}const wi="15.4.2",bi="object"==typeof self?self:null,Ti=bi&&(bi.hasOwnProperty("AudioContext")||bi.hasOwnProperty("webkitAudioContext"));class Si{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||bi&&this.toString()===bi.TONE_DEBUG_CLASS)&&ci(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}Si.version=wi;class ki extends Si{constructor(){super(),this.name="Timeline",this._timeline=[];const t=pi(ki.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(Kn(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){const e=this._timeline[this.length-1];Kn(gi(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{const e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(t){const e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this}get(t,e="time"){const s=this._search(t,e);return-1!==s?this._timeline[s]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const s=this._search(t,e);return s+1<this._timeline.length?this._timeline[s+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const s=this._search(t);return s-1>=0?this._timeline[s-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(yi(this._timeline[e].time,t)){for(let s=e;s>=0&&yi(this._timeline[s].time,t);s--)e=s;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&gi(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(0===this._timeline.length)return-1;let s=0;const n=this._timeline.length;let i=n;if(n>0&&this._timeline[n-1][e]<=t)return n-1;for(;s<i;){let n=Math.floor(s+(i-s)/2);const o=this._timeline[n],r=this._timeline[n+1];if(yi(o[e],t)){for(let s=n;s<this._timeline.length&&yi(this._timeline[s][e],t);s++)n=s;return n}if(vi(o[e],t)&&mi(r[e],t))return n;mi(o[e],t)?i=n:s=n+1}return-1}_iterate(t,e=0,s=this._timeline.length-1){this._timeline.slice(e,s+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const s=this._search(t);return-1!==s&&this._iterate(e,0,s),this}forEachAfter(t,e){const s=this._search(t);return this._iterate(e,s+1),this}forEachBetween(t,e,s){let n=this._search(t),i=this._search(e);return-1!==n&&-1!==i?(this._timeline[n].time!==t&&(n+=1),this._timeline[i].time===e&&(i-=1),this._iterate(s,n,i)):-1===n&&this._iterate(s,0,i),this}forEachFrom(t,e){let s=this._search(t);for(;s>=0&&this._timeline[s].time>=t;)s--;return this._iterate(e,s+1),this}forEachAtTime(t,e){const s=this._search(t);if(-1!==s&&yi(this._timeline[s].time,t)){let n=s;for(let e=s;e>=0&&yi(this._timeline[e].time,t);e--)n=e;this._iterate((t=>{e(t)}),n,s)}return this}dispose(){return super.dispose(),this._timeline=[],this}}function Ai(t,e,s,n){var i,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o<3?i(r):o>3?i(e,s,r):i(e,s))||r);return o>3&&r&&Object.defineProperty(e,s,r),r}function Ci(t,e,s,n){return new(s||(s=Promise))((function(i,o){function r(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}c((n=n.apply(t,e||[])).next())}))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;class Oi{constructor(t,e,s,n){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(n||44100),.001),this.updateInterval=s,this._createClock()}_createWorker(){const t=new Blob([`\n\t\t\t// the initial timeout time\n\t\t\tlet timeoutTime = ${(1e3*this._updateInterval).toFixed(1)};\n\t\t\t// onmessage callback\n\t\t\tself.onmessage = function(msg){\n\t\t\t\ttimeoutTime = parseInt(msg.data);\n\t\t\t};\n\t\t\t// the tick function which posts a message\n\t\t\t// and schedules a new tick\n\t\t\tfunction tick(){\n\t\t\t\tsetTimeout(tick, timeoutTime);\n\t\t\t\tself.postMessage('tick');\n\t\t\t}\n\t\t\t// call tick initially\n\t\t\ttick();\n\t\t\t`],{type:"text/javascript"}),e=URL.createObjectURL(t),s=new Worker(e);s.onmessage=this._callback.bind(this),this._worker=s}_createTimeout(){this._timeout=setTimeout((()=>{this._createTimeout(),this._callback()}),1e3*this._updateInterval)}_createClock(){if("worker"===this._type)try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else"timeout"===this._type&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),"worker"===this._type&&(null===(e=this._worker)||void 0===e||e.postMessage(1e3*this._updateInterval))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}}class Di extends Si{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach((t=>{Un(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)})),this}once(t,e){const s=(...n)=>{e(...n),this.off(t,s)};return this.on(t,s),this}off(t,e){return t.split(/\W+/).forEach((t=>{if(Un(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(Un(e))this._events[t]=[];else{const s=this._events[t];for(let t=s.length-1;t>=0;t--)s[t]===e&&s.splice(t,1)}})),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const s=this._events[t].slice(0);for(let t=0,n=s.length;t<n;t++)s[t].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach((e=>{const s=Object.getOwnPropertyDescriptor(Di.prototype,e);Object.defineProperty(t.prototype,e,s)}))}dispose(){return super.dispose(),this._events=void 0,this}}class Mi extends Di{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}const Ei=[];function Ri(t){Ei.push(t)}const qi=[];function Vi(t){qi.push(t)}class Ii extends Mi{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new ki,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromises=new Set;const s=pi(Ii.getDefaults(),arguments,["context"]);s.context?(this._context=s.context,this._latencyHint=(null===(t=arguments[0])||void 0===t?void 0:t.latencyHint)||""):(this._context=function(t){return new vn(t)}(s.sampleRate?{latencyHint:s.latencyHint,sampleRate:s.sampleRate}:{latencyHint:s.latencyHint}),this._latencyHint=s.latencyHint),this._ticker=new Oi(this.emit.bind(this,"tick"),s.clockSource,s.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[(null===(e=arguments[0])||void 0===e?void 0:e.hasOwnProperty("updateInterval"))?"_lookAhead":"lookAhead"]=s.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){var t;return this._initialized||(t=this,Ei.forEach((e=>e(t))),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(t,e,s){return this._context.createBuffer(t,e,s)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,s){return this._context.createPeriodicWave(t,e,s)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return Kn(Bn(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return Kn(Bn(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return Kn(Bn(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}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(t){Kn(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Kn(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Kn(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Kn(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,s){return Kn(Gn(En),"AudioWorkletNode only works in a secure context (https or localhost)"),new(t instanceof(null==bi?void 0:bi.BaseAudioContext)?null==bi?void 0:bi.AudioWorkletNode:En)(t,e,s)}(this.rawContext,t,e)}addAudioWorkletModule(t){return Ci(this,void 0,void 0,(function*(){Kn(Gn(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)");const e=this.rawContext.audioWorklet.addModule(t);return this._workletPromises.add(e),e.finally((()=>this._workletPromises.delete(e))),e}))}workletsAreReady(){return Ci(this,void 0,void 0,(function*(){yield Promise.all(this._workletPromises)}))}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/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 Bn(this._context)?this._context.resume():Promise.resolve()}close(){return Ci(this,void 0,void 0,(function*(){var t;Bn(this._context)&&"closed"!==this.state&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&(t=this,qi.forEach((e=>e(t))))}))}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),s=e.getChannelData(0);for(let e=0;e<s.length;e++)s[e]=t;const n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants.set(t,n),n}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map((t=>this._constants[t].disconnect())),this.close(),this}_timeoutLoop(){const t=this.now();this._timeouts.forEachBefore(t,(t=>{try{t.callback()}finally{this._timeouts.remove(t)}}))}setTimeout(t,e){this._timeoutIds++;const s=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:s+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach((e=>{e.id===t&&this._timeouts.remove(e)})),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const s=++this._timeoutIds,n=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),n()},id:s,time:i+e})};return n(),s}}function Fi(t,e){Hn(e)?e.forEach((e=>Fi(t,e))):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function Pi(t,e){Hn(e)?e.forEach((e=>Pi(t,e))):Object.defineProperty(t,e,{writable:!0})}const Ni=()=>{};class ji extends Si{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Ni;const t=pi(ji.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,$n(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:Ni,onload:Ni,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Bi().sampleRate}set(t){return t instanceof ji?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return Ci(this,void 0,void 0,(function*(){const e=ji.load(t).then((t=>{this.set(t),this.onload(this)}));ji.downloads.push(e);try{yield e}finally{const t=ji.downloads.indexOf(e);ji.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=Hn(t)&&t[0].length>0,s=e?t.length:1,n=e?t[0].length:t.length,i=Bi(),o=i.createBuffer(s,n,i.sampleRate),r=e||1!==s?t:[t];for(let t=0;t<s;t++)o.copyToChannel(r[t],t);return this._buffer=o,this}toMono(t){if(Zn(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let s=0;s<e;s++){const e=this.toArray(s);for(let s=0;s<e.length;s++)t[s]+=e[s]}t=t.map((t=>t/e)),this.fromArray(t)}return this}toArray(t){if(Zn(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this.toArray(0);{const t=[];for(let e=0;e<this.numberOfChannels;e++)t[e]=this.getChannelData(e);return t}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){Kn(this.loaded,"Buffer is not loaded");const s=Math.floor(t*this.sampleRate),n=Math.floor(e*this.sampleRate);Kn(s<n,"The start time must be less than the end time");const i=n-s,o=Bi().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let t=0;t<this.numberOfChannels;t++)o.copyToChannel(this.getChannelData(t).subarray(s,n),t);return new ji(o)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).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(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return(new ji).fromArray(t)}static fromUrl(t){return Ci(this,void 0,void 0,(function*(){const e=new ji;return yield e.load(t)}))}static load(t){return Ci(this,void 0,void 0,(function*(){const e=""===ji.baseUrl||ji.baseUrl.endsWith("/")?ji.baseUrl:ji.baseUrl+"/",s=yield fetch(e+t);if(!s.ok)throw new Error(`could not load url: ${t}`);const n=yield s.arrayBuffer();return yield Bi().decodeAudioData(n)}))}static supportsType(t){const e=t.split("."),s=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+s)}static loaded(){return Ci(this,void 0,void 0,(function*(){for(yield Promise.resolve();ji.downloads.length;)yield ji.downloads[0]}))}}ji.baseUrl="",ji.downloads=[];class Li extends Ii{constructor(){var t,e,s;super({clockSource:"offline",context:Wn(arguments[0])?arguments[0]:(t=arguments[0],e=arguments[1]*arguments[2],s=arguments[2],new Vn(t,e,s)),lookAhead:0,updateInterval:Wn(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Wn(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return Ci(this,void 0,void 0,(function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const s=Math.floor(this.sampleRate/128);t&&e%s===0&&(yield new Promise((t=>setTimeout(t,1))))}}))}render(){return Ci(this,arguments,void 0,(function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new ji(e)}))}close(){return Promise.resolve()}}const zi=new class extends Mi{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,s){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,s){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return Ci(this,void 0,void 0,(function*(){return Promise.resolve()}))}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};let Wi=zi;function Bi(){return Wi===zi&&Ti&&Ui(new Ii),Wi}function Ui(t,e=!1){e&&Wi.dispose(),Wi=Bn(t)?new Ii(t):Wn(t)?new Li(t):t}function Gi(){return Wi.resume()}if(bi&&!bi.TONE_SILENCE_LOGGING){let t="v";"dev"===wi&&(t="");const e=` * Tone.js ${t}${wi} * `;console.log(`%c${e}`,"background: #000; color: #fff")}class Qi extends Si{constructor(t,e,s){super(),this.defaultUnits="s",this._val=e,this._units=s,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const s=parseInt(t,10),n="."===e?1.5:1;return 1===s?this._beatsToUnits(this._getTimeSignature())*n:this._beatsToUnits(4/s)*n},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(3*Math.floor(e)))},regexp:/^(\d+)t$/i},tr:{method:(t,e,s)=>{let n=0;return t&&"0"!==t&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n+=this._beatsToUnits(parseFloat(e))),s&&"0"!==s&&(n+=this._beatsToUnits(parseFloat(s)/4)),n},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof Qi&&this.fromType(this._val),Un(this._val))return this._noArg();if($n(this._val)&&Un(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(Xn(this._val)){let t=0;for(const e in this._val)if(Gn(this._val[e])){const s=this._val[e];t+=new this.constructor(this.context,e).valueOf()*s}return t}if(Gn(this._units)){const t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}return $n(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*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(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi()}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return 1e3*this.toSeconds()}}class Zi extends Qi{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{const e=new Zi(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const s=new this.constructor(this.context,t).valueOf(),n=this.valueOf();return n+(Math.round(n/s)*s-n)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const s=Math.pow(2,t);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let s=e[0],n=new Zi(this.context,e[0]).toSeconds();return e.forEach((e=>{const i=new Zi(this.context,e).toSeconds();Math.abs(i-t)<Math.abs(n-t)&&(s=e,n=i)})),s}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const s=Math.floor(e/this._getTimeSignature());let n=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=n.toString();return i.length>3&&(n=parseFloat(parseFloat(i).toFixed(3))),[s,e,n].join(":")}toTicks(){const t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return c(this.toFrequency())}_now(){return this.context.now()}}function Xi(t,e){return new Zi(Bi(),t,e)}class Yi extends Zi{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return a}static set A4(t){!function(t){a=t}(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return"midi"===this.defaultUnits?t:Yi.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){const s=Hi[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?s:Yi.mtof(s)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,s){let n=1;return t&&"0"!==t&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n*=this._beatsToUnits(parseFloat(e))),s&&"0"!==s&&(n*=this._beatsToUnits(parseFloat(s)/4)),n}}})}transpose(t){return new Yi(this.context,this.valueOf()*r(t))}harmonize(t){return t.map((t=>this.transpose(t)))}toMidi(){return c(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/Yi.A4);let s=Math.round(12*e)+57;const n=Math.floor(s/12);return n<0&&(s+=-12*n),$i[s%12]+n.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return l(t)}static ftom(t){return c(t)}}const Hi={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},$i=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function Ji(t,e){return new Yi(Bi(),t,e)}class Ki extends Zi{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}function to(t,e){return new Ki(Bi(),t,e)}class eo extends Si{constructor(){super();const t=pi(eo.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Bi()}}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(t){return oi(t),new Zi(this.context,t).toSeconds()}toFrequency(t){return new Yi(this.context,t).toFrequency()}toTicks(t){return new Ki(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach((s=>{Un(t[s])&&delete e[s]})),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach((e=>{if(Reflect.has(this,e)){const s=this[e];Gn(s)&&Gn(s.value)&&Gn(s.setValueAtTime)?t[e]=s.value:s instanceof eo?t[e]=s._getPartialProperties(t[e]):Hn(s)||Zn(s)||$n(s)||Yn(s)?t[e]=s:delete t[e]}})),t}set(t){return Object.keys(t).forEach((e=>{Reflect.has(this,e)&&Gn(this[e])&&(this[e]&&Gn(this[e].value)&&Gn(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof eo?this[e].set(t[e]):this[e]=t[e])})),this}}class so extends eo{constructor(){const t=pi(so.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,Kn(Gn(t.param)&&(Ln(t.param)||t.param instanceof so),"param must be an AudioParam");!Ln(t.param);)t.param=t.param._param;this._swappable=!!Gn(t.swappable)&&t.swappable,this._swappable?(this.input=this.context.createGain(),this._param=t.param,this.input.connect(this._param)):this._param=this.input=t.param,this._events=new ki(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,Gn(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(eo.getDefaults(),{convert:!0,units:"number"})}get value(){const t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return Gn(this._minValue)?this._minValue:"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"===this.units?0:"audioRange"===this.units?-1:"decibels"===this.units?-1/0:this._param.minValue}get maxValue(){return Gn(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return Gn(this.maxValue)&&Gn(this.minValue)&&ti(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?i(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&"decibels"===this.units?o(t):t}setValueAtTime(t,e){const s=this.toSeconds(e),n=this._fromType(t);return Kn(isFinite(n)&&isFinite(s),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this.log(this.units,"setValueAtTime",t,s),this._events.add({time:s,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,s),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),s=this._events.getAfter(e),n=this._events.get(e);let i=this._initialValue;if(null===n)i=this._initialValue;else if("setTargetAtTime"!==n.type||null!==s&&"setValueAtTime"!==s.type)if(null===s)i=n.value;else if("linearRampToValueAtTime"===s.type||"exponentialRampToValueAtTime"===s.type){let t=n.value;if("setTargetAtTime"===n.type){const e=this._events.getBefore(n.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===s.type?this._linearInterpolate(n.time,t,s.time,s.value,e):this._exponentialInterpolate(n.time,t,s.time,s.value,e)}else i=n.value;else{const t=this._events.getBefore(n.time);let s;s=null===t?this._initialValue:t.value,"setTargetAtTime"===n.type&&(i=this._exponentialApproach(n.time,s,n.value,n.constant,e))}return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===this._fromType(e)&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const s=this._fromType(t),n=this.toSeconds(e);return Kn(isFinite(s)&&isFinite(n),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(s),this._events.add({time:n,type:"linearRampToValueAtTime",value:s}),this.log(this.units,"linearRampToValueAtTime",t,n),this._param.linearRampToValueAtTime(s,n),this}exponentialRampToValueAtTime(t,e){let s=this._fromType(t);s=yi(s,0)?this._minOutput:s,this._assertRange(s);const n=this.toSeconds(e);return Kn(isFinite(s)&&isFinite(n),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:n,type:"exponentialRampToValueAtTime",value:s}),this.log(this.units,"exponentialRampToValueAtTime",t,n),this._param.exponentialRampToValueAtTime(s,n),this}exponentialRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.exponentialRampToValueAtTime(t,s+this.toSeconds(e)),this}linearRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.linearRampToValueAtTime(t,s+this.toSeconds(e)),this}targetRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.exponentialApproachValueAtTime(t,s,e),this}exponentialApproachValueAtTime(t,e,s){e=this.toSeconds(e),s=this.toSeconds(s);const n=Math.log(s+1)/Math.log(200);return this.setTargetAtTime(t,e,n),this.cancelAndHoldAtTime(e+.9*s),this.linearRampToValueAtTime(t,e+s),this}setTargetAtTime(t,e,s){const n=this._fromType(t);Kn(isFinite(s)&&s>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(n),Kn(isFinite(n)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:s,time:i,type:"setTargetAtTime",value:n}),this.log(this.units,"setTargetAtTime",t,i,s),this._param.setTargetAtTime(n,i,s),this}setValueCurveAtTime(t,e,s,n=1){s=this.toSeconds(s),e=this.toSeconds(e);const i=this._fromType(t[0])*n;this.setValueAtTime(this._toType(i),e);const o=s/(t.length-1);for(let s=1;s<t.length;s++){const i=this._fromType(t[s])*n;this.linearRampToValueAtTime(this._toType(i),e+s*o)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return Kn(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){const e=this.toSeconds(t),s=this._fromType(this.getValueAtTime(e));Kn(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+s);const n=this._events.get(e),i=this._events.getAfter(e);return n&&yi(n.time,e)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),"linearRampToValueAtTime"===i.type?this.linearRampToValueAtTime(this._toType(s),e):"exponentialRampToValueAtTime"===i.type&&this.exponentialRampToValueAtTime(this._toType(s),e)),this._events.add({time:e,type:"setValueAtTime",value:s}),this._param.setValueAtTime(s,e),this}rampTo(t,e=.1,s){return"frequency"===this.units||"bpm"===this.units||"decibels"===this.units?this.exponentialRampTo(t,e,s):this.linearRampTo(t,e,s),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const s=this._events.get(e);if(s&&"setTargetAtTime"===s.type){const n=this._events.getAfter(s.time),i=n?n.time:e+2,o=(i-e)/10;for(let s=e;s<i;s+=o)t.linearRampToValueAtTime(this.getValueAtTime(s),s)}return this._events.forEachAfter(this.context.currentTime,(e=>{"cancelScheduledValues"===e.type?t.cancelScheduledValues(e.time):"setTargetAtTime"===e.type?t.setTargetAtTime(e.value,e.time,e.constant):t[e.type](e.value,e.time)})),this}setParam(t){Kn(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,s,n,i){return s+(e-s)*Math.exp(-(i-t)/n)}_linearInterpolate(t,e,s,n,i){return e+(i-t)/(s-t)*(n-e)}_exponentialInterpolate(t,e,s,n,i){return e*Math.pow(n/e,(i-t)/(s-t))}}class no extends eo{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return Gn(this.input)?Ln(this.input)||this.input instanceof so?1:this.input.numberOfInputs:0}get numberOfOutputs(){return Gn(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return Gn(t)&&(t instanceof no||zn(t))}_getInternalNodes(){const t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach((e=>{e.channelCount=t.channelCount,e.channelCountMode=t.channelCountMode,e.channelInterpretation=t.channelInterpretation}))}_getChannelProperties(){const t=this._getInternalNodes();Kn(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,s=0){return oo(this,t,e,s),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return hi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,s=0){return ro(this,t,e,s),this}chain(...t){return io(this,...t),this}fan(...t){return t.forEach((t=>this.connect(t))),this}dispose(){return super.dispose(),Gn(this.input)&&(this.input instanceof no?this.input.dispose():zn(this.input)&&this.input.disconnect()),Gn(this.output)&&(this.output instanceof no?this.output.dispose():zn(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function io(...t){const e=t.shift();t.reduce(((t,e)=>(t instanceof no?t.connect(e):zn(t)&&oo(t,e),e)),e)}function oo(t,e,s=0,n=0){for(Kn(Gn(t),"Cannot connect from undefined node"),Kn(Gn(e),"Cannot connect to undefined node"),(e instanceof no||zn(e))&&Kn(e.numberOfInputs>0,"Cannot connect to node with no inputs"),Kn(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof no||e instanceof so;)Gn(e.input)&&(e=e.input);for(;t instanceof no;)Gn(t.output)&&(t=t.output);Ln(e)?t.connect(e,s):t.connect(e,s,n)}function ro(t,e,s=0,n=0){if(Gn(e))for(;e instanceof no||e instanceof so;)e=e.input;for(;!zn(t);)Gn(t.output)&&(t=t.output);Ln(e)?t.disconnect(e,s):zn(e)?t.disconnect(e,s,n):t.disconnect()}function ao(...t){const e=t.pop();Gn(e)&&t.forEach((t=>oo(t,e)))}class co extends no{constructor(){const t=pi(co.getDefaults(),arguments,["gain","units"]);super(t),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new so({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),Fi(this,"gain")}static getDefaults(){return Object.assign(no.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class ho extends no{constructor(){const t=pi(ho.getDefaults(),arguments,["channels"]);super(t),this.name="Split",this._splitter=this.input=this.output=this.context.createChannelSplitter(t.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign(no.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}}class lo extends no{constructor(){const t=pi(lo.getDefaults(),arguments,["type","size"]);super(t),this.name="Analyser",this._analyzers=[],this._buffers=[],this.input=this.output=this._gain=new co({context:this.context}),this._split=new ho({context:this.context,channels:t.channels}),this.input.connect(this._split),ti(t.channels,1);for(let e=0;e<t.channels;e++)this._analyzers[e]=this.context.createAnalyser(),this._split.connect(this._analyzers[e],e,0);this.size=t.size,this.type=t.type,this.smoothing=t.smoothing}static getDefaults(){return Object.assign(no.getDefaults(),{size:1024,smoothing:.8,type:"fft",channels:1})}getValue(){return this._analyzers.forEach(((t,e)=>{const s=this._buffers[e];"fft"===this._type?t.getFloatFrequencyData(s):"waveform"===this._type&&t.getFloatTimeDomainData(s)})),1===this.channels?this._buffers[0]:this._buffers}get size(){return this._analyzers[0].frequencyBinCount}set size(t){this._analyzers.forEach(((e,s)=>{e.fftSize=2*t,this._buffers[s]=new Float32Array(t)}))}get channels(){return this._analyzers.length}get type(){return this._type}set type(t){Kn("waveform"===t||"fft"===t,`Analyser: invalid type: ${t}`),this._type=t}get smoothing(){return this._analyzers[0].smoothingTimeConstant}set smoothing(t){this._analyzers.forEach((e=>e.smoothingTimeConstant=t))}dispose(){return super.dispose(),this._analyzers.forEach((t=>t.disconnect())),this._split.dispose(),this._gain.dispose(),this}}class uo extends no{constructor(){super(pi(uo.getDefaults(),arguments)),this.name="MeterBase",this.input=this.output=this._analyser=new lo({context:this.context,size:256,type:"waveform"})}dispose(){return super.dispose(),this._analyser.dispose(),this}}class po extends uo{constructor(){super(pi(po.getDefaults(),arguments)),this.name="DCMeter",this._analyser.type="waveform",this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}}class fo extends uo{constructor(){const t=pi(fo.getDefaults(),arguments,["size"]);super(t),this.name="FFT",this.normalRange=t.normalRange,this._analyser.type="fft",this.size=t.size}static getDefaults(){return Object.assign(no.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map((t=>this.normalRange?i(t):t))}get size(){return this._analyser.size}set size(t){this._analyser.size=t}get smoothing(){return this._analyser.smoothing}set smoothing(t){this._analyser.smoothing=t}getFrequencyOfIndex(t){return Kn(0<=t&&t<this.size,`index must be greater than or equal to 0 and less than ${this.size}`),t*this.context.sampleRate/(2*this.size)}}class _o extends no{constructor(t){super(t),this.onended=Ni,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new co({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const e=this.toSeconds(t);return-1!==this._startTime&&e>=this._startTime&&(-1===this._stopTime||e<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(no.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Ni})}_startGain(t,e=1){Kn(-1===this._startTime,"Source cannot be started more than once");const s=this.toSeconds(this._fadeIn);return this._startTime=t+s,this._startTime=Math.max(this._startTime,this.context.currentTime),s>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+s):this._gainNode.gain.exponentialApproachValueAtTime(e,t,s)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Kn(-1!==this._startTime,"'start' must be called before 'stop'"),this.cancelStop();const e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?"linear"===this._curve?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout((()=>{const t="exponential"===this._curve?2*e:0;this._stopSource(this.now()+t),this._onended()}),this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==Ni&&(this.onended(this),this.onended=Ni,!this.context.isOffline)){const t=()=>this.dispose();"undefined"!=typeof requestIdleCallback?requestIdleCallback(t):setTimeout(t,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Kn(-1!==this._startTime,"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=Ni,this}}class mo extends _o{constructor(){var t;const e=pi(mo.getDefaults(),arguments,["offset"]);super(e),this.name="ToneConstantSource",this._contextStarted=t=>{"running"===t&&(this._source=this.context.createConstantSource(),oo(this._source,this._gainNode),this.offset.setParam(this._source.offset),"started"===this.state&&this._source.start(0))};const s=!this.context.isOffline&&"running"!==this.context.state;s?this.context.on("statechange",this._contextStarted):(this._source=this.context.createConstantSource(),oo(this._source,this._gainNode)),this.offset=new so({context:this.context,convert:e.convert,param:s?this.context.createGain().gain:null===(t=this._source)||void 0===t?void 0:t.offset,swappable:s,units:e.units,value:e.offset,minValue:e.minValue,maxValue:e.maxValue})}static getDefaults(){return Object.assign(_o.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){var e;const s=this.toSeconds(t);return this.log("start",s),this._startGain(s),null===(e=this._source)||void 0===e||e.start(s),this}_stopSource(t){var e;"stopped"!==this.state&&(null===(e=this._source)||void 0===e||e.stop(t))}dispose(){var t;return super.dispose(),"started"===this.state&&this.stop(),null===(t=this._source)||void 0===t||t.disconnect(),this.offset.dispose(),this.context.off("statechange",this._contextStarted),this}}class go extends no{constructor(){const t=pi(go.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new mo({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(no.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,s=0){return yo(this,t,e,s),this}disconnect(t,e,s){return xo(this,t,e,s),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,s){return this._param.exponentialRampTo(t,e,s),this}linearRampTo(t,e,s){return this._param.linearRampTo(t,e,s),this}targetRampTo(t,e,s){return this._param.targetRampTo(t,e,s),this}exponentialApproachValueAtTime(t,e,s){return this._param.exponentialApproachValueAtTime(t,e,s),this}setTargetAtTime(t,e,s){return this._param.setTargetAtTime(t,e,s),this}setValueCurveAtTime(t,e,s,n){return this._param.setValueCurveAtTime(t,e,s,n),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,s){return this._param.rampTo(t,e,s),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}const vo=new WeakMap;function yo(t,e,s,n){var i;if(e instanceof so||Ln(e)||e instanceof go&&e.override){const o=e.value;e.cancelScheduledValues(0),e.setValueAtTime(0,0),(e instanceof go||e instanceof so)&&(e.overridden=!0),vo.has(t)||vo.set(t,[]),null===(i=vo.get(t))||void 0===i||i.push({destination:e,outputNum:s||0,inputNum:n||0,previousValue:o})}oo(t,e,s,n)}function xo(t,e,s,n){if((e instanceof so||Ln(e)||e instanceof go&&e.override||void 0===e)&&vo.has(t)){let i=vo.get(t);if(e&&(i=i.filter((t=>t.destination===e&&(Un(s)||t.outputNum===s)&&(Un(n)||t.inputNum===n)))),!i.length)throw new Error("Not connected to destination node");i.forEach((t=>{(t.destination instanceof go||t.destination instanceof so)&&(t.destination.overridden=!1),t.destination.setValueAtTime(t.previousValue,0)})),vo.set(t,vo.get(t).filter((t=>!i.includes(t))))}ro(t,e,s,n)}class wo extends no{constructor(){super(pi(wo.getDefaults(),arguments,["context"]))}connect(t,e=0,s=0){return yo(this,t,e,s),this}disconnect(t,e=0,s=0){return xo(this,t,e,s),this}}class bo extends wo{constructor(){const t=pi(bo.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Hn(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Qn(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(go.getDefaults(),{length:1024})}setMap(t,e=1024){const s=new Float32Array(e);for(let n=0,i=e;n<i;n++){const e=n/(i-1)*2-1;s[n]=t(e,n)}return this.curve=s,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){Kn(["none","2x","4x"].some((e=>e.includes(t))),"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class To extends wo{constructor(){super(...arguments),this.name="Abs",this._abs=new bo({context:this.context,mapping:t=>Math.abs(t)<.001?0:Math.abs(t)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}}class So extends no{constructor(){const t=pi(So.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OnePoleFilter",this._frequency=t.frequency,this._type=t.type,this.input=new co({context:this.context}),this.output=new co({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign(no.getDefaults(),{frequency:880,type:"lowpass"})}_createFilter(){const t=this._filter,e=this.toFrequency(this._frequency),s=1/(2*Math.PI*e);if("lowpass"===this._type){const t=1/(s*this.context.sampleRate),e=t-1;this._filter=this.context.createIIRFilter([t,0],[1,e])}else{const t=1/(s*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,t])}this.input.chain(this._filter,this.output),t&&this.context.setTimeout((()=>{this.disposed||(this.input.disconnect(t),t.disconnect())}),this.blockTime)}get frequency(){return this._frequency}set frequency(t){this._frequency=t,this._createFilter()}get type(){return this._type}set type(t){this._type=t,this._createFilter()}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let s=0;s<t;s++){const n=19980*Math.pow(s/t,2)+20;e[s]=n}const s=new Float32Array(t),n=new Float32Array(t);return this._filter.getFrequencyResponse(e,s,n),s}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this._filter.disconnect(),this}}class ko extends no{constructor(){const t=pi(ko.getDefaults(),arguments,["smoothing"]);super(t),this.name="Follower",this._abs=this.input=new To({context:this.context}),this._lowpass=this.output=new So({context:this.context,frequency:1/this.toSeconds(t.smoothing),type:"lowpass"}),this._abs.connect(this._lowpass),this._smoothing=t.smoothing}static getDefaults(){return Object.assign(no.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}}class Ao extends uo{constructor(){const t=pi(Ao.getDefaults(),arguments,["smoothing"]);super(t),this.name="Meter",this.input=this.output=this._analyser=new lo({context:this.context,size:256,type:"waveform",channels:t.channelCount}),this.smoothing=t.smoothing,this.normalRange=t.normalRange,this._rms=new Array(t.channelCount),this._rms.fill(0)}static getDefaults(){return Object.assign(uo.getDefaults(),{smoothing:.8,normalRange:!1,channelCount:1})}getLevel(){return hi("'getLevel' has been changed to 'getValue'"),this.getValue()}getValue(){const t=this._analyser.getValue(),e=(1===this.channels?[t]:t).map(((t,e)=>{const s=t.reduce(((t,e)=>t+e*e),0),n=Math.sqrt(s/t.length);return this._rms[e]=Math.max(n,this._rms[e]*this.smoothing),this.normalRange?this._rms[e]:o(this._rms[e])}));return 1===this.channels?e[0]:e}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}}class Co extends uo{constructor(){const t=pi(Co.getDefaults(),arguments,["size"]);super(t),this.name="Waveform",this._analyser.type="waveform",this.size=t.size}static getDefaults(){return Object.assign(uo.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(t){this._analyser.size=t}}class Oo extends no{constructor(){const t=pi(Oo.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new so({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",Fi(this,"pan")}static getDefaults(){return Object.assign(no.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}class Do extends no{constructor(){const t=pi(Do.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new co({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,Fi(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class Mo extends no{constructor(){const t=pi(Mo.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new Oo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,Fi(this,["pan","volume"])}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class Eo extends no{constructor(){const t=pi(Eo.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new co({context:this.context}),Eo._allSolos.has(this.context)||Eo._allSolos.set(this.context,new Set),Eo._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(no.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),Eo._allSolos.get(this.context).forEach((t=>t._updateSolo()))}get muted(){return 0===this.input.gain.value}_addSolo(){Eo._soloed.has(this.context)||Eo._soloed.set(this.context,new Set),Eo._soloed.get(this.context).add(this)}_removeSolo(){Eo._soloed.has(this.context)&&Eo._soloed.get(this.context).delete(this)}_isSoloed(){return Eo._soloed.has(this.context)&&Eo._soloed.get(this.context).has(this)}_noSolos(){return!Eo._soloed.has(this.context)||Eo._soloed.has(this.context)&&0===Eo._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),Eo._allSolos.get(this.context).delete(this),this._removeSolo(),this}}Eo._allSolos=new Map,Eo._soloed=new Map;class Ro extends no{constructor(){const t=pi(Ro.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new Eo({solo:t.solo,context:this.context}),this._panVol=this.output=new Mo({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),Fi(this,["pan","volume"])}static getDefaults(){return Object.assign(no.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return Ro.buses.has(t)||Ro.buses.set(t,new co({context:this.context})),Ro.buses.get(t)}send(t,e=0){const s=this._getBus(t),n=new co({context:this.context,units:"decibels",gain:e});return this.connect(n),n.connect(s),n}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}Ro.buses=new Map;class qo extends wo{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new bo({context:this.context,mapping:t=>2*Math.abs(t)-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Vo extends no{constructor(){const t=pi(Vo.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new qo({context:this.context}),this.a=new co({context:this.context,gain:0}),this.b=new co({context:this.context,gain:0}),this.output=new co({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new go({context:this.context,units:"normalRange",value:t.fade}),Fi(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",oo(this._split,this.a.gain,0),oo(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(no.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 Io extends no{constructor(){const t=pi(Io.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(no.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}class Fo extends go{constructor(){super(pi(Fo.getDefaults(),arguments,["value"])),this.override=!1,this.name="Add",this._sum=new co({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,io(this._constantSource,this._sum)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class Po extends go{constructor(){const t=pi(Po.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new co({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class No extends wo{constructor(){super(...arguments),this.name="Negate",this._multiply=new Po({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}}class jo extends go{constructor(){super(pi(jo.getDefaults(),arguments,["value"])),this.override=!1,this.name="Subtract",this._sum=new co({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new No({context:this.context}),this.subtrahend=this._param,io(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}}class Lo extends no{constructor(){super(pi(Lo.getDefaults(),arguments)),this.name="MidSideMerge",this.mid=new co({context:this.context}),this.side=new co({context:this.context}),this._left=new Fo({context:this.context}),this._leftMult=new Po({context:this.context,value:Math.SQRT1_2}),this._right=new jo({context:this.context}),this._rightMult=new Po({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Io({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 zo extends no{constructor(){super(pi(zo.getDefaults(),arguments)),this.name="MidSideSplit",this._split=this.input=new ho({channels:2,context:this.context}),this._midAdd=new Fo({context:this.context}),this.mid=new Po({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new jo({context:this.context}),this.side=new Po({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 Wo extends no{constructor(){super(pi(Wo.getDefaults(),arguments)),this.name="Mono",this.input=new co({context:this.context}),this._merge=this.output=new Io({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 Bo extends no{constructor(){const t=pi(Bo.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new so({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new so({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new so({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new so({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(no.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Kn(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let s=0;s<t;s++){const n=19980*Math.pow(s/t,2)+20;e[s]=n}const s=new Float32Array(t),n=new Float32Array(t),i=this.context.createBiquadFilter();return i.type=this.type,i.Q.value=this.Q.value,i.frequency.value=this.frequency.value,i.gain.value=this.gain.value,i.getFrequencyResponse(e,s,n),s}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}class Uo extends no{constructor(){const t=pi(Uo.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this._filters=[],this._filters=[],this.Q=new go({context:this.context,units:"positive",value:t.Q}),this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this.detune=new go({context:this.context,units:"cents",value:t.detune}),this.gain=new go({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,Fi(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(no.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Kn(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),`Invalid filter type: ${t}`),this._type=t,this._filters.forEach((e=>e.type=t))}get rolloff(){return this._rolloff}set rolloff(t){const e=Zn(t)?t:parseInt(t,10),s=[-12,-24,-48,-96];let n=s.indexOf(e);Kn(-1!==n,`rolloff can only be ${s.join(", ")}`),n+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach((t=>t.disconnect())),this._filters=new Array(n);for(let t=0;t<n;t++){const e=new Bo({context:this.context});e.type=this._type,this.frequency.connect(e.frequency),this.detune.connect(e.detune),this.Q.connect(e.Q),this.gain.connect(e.gain),this._filters[t]=e}this._internalChannels=this._filters,io(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){const e=new Bo({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),s=new Float32Array(t).map((()=>1));return this._filters.forEach((()=>{e.getFrequencyResponse(t).forEach(((t,e)=>s[e]*=t))})),e.dispose(),s}dispose(){return super.dispose(),this._filters.forEach((t=>{t.dispose()})),Pi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class Go extends no{constructor(){const t=pi(Go.getDefaults(),arguments,["lowFrequency","highFrequency"]);super(t),this.name="MultibandSplit",this.input=new co({context:this.context}),this.output=void 0,this.low=new Uo({context:this.context,frequency:0,type:"lowpass"}),this._lowMidFilter=new Uo({context:this.context,frequency:0,type:"highpass"}),this.mid=new Uo({context:this.context,frequency:0,type:"lowpass"}),this.high=new Uo({context:this.context,frequency:0,type:"highpass"}),this._internalChannels=[this.low,this.mid,this.high],this.lowFrequency=new go({context:this.context,units:"frequency",value:t.lowFrequency}),this.highFrequency=new go({context:this.context,units:"frequency",value:t.highFrequency}),this.Q=new go({context:this.context,units:"positive",value:t.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),Fi(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(no.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),Pi(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 Qo extends no{constructor(){super(...arguments),this.name="Listener",this.positionX=new so({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new so({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new so({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new so({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new so({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new so({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new so({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new so({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new so({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(no.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}}Ri((t=>{t.listener=new Qo({context:t})})),Vi((t=>{t.listener.dispose()}));class Zo extends no{constructor(){const t=pi(Zo.getDefaults(),arguments,["positionX","positionY","positionZ"]);super(t),this.name="Panner3D",this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=t.panningModel,this.maxDistance=t.maxDistance,this.distanceModel=t.distanceModel,this.coneOuterGain=t.coneOuterGain,this.coneOuterAngle=t.coneOuterAngle,this.coneInnerAngle=t.coneInnerAngle,this.refDistance=t.refDistance,this.rolloffFactor=t.rolloffFactor,this.positionX=new so({context:this.context,param:this._panner.positionX,value:t.positionX}),this.positionY=new so({context:this.context,param:this._panner.positionY,value:t.positionY}),this.positionZ=new so({context:this.context,param:this._panner.positionZ,value:t.positionZ}),this.orientationX=new so({context:this.context,param:this._panner.orientationX,value:t.orientationX}),this.orientationY=new so({context:this.context,param:this._panner.orientationY,value:t.orientationY}),this.orientationZ=new so({context:this.context,param:this._panner.orientationZ,value:t.orientationZ})}static getDefaults(){return Object.assign(no.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(t,e,s){return this.positionX.value=t,this.positionY.value=e,this.positionZ.value=s,this}setOrientation(t,e,s){return this.orientationX.value=t,this.orientationY.value=e,this.orientationZ.value=s,this}get panningModel(){return this._panner.panningModel}set panningModel(t){this._panner.panningModel=t}get refDistance(){return this._panner.refDistance}set refDistance(t){this._panner.refDistance=t}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(t){this._panner.rolloffFactor=t}get distanceModel(){return this._panner.distanceModel}set distanceModel(t){this._panner.distanceModel=t}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(t){this._panner.coneInnerAngle=t}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(t){this._panner.coneOuterAngle=t}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(t){this._panner.coneOuterGain=t}get maxDistance(){return this._panner.maxDistance}set maxDistance(t){this._panner.maxDistance=t}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 Xo extends no{constructor(){const t=pi(Xo.getDefaults(),arguments);super(t),this.name="Recorder",this.input=new co({context:this.context}),Kn(Xo.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:t.mimeType})}static getDefaults(){return no.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return null!==bi&&Reflect.has(bi,"MediaRecorder")}get state(){return"inactive"===this._recorder.state?"stopped":"paused"===this._recorder.state?"paused":"started"}start(){return Ci(this,void 0,void 0,(function*(){Kn("started"!==this.state,"Recorder is already started");const t=new Promise((t=>{const e=()=>{this._recorder.removeEventListener("start",e,!1),t()};this._recorder.addEventListener("start",e,!1)}));return"stopped"===this.state?this._recorder.start():this._recorder.resume(),yield t}))}stop(){return Ci(this,void 0,void 0,(function*(){Kn("stopped"!==this.state,"Recorder is not started");const t=new Promise((t=>{const e=s=>{this._recorder.removeEventListener("dataavailable",e,!1),t(s.data)};this._recorder.addEventListener("dataavailable",e,!1)}));return this._recorder.stop(),yield t}))}pause(){return Kn("started"===this.state,"Recorder must be started"),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}}class Yo extends no{constructor(){const t=pi(Yo.getDefaults(),arguments,["threshold","ratio"]);super(t),this.name="Compressor",this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor,this.threshold=new so({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:"decibels",value:t.threshold}),this.attack=new so({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:"time",value:t.attack}),this.release=new so({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:"time",value:t.release}),this.knee=new so({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:"decibels",value:t.knee}),this.ratio=new so({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:"positive",value:t.ratio}),Fi(this,["knee","release","attack","ratio","threshold"])}static getDefaults(){return Object.assign(no.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 Ho extends wo{constructor(){super(pi(Ho.getDefaults(),arguments)),this.name="GreaterThanZero",this._thresh=this.output=new bo({context:this.context,length:127,mapping:t=>t<=0?0:1}),this._scale=this.input=new Po({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}}class $o extends go{constructor(){const t=pi($o.getDefaults(),arguments,["value"]);super(t),this.name="GreaterThan",this.override=!1,this._subtract=this.input=new jo({context:this.context,value:t.value}),this._gtz=this.output=new Ho({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,Fi(this,"comparator"),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(go.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}}class Jo extends no{constructor(){const t=pi(Jo.getDefaults(),arguments,["threshold","smoothing"]);super(t),this.name="Gate",this._follower=new ko({context:this.context,smoothing:t.smoothing}),this._gt=new $o({context:this.context,value:i(t.threshold)}),this.input=new co({context:this.context}),this._gate=this.output=new co({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign(no.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return o(this._gt.value)}set threshold(t){this._gt.value=i(t)}get smoothing(){return this._follower.smoothing}set smoothing(t){this._follower.smoothing=t}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}}class Ko extends no{constructor(){const t=pi(Ko.getDefaults(),arguments,["threshold"]);super(t),this.name="Limiter",this._compressor=this.input=this.output=new Yo({context:this.context,ratio:20,attack:.003,release:.01,threshold:t.threshold}),this.threshold=this._compressor.threshold,Fi(this,"threshold")}static getDefaults(){return Object.assign(no.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}}class tr extends no{constructor(){const t=pi(tr.getDefaults(),arguments);super(t),this.name="MidSideCompressor",this._midSideSplit=this.input=new zo({context:this.context}),this._midSideMerge=this.output=new Lo({context:this.context}),this.mid=new Yo(Object.assign(t.mid,{context:this.context})),this.side=new Yo(Object.assign(t.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),Fi(this,["mid","side"])}static getDefaults(){return Object.assign(no.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 er extends no{constructor(){const t=pi(er.getDefaults(),arguments);super(t),this.name="MultibandCompressor",this._splitter=this.input=new Go({context:this.context,lowFrequency:t.lowFrequency,highFrequency:t.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new co({context:this.context}),this.low=new Yo(Object.assign(t.low,{context:this.context})),this.mid=new Yo(Object.assign(t.mid,{context:this.context})),this.high=new Yo(Object.assign(t.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),Fi(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(no.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}}function sr(t,e=1/0){const s=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return s.get(this)},set:function(n){ti(n,t,e),s.set(this,n)}})}}function nr(t,e=1/0){const s=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return s.get(this)},set:function(n){ti(this.toSeconds(n),t,e),s.set(this,n)}})}}class ir extends no{constructor(){const t=pi(ir.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new go({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(no.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if($n(t))return t;{let s;for(s in or)if(or[s][e]===t)return s;return t}}_setCurve(t,e,s){if($n(s)&&Reflect.has(or,s)){const n=or[s];Xn(n)?"_decayCurve"!==t&&(this[t]=n[e]):this[t]=n}else{if(!Hn(s)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+s);this[t]=s}}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let s=this.toSeconds(this.attack);const n=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0&&(s=(1-i)/(1/s)),s<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if("linear"===this._attackCurve)this._sig.linearRampTo(e,s,t);else if("exponential"===this._attackCurve)this._sig.targetRampTo(e,s,t);else{this._sig.cancelAndHoldAtTime(t);let n=this._attackCurve;for(let t=1;t<n.length;t++)if(n[t-1]<=i&&i<=n[t]){n=this._attackCurve.slice(t),n[0]=i;break}this._sig.setValueCurveAtTime(n,t,s,e)}if(n&&this.sustain<1){const i=e*this.sustain,o=t+s;this.log("decay",o),"linear"===this._decayCurve?this._sig.linearRampToValueAtTime(i,n+o):this._sig.exponentialApproachValueAtTime(i,o,n)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const s=this.toSeconds(this.release);s<this.sampleTime?this._sig.setValueAtTime(0,t):"linear"===this._releaseCurve?this._sig.linearRampTo(0,s,t):"exponential"===this._releaseCurve?this._sig.targetRampTo(0,s,t):(Kn(Hn(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,s,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,s=1){return e=this.toSeconds(e),this.triggerAttack(e,s),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,s=0){return yo(this,t,e,s),this}disconnect(t,e=0,s=0){return xo(this,t,e,s),this}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){const e=t/this.context.sampleRate,s=new Li(1,e,this.context.sampleRate),n=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=n+this.toSeconds(this.release),o=.1*i,r=i+o,a=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/r,decay:e*this.toSeconds(this.decay)/r,release:e*this.toSeconds(this.release)/r,context:s}));return a._sig.toDestination(),a.triggerAttackRelease(e*(n+o)/r,0),(yield s.render()).getChannelData(0)}))}dispose(){return super.dispose(),this._sig.dispose(),this}}Ai([nr(0)],ir.prototype,"attack",void 0),Ai([nr(0)],ir.prototype,"decay",void 0),Ai([sr(0,1)],ir.prototype,"sustain",void 0),Ai([nr(0)],ir.prototype,"release",void 0);const or=(()=>{const t=128;let e,s;const n=[];for(e=0;e<t;e++)n[e]=Math.sin(e/127*(Math.PI/2));const i=[];for(e=0;e<127;e++){s=e/127;const t=Math.sin(s*(2*Math.PI)*6.4-Math.PI/2)+1;i[e]=t/10+.83*s}i[127]=1;const o=[];for(e=0;e<t;e++)o[e]=Math.ceil(e/127*5)/5;const r=[];for(e=0;e<t;e++)s=e/127,r[e]=.5*(1-Math.cos(Math.PI*s));const a=[];for(e=0;e<t;e++){s=e/127;const t=4*Math.pow(s,3)+.2,n=Math.cos(t*Math.PI*2*s);a[e]=Math.abs(n*(1-s))}function c(t){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=1-t[s];return e}return{bounce:{In:c(a),Out:a},cosine:{In:n,Out:(h=n,h.slice(0).reverse())},exponential:"exponential",linear:"linear",ripple:{In:i,Out:c(i)},sine:{In:r,Out:c(r)},step:{In:o,Out:c(o)}};var h})();class rr extends ir{constructor(){super(pi(rr.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new co({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 ar extends wo{constructor(){const t=pi(ar.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new bo({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(wo.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class cr extends wo{constructor(){const t=pi(cr.getDefaults(),arguments,["min","max"]);super(t),this.name="Scale",this._mult=this.input=new Po({context:this.context,value:t.max-t.min}),this._add=this.output=new Fo({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(wo.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(t){this._min=t,this._setRange()}get max(){return this._max}set max(t){this._max=t,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 hr extends ir{constructor(){const t=pi(hr.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="FrequencyEnvelope",this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new ar({context:this.context,value:t.exponent}),this._scale=this.output=new cr({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(ir.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){const e=this.toFrequency(t);ti(e,0),this._baseFrequency=e,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._scale.max=this._baseFrequency*Math.pow(2,t)}get exponent(){return this._exponent.value}set exponent(t){this._exponent.value=t}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class lr extends no{constructor(){const t=pi(lr.getDefaults(),arguments,["url","onload"]);super(t),this.name="Convolver",this._convolver=this.context.createConvolver(),this._buffer=new ji(t.url,(e=>{this.buffer=e,t.onload()})),this.input=new co({context:this.context}),this.output=new co({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=t.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign(no.getDefaults(),{normalize:!0,onload:Ni})}load(t){return Ci(this,void 0,void 0,(function*(){this.buffer=yield this._buffer.load(t)}))}get buffer(){return this._buffer.length?this._buffer:null}set buffer(t){t&&this._buffer.set(t),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));const e=this._buffer.get();this._convolver.buffer=e||null}get normalize(){return this._convolver.normalize}set normalize(t){this._convolver.normalize=t}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}}class ur extends no{constructor(){const t=pi(ur.getDefaults(),arguments,["low","mid","high"]);super(t),this.name="EQ3",this.output=new co({context:this.context}),this._internalChannels=[],this.input=this._multibandSplit=new Go({context:this.context,highFrequency:t.highFrequency,lowFrequency:t.lowFrequency}),this._lowGain=new co({context:this.context,gain:t.low,units:"decibels"}),this._midGain=new co({context:this.context,gain:t.mid,units:"decibels"}),this._highGain=new co({context:this.context,gain:t.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),Fi(this,["low","mid","high","lowFrequency","highFrequency"]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign(no.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),Pi(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}}const pr=new Set;function dr(t){pr.add(t)}function fr(t,e){const s=`registerProcessor("${t}", ${e})`;pr.add(s)}class _r extends no{constructor(t){super(t),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=Ni;const e=URL.createObjectURL(new Blob([Array.from(pr).join("\n")],{type:"text/javascript"})),s=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain;let n=_r._workletPromises.get(this.context);t.workletOptions&&(this.workletOptions=Object.assign({},this.workletOptions,t.workletOptions)),void 0===n&&(n=this.context.addAudioWorkletModule(e),_r._workletPromises.set(this.context,n)),n.then((()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(s,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}}_r._workletPromises=new WeakMap,dr('\n\t/**\n\t * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}. \n\t */\n\tclass ToneAudioWorkletProcessor extends AudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\t\n\t\t\tsuper(options);\n\t\t\t/**\n\t\t\t * If the processor was disposed or not. Keep alive until its disposed.\n\t\t\t */\n\t\t\tthis.disposed = false;\n\t\t \t/** \n\t\t\t * The number of samples in the processing block\n\t\t\t */\n\t\t\tthis.blockSize = 128;\n\t\t\t/**\n\t\t\t * the sample rate\n\t\t\t */\n\t\t\tthis.sampleRate = sampleRate;\n\n\t\t\tthis.port.onmessage = (event) => {\n\t\t\t\t// when it receives a dispose \n\t\t\t\tif (event.data === "dispose") {\n\t\t\t\t\tthis.disposed = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n'),dr("\n\t/**\n\t * Abstract class for a single input/output processor. \n\t * has a 'generate' function which processes one sample at a time\n\t */\n\tclass SingleIOProcessor extends ToneAudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(Object.assign(options, {\n\t\t\t\tnumberOfInputs: 1,\n\t\t\t\tnumberOfOutputs: 1\n\t\t\t}));\n\t\t\t/**\n\t\t\t * Holds the name of the parameter and a single value of that\n\t\t\t * parameter at the current sample\n\t\t\t * @type { [name: string]: number }\n\t\t\t */\n\t\t\tthis.params = {}\n\t\t}\n\n\t\t/**\n\t\t * Generate an output sample from the input sample and parameters\n\t\t * @abstract\n\t\t * @param input number\n\t\t * @param channel number\n\t\t * @param parameters { [name: string]: number }\n\t\t * @returns number\n\t\t */\n\t\tgenerate(){}\n\n\t\t/**\n\t\t * Update the private params object with the \n\t\t * values of the parameters at the given index\n\t\t * @param parameters { [name: string]: Float32Array },\n\t\t * @param index number\n\t\t */\n\t\tupdateParams(parameters, index) {\n\t\t\tfor (const paramName in parameters) {\n\t\t\t\tconst param = parameters[paramName];\n\t\t\t\tif (param.length > 1) {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][index];\n\t\t\t\t} else {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][0];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Process a single frame of the audio\n\t\t * @param inputs Float32Array[][]\n\t\t * @param outputs Float32Array[][]\n\t\t */\n\t\tprocess(inputs, outputs, parameters) {\n\t\t\tconst input = inputs[0];\n\t\t\tconst output = outputs[0];\n\t\t\t// get the parameter values\n\t\t\tconst channelCount = Math.max(input && input.length || 0, output.length);\n\t\t\tfor (let sample = 0; sample < this.blockSize; sample++) {\n\t\t\t\tthis.updateParams(parameters, sample);\n\t\t\t\tfor (let channel = 0; channel < channelCount; channel++) {\n\t\t\t\t\tconst inputSample = input && input.length ? input[channel][sample] : 0;\n\t\t\t\t\toutput[channel][sample] = this.generate(inputSample, channel, this.params);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn !this.disposed;\n\t\t}\n\t};\n"),dr("\n\t/**\n\t * A multichannel buffer for use within an AudioWorkletProcessor as a delay line\n\t */\n\tclass DelayLine {\n\n\t\tconstructor(size, channels) {\n\t\t\tthis.buffer = [];\n\t\t\tthis.writeHead = []\n\t\t\tthis.size = size;\n\n\t\t\t// create the empty channels\n\t\t\tfor (let i = 0; i < channels; i++) {\n\t\t\t\tthis.buffer[i] = new Float32Array(this.size);\n\t\t\t\tthis.writeHead[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Push a value onto the end\n\t\t * @param channel number\n\t\t * @param value number\n\t\t */\n\t\tpush(channel, value) {\n\t\t\tthis.writeHead[channel] += 1;\n\t\t\tif (this.writeHead[channel] >= this.size) {\n\t\t\t\tthis.writeHead[channel] = 0;\n\t\t\t}\n\t\t\tthis.buffer[channel][this.writeHead[channel]] = value;\n\t\t}\n\n\t\t/**\n\t\t * Get the recorded value of the channel given the delay\n\t\t * @param channel number\n\t\t * @param delay number delay samples\n\t\t */\n\t\tget(channel, delay) {\n\t\t\tlet readHead = this.writeHead[channel] - Math.floor(delay);\n\t\t\tif (readHead < 0) {\n\t\t\t\treadHead += this.size;\n\t\t\t}\n\t\t\treturn this.buffer[channel][readHead];\n\t\t}\n\n\t\t/**\n\t\t * Get the reverse recorded value of the channel given the delay\n\t\t * @param channel number\n\t\t * @param delay number delay samples\n\t\t */\n\t\tgetReverse(channel, delay) {\n\t\t\tif (!this.size || !delay) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tconst readHead = delay * 2 - this.writeHead[channel] - 1;\n\n\t\t\t// Gain function to reduce clicking when read is too close to write\n\t\t\tlet readWriteDifference = this.writeHead[channel] - readHead;\n\t\t\tif (readWriteDifference < 0) {\n\t\t\t\treadWriteDifference += this.size\n\t\t\t}\n\t\t\tconst delayPct = readWriteDifference / this.size;\n\t\t\tconst gainFunction = 4 * delayPct * (1 - delayPct);\n\n\t\t\treturn this.buffer[channel][readHead] * gainFunction;\n\t\t}\n\t}\n");const mr="feedback-comb-filter";fr(mr,'\n\tclass FeedbackCombFilterWorklet extends SingleIOProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(options);\n\t\t\tthis.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);\n\t\t}\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: "delayTime",\n\t\t\t\tdefaultValue: 0.1,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 1,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}, {\n\t\t\t\tname: "feedback",\n\t\t\t\tdefaultValue: 0.5,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 0.9999,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, channel, parameters) {\n\t\t\tconst delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);\n\t\t\tthis.delayLine.push(channel, input + delayedSample * parameters.feedback);\n\t\t\treturn delayedSample;\n\t\t}\n\t}\n');class gr extends _r{constructor(){const t=pi(gr.getDefaults(),arguments,["delayTime","resonance"]);super(t),this.name="FeedbackCombFilter",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.delayTime=new so({context:this.context,value:t.delayTime,units:"time",minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new so({context:this.context,value:t.resonance,units:"normalRange",param:this._dummyParam,swappable:!0}),Fi(this,["resonance","delayTime"])}_audioWorkletName(){return mr}static getDefaults(){return Object.assign(no.getDefaults(),{delayTime:.1,resonance:.5})}onReady(t){io(this.input,t,this.output);const e=t.parameters.get("delayTime");this.delayTime.setParam(e);const s=t.parameters.get("feedback");this.resonance.setParam(s)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}}class vr extends no{constructor(){const t=pi(vr.getDefaults(),arguments,["delayTime","resonance","dampening"]);super(t),this.name="LowpassCombFilter",this._combFilter=this.output=new gr({context:this.context,delayTime:t.delayTime,resonance:t.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new So({context:this.context,frequency:t.dampening,type:"lowpass"}),this._lowpass.connect(this._combFilter)}static getDefaults(){return Object.assign(no.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})}get dampening(){return this._lowpass.frequency}set dampening(t){this._lowpass.frequency=t}dispose(){return super.dispose(),this._combFilter.dispose(),this._lowpass.dispose(),this}}class yr extends ki{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){const e=this.get(t);return null!==e?e.state:this._initial}setStateAtTime(t,e,s){return ti(e,0),this.add(Object.assign({},s,{state:t,time:e})),this}getLastState(t,e){for(let s=this._search(e);s>=0;s--){const e=this._timeline[s];if(e.state===t)return e}}getNextState(t,e){const s=this._search(e);if(-1!==s)for(let e=s;e<this._timeline.length;e++){const s=this._timeline[e];if(s.state===t)return s}}}class xr extends so{constructor(){const t=pi(xr.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new ki(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(so.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,s){e=this.toSeconds(e),this.setRampPoint(e);const n=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max(1/s,1));for(let t=0;t<=o;t++){const o=s*t+e,r=this._exponentialApproach(i.time,i.value,n,s,o);this.linearRampToValueAtTime(this._toType(r),o)}return this}setValueAtTime(t,e){const s=this.toSeconds(e);super.setValueAtTime(t,e);const n=this._events.get(s),i=this._events.previousEvent(n),o=this._getTicksUntilEvent(i,s);return n.ticks=Math.max(o,0),this}linearRampToValueAtTime(t,e){const s=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const n=this._events.get(s),i=this._events.previousEvent(n),o=this._getTicksUntilEvent(i,s);return n.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const s=this._fromType(t),n=this._events.get(e),i=Math.round(Math.max(10*(e-n.time),1)),o=(e-n.time)/i;for(let t=0;t<=i;t++){const i=o*t+n.time,r=this._exponentialInterpolate(n.time,n.value,e,s,i);this.linearRampToValueAtTime(this._toType(r),i)}return this}_getTicksUntilEvent(t,e){if(null===t)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Un(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const s=this._fromType(this.getValueAtTime(t.time));let n=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(n=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(s+n)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),s=this._events.get(e);return Math.max(this._getTicksUntilEvent(s,e),0)}getDurationOfTicks(t,e){const s=this.toSeconds(e),n=this.getTicksAtTime(e);return this.getTimeOfTick(n+t)-s}getTimeOfTick(t){const e=this._events.get(t,"ticks"),s=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&s&&"linearRampToValueAtTime"===s.type&&e.value!==s.value){const n=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(s.time))-n)/(s.time-e.time),o=Math.sqrt(Math.pow(n,2)-2*i*(e.ticks-t)),r=(-n+o)/i;return(r>0?r:(-n-o)/i)+e.time}return e?0===e.value?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){const s=this.toSeconds(e),n=this.toSeconds(t),i=this.getTicksAtTime(s);return this.getTicksAtTime(s+n)-i}_fromType(t){return"bpm"===this.units&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return"bpm"===this.units&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class wr extends go{constructor(){const t=pi(wr.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new xr({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(go.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}}class br extends eo{constructor(){const t=pi(br.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new yr,this._tickOffset=new ki,this._ticksAtTime=new ki,this._secondsAtTime=new ki,this.frequency=new wr({context:this.context,units:t.units,value:t.frequency}),Fi(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},eo.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){const s=this.toSeconds(t);return"started"!==this._state.getValueAtTime(s)&&(this._state.setStateAtTime("started",s),Gn(e)&&this.setTicksAtTime(e,s),this._ticksAtTime.cancel(s),this._secondsAtTime.cancel(s)),this}stop(t){const e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){const t=this._state.get(e);t&&t.time>0&&(this._tickOffset.cancel(t.time),this._state.cancel(t.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){const e=this.toSeconds(t),s=this._state.getLastState("stopped",e),n=this._ticksAtTime.get(e),i={state:"paused",time:e};this._state.add(i);let o=n||s,r=n?n.ticks:0,a=null;return this._state.forEachBetween(o.time,e+this.sampleTime,(t=>{let e=o.time;const s=this._tickOffset.get(t.time);s&&s.time>=o.time&&(r=s.ticks,e=s.time),"started"===o.state&&"started"!==t.state&&(r+=this.frequency.getTicksAtTime(t.time)-this.frequency.getTicksAtTime(e),t.time!==i.time&&(a={state:t.state,time:t.time,ticks:r})),o=t})),this._state.remove(i),a&&this._ticksAtTime.add(a),r}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),s=this.frequency.timeToTicks(t,e);this.setTicksAtTime(s,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),s={state:"paused",time:t};this._state.add(s);const n=this._secondsAtTime.get(t);let i=n||e,o=n?n.seconds:0,r=null;return this._state.forEachBetween(i.time,t+this.sampleTime,(t=>{let e=i.time;const n=this._tickOffset.get(t.time);n&&n.time>=i.time&&(o=n.seconds,e=n.time),"started"===i.state&&"started"!==t.state&&(o+=t.time-e,t.time!==s.time&&(r={state:t.state,time:t.time,seconds:o})),i=t})),this._state.remove(s),r&&this._secondsAtTime.add(r),o}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){const s=this._tickOffset.get(e),n=this._state.get(e),i=Math.max(s.time,n.time),o=this.frequency.getTicksAtTime(i)+t-s.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(t,e,s){let n=this._state.get(t);this._state.forEachBetween(t,e,(e=>{n&&"started"===n.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(n.time,t),e.time-this.sampleTime,s),n=e}));let i=null;if(n&&"started"===n.state){const o=Math.max(n.time,t),r=this.frequency.getTicksAtTime(o),a=r-this.frequency.getTicksAtTime(n.time);let c=Math.ceil(a)-a;c=yi(c,1)?0:c;let h=this.frequency.getTimeOfTick(r+c);for(;h<e;){try{s(h,Math.round(this.getTicksAtTime(h)))}catch(t){i=t;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}}class Tr extends eo{constructor(){const t=pi(Tr.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=Ni,this._lastUpdate=0,this._state=new yr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new br({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,Fi(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(eo.getDefaults(),{callback:Ni,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){ei(this.context);const s=this.toSeconds(t);return this.log("start",s),"started"!==this._state.getValueAtTime(s)&&(this._state.setStateAtTime("started",s),this._tickSource.start(s,e),s<this._lastUpdate&&this.emit("start",s,e)),this}stop(t){const e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){const s=this.toSeconds(e),n=this.getTicksAtTime(s);return this._tickSource.getTimeOfTick(n+t,s)}_loop(){const t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,(t=>{switch(t.state){case"started":const e=this._tickSource.getTicksAtTime(t.time);this.emit("start",t.time,e);break;case"stopped":0!==t.time&&this.emit("stop",t.time);break;case"paused":this.emit("pause",t.time)}})),this._tickSource.forEachTickBetween(t,e,((t,e)=>{this.callback(t,e)})))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Di.mixin(Tr);class Sr extends no{constructor(){const t=pi(Sr.getDefaults(),arguments,["delayTime","maxDelay"]);super(t),this.name="Delay";const e=this.toSeconds(t.maxDelay);this._maxDelay=Math.max(e,this.toSeconds(t.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(e),this.delayTime=new so({context:this.context,param:this._delayNode.delayTime,units:"time",value:t.delayTime,minValue:0,maxValue:this.maxDelay}),Fi(this,"delayTime")}static getDefaults(){return Object.assign(no.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}}class kr extends no{constructor(){const t=pi(kr.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Do({context:this.context}),this.output=new co({context:this.context}),this.volume=this.input.volume,io(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),io(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}function Ar(t,e){return Ci(this,arguments,void 0,(function*(t,e,s=2,n=Bi().sampleRate){const i=Bi(),o=new Li(s,e,n);Ui(o),yield t(o);const r=o.render();Ui(i);const a=yield r;return new ji(a)}))}Ri((t=>{t.destination=new kr({context:t})})),Vi((t=>{t.destination.dispose()}));class Cr extends Si{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=pi(Cr.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach((e=>{this._loadingCount++;const s=t.urls[e];this.add(e,s,this._bufferLoaded.bind(this,t.onload),t.onerror)}))}static getDefaults(){return{baseUrl:"",onerror:Ni,onload:Ni,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Kn(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,0===this._loadingCount&&t&&t()}get loaded(){return Array.from(this._buffers).every((([t,e])=>e.loaded))}add(t,e,s=Ni,n=Ni){return $n(e)?(this.baseUrl&&"data:audio/"===e.trim().substring(0,11).toLowerCase()&&(this.baseUrl=""),this._buffers.set(t.toString(),new ji(this.baseUrl+e,s,n))):this._buffers.set(t.toString(),new ji(e,s,n)),this}dispose(){return super.dispose(),this._buffers.forEach((t=>t.dispose())),this._buffers.clear(),this}}class Or extends Yi{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return c(super._frequencyToUnits(t))}_ticksToUnits(t){return c(super._ticksToUnits(t))}_beatsToUnits(t){return c(super._beatsToUnits(t))}_secondsToUnits(t){return c(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return l(this.toMidi())}transpose(t){return new Or(this.context,this.toMidi()+t)}}function Dr(t,e){return new Or(Bi(),t,e)}class Mr extends Ki{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}function Er(t,e){return new Mr(Bi(),t,e)}class Rr extends eo{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new ki,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){const t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,(e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)})),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}Ri((t=>{t.draw=new Rr({context:t})})),Vi((t=>{t.draw.dispose()}));class qr extends Si{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Kn(Gn(t.time),"Events must have a time property"),Kn(Gn(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Vr(t.time,t.time+t.duration,t);for(null===this._root?this._root=e:this._root.insert(e),this._length++;null!==e;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(null!==this._root){const e=[];this._root.search(t.time,e);for(const s of e)if(s.event===t){this._removeNode(s),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,(t=>this.remove(t))),this}_setRoot(t){this._root=t,null!==this._root&&(this._root.parent=null)}_replaceNodeInParent(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{let e,s=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,s=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,s=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,s=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,s=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),s&&this._rebalance(s)}t.dispose()}_rotateLeft(t){const e=t.parent,s=t.isLeftChild(),n=t.right;n&&(t.right=n.left,n.left=t),null!==e?s?e.left=n:e.right=n:this._setRoot(n)}_rotateRight(t){const e=t.parent,s=t.isLeftChild(),n=t.left;n&&(t.left=n.right,n.right=t),null!==e?s?e.left=n:e.right=n:this._setRoot(n)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(null!==this._root){const e=[];if(this._root.search(t,e),e.length>0){let t=e[0];for(let s=1;s<e.length;s++)e[s].low>t.low&&(t=e[s]);return t.event}}return null}forEach(t){if(null!==this._root){const e=[];this._root.traverse((t=>e.push(t))),e.forEach((e=>{e.event&&t(e.event)}))}return this}forEachAtTime(t,e){if(null!==this._root){const s=[];this._root.search(t,s),s.forEach((t=>{t.event&&e(t.event)}))}return this}forEachFrom(t,e){if(null!==this._root){const s=[];this._root.searchAfter(t,s),s.forEach((t=>{t.event&&e(t.event)}))}return this}dispose(){return super.dispose(),null!==this._root&&this._root.traverse((t=>t.dispose())),this._root=null,this}}class Vr{constructor(t,e,s){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=s,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)}traverse(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)}updateHeight(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t}isLeftChild(){return null!==this.parent&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}class Ir extends no{constructor(t){super(t),this.name="Effect",this._dryWet=new Vo({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new co({context:this.context}),this.effectReturn=new co({context:this.context}),this.input=new co({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],Fi(this,"wet")}static getDefaults(){return Object.assign(no.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}}class Fr extends wo{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new bo({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class Pr extends wo{constructor(){super(pi(Pr.getDefaults(),arguments)),this.name="Zero",this._gain=new co({context:this.context}),this.output=this._gain,this.input=void 0,oo(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),ro(this.context.getConstant(0),this._gain),this}}class Nr extends Si{constructor(t){super(),this.name="TimelineValue",this._timeline=new ki({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){const e=this._timeline.get(t);return e?e.value:this._initialValue}}class jr{constructor(t,e){this.id=jr._eventId++,this._remainderTime=0;const s=Object.assign(jr.getDefaults(),e);this.transport=t,this.callback=s.callback,this._once=s.once,this.time=Math.floor(s.time),this._remainderTime=s.time-this.time}static getDefaults(){return{callback:Ni,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){const e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}}jr._eventId=0;class Lr extends jr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const s=Object.assign(Lr.getDefaults(),e);this.duration=s.duration,this._interval=s.interval,this._nextTick=s.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({},jr.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(),super.invoke(t)}_createEvent(){return vi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Mr(this.context,this._nextTick).toSeconds()):-1}_createEvents(){vi(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 Mr(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;const e=this.transport.getTicksAtTime(t);mi(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-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 zr extends eo{constructor(){const t=pi(zr.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Nr(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new ki,this._repeatedEvents=new qr,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new Tr({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),Fi(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(eo.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(2*this._swingTicks)!=0){const s=e%(2*this._swingTicks)/(2*this._swingTicks),n=Math.sin(s*Math.PI)*this._swingAmount;t+=new Mr(this.context,2*this._swingTicks/3).toSeconds()*n}ii(!0),this._timeline.forEachAtTime(e,(e=>e.invoke(t))),ii(!1)}schedule(t,e){const s=new jr(this,{callback:t,time:new Ki(this.context,e).toTicks()});return this._addEvent(s,this._timeline)}scheduleRepeat(t,e,s,n=1/0){const i=new Lr(this,{callback:t,duration:new Zi(this.context,n).toTicks(),interval:new Zi(this.context,e).toTicks(),time:new Ki(this.context,s).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const s=new jr(this,{callback:t,once:!0,time:new Ki(this.context,e).toTicks()});return this._addEvent(s,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,(t=>this.clear(t.id))),this._repeatedEvents.forEachFrom(e,(t=>this.clear(t.id))),this}_bindClockEvents(){this._clock.on("start",((t,e)=>{e=new Mr(this.context,e).toSeconds(),this.emit("start",t,e)})),this._clock.on("stop",(t=>{this.emit("stop",t)})),this._clock.on("pause",(t=>{this.emit("pause",t)}))}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){let s;return this.context.resume(),Gn(e)&&(s=this.toTicks(e)),this._clock.start(t,s),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Hn(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Zi(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Zi(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Mr(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){const t=this.now(),e=this._clock.getTicksAtTime(t);return new Mr(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),s=this._clock.frequency.timeToTicks(t,e);this.ticks=s}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(t){if(oi(),t=Math.floor(t),this._clock.ticks===t)return;const e=this.now();if("started"===this.state){const s=this._clock.getTicksAtTime(e),n=e+this._clock.frequency.getDurationOfTicks(Math.ceil(s)-s,e);this.emit("stop",n),this._clock.setTicksAtTime(t,n),this.emit("start",n,this._clock.getSecondsAtTime(n))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}setTicksAtTime(t,e){return this._clock.setTicksAtTime(t,e),this}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}setSecondsAtTime(t,e){return this.setTicksAtTime(this.toTicks(t),e),this}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),"started"!==this.state)return 0;{const e=this.now(),s=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(s,e)}}syncSignal(t,e){const s=this.now();let n=this.bpm,i=1/(60/n.getValueAtTime(s)/this.PPQ),o=[];if("time"===t.units){const t=1/64/i,e=new co(t),s=new ar(-1),r=new co(t);n.chain(e,s,r),n=r,i=1/i,o=[e,s,r]}e||(e=0!==t.getValueAtTime(s)?t.getValueAtTime(s)/i:0);const r=new co(e);return n.connect(r),r.connect(t._param),o.push(r),this._syncedSignals.push({initial:t.value,nodes:o,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const s=this._syncedSignals[e];s.signal===t&&(s.nodes.forEach((t=>t.dispose())),s.signal.value=s.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Pi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Di.mixin(zr),Ri((t=>{t.transport=new zr({context:t})})),Vi((t=>{t.transport.dispose()}));class Wr extends no{constructor(t){super(t),this.input=void 0,this._state=new yr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Ni,this._syncedStop=Ni,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Do({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,onstop:Ni,volume:0})}get state(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,s){let n=Un(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(n=this._clampToCurrentTime(n),this._synced||"started"!==this._state.getValueAtTime(n))if(this._state.setStateAtTime("started",n),this._synced){const t=this._state.get(n);t&&(t.offset=this.toSeconds(di(e,0)),t.duration=s?this.toSeconds(s):void 0);const i=this.context.transport.schedule((t=>{this._start(t,e,s)}),n);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>n&&this._syncedStart(this.now(),this.context.transport.seconds)}else ei(this.context),this._start(n,e,s);else Kn(mi(n,this._state.get(n).time),"Start time must be strictly greater than previous start time"),this._state.cancel(n),this._state.setStateAtTime("started",n),this.log("restart",n),this.restart(n,e,s);return this}stop(t){let e=Un(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||Gn(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){const t=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(t)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,s){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,s)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(mi(e,0)){const s=this._state.get(e);if(s&&"started"===s.state&&s.time!==e){const n=e-this.toSeconds(s.time);let i;s.duration&&(i=this.toSeconds(s.duration)-n),this._start(t,this.toSeconds(s.offset)+n,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));"started"===this._state.getValueAtTime(e)&&this._stop(t)},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((t=>this.context.transport.clear(t))),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=Ni,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}function Br(t,e){return Ci(this,void 0,void 0,(function*(){const s=e/t.context.sampleRate,n=new Li(1,s,t.context.sampleRate);return new t.constructor(Object.assign(t.get(),{frequency:2/s,detune:0,context:n})).toDestination().start(0),(yield n.render()).getChannelData(0)}))}class Ur extends _o{constructor(){const t=pi(Ur.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],oo(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new so({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new so({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),Fi(this,["frequency","detune"])}static getDefaults(){return Object.assign(_o.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),"started"===this.state&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class Gr extends Wr{constructor(){const t=pi(Gr.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),Fi(this,"frequency"),this.detune=new go({context:this.context,units:"cents",value:t.detune}),Fi(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&"custom"!==t.type&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(Wr.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),s=new Ur({context:this.context,onended:()=>{this._cleanUpConnections(s),this.onstop(this)}});this._oscillator=s,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(e)}_cleanUpConnections(t){this.context.isOffline||(this.frequency.disconnect(t.frequency),this.detune.disconnect(t.detune),t.disconnect())}_stop(t){const e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){const e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if("custom"===this._type)return Gr._periodicWaveCache.find((t=>{return t.phase===this._phase&&(e=t.partials,s=this._partials,e.length===s.length&&e.every(((t,e)=>s[e]===t)));var e,s}));{const t=Gr._periodicWaveCache.find((t=>t.type===this._type&&t.phase===this._phase));return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;const e=-1!==["sine","square","sawtooth","triangle"].indexOf(t);if(0===this._phase&&e)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=t);else{const e=this._getCachedPeriodicWave();if(Gn(e)){const{partials:t,wave:s}=e;this._wave=s,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[e,s]=this._getRealImaginary(t,this._phase),n=this.context.createPeriodicWave(e,s);this._wave=n,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),Gr._periodicWaveCache.push({imag:s,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:e,type:this._type,wave:this._wave}),Gr._periodicWaveCache.length>100&&Gr._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&"custom"!==this._type&&"custom"!==t?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){ti(t,0);let e=this._type;const s=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(s&&(e=s[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach(((t,s)=>e[s]=t)),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let s=2048;const n=new Float32Array(s),i=new Float32Array(s);let o=1;if("custom"===t){if(o=this._partials.length+1,this._partialCount=this._partials.length,s=o,0===this._partials.length)return[n,i]}else{const e=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);e?(o=parseInt(e[2],10)+1,this._partialCount=parseInt(e[2],10),t=e[1],o=Math.max(o,2),s=o):this._partialCount=0,this._partials=[]}for(let r=1;r<s;++r){const s=2/(r*Math.PI);let a;switch(t){case"sine":a=r<=o?1:0,this._partials[r-1]=a;break;case"square":a=1&r?2*s:0,this._partials[r-1]=a;break;case"sawtooth":a=s*(1&r?1:-1),this._partials[r-1]=a;break;case"triangle":a=1&r?s*s*2*(r-1>>1&1?-1:1):0,this._partials[r-1]=a;break;case"custom":a=this._partials[r-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}0!==a?(n[r]=-a*Math.sin(e*r),i[r]=a*Math.cos(e*r)):(n[r]=0,i[r]=0)}return[n,i]}_inverseFFT(t,e,s){let n=0;const i=t.length;for(let o=0;o<i;o++)n+=t[o]*Math.cos(o*s)+e[o]*Math.sin(o*s);return n}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let s=0;const n=2*Math.PI;for(let i=0;i<32;i++)s=Math.max(this._inverseFFT(t,e,i/32*n),s);return xi(-this._inverseFFT(t,e,this._phase)/s,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),null!==this._oscillator&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}Gr._periodicWaveCache=[];class Qr extends no{constructor(){const t=pi(Qr.getDefaults(),arguments,["frequency","min","max"]);super(t),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=so.prototype._fromType,this._toType=so.prototype._toType,this._is=so.prototype._is,this._clampValue=so.prototype._clampValue,this._oscillator=new Gr(t),this.frequency=this._oscillator.frequency,this._amplitudeGain=new co({context:this.context,gain:t.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new go({context:this.context,units:"audioRange",value:0}),this._zeros=new Pr({context:this.context}),this._a2g=new Fr({context:this.context}),this._scaler=this.output=new cr({context:this.context,max:t.max,min:t.min}),this.units=t.units,this.min=t.min,this.max=t.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),Fi(this,["amplitude","frequency"]),this.phase=t.phase}static getDefaults(){return Object.assign(Gr.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,type:"sine",units:"number"})}start(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this}stop(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),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(t){t=this._fromType(t),this._scaler.min=t}get max(){return this._toType(this._scaler.max)}set max(t){t=this._fromType(t),this._scaler.max=t}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(t){this._oscillator.partials=t,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t,this._setStoppedValue()}get units(){return this._units}set units(t){const e=this.min,s=this.max;this._units=t,this.min=e,this.max=s}get state(){return this._oscillator.state}connect(t,e,s){return(t instanceof so||t instanceof go)&&(this.convert=t.convert,this.units=t.units),yo(this,t,e,s),this}disconnect(t,e=0,s=0){return xo(this,t,e,s),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}}class Zr extends Ir{constructor(t){super(t),this.name="LFOEffect",this._lfo=new Qr({context:this.context,frequency:t.frequency,amplitude:t.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=t.type,Fi(this,["frequency","depth"])}static getDefaults(){return Object.assign(Ir.getDefaults(),{frequency:1,type:"sine",depth:1})}start(t){return this._lfo.start(t),this}stop(t){return this._lfo.stop(t),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Xr extends Zr{constructor(){const t=pi(Xr.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);super(t),this.name="AutoFilter",this.filter=new Uo(Object.assign(t.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=t.octaves,this.baseFrequency=t.baseFrequency}static getDefaults(){return Object.assign(Zr.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._lfo.max=this._lfo.min*Math.pow(2,t)}dispose(){return super.dispose(),this.filter.dispose(),this}}class Yr extends Zr{constructor(){const t=pi(Yr.getDefaults(),arguments,["frequency"]);super(t),this.name="AutoPanner",this._panner=new Oo({context:this.context,channelCount:t.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(Zr.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}}class Hr extends cr{constructor(){const t=pi(Hr.getDefaults(),arguments,["min","max","exponent"]);super(t),this.name="ScaleExp",this.input=this._exp=new ar({context:this.context,value:t.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(cr.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(t){this._exp.value=t}dispose(){return super.dispose(),this._exp.dispose(),this}}class $r extends Ir{constructor(){const t=pi($r.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);super(t),this.name="AutoWah",this._follower=new ko({context:this.context,smoothing:t.follower}),this._sweepRange=new Hr({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this._inputBoost=new co({context:this.context}),this._bandpass=new Uo({context:this.context,rolloff:-48,frequency:0,Q:t.Q}),this._peaking=new Uo({context:this.context,type:"peaking"}),this._peaking.gain.value=t.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=t.sensitivity,Fi(this,["gain","Q"])}static getDefaults(){return Object.assign(Ir.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(t){this._follower.smoothing=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),this._setSweepRange()}get sensitivity(){return o(1/this._inputBoost.gain.value)}set sensitivity(t){this._inputBoost.gain.value=1/i(t)}_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 Jr="bit-crusher";fr(Jr,"\n\tclass BitCrusherWorklet extends SingleIOProcessor {\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: \"bits\",\n\t\t\t\tdefaultValue: 12,\n\t\t\t\tminValue: 1,\n\t\t\t\tmaxValue: 16,\n\t\t\t\tautomationRate: 'k-rate'\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, _channel, parameters) {\n\t\t\tconst step = Math.pow(0.5, parameters.bits - 1);\n\t\t\tconst val = step * Math.floor(input / step + 0.5);\n\t\t\treturn val;\n\t\t}\n\t}\n");class Kr extends Ir{constructor(){const t=pi(Kr.getDefaults(),arguments,["bits"]);super(t),this.name="BitCrusher",this._bitCrusherWorklet=new ta({context:this.context,bits:t.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(Ir.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}}class ta extends _r{constructor(){const t=pi(ta.getDefaults(),arguments);super(t),this.name="BitCrusherWorklet",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.bits=new so({context:this.context,value:t.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(_r.getDefaults(),{bits:12})}_audioWorkletName(){return Jr}onReady(t){io(this.input,t,this.output);const e=t.parameters.get("bits");this.bits.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class ea extends Ir{constructor(){const t=pi(ea.getDefaults(),arguments,["order"]);super(t),this.name="Chebyshev",this._shaper=new bo({context:this.context,length:4096}),this._order=t.order,this.connectEffect(this._shaper),this.order=t.order,this.oversample=t.oversample}static getDefaults(){return Object.assign(Ir.getDefaults(),{order:1,oversample:"none"})}_getCoefficient(t,e,s){return s.has(e)||(0===e?s.set(e,0):1===e?s.set(e,t):s.set(e,2*t*this._getCoefficient(t,e-1,s)-this._getCoefficient(t,e-2,s))),s.get(e)}get order(){return this._order}set order(t){Kn(Number.isInteger(t),"'order' must be an integer"),this._order=t,this._shaper.setMap((e=>this._getCoefficient(e,t,new Map)))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class sa extends no{constructor(t){super(t),this.name="StereoEffect",this.input=new co({context:this.context}),this.input.channelCount=2,this.input.channelCountMode="explicit",this._dryWet=this.output=new Vo({context:this.context,fade:t.wet}),this.wet=this._dryWet.fade,this._split=new ho({context:this.context,channels:2}),this._merge=new Io({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),Fi(this,["wet"])}connectEffectLeft(...t){this._split.connect(t[0],0,0),io(...t),oo(t[t.length-1],this._merge,0,0)}connectEffectRight(...t){this._split.connect(t[0],1,0),io(...t),oo(t[t.length-1],this._merge,0,1)}static getDefaults(){return Object.assign(no.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}}class na extends sa{constructor(t){super(t),this.feedback=new go({context:this.context,value:t.feedback,units:"normalRange"}),this._feedbackL=new co({context:this.context}),this._feedbackR=new co({context:this.context}),this._feedbackSplit=new ho({context:this.context,channels:2}),this._feedbackMerge=new Io({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),Fi(this,["feedback"])}static getDefaults(){return Object.assign(sa.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}}class ia extends na{constructor(){const t=pi(ia.getDefaults(),arguments,["frequency","delayTime","depth"]);super(t),this.name="Chorus",this._depth=t.depth,this._delayTime=t.delayTime/1e3,this._lfoL=new Qr({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new Qr({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Sr({context:this.context}),this._delayNodeR=new Sr({context:this.context}),this.frequency=this._lfoL.frequency,Fi(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=t.type,this.spread=t.spread}static getDefaults(){return Object.assign(na.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(t){this._depth=t;const e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}get delayTime(){return 1e3*this._delayTime}set delayTime(t){this._delayTime=t/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),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 oa extends Ir{constructor(){const t=pi(oa.getDefaults(),arguments,["distortion"]);super(t),this.name="Distortion",this._shaper=new bo({context:this.context,length:4096}),this._distortion=t.distortion,this.connectEffect(this._shaper),this.distortion=t.distortion,this.oversample=t.oversample}static getDefaults(){return Object.assign(Ir.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(t){this._distortion=t;const e=100*t,s=Math.PI/180;this._shaper.setMap((t=>Math.abs(t)<.001?0:(3+e)*t*20*s/(Math.PI+e*Math.abs(t))))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class ra extends Ir{constructor(t){super(t),this.name="FeedbackEffect",this._feedbackGain=new co({context:this.context,gain:t.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,Fi(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(Ir.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class aa extends ra{constructor(){const t=pi(aa.getDefaults(),arguments,["delayTime","feedback"]);super(t),this.name="FeedbackDelay",this._delayNode=new Sr({context:this.context,delayTime:t.delayTime,maxDelay:t.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),Fi(this,"delayTime")}static getDefaults(){return Object.assign(ra.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}const ca=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],ha=[225,556,441,341];class la extends sa{constructor(){const t=pi(la.getDefaults(),arguments,["roomSize","dampening"]);super(t),this.name="Freeverb",this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[],this.roomSize=new go({context:this.context,value:t.roomSize,units:"normalRange"}),this._allpassFiltersL=ha.map((t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e})),this._allpassFiltersR=ha.map((t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e})),this._combFilters=ca.map(((e,s)=>{const n=new vr({context:this.context,dampening:t.dampening,delayTime:e});return s<ca.length/2?this.connectEffectLeft(n,...this._allpassFiltersL):this.connectEffectRight(n,...this._allpassFiltersR),this.roomSize.connect(n.resonance),n})),Fi(this,["roomSize"])}static getDefaults(){return Object.assign(sa.getDefaults(),{roomSize:.7,dampening:3e3})}get dampening(){return this._combFilters[0].dampening}set dampening(t){this._combFilters.forEach((e=>e.dampening=t))}dispose(){return super.dispose(),this._allpassFiltersL.forEach((t=>t.disconnect())),this._allpassFiltersR.forEach((t=>t.disconnect())),this._combFilters.forEach((t=>t.dispose())),this.roomSize.dispose(),this}}class ua extends no{constructor(t){super(t),this.name="PhaseShiftAllpass",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.offset90=new co({context:this.context}),this._bank0=this._createAllPassFilterBank([.6923878,.9360654322959,.988229522686,.9987488452737]),this._bank1=this._createAllPassFilterBank([.4021921162426,.856171088242,.9722909545651,.9952884791278]),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),io(this.input,...this._bank0,this._oneSampleDelay,this.output),io(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(t){return t.map((t=>{const e=[[t*t,0,-1],[1,0,-t*t]];return this.context.createIIRFilter(e[0],e[1])}))}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach((t=>t.disconnect())),this._bank1.forEach((t=>t.disconnect())),this._oneSampleDelay.disconnect(),this}}class pa extends Ir{constructor(){const t=pi(pa.getDefaults(),arguments,["frequency"]);super(t),this.name="FrequencyShifter",this.frequency=new go({context:this.context,units:"frequency",value:t.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new Ur({context:this.context,type:"sine"}),this._cosine=new Gr({context:this.context,phase:-90,type:"sine"}),this._sineMultiply=new Po({context:this.context}),this._cosineMultiply=new Po({context:this.context}),this._negate=new No({context:this.context}),this._add=new Fo({context:this.context}),this._phaseShifter=new ua({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 e=this.immediate();this._sine.start(e),this._cosine.start(e)}static getDefaults(){return Object.assign(Ir.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 da=[.06748,.06404,.08212,.09004],fa=[.773,.802,.753,.733],_a=[347,113,37];class ma extends sa{constructor(){const t=pi(ma.getDefaults(),arguments,["roomSize"]);super(t),this.name="JCReverb",this._allpassFilters=[],this._feedbackCombFilters=[],this.roomSize=new go({context:this.context,value:t.roomSize,units:"normalRange"}),this._scaleRoomSize=new cr({context:this.context,min:-.733,max:.197}),this._allpassFilters=_a.map((t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e})),this._feedbackCombFilters=da.map(((t,e)=>{const s=new gr({context:this.context,delayTime:t});return this._scaleRoomSize.connect(s.resonance),s.resonance.value=fa[e],e<da.length/2?this.connectEffectLeft(...this._allpassFilters,s):this.connectEffectRight(...this._allpassFilters,s),s})),this.roomSize.connect(this._scaleRoomSize),Fi(this,["roomSize"])}static getDefaults(){return Object.assign(sa.getDefaults(),{roomSize:.5})}dispose(){return super.dispose(),this._allpassFilters.forEach((t=>t.disconnect())),this._feedbackCombFilters.forEach((t=>t.dispose())),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}}class ga extends sa{constructor(){const t=pi(ga.getDefaults(),arguments,["frequency","octaves","baseFrequency"]);super(t),this.name="Phaser",this._lfoL=new Qr({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new Qr({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this.Q=new go({context:this.context,value:t.Q,units:"positive"}),this._filtersL=this._makeFilters(t.stages,this._lfoL),this._filtersR=this._makeFilters(t.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=t.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=t.baseFrequency,this.octaves=t.octaves,this._lfoL.start(),this._lfoR.start(),Fi(this,["frequency","Q"])}static getDefaults(){return Object.assign(sa.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(t,e){const s=[];for(let n=0;n<t;n++){const t=this.context.createBiquadFilter();t.type="allpass",this.Q.connect(t.Q),e.connect(t.frequency),s.push(t)}return s}get octaves(){return this._octaves}set octaves(t){this._octaves=t;const e=this._baseFrequency*Math.pow(2,t);this._lfoL.max=e,this._lfoR.max=e}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),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((t=>t.disconnect())),this._filtersR.forEach((t=>t.disconnect())),this.frequency.dispose(),this}}class va extends na{constructor(t){super(t),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),Fi(this,["feedback"])}}class ya extends va{constructor(){const t=pi(ya.getDefaults(),arguments,["delayTime","feedback"]);super(t),this.name="PingPongDelay",this._leftDelay=new Sr({context:this.context,maxDelay:t.maxDelay}),this._rightDelay=new Sr({context:this.context,maxDelay:t.maxDelay}),this._rightPreDelay=new Sr({context:this.context,maxDelay:t.maxDelay}),this.delayTime=new go({context:this.context,units:"time",value:t.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),Fi(this,["delayTime"])}static getDefaults(){return Object.assign(va.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}}class xa extends ra{constructor(){const t=pi(xa.getDefaults(),arguments,["pitch"]);super(t),this.name="PitchShift",this._frequency=new go({context:this.context}),this._delayA=new Sr({maxDelay:1,context:this.context}),this._lfoA=new Qr({context:this.context,min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new Sr({maxDelay:1,context:this.context}),this._lfoB=new Qr({context:this.context,min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new Vo({context:this.context}),this._crossFadeLFO=new Qr({context:this.context,min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Sr({delayTime:t.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,Fi(this,"delayTime"),this._pitch=t.pitch,this._windowSize=t.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 e=this.now();this._lfoA.start(e),this._lfoB.start(e),this._crossFadeLFO.start(e),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(ra.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(t){this._pitch=t;let e=0;t<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,e=r(t-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,e=r(t)-1),this._frequency.value=e*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(t){this._windowSize=this.toSeconds(t),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 wa extends _o{constructor(){const t=pi(wa.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,oo(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new so({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new ji(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(_o.getDefaults(),{url:new ji,loop:!1,loopEnd:0,loopStart:0,onload:Ni,onerror:Ni,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,s,n=1){Kn(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,n),e=this.loop?di(e,this.loopStart):di(e,0);let o=Math.max(this.toSeconds(e),0);if(this.loop){const t=this.toSeconds(this.loopEnd)||this.buffer.duration,e=this.toSeconds(this.loopStart),s=t-e;gi(o,t)&&(o=(o-e)%s+e),yi(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,vi(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,o)),Gn(s)){let t=this.toSeconds(s);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class ba extends Wr{constructor(){const t=pi(ba.getDefaults(),arguments,["type"]);super(t),this.name="Noise",this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Wr.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Kn(t in ka,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,"started"===this.state)){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){const e=ka[this._type];this._source=new wa({url:e,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(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Ta=220500,Sa={brown:null,pink:null,white:null},ka={get brown(){if(!Sa.brown){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Ta);t[e]=s;let n=0;for(let t=0;t<Ta;t++){const e=2*Math.random()-1;s[t]=(n+.02*e)/1.02,n=s[t],s[t]*=3.5}}Sa.brown=(new ji).fromArray(t)}return Sa.brown},get pink(){if(!Sa.pink){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Ta);let n,i,o,r,a,c,h;t[e]=s,n=i=o=r=a=c=h=0;for(let t=0;t<Ta;t++){const e=2*Math.random()-1;n=.99886*n+.0555179*e,i=.99332*i+.0750759*e,o=.969*o+.153852*e,r=.8665*r+.3104856*e,a=.55*a+.5329522*e,c=-.7616*c-.016898*e,s[t]=n+i+o+r+a+c+h+.5362*e,s[t]*=.11,h=.115926*e}}Sa.pink=(new ji).fromArray(t)}return Sa.pink},get white(){if(!Sa.white){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Ta);t[e]=s;for(let t=0;t<Ta;t++)s[t]=2*Math.random()-1}Sa.white=(new ji).fromArray(t)}return Sa.white}};class Aa extends Ir{constructor(){const t=pi(Aa.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const e=this.toSeconds(t.decay);ti(e,.001),this._decay=e;const s=this.toSeconds(t.preDelay);ti(s,0),this._preDelay=s,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Ir.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){ti(t=this.toSeconds(t),.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){ti(t=this.toSeconds(t),0),this._preDelay=t,this.generate()}generate(){return Ci(this,void 0,void 0,(function*(){const t=this.ready,e=new Li(2,this._decay+this._preDelay,this.context.sampleRate),s=new ba({context:e}),n=new ba({context:e}),i=new Io({context:e});s.connect(i,0,0),n.connect(i,0,1);const o=new co({context:e}).toDestination();i.connect(o),s.start(0),n.start(0),o.gain.setValueAtTime(0,0),o.gain.setValueAtTime(1,this._preDelay),o.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const r=e.render();return this.ready=r.then(Ni),yield t,this._convolver.buffer=(yield r).get(),this}))}dispose(){return super.dispose(),this._convolver.disconnect(),this}}const Ca="reverse-delay";fr(Ca,'\n\tclass ReverseDelayWorklet extends SingleIOProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(options);\n\t\t\tthis.delayTime = Math.floor(this.sampleRate * options.processorOptions.delayTime);\n\t\t\tconst channels = options.channelCount || 2;\n\t\t\tthis.delayLine = new DelayLine(this.delayTime * 2, channels);\n\t\t}\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: "feedback",\n\t\t\t\tdefaultValue: 0.5,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 0.9999,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, channel, parameters) {\n\t\t\tconst reversedSample = this.delayLine.getReverse(channel, this.delayTime);\n\t\t\tconst delayedSample = this.delayLine.get(channel, this.delayTime);\n\n\t\t\t// Push the forward sample back on the line\n\t\t\tthis.delayLine.push(channel, input + delayedSample * parameters.feedback);\n\n\t\t\t// Play the reversed sample\n\t\t\treturn reversedSample;\n\t\t}\n\t}\n');class Oa extends Ir{constructor(){const t=pi(Oa.getDefaults(),arguments,["delayTime","feedback"]);super(t),this.name="ReverseDelay",this._reverseDelayWorklet=this._connectWorklet(t.delayTime,t.feedback)}_connectWorklet(t,e){const s=new Da({context:this.context,delayTime:this.toSeconds(t),feedback:e});return this.connectEffect(s),s}get delayTime(){return this._reverseDelayWorklet.delayTime}set delayTime(t){const e=this._reverseDelayWorklet;this._reverseDelayWorklet=this._connectWorklet(t,this.feedback),e.output.gain.linearRampTo(0,this.toSeconds(this.delayTime)),this.context.setTimeout((()=>e.dispose()),this.toSeconds(this.delayTime))}get feedback(){return this._reverseDelayWorklet.feedback.value}set feedback(t){this._reverseDelayWorklet.set({feedback:t})}static getDefaults(){return Object.assign(Ir.getDefaults(),{wet:.5,delayTime:1,feedback:.5})}dispose(){return super.dispose(),this._reverseDelayWorklet.dispose(),this}}class Da extends _r{constructor(){const t=pi(Da.getDefaults(),arguments,["delayTime","feedback"]);super(Object.assign(Object.assign({},t),{workletOptions:{processorOptions:{delayTime:t.delayTime}}})),this.name="ReverseDelayWorklet",this.input=new co({context:this.context}),this.output=new co({context:this.context}),this.delayTime=t.delayTime,this.feedback=new so({context:this.context,value:t.feedback,units:"normalRange",param:this._dummyParam,swappable:!0,minValue:0,maxValue:.9999})}static getDefaults(){return Object.assign(_r.getDefaults(),{delayTime:1,feedback:.5})}_audioWorkletName(){return Ca}onReady(t){io(this.input,t,this.output);const e=t.parameters.get("feedback");this.feedback.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.feedback.dispose(),this}}class Ma extends Ir{constructor(t){super(t),this.name="MidSideEffect",this._midSideMerge=new Lo({context:this.context}),this._midSideSplit=new zo({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(...t){this._midSend.chain(...t,this._midReturn)}connectEffectSide(...t){this._sideSend.chain(...t,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 Ea extends Ma{constructor(){const t=pi(Ea.getDefaults(),arguments,["width"]);super(t),this.name="StereoWidener",this.width=new go({context:this.context,value:t.width,units:"normalRange"}),Fi(this,["width"]),this._twoTimesWidthMid=new Po({context:this.context,value:2}),this._twoTimesWidthSide=new Po({context:this.context,value:2}),this._midMult=new Po({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new jo({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),oo(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new Po({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(Ma.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 Ra extends sa{constructor(){const t=pi(Ra.getDefaults(),arguments,["frequency","depth"]);super(t),this.name="Tremolo",this._lfoL=new Qr({context:this.context,type:t.type,min:1,max:0}),this._lfoR=new Qr({context:this.context,type:t.type,min:1,max:0}),this._amplitudeL=new co({context:this.context}),this._amplitudeR=new co({context:this.context}),this.frequency=new go({context:this.context,value:t.frequency,units:"frequency"}),this.depth=new go({context:this.context,value:t.depth,units:"normalRange"}),Fi(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=t.spread}static getDefaults(){return Object.assign(sa.getDefaults(),{frequency:10,type:"sine",depth:.5,spread:180})}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),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(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/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 qa extends Ir{constructor(){const t=pi(qa.getDefaults(),arguments,["frequency","depth"]);super(t),this.name="Vibrato",this._delayNode=new Sr({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new Qr({context:this.context,type:t.type,min:0,max:t.maxDelay,frequency:t.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=t.depth,Fi(this,["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(Ir.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:"sine"})}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Va extends eo{constructor(){const t=pi(Va.getDefaults(),arguments,["callback","value"]);super(t),this.name="ToneEvent",this._state=new yr("stopped"),this._startOffset=0,this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(eo.getDefaults(),{callback:Ni,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(t=-1){this._state.forEachFrom(t,(t=>{let e;if("started"===t.state){-1!==t.id&&this.context.transport.clear(t.id);const s=t.time+Math.round(this.startOffset/this._playbackRate);if(!0===this._loop||Zn(this._loop)&&this._loop>1){e=1/0,Zn(this._loop)&&(e=this._loop*this._getLoopDuration());const n=this._state.getAfter(s);null!==n&&(e=Math.min(e,n.time-s)),e!==1/0&&(e=new Mr(this.context,e));const i=new Mr(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new Mr(this.context,s),e)}else t.id=this.context.transport.schedule(this._tick.bind(this),new Mr(this.context,s))}}))}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t}get probability(){return this._probability}set probability(t){this._probability=t}get humanize(){return this._humanize}set humanize(t){this._humanize=t}start(t){const e=this.toTicks(t);return"stopped"===this._state.getValueAtTime(e)&&(this._state.add({id:-1,state:"started",time:e}),this._rescheduleEvents(e)),this}stop(t){this.cancel(t);const e=this.toTicks(t);if("started"===this._state.getValueAtTime(e)){this._state.setStateAtTime("stopped",e,{id:-1});const t=this._state.getBefore(e);let s=e;null!==t&&(s=t.time),this._rescheduleEvents(s)}return this}cancel(t){t=di(t,-1/0);const e=this.toTicks(t);return this._state.forEachFrom(e,(t=>{this.context.transport.clear(t.id)})),this._state.cancel(e),this}_tick(t){const e=this.context.transport.getTicksAtTime(t);if(!this.mute&&"started"===this._state.getValueAtTime(e)){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let e=.02;Yn(this.humanize)||(e=this.toSeconds(this.humanize)),t+=(2*Math.random()-1)*e}this.callback(t,this.value)}}_getLoopDuration(){return(this._loopEnd-this._loopStart)/this._playbackRate}get loop(){return this._loop}set loop(t){this._loop=t,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._rescheduleEvents()}get loopEnd(){return new Mr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}get loopStart(){return new Mr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){const s=this._getLoopDuration();return(t-e.time)%s/s}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class Ia extends eo{constructor(){const t=pi(Ia.getDefaults(),arguments,["callback","interval"]);super(t),this.name="Loop",this._event=new Va({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:t.interval,playbackRate:t.playbackRate,probability:t.probability,humanize:t.humanize}),this.callback=t.callback,this.iterations=t.iterations}static getDefaults(){return Object.assign(eo.getDefaults(),{interval:"4n",callback:Ni,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(t){return this._event.start(t),this}stop(t){return this._event.stop(t),this}cancel(t){return this._event.cancel(t),this}_tick(t){this.callback(t)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(t){this._event.loopEnd=t}get playbackRate(){return this._event.playbackRate}set playbackRate(t){this._event.playbackRate=t}get humanize(){return this._event.humanize}set humanize(t){this._event.humanize=t}get probability(){return this._event.probability}set probability(t){this._event.probability=t}get mute(){return this._event.mute}set mute(t){this._event.mute=t}get iterations(){return!0===this._event.loop?1/0:this._event.loop}set iterations(t){this._event.loop=t===1/0||t}dispose(){return super.dispose(),this._event.dispose(),this}}class Fa extends Va{constructor(){const t=pi(Fa.getDefaults(),arguments,["callback","events"]);super(t),this.name="Part",this._state=new yr("stopped"),this._events=new Set,this._state.increasing=!0,t.events.forEach((t=>{Hn(t)?this.add(t[0],t[1]):this.add(t)}))}static getDefaults(){return Object.assign(Va.getDefaults(),{events:[]})}start(t,e){const s=this.toTicks(t);if("started"!==this._state.getValueAtTime(s)){e=di(e,this._loop?this._loopStart:0),e=this._loop?di(e,this._loopStart):di(e,0);const t=this.toTicks(e);this._state.add({id:-1,offset:t,state:"started",time:s}),this._forEach((e=>{this._startNote(e,s,t)}))}return this}_startNote(t,e,s){e-=s,this._loop?t.startOffset>=this._loopStart&&t.startOffset<this._loopEnd?(t.startOffset<s&&(e+=this._getLoopDuration()),t.start(new Mr(this.context,e))):t.startOffset<this._loopStart&&t.startOffset>=s&&(t.loop=!1,t.start(new Mr(this.context,e))):t.startOffset>=s&&t.start(new Mr(this.context,e))}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t,this._forEach((t=>{t.startOffset+=this._startOffset}))}stop(t){const e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach((e=>{e.stop(t)})),this}at(t,e){const s=new Ki(this.context,t).toTicks(),n=new Mr(this.context,1).toSeconds(),i=this._events.values();let o=i.next();for(;!o.done;){const t=o.value;if(Math.abs(s-t.startOffset)<n)return Gn(e)&&(t.value=e),t;o=i.next()}return Gn(e)?(this.add(t,e),this.at(t)):null}add(t,e){t instanceof Object&&Reflect.has(t,"time")&&(t=(e=t).time);const s=this.toTicks(t);let n;return e instanceof Va?(n=e,n.callback=this._tick.bind(this)):n=new Va({callback:this._tick.bind(this),context:this.context,value:e}),n.startOffset=s,n.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(n),this._restartEvent(n),this}_restartEvent(t){this._state.forEach((e=>{"started"===e.state?this._startNote(t,e.time,e.offset):t.stop(new Mr(this.context,e.time))}))}remove(t,e){return Xn(t)&&t.hasOwnProperty("time")&&(t=(e=t).time),t=this.toTicks(t),this._events.forEach((s=>{s.startOffset===t&&(Un(e)||Gn(e)&&s.value===e)&&(this._events.delete(s),s.dispose())})),this}clear(){return this._forEach((t=>t.dispose())),this._events.clear(),this}cancel(t){return this._forEach((e=>e.cancel(t))),this._state.cancel(this.toTicks(t)),this}_forEach(t){return this._events&&this._events.forEach((e=>{e instanceof Fa?e._forEach(t):t(e)})),this}_setAll(t,e){this._forEach((s=>{s[t]=e}))}_tick(t,e){this.mute||this.callback(t,e)}_testLoopBoundaries(t){this._loop&&(t.startOffset<this._loopStart||t.startOffset>=this._loopEnd)?t.cancel(0):"stopped"===t.state&&this._restartEvent(t)}get probability(){return this._probability}set probability(t){this._probability=t,this._setAll("probability",t)}get humanize(){return this._humanize}set humanize(t){this._humanize=t,this._setAll("humanize",t)}get loop(){return this._loop}set loop(t){this._loop=t,this._forEach((e=>{e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.loop=t,this._testLoopBoundaries(e)}))}get loopEnd(){return new Mr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach((e=>{e.loopEnd=t,this._testLoopBoundaries(e)}))}get loopStart(){return new Mr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach((t=>{t.loopStart=this.loopStart,this._testLoopBoundaries(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._setAll("playbackRate",t)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}function*Pa(t){let e=0;for(;e<t;)e=xi(e,0,t-1),yield e,e++}function*Na(t){let e=t-1;for(;e>=0;)e=xi(e,0,t-1),yield e,e--}function*ja(t,e){for(;;)yield*e(t)}function*La(t,e){let s=e?0:t-1;for(;;)s=xi(s,0,t-1),yield s,e?(s++,s>=t-1&&(e=!1)):(s--,s<=0&&(e=!0))}function*za(t){let e=0,s=0;for(;e<t;)e=xi(e,0,t-1),yield e,s++,e+=s%2?2:-1}function*Wa(t){let e=t-1,s=0;for(;e>=0;)e=xi(e,0,t-1),yield e,s++,e+=s%2?-2:1}function*Ba(t){const e=[];for(let s=0;s<t;s++)e.push(s);for(;e.length>0;){const s=xi(e.splice(Math.floor(e.length*Math.random()),1)[0],0,t-1);yield s}}function*Ua(t,e="up"){switch(Kn(t>=1,"The number of values must be at least one"),e){case"up":yield*ja(t,Pa);case"down":yield*ja(t,Na);case"upDown":yield*La(t,!0);case"downUp":yield*La(t,!1);case"alternateUp":yield*ja(t,za);case"alternateDown":yield*ja(t,Wa);case"random":yield*function*(t){for(;;){const e=Math.floor(Math.random()*t);yield e}}(t);case"randomOnce":yield*ja(t,Ba);case"randomWalk":yield*function*(t){let e=Math.floor(Math.random()*t);for(;;)0===e?e++:e===t-1||Math.random()<.5?e--:e++,yield e}(t)}}class Ga extends Ia{constructor(){const t=pi(Ga.getDefaults(),arguments,["callback","values","pattern"]);super(t),this.name="Pattern",this.callback=t.callback,this._values=t.values,this._pattern=Ua(t.values.length,t.pattern),this._type=t.pattern}static getDefaults(){return Object.assign(Ia.getDefaults(),{pattern:"up",values:[],callback:Ni})}_tick(t){const e=this._pattern.next();this._index=e.value,this._value=this._values[e.value],this.callback(t,this._value)}get values(){return this._values}set values(t){this._values=t,this.pattern=this._type}get value(){return this._value}get index(){return this._index}get pattern(){return this._type}set pattern(t){this._type=t,this._pattern=Ua(this._values.length,this._type)}}class Qa extends Va{constructor(){const t=pi(Qa.getDefaults(),arguments,["callback","events","subdivision"]);super(t),this.name="Sequence",this._part=new Fa({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[],this._subdivision=this.toTicks(t.subdivision),this.events=t.events,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.playbackRate=t.playbackRate,this.probability=t.probability,this.humanize=t.humanize,this.mute=t.mute,this.playbackRate=t.playbackRate}static getDefaults(){return Object.assign(fi(Va.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})}_seqCallback(t,e){null===e||this.mute||this.callback(t,e)}get events(){return this._events}set events(t){this.clear(),this._eventsArray=t,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(t,e){return this._part.start(t,e?this._indexTime(e):e),this}stop(t){return this._part.stop(t),this}get subdivision(){return new Mr(this.context,this._subdivision).toSeconds()}_createSequence(t){return new Proxy(t,{get:(t,e)=>t[e],set:(t,e,s)=>($n(e)&&isFinite(parseInt(e,10))&&Hn(s)?t[e]=this._createSequence(s):t[e]=s,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(t,e,s){t.forEach(((t,n)=>{const i=n*e+s;if(Hn(t))this._rescheduleSequence(t,e/t.length,i);else{const e=new Mr(this.context,i,"i").toSeconds();this._part.add(e,t)}}))}_indexTime(t){return new Mr(this.context,t*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(t){this._part.loop=t}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this._part.loopStart=this._indexTime(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this._part.loopEnd=0===t?this._indexTime(this._eventsArray.length):this._indexTime(t)}get startOffset(){return this._part.startOffset}set startOffset(t){this._part.startOffset=t}get playbackRate(){return this._part.playbackRate}set playbackRate(t){this._part.playbackRate=t}get probability(){return this._part.probability}set probability(t){this._part.probability=t}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(t){this._part.humanize=t}get length(){return this._part.length}}class Za extends Wr{constructor(){const t=pi(Za.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new Fr({context:this.context}),this._modulationNode=new co({context:this.context}),this._carrier=new Gr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new Gr({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Po({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),Fi(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Gr.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}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 Xa extends Wr{constructor(){const t=pi(Xa.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this.detune=new go({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,Fi(this,["frequency","detune"])}static getDefaults(){return Object.assign(Gr.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach((e=>e.start(t)))}_stop(t){t=this.toSeconds(t),this._forEach((e=>e.stop(t)))}_restart(t){this._forEach((e=>e.restart(t)))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach((e=>e.type=t))}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,s=t/(this._oscillators.length-1);this._forEach(((t,n)=>t.detune.value=e+s*n))}}get count(){return this._oscillators.length}set count(t){if(ti(t,1),this._oscillators.length!==t){this._forEach((t=>t.dispose())),this._oscillators=[];for(let e=0;e<t;e++){const s=new Gr({context:this.context,volume:-6-1.1*t,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:0===e?()=>this.onstop(this):Ni});"custom"===this.type&&(s.partials=this._partials),this.frequency.connect(s.frequency),this.detune.connect(s.detune),s.detune.overridden=!1,s.connect(this.output),this._oscillators[e]=s}this.spread=this._spread,"started"===this.state&&this._forEach((t=>t.start()))}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach(((t,e)=>t.phase=this._phase+e/this.count*360))}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach((e=>e.baseType=t)),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach((e=>e.partials=t)))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach((e=>e.partialCount=t)),this._type=this._oscillators[0].type}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach((t=>t.dispose())),this}}class Ya extends Wr{constructor(){const t=pi(Ya.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new co({context:this.context,gain:0}),this._carrier=new Gr({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Gr({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Po({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Po({context:this.context,units:"positive",value:t.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),Fi(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Gr.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class Ha extends Wr{constructor(){const t=pi(Ha.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new co({context:this.context,gain:0}),this._thresh=new bo({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new go({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Gr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.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),Fi(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Wr.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class $a extends Wr{constructor(){const t=pi($a.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Po({context:this.context,value:2}),this._pulse=new Ha({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Gr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),Fi(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Wr.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Ja={am:Za,fat:Xa,fm:Ya,oscillator:Gr,pulse:Ha,pwm:$a};class Ka extends Wr{constructor(){const t=pi(Ka.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new go({context:this.context,units:"frequency",value:t.frequency}),this.detune=new go({context:this.context,units:"cents",value:t.detune}),Fi(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Gr.getDefaults(),Ya.getDefaults(),Za.getDefaults(),Xa.getDefaults(),Ha.getDefaults(),$a.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some((t=>this._sourceType===t))&&(t=this._sourceType),t+this._oscillator.type}set type(t){"fm"===t.substr(0,2)?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):"pwm"===t?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):"pulse"===t?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;const e=Ja[t],s=this.now();if(this._oscillator){const t=this._oscillator;t.stop(s),this.context.setTimeout((()=>t.dispose()),this.blockTime)}this._oscillator=new e({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),"started"===this.state&&this._oscillator.start(s)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";"pwm"!==this._oscillator.type&&"pulse"!==this._oscillator.type&&(e=this._oscillator.type),"fm"===t?this.type="fm"+e:"am"===t?this.type="am"+e:"fat"===t?this.type="fat"+e:"oscillator"===t?this.type=e:"pulse"===t?this.type="pulse":"pwm"===t&&(this.type="pwm")}_getOscType(t,e){return t instanceof Ja[e]}get baseType(){return this._oscillator.baseType}set baseType(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||"pulse"===t||"pwm"===t||(this._oscillator.baseType=t)}get width(){return this._getOscType(this._oscillator,"pulse")?this._oscillator.width:void 0}get count(){return this._getOscType(this._oscillator,"fat")?this._oscillator.count:void 0}set count(t){this._getOscType(this._oscillator,"fat")&&Zn(t)&&(this._oscillator.count=t)}get spread(){return this._getOscType(this._oscillator,"fat")?this._oscillator.spread:void 0}set spread(t){this._getOscType(this._oscillator,"fat")&&Zn(t)&&(this._oscillator.spread=t)}get modulationType(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.modulationType:void 0}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&$n(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){return this._getOscType(this._oscillator,"fm")?this._oscillator.modulationIndex:void 0}get harmonicity(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.harmonicity:void 0}get modulationFrequency(){return this._getOscType(this._oscillator,"pwm")?this._oscillator.modulationFrequency:void 0}asArray(){return Ci(this,arguments,void 0,(function*(t=1024){return Br(this,t)}))}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class tc extends no{constructor(){const t=pi(tc.getDefaults(),arguments);super(t),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 Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume")}static getDefaults(){return Object.assign(no.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 t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){const s=this["_original_"+t]=this[t];this[t]=(...t)=>{const n=t[e],i=this.context.transport.schedule((n=>{t[e]=n,s.apply(this,t)}),n);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach((t=>this.context.transport.clear(t))),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(t,e,s,n){const i=this.toSeconds(s),o=this.toSeconds(e);return this.triggerAttack(t,i,n),this.triggerRelease(i+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class ec extends tc{constructor(){const t=pi(ec.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(tc.getDefaults(),{detune:0,onsilence:Ni,portamento:0})}triggerAttack(t,e,s=1){this.log("triggerAttack",t,e,s);const n=this.toSeconds(e);return this._triggerEnvelopeAttack(n,s),this.setNote(t,n),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const s=this.toSeconds(e),n=t instanceof Yi?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(s)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(n,t,s)}else this.frequency.setValueAtTime(n,s);return this}}Ai([nr(0)],ec.prototype,"portamento",void 0);class sc extends ec{constructor(){const t=pi(sc.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new Ka(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new rr(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),Fi(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ec.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(fi(Ka.getDefaults(),[...Object.keys(Wr.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),s=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+s)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class nc extends ec{constructor(){const t=pi(nc.getDefaults(),arguments);super(t),this.name="ModulationSynth",this._carrier=new sc({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new sc({context:this.context,oscillator:t.modulation,envelope:t.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 go({context:this.context,units:"frequency"}),this.detune=new go({context:this.context,value:t.detune,units:"cents"}),this.harmonicity=new Po({context:this.context,value:t.harmonicity,minValue:0}),this._modulationNode=new co({context:this.context,gain:0}),Fi(this,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])}static getDefaults(){return Object.assign(ec.getDefaults(),{harmonicity:3,oscillator:Object.assign(fi(Ka.getDefaults(),[...Object.keys(Wr.getDefaults()),"frequency","detune"]),{type:"sine"}),envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(fi(Ka.getDefaults(),[...Object.keys(Wr.getDefaults()),"frequency","detune"]),{type:"square"}),modulationEnvelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(t,e){this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}}class ic extends nc{constructor(){super(pi(ic.getDefaults(),arguments)),this.name="AMSynth",this._modulationScale=new Fr({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 oc extends ec{constructor(){const t=pi(oc.getDefaults(),arguments);super(t),this.name="MonoSynth",this.oscillator=new Ka(Object.assign(t.oscillator,{context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new Uo(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new hr(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new rr(Object.assign(t.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),Fi(this,["oscillator","frequency","detune","filter","filterEnvelope","envelope"])}static getDefaults(){return Object.assign(ec.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(fi(Uo.getDefaults(),Object.keys(no.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(fi(hr.getDefaults(),Object.keys(no.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(fi(Ka.getDefaults(),Object.keys(Wr.getDefaults())),{type:"sawtooth"})})}_triggerEnvelopeAttack(t,e=1){if(this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),s=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+s)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}}class rc extends ec{constructor(){const t=pi(rc.getDefaults(),arguments);super(t),this.name="DuoSynth",this.voice0=new oc(Object.assign(t.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new oc(Object.assign(t.voice1,{context:this.context})),this.harmonicity=new Po({context:this.context,units:"positive",value:t.harmonicity}),this._vibrato=new Qr({frequency:t.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new co({context:this.context,units:"normalRange",gain:t.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new go({context:this.context,units:"frequency",value:440}),this.detune=new go({context:this.context,units:"cents",value:t.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),Fi(this,["voice0","voice1","frequency","vibratoAmount","vibratoRate"])}getLevelAtTime(t){return t=this.toSeconds(t),this.voice0.envelope.getValueAtTime(t)+this.voice1.envelope.getValueAtTime(t)}static getDefaults(){return ui(ec.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:ui(fi(oc.getDefaults(),Object.keys(ec.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:ui(fi(oc.getDefaults(),Object.keys(ec.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(t,e){this.voice0._triggerEnvelopeAttack(t,e),this.voice1._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this.voice0._triggerEnvelopeRelease(t),this.voice1._triggerEnvelopeRelease(t),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 ac extends nc{constructor(){const t=pi(ac.getDefaults(),arguments);super(t),this.name="FMSynth",this.modulationIndex=new Po({context:this.context,value:t.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(nc.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}}class cc extends sc{constructor(){const t=pi(cc.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Fi(this,["oscillator","envelope"])}static getDefaults(){return ui(ec.getDefaults(),sc.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:8,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const s=this.toSeconds(e),n=this.toFrequency(t instanceof Yi?t.toFrequency():t),i=n*Math.pow(2,this.octaves);return this.oscillator.frequency.setValueAtTime(i,s),this.oscillator.frequency.exponentialRampToValueAtTime(n,s+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}Ai([sr(.5,8)],cc.prototype,"octaves",void 0),Ai([nr(0,.5)],cc.prototype,"pitchDecay",void 0);const hc=[1,1.483,1.932,2.546,2.63,3.897];class lc extends ec{constructor(){const t=pi(lc.getDefaults(),arguments);super(t),this.name="MetalSynth",this._oscillators=[],this._freqMultipliers=[],this.detune=new go({context:this.context,units:"cents",value:t.detune}),this.frequency=new go({context:this.context,units:"frequency"}),this._amplitude=new co({context:this.context,gain:0}).connect(this.output),this._highpass=new Uo({Q:0,context:this.context,type:"highpass"}).connect(this._amplitude);for(let e=0;e<hc.length;e++){const s=new Ya({context:this.context,harmonicity:t.harmonicity,modulationIndex:t.modulationIndex,modulationType:"square",onstop:0===e?()=>this.onsilence(this):Ni,type:"square"});s.connect(this._highpass),this._oscillators[e]=s;const n=new Po({context:this.context,value:hc[e]});this._freqMultipliers[e]=n,this.frequency.chain(n,s.frequency),this.detune.connect(s.detune)}this._filterFreqScaler=new cr({context:this.context,max:7e3,min:this.toFrequency(t.resonance)}),this.envelope=new ir({attack:t.envelope.attack,attackCurve:"linear",context:this.context,decay:t.envelope.decay,release:t.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=t.octaves,this.octaves=t.octaves}static getDefaults(){return ui(ec.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(t,e=1){return this.envelope.triggerAttack(t,e),this._oscillators.forEach((e=>e.start(t))),0===this.envelope.sustain&&this._oscillators.forEach((e=>{e.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))})),this}_triggerEnvelopeRelease(t){return this.envelope.triggerRelease(t),this._oscillators.forEach((e=>e.stop(t+this.toSeconds(this.envelope.release)))),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(t){this._oscillators.forEach((e=>e.modulationIndex.value=t))}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(t){this._oscillators.forEach((e=>e.harmonicity.value=t))}get resonance(){return this._filterFreqScaler.min}set resonance(t){this._filterFreqScaler.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}dispose(){return super.dispose(),this._oscillators.forEach((t=>t.dispose())),this._freqMultipliers.forEach((t=>t.dispose())),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}}class uc extends tc{constructor(){const t=pi(uc.getDefaults(),arguments);super(t),this.name="NoiseSynth",this.noise=new ba(Object.assign({context:this.context},t.noise)),this.envelope=new rr(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(tc.getDefaults(),{envelope:Object.assign(fi(ir.getDefaults(),Object.keys(no.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(fi(ba.getDefaults(),Object.keys(Wr.getDefaults())),{type:"white"})})}triggerAttack(t,e=1){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.noise.start(t),0===this.envelope.sustain&&this.noise.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.noise.stop(t+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0)),this}triggerAttackRelease(t,e,s=1){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,s),this.triggerRelease(e+t),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}class pc extends tc{constructor(){const t=pi(pc.getDefaults(),arguments);super(t),this.name="PluckSynth",this._noise=new ba({context:this.context,type:"pink"}),this.attackNoise=t.attackNoise,this._lfcf=new vr({context:this.context,dampening:t.dampening,resonance:t.resonance}),this.resonance=t.resonance,this.release=t.release,this._noise.connect(this._lfcf),this._lfcf.connect(this.output)}static getDefaults(){return ui(tc.getDefaults(),{attackNoise:1,dampening:4e3,resonance:.7,release:1})}get dampening(){return this._lfcf.dampening}set dampening(t){this._lfcf.dampening=t}triggerAttack(t,e){const s=this.toFrequency(t);e=this.toSeconds(e);const n=1/s;return this._lfcf.delayTime.setValueAtTime(n,e),this._noise.start(e),this._noise.stop(e+n*this.attackNoise),this._lfcf.resonance.cancelScheduledValues(e),this._lfcf.resonance.setValueAtTime(this.resonance,e),this}triggerRelease(t){return this._lfcf.resonance.linearRampTo(0,this.release,t),this}dispose(){return super.dispose(),this._noise.dispose(),this._lfcf.dispose(),this}}class dc extends tc{constructor(){const t=pi(dc.getDefaults(),arguments,["voice","options"]);super(t),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=t=>this.releaseAll(t),Kn(!Zn(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");const e=t.voice.getDefaults();this.options=Object.assign(e,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();const s=this._voices.indexOf(this._dummyVoice);this._voices.splice(s,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(tc.getDefaults(),{maxPolyphony:32,options:{},voice:sc})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);const e=this._activeVoices.findIndex((e=>e.voice===t));this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){const t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return Kn(t instanceof ec,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}hi("Max polyphony exceeded. Note dropped.")}_collectGarbage(){if(this._averageActiveVoices=Math.max(.95*this._averageActiveVoices,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){const t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,s){t.forEach((t=>{const n=new Or(this.context,t).toMidi(),i=this._getNextAvailableVoice();i&&(i.triggerAttack(t,e,s),this._activeVoices.push({midi:n,voice:i,released:!1}),this.log("triggerAttack",t,e))}))}_triggerRelease(t,e){t.forEach((t=>{const s=new Or(this.context,t).toMidi(),n=this._activeVoices.find((({midi:t,released:e})=>t===s&&!e));n&&(n.voice.triggerRelease(e),n.released=!0,this.log("triggerRelease",t,e))}))}_scheduleEvent(t,e,s,n){Kn(!this.disposed,"Synth was already disposed"),s<=this.now()?"attack"===t?this._triggerAttack(e,s,n):this._triggerRelease(e,s):this.context.setTimeout((()=>{this.disposed||this._scheduleEvent(t,e,s,n)}),s-this.now())}triggerAttack(t,e,s){Array.isArray(t)||(t=[t]);const n=this.toSeconds(e);return this._scheduleEvent("attack",t,n,s),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);const s=this.toSeconds(e);return this._scheduleEvent("release",t,s),this}triggerAttackRelease(t,e,s,n){const i=this.toSeconds(s);if(this.triggerAttack(t,i,n),Hn(e)){Kn(Hn(t),"If the duration is an array, the notes must also be an array");for(let s=0;s<t.length;s++){const n=e[Math.min(s,e.length-1)],o=this.toSeconds(n);Kn(o>0,"The duration must be greater than 0"),this.triggerRelease(t[s],i+o)}}else{const s=this.toSeconds(e);Kn(s>0,"The duration must be greater than 0"),this.triggerRelease(t,i+s)}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(t){const e=fi(t,["onsilence","context"]);return this.options=ui(this.options,e),this._voices.forEach((t=>t.set(e))),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){const e=this.toSeconds(t);return this._activeVoices.forEach((({voice:t})=>{t.triggerRelease(e)})),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach((t=>t.dispose())),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}}class fc extends tc{constructor(){const t=pi(fc.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map,this._providedMidiNotes=[];const e={};Object.keys(t.urls).forEach((s=>{const n=parseInt(s,10);if(Kn(Jn(s)||Zn(n)&&isFinite(n),`url key is neither a note or midi pitch: ${s}`),Jn(s)){const n=new Yi(this.context,s).toMidi();e[n]=t.urls[s]}else Zn(n)&&isFinite(n)&&(e[n]=t.urls[n])})),this._buffers=new Cr({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(tc.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Ni,onerror:Ni,release:.1,urls:{},loop:!1,loopEnd:0,loopStart:0})}_findClosest(t){let e=0;for(;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,s=1){this.log("triggerAttack",t,e,s),Array.isArray(t)||(t=[t]);const n=di(this._loopStart,0);return t.forEach((t=>{const i=h(new Yi(this.context,t).toFrequency()),o=Math.round(i),a=i-o,c=this._findClosest(o),l=o-c,u=this._buffers.get(l),p=r(c+a),d=this._loop?void 0:u.duration/p,f=new wa({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,loop:this._loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:p}).connect(this.output);f.start(e,n,d,s),Hn(this._activeSources.get(o))||this._activeSources.set(o,[]),this._activeSources.get(o).push(f),f.onended=()=>{if(this._activeSources&&this._activeSources.has(o)){const t=this._activeSources.get(o),e=t.indexOf(f);-1!==e&&t.splice(e,1)}}})),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach((t=>{const s=new Yi(this.context,t).toMidi();if(this._activeSources.has(s)&&this._activeSources.get(s).length){const t=this._activeSources.get(s);e=this.toSeconds(e),t.forEach((t=>{t.stop(e)})),this._activeSources.set(s,[])}})),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach((t=>{for(;t.length;)t.shift().stop(e)})),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,s,n=1){const i=this.toSeconds(s);return this.triggerAttack(t,i,n),Hn(e)?(Kn(Hn(t),"notes must be an array when duration is array"),t.forEach(((t,s)=>{const n=e[Math.min(s,e.length-1)];this.triggerRelease(t,i+this.toSeconds(n))}))):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,s){if(Kn(Jn(t)||isFinite(t),`note must be a pitch or midi: ${t}`),Jn(t)){const n=new Yi(this.context,t).toMidi();this._buffers.add(n,e,s)}else this._buffers.add(t,e,s);return this}get loaded(){return this._buffers.loaded}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this._providedMidiNotes.forEach((e=>{const s=this._buffers.get(e);s.loaded&&ti(this.toSeconds(t),0,s.duration)})),this._activeSources.forEach((e=>{e.forEach((e=>{e.loopStart=t}))}))}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this._providedMidiNotes.forEach((e=>{const s=this._buffers.get(e);s.loaded&&ti(this.toSeconds(t),0,s.duration)})),this._activeSources.forEach((e=>{e.forEach((e=>{e.loopEnd=t}))}))}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this._activeSources.forEach((e=>{e.forEach((e=>{e.loop=t}))})))}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach((t=>{t.forEach((t=>t.dispose()))})),this._activeSources.clear(),this}}Ai([nr(0)],fc.prototype,"attack",void 0),Ai([nr(0)],fc.prototype,"release",void 0);class _c extends go{constructor(){const t=pi(go.getDefaults(),arguments,["value","units"]);super(t),this.name="SyncedSignal",this.override=!1,this._lastVal=t.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 mo({context:this.context,offset:t.value,units:t.units}).start(0),this.setValueAtTime(t.value,0)}_onTick(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==e&&(this._lastVal=e,this._constantSource.offset.setValueAtTime(e,t))}_anchorValue(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal=e,this._constantSource.offset.cancelAndHoldAtTime(t),this._constantSource.offset.setValueAtTime(e,t)}getValueAtTime(t){const e=new Ki(this.context,t).toSeconds();return super.getValueAtTime(e)}setValueAtTime(t,e){const s=new Ki(this.context,e).toSeconds();return super.setValueAtTime(t,s),this}linearRampToValueAtTime(t,e){const s=new Ki(this.context,e).toSeconds();return super.linearRampToValueAtTime(t,s),this}exponentialRampToValueAtTime(t,e){const s=new Ki(this.context,e).toSeconds();return super.exponentialRampToValueAtTime(t,s),this}setTargetAtTime(t,e,s){const n=new Ki(this.context,e).toSeconds();return super.setTargetAtTime(t,n,s),this}cancelScheduledValues(t){const e=new Ki(this.context,t).toSeconds();return super.cancelScheduledValues(e),this}setValueCurveAtTime(t,e,s,n){const i=new Ki(this.context,e).toSeconds();return s=this.toSeconds(s),super.setValueCurveAtTime(t,i,s,n),this}cancelAndHoldAtTime(t){const e=new Ki(this.context,t).toSeconds();return super.cancelAndHoldAtTime(e),this}setRampPoint(t){const e=new Ki(this.context,t).toSeconds();return super.setRampPoint(e),this}exponentialRampTo(t,e,s){const n=new Ki(this.context,s).toSeconds();return super.exponentialRampTo(t,e,n),this}linearRampTo(t,e,s){const n=new Ki(this.context,s).toSeconds();return super.linearRampTo(t,e,n),this}targetRampTo(t,e,s){const n=new Ki(this.context,s).toSeconds();return super.targetRampTo(t,e,n),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 mc extends Wr{constructor(){const t=pi(mc.getDefaults(),arguments,["url","onload"]);super(t),this.name="GrainPlayer",this._loopStart=0,this._loopEnd=0,this._activeSources=[],this.buffer=new ji({onload:t.onload,onerror:t.onerror,reverse:t.reverse,url:t.url}),this._clock=new Tr({context:this.context,callback:this._tick.bind(this),frequency:1/t.grainSize}),this._playbackRate=t.playbackRate,this._grainSize=t.grainSize,this._overlap=t.overlap,this.detune=t.detune,this.overlap=t.overlap,this.loop=t.loop,this.playbackRate=t.playbackRate,this.grainSize=t.grainSize,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.reverse=t.reverse,this._clock.on("stop",this._onstop.bind(this))}static getDefaults(){return Object.assign(Wr.getDefaults(),{onload:Ni,onerror:Ni,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(t,e,s){e=di(e,0),e=this.toSeconds(e),t=this.toSeconds(t);const n=1/this._clock.frequency.getValueAtTime(t);this._clock.start(t,e/n),s&&this.stop(t+this.toSeconds(s))}restart(t,e,s){return super.restart(t,e,s),this}_restart(t,e,s){this._stop(t),this._start(t,e,s)}_stop(t){this._clock.stop(t)}_onstop(t){this._activeSources.forEach((e=>{e.fadeOut=0,e.stop(t)})),this.onstop(this)}_tick(t){const e=this._clock.getTicksAtTime(t),s=e*this._grainSize;if(this.log("offset",s),!this.loop&&s>this.buffer.duration)return void this.stop(t);const n=s<this._overlap?0:this._overlap,i=new wa({context:this.context,url:this.buffer,fadeIn:n,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:r(this.detune/100)}).connect(this.output);i.start(t,this._grainSize*e),i.stop(t+this._grainSize/this.playbackRate),this._activeSources.push(i),i.onended=()=>{const t=this._activeSources.indexOf(i);-1!==t&&this._activeSources.splice(t,1)}}get playbackRate(){return this._playbackRate}set playbackRate(t){ti(t,.001),this._playbackRate=t,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(t){this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._loopStart=this.toSeconds(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._loopEnd=this.toSeconds(t)}get reverse(){return this.buffer.reverse}set reverse(t){this.buffer.reverse=t}get grainSize(){return this._grainSize}set grainSize(t){this._grainSize=this.toSeconds(t),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(t){const e=this.toSeconds(t);ti(e,0),this._overlap=e}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach((t=>t.dispose())),this}}class gc extends Wr{constructor(){const t=pi(gc.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._constantSource=new mo({context:this.context,units:"hertz",offset:0}),this._progressTracker=new xr({context:this.context,units:"hertz",value:0,param:this._constantSource.offset}),this._progressOffset=new ki(1/0),this._buffer=new ji({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Wr.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Ni,onerror:Ni,playbackRate:1,reverse:!1})}load(t){return Ci(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_getProgressAtTime(t){if("stopped"===this._state.getValueAtTime(t))return 0;const e=this._state.getLastState("started",t);let s=0;this._progressOffset.forEachBetween(e.time,t,(t=>{s+=t.seek}));const n=this._progressTracker.getTicksAtTime(t)+s;if(this._loop){const t=0===this.loopEnd?this.buffer.duration:this.toSeconds(this.loopEnd),e=this.toSeconds(this.loopStart);return n%(t-e)+e}return n}get progress(){const t=this.now();return this._getProgressAtTime(t)}_onload(t=Ni){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),0!==this._activeSources.size||this._synced||"started"!==this._state.getValueAtTime(this.now())||(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,s){return super.start(t,e,s),this}_start(t,e,s){e=this._loop?di(e,this._loopStart):di(e,0);const n=this.toSeconds(e),i=s;s=di(s,Math.max(this._buffer.duration-n,0));let o=this.toSeconds(s);o/=this._playbackRate,t=this.toSeconds(t);const r=new wa({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(t+o),this._state.setStateAtTime("stopped",t+o,{implicitEnd:!0})),this._activeSources.add(r);const a=n-this._getProgressAtTime(t);this._progressOffset.add({time:t,seek:a}),this._progressTracker.setValueAtTime(this._playbackRate,t),this._loop&&Un(i)?r.start(t,n):r.start(t,n,o-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach((t=>t.stop(e))),this._progressTracker.setValueAtTime(0,e)}restart(t,e,s){return super.restart(t,e,s),this}_restart(t,e,s){var n;null===(n=[...this._activeSources].pop())||void 0===n||n.stop(t),this._start(t,e,s)}seek(t,e){const s=this.toSeconds(e);if("started"===this._state.getValueAtTime(s)){const e=this.toSeconds(t);this._stop(s),this._state.cancel(s),this._start(s,e)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach((e=>{e.loopStart=t}))}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&ti(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach((e=>{e.loopEnd=t}))}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach((e=>{e.loop=t})),t)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;const e=this.now();this._progressTracker.setValueAtTime(t,e);const s=this._state.getNextState("stopped",e);if(s&&s.implicitEnd){this._state.cancel(s.time),this._activeSources.forEach((t=>t.cancelStop()));const n=this._getProgressAtTime(e),i=this._buffer.duration-n,o=e+i/t;this._state.setStateAtTime("stopped",o,{implicitEnd:!0})}this._activeSources.forEach((s=>{s.playbackRate.setValueAtTime(t,e)}))}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach((t=>t.dispose())),this._activeSources.clear(),this._buffer.dispose(),this._constantSource.dispose(),this._progressTracker.dispose(),this._progressOffset.dispose(),this}}Ai([nr(0)],gc.prototype,"fadeIn",void 0),Ai([nr(0)],gc.prototype,"fadeOut",void 0);class vc extends no{constructor(){const t=pi(vc.getDefaults(),arguments,["urls","onload"],"urls");super(t),this.name="Players",this.input=void 0,this._players=new Map,this._volume=this.output=new Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume"),this._buffers=new Cr({urls:t.urls,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.mute=t.mute,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Wr.getDefaults(),{baseUrl:"",fadeIn:0,fadeOut:0,mute:!1,onload:Ni,onerror:Ni,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._players.forEach((e=>{e.fadeIn=t}))}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._players.forEach((e=>{e.fadeOut=t}))}get state(){return Array.from(this._players).some((([t,e])=>"started"===e.state))?"started":"stopped"}has(t){return this._buffers.has(t)}player(t){if(Kn(this.has(t),`No Player with the name ${t} exists on this object`),!this._players.has(t)){const e=new gc({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(t)}).connect(this.output);this._players.set(t,e)}return this._players.get(t)}get loaded(){return this._buffers.loaded}add(t,e,s){return Kn(!this._buffers.has(t),"A buffer with that name already exists on this object"),this._buffers.add(t,e,s),this}stopAll(t){return this._players.forEach((e=>e.stop(t))),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach((t=>t.dispose())),this._buffers.dispose(),this}}class yc extends no{constructor(){const t=pi(yc.getDefaults(),arguments,["volume"]);super(t),this.name="UserMedia",this._volume=this.output=new Do({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Fi(this,"volume"),this.mute=t.mute}static getDefaults(){return Object.assign(no.getDefaults(),{mute:!1,volume:0})}open(t){return Ci(this,void 0,void 0,(function*(){Kn(yc.supported,"UserMedia is not supported"),"started"===this.state&&this.close();const e=yield yc.enumerateDevices();Zn(t)?this._device=e[t]:(this._device=e.find((e=>e.label===t||e.deviceId===t)),!this._device&&e.length>0&&(this._device=e[0]),Kn(Gn(this._device),`No matching device ${t}`));const s={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(s.audio.deviceId=this._device.deviceId);const n=yield navigator.mediaDevices.getUserMedia(s);if(!this._stream){this._stream=n;const t=this.context.createMediaStreamSource(n);oo(t,this.output),this._mediaStream=t}return this}))}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach((t=>{t.stop()})),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return Ci(this,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((t=>"audioinput"===t.kind))}))}get state(){return this._stream&&this._stream.active?"started":"stopped"}get deviceId(){return this._device?this._device.deviceId:void 0}get groupId(){return this._device?this._device.groupId:void 0}get label(){return this._device?this._device.label:void 0}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return Gn(navigator.mediaDevices)&&Gn(navigator.mediaDevices.getUserMedia)}}function xc(){return Bi().now()}function wc(){return Bi().immediate()}const bc=Bi().transport;function Tc(){return Bi().transport}const Sc=Bi().destination,kc=Bi().destination;function Ac(){return Bi().destination}const Cc=Bi().listener;function Oc(){return Bi().listener}const Dc=Bi().draw;function Mc(){return Bi().draw}const Ec=Bi();function Rc(){return ji.loaded()}const qc=ji,Vc=Cr,Ic=wa})(),n})()));
3
3
  //# sourceMappingURL=Tone.js.map