/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/simple-notification-sounds@1.0.0/dist/simple-notification-sounds.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SimpleNotificationSounds={})}(this,(function(t){"use strict";const e="15.0.4",n=(t,e,n)=>({endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}),s=(t,e,n)=>({endTime:e,insertTime:n,type:"linearRampToValue",value:t}),i=(t,e)=>({startTime:e,type:"setValue",value:t}),o=(t,e,n)=>({duration:n,startTime:e,type:"setValueCurve",values:t}),r=(t,e,{startTime:n,target:s,timeConstant:i})=>s+(e-s)*Math.exp((n-t)/i),a=t=>"exponentialRampToValue"===t.type,c=t=>"linearRampToValue"===t.type,l=t=>a(t)||c(t),u=t=>"setValue"===t.type,h=t=>"setValueCurve"===t.type,p=(t,e,n,s)=>{const i=t[e];return void 0===i?s:l(i)||u(i)?i.value:h(i)?i.values[i.values.length-1]:r(n,p(t,e-1,i.startTime,s),i)},d=(t,e,n,s,i)=>void 0===n?[s.insertTime,i]:l(n)?[n.endTime,n.value]:u(n)?[n.startTime,n.value]:h(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,p(t,e-1,n.startTime,i)],f=t=>"cancelAndHold"===t.type,m=t=>"cancelScheduledValues"===t.type,_=t=>f(t)||m(t)?t.cancelTime:a(t)||c(t)?t.endTime:t.startTime,g=(t,e,n,{endTime:s,value:i})=>n===i?i:0<n&&0<i||n<0&&i<0?n*(i/n)**((t-e)/(s-e)):0,v=(t,e,n,{endTime:s,value:i})=>n+(t-e)/(s-e)*(i-n),y=(t,{duration:e,startTime:n,values:s})=>((t,e)=>{const n=Math.floor(e),s=Math.ceil(e);return n===s?t[n]:(1-(e-n))*t[n]+(1-(s-e))*t[s]})(s,(t-n)/e*(s.length-1)),w=t=>"setTarget"===t.type;class T{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){const e=_(t);if(f(t)||m(t)){const r=this._automationEvents.findIndex((n=>m(t)&&h(n)?n.startTime+n.duration>=e:_(n)>=e)),c=this._automationEvents[r];if(-1!==r&&(this._automationEvents=this._automationEvents.slice(0,r)),f(t)){const t=this._automationEvents[this._automationEvents.length-1];if(void 0!==c&&l(c)){if(void 0!==t&&w(t))throw new Error("The internal list is malformed.");const i=void 0===t?c.insertTime:h(t)?t.startTime+t.duration:_(t),o=void 0===t?this._defaultValue:h(t)?t.values[t.values.length-1]:t.value,r=a(c)?g(e,i,o,c):v(e,i,o,c),l=a(c)?n(r,e,this._currenTime):s(r,e,this._currenTime);this._automationEvents.push(l)}if(void 0!==t&&w(t)&&this._automationEvents.push(i(this.getValue(e),e)),void 0!==t&&h(t)&&t.startTime+t.duration>e){const n=e-t.startTime,s=(t.values.length-1)/t.duration,i=Math.max(2,1+Math.ceil(n*s)),r=n/(i-1)*s,a=t.values.slice(0,i);if(r<1)for(let e=1;e<i;e+=1){const n=r*e%1;a[e]=t.values[e-1]*(1-n)+t.values[e]*n}this._automationEvents[this._automationEvents.length-1]=o(a,t.startTime,n)}}}else{const i=this._automationEvents.findIndex((t=>_(t)>e)),o=-1===i?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[i-1];if(void 0!==o&&h(o)&&_(o)+o.duration>e)return!1;const r=a(t)?n(t.value,t.endTime,this._currenTime):c(t)?s(t.value,e,this._currenTime):t;if(-1===i)this._automationEvents.push(r);else{if(h(t)&&e+t.duration>_(this._automationEvents[i]))return!1;this._automationEvents.splice(i,0,r)}}return!0}flush(t){const e=this._automationEvents.findIndex((e=>_(e)>t));if(e>1){const t=this._automationEvents.slice(e-1),n=t[0];w(n)&&t.unshift(i(p(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=t}}getValue(t){if(0===this._automationEvents.length)return this._defaultValue;const e=this._automationEvents.findIndex((e=>_(e)>t)),n=this._automationEvents[e],s=(-1===e?this._automationEvents.length:e)-1,i=this._automationEvents[s];if(void 0!==i&&w(i)&&(void 0===n||!l(n)||n.insertTime>t))return r(t,p(this._automationEvents,s-1,i.startTime,this._defaultValue),i);if(void 0!==i&&u(i)&&(void 0===n||!l(n)))return i.value;if(void 0!==i&&h(i)&&(void 0===n||!l(n)||i.startTime+i.duration>t))return t<i.startTime+i.duration?y(t,i):i.values[i.values.length-1];if(void 0!==i&&l(i)&&(void 0===n||!l(n)))return i.value;if(void 0!==n&&a(n)){const[e,o]=d(this._automationEvents,s,i,n,this._defaultValue);return g(t,e,o,n)}if(void 0!==n&&c(n)){const[e,o]=d(this._automationEvents,s,i,n,this._defaultValue);return v(t,e,o,n)}return this._defaultValue}}const x=new WeakSet,b=new WeakMap,C=new WeakMap,A=new WeakMap,k=new WeakMap,S=new WeakMap,O=new WeakMap,M=new WeakMap,E=new WeakMap,R=new WeakMap,I={construct:()=>I},D=/^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]*);?/,N=(t,e)=>{const n=[];let s=t.replace(/^[\s]+/,""),i=s.match(D);for(;null!==i;){const t=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(o),s=s.slice(i[0].length).replace(/^[\s]+/,""),i=s.match(D)}return[n.join(";"),s]},V=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},P=t=>{if(!(t=>{try{new new Proxy(t,I)}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.")},q=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},F=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[s]=n;return t.delete(s),s},j=(t,e,n,s)=>{const i=q(t,e),o=F(i,(t=>t[0]===n&&t[1]===s));return 0===i.size&&t.delete(e),o},W=t=>q(O,t),B=t=>{if(x.has(t))throw new Error("The AudioNode is already stored.");x.add(t),W(t).forEach((t=>t(!0)))},L=t=>"port"in t,U=t=>{if(!x.has(t))throw new Error("The AudioNode is not stored.");x.delete(t),W(t).forEach((t=>t(!1)))},z=(t,e)=>{!L(t)&&e.every((t=>0===t.size))&&U(t)},G={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},X=(t,e)=>t.context===e,Y=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},Z=()=>new DOMException("","IndexSizeError"),H=t=>{var e;t.getChannelData=(e=t.getChannelData,n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw Z();throw t}})},$={numberOfChannels:1},Q=-34028234663852886e22,J=-Q,K=t=>x.has(t),tt={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},et=t=>q(b,t),nt=t=>q(A,t),st=(t,e)=>{const{activeInputs:n}=et(t);n.forEach((n=>n.forEach((([n])=>{e.includes(t)||st(n,[...e,t])}))));const s=(t=>"playbackRate"in t)(t)?[t.playbackRate]:L(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 s){const n=nt(t);void 0!==n&&n.activeInputs.forEach((([t])=>st(t,e)))}K(t)&&U(t)},it=t=>{st(t.destination,[])},ot=t=>"context"in t,rt=t=>ot(t[0]),at=(t,e,n,s)=>{for(const e of t)if(n(e)){if(s)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},ct=(t,e,[n,s],i)=>{at(t,[e,n,s],(t=>t[0]===e&&t[1]===n),i)},lt=(t,[e,n,s],i)=>{const o=t.get(e);void 0===o?t.set(e,new Set([[n,s]])):at(o,[n,s],(t=>t[0]===n),i)},ut=t=>"inputs"in t,ht=(t,e,n,s)=>{if(ut(e)){const i=e.inputs[s];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,s),[e,n,s]},pt=(t,e,n)=>{for(const s of t)if(s[0]===e&&s[1]===n)return t.delete(s),s;return null},dt=(t,e)=>{if(!W(t).delete(e))throw new Error("Missing the expected event listener.")},ft=(t,e,n)=>{const s=q(t,e),i=F(s,(t=>t[0]===n));return 0===s.size&&t.delete(e),i},mt=(t,e,n,s)=>{ut(e)?t.disconnect(e.inputs[s],n,0):t.disconnect(e,n,s)},_t=t=>q(C,t),gt=t=>q(k,t),vt=t=>M.has(t),yt=t=>!x.has(t),wt=(t,e)=>new Promise((n=>{if(null!==e)n(!0);else{const e=t.createScriptProcessor(256,1,1),s=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(s),r.disconnect(s),e.onaudioprocess=s=>{const i=s.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?n(!0):n(!1),r.stop(),e.onaudioprocess=null,r.disconnect(e),e.disconnect(t.destination)},r.start()}})),Tt=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach(((t,n)=>e(n,t)))},xt=t=>"context"in t,bt=(t,e,n,s)=>{const{activeInputs:i,passiveInputs:o}=nt(e),{outputs:r}=et(t),a=W(t),c=r=>{const a=_t(t),c=gt(e);if(r){const e=ft(o,t,n);ct(i,t,e,!1),s||vt(t)||a.connect(c,n)}else{const e=((t,e,n)=>F(t,(t=>t[0]===e&&t[1]===n)))(i,t,n);lt(o,e,!1),s||vt(t)||a.disconnect(c,n)}};return!!at(r,[e,n],(t=>t[0]===e&&t[1]===n),!0)&&(a.add(c),K(t)?ct(i,t,[n,c],!0):lt(o,[t,n,c],!0),!0)},Ct=(t,e,n,s,i)=>{const[o,r]=((t,e,n,s)=>{const{activeInputs:i,passiveInputs:o}=et(e),r=pt(i[s],t,n);if(null===r)return[j(o,t,n,s)[2],!1];return[r[2],!0]})(t,n,s,i);if(null!==o&&(dt(t,o),!r||e||vt(t)||mt(_t(t),_t(n),s,i)),K(n)){const{activeInputs:t}=et(n);z(n,t)}},At=(t,e,n,s)=>{const[i,o]=((t,e,n)=>{const{activeInputs:s,passiveInputs:i}=nt(e),o=pt(s,t,n);if(null===o)return[ft(i,t,n)[1],!1];return[o[2],!0]})(t,n,s);null!==i&&(dt(t,i),!o||e||vt(t)||_t(t).disconnect(gt(n),s))};class kt{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(((n,s)=>t.call(e,n,s,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 St={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function Ot(t,e,n,s,i){if("function"==typeof t.copyFromChannel)0===e[n].byteLength&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],s,i);else{const o=t.getChannelData(s);if(0===e[n].byteLength)e[n]=o.slice(i,i+128);else{const t=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(t)}}}const Mt=(t,e,n,s,i)=>{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],s,i):0!==e[n].byteLength&&t.getChannelData(s).set(e[n],i)},Et=(t,e)=>{const n=[];for(let s=0;s<t;s+=1){const t=[],i="number"==typeof e?e:e[s];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));n.push(t)}return n},Rt=async(t,e,n,s,i,o,r)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,c=s.channelCount*s.numberOfInputs,l=i.reduce(((t,e)=>t+e),0),u=0===l?null:n.createBuffer(l,a,n.sampleRate);if(void 0===o)throw new Error("Missing the processor constructor.");const h=et(t),p=await((t,e)=>{const n=q(R,t),s=_t(e);return q(n,s)})(n,t),d=Et(s.numberOfInputs,s.channelCount),f=Et(s.numberOfOutputs,i),m=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let l=0;l<a;l+=128){if(s.numberOfInputs>0&&null!==e)for(let t=0;t<s.numberOfInputs;t+=1)for(let n=0;n<s.channelCount;n+=1)Ot(e,d[t],n,n,l);void 0!==o.parameterDescriptors&&null!==e&&o.parameterDescriptors.forEach((({name:t},n)=>{Ot(e,m,t,c+n,l)}));for(let t=0;t<s.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===h.activeInputs[e].size?[]:t)),e=r(l/n.sampleRate,n.sampleRate,(()=>p.process(t,f,m)));if(null!==u)for(let t=0,e=0;t<s.numberOfOutputs;t+=1){for(let n=0;n<i[t];n+=1)Mt(u,f[t],n,e+n,l);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 u},It={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Dt={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Nt={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Vt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},Pt={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},qt=t=>{const{port1:e,port2:n}=new MessageChannel;return new Promise((s=>{const i=()=>{n.onmessage=null,e.close(),n.close(),s()};n.onmessage=()=>i();try{e.postMessage(t,[t])}catch{}finally{i()}}))},Ft={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},jt=(t,e,n)=>{const s=e[n];if(void 0===s)throw t();return s},Wt={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},Bt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Lt=()=>new DOMException("","InvalidStateError"),Ut=()=>new DOMException("","InvalidAccessError"),zt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Gt=(t,e,n,s,i,o,r,a,c,l,u)=>{const h=l.length;let p=a;for(let a=0;a<h;a+=1){let h=n[0]*l[a];for(let e=1;e<i;e+=1){const s=p-e&c-1;h+=n[e]*o[s],h-=t[e]*r[s]}for(let t=i;t<s;t+=1)h+=n[t]*o[p-t&c-1];for(let n=i;n<e;n+=1)h-=t[n]*r[p-n&c-1];o[p]=l[a],r[p]=h,p=p+1&c-1,u[a]=h}return p},Xt={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Yt=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==n&&(n.catch((()=>{})),!0)}catch{}return!1},Zt=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n]&&(t[n]=s)},Ht=(t,e)=>{Zt(t,e,"channelCount"),Zt(t,e,"channelCountMode"),Zt(t,e,"channelInterpretation")},$t=t=>"function"==typeof t.getFloatTimeDomainData,Qt=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n].value&&(t[n].value=s)},Jt=t=>{t.start=(e=>(n=0,s=0,i)=>{if("number"==typeof i&&i<0||s<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,s,i)})(t.start)},Kt=t=>{var e;t.stop=(e=t.stop,(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})},te=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),ee=async(t,e)=>{const n=await(t=>new Promise(((e,n)=>{const{port1:s,port2:i}=new MessageChannel;s.onmessage=({data:t})=>{s.close(),i.close(),e(t)},s.onmessageerror=({data:t})=>{s.close(),i.close(),n(t)},i.postMessage(t)})))(e);return new t(n)},ne=(t,e)=>{const n=t.createBiquadFilter();return Ht(n,e),Qt(n,e,"Q"),Qt(n,e,"detune"),Qt(n,e,"frequency"),Qt(n,e,"gain"),Zt(n,e,"type"),n},se=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return Ht(n,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Lt()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Lt()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Lt()}})})(n),n},ie=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),oe=(t,e)=>{const n=t.createDelay(e.maxDelayTime);return Ht(n,e),Qt(n,e,"delayTime"),n},re=(t,e)=>{const n=t.createGain();return Ht(n,e),Qt(n,e,"gain"),n};function ae(t,e){const n=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/n,(t[1]*e[0]-t[0]*e[1])/n]}function ce(t,e){let n=[0,0];for(let o=t.length-1;o>=0;o-=1)i=e,n=[(s=n)[0]*i[0]-s[1]*i[1],s[0]*i[1]+s[1]*i[0]],n[0]+=t[o];var s,i;return n}const le=(t,e,n,s)=>t.createScriptProcessor(e,n,s),ue=()=>new DOMException("","NotSupportedError"),he={numberOfChannels:1},pe={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},de={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},fe={disableNormalization:!1},me={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},_e={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},ge=(t,e,n)=>void 0===t.copyFromChannel?t.getChannelData(n)[0]:(t.copyFromChannel(e,n),e[0]),ve=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},ye=(t,e,n,s)=>{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:n(o),set:s(r)})},we=(t,e,n)=>{try{t.setValueAtTime(e,n)}catch(s){if(9!==s.code)throw s;we(t,e,n+1e-7)}},Te=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},xe=t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},be=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},Ce=(t,e)=>{const n=e.createGain();t.connect(n);const s=(e=>()=>{e.call(t,n),t.removeEventListener("ended",s)})(t.disconnect);t.addEventListener("ended",s),ie(t,n),t.stop=(e=>{let s=!1;return(i=0)=>{if(s)try{e.call(t,i)}catch{n.gain.setValueAtTime(0,i)}else e.call(t,i),s=!0}})(t.stop)},Ae=(t,e)=>n=>{const s={value:t};return Object.defineProperties(n,{currentTarget:s,target:s}),"function"==typeof e?e.call(t,n):e.handleEvent.call(t,n)},ke=(t=>(e,n,[s,i,o],r)=>{t(e[i],[n,s,o],(t=>t[0]===n&&t[1]===s),r)})(at),Se=(t=>(e,n,[s,i,o],r)=>{const a=e.get(s);void 0===a?e.set(s,new Set([[i,n,o]])):t(a,[i,n,o],(t=>t[0]===i&&t[1]===n),r)})(at),Oe=(t=>(e,n,s,i)=>t(e[i],(t=>t[0]===n&&t[1]===s)))(F),Me=new WeakMap,Ee=(t=>e=>{var n;return null!==(n=t.get(e))&&void 0!==n?n:0})(Me),Re=(Ie=new Map,De=new WeakMap,(t,e)=>{const n=De.get(t);if(void 0!==n)return n;const s=Ie.get(t);if(void 0!==s)return s;try{const n=e();return n instanceof Promise?(Ie.set(t,n),n.catch((()=>!1)).then((e=>(Ie.delete(t),De.set(t,e),e)))):(De.set(t,n),n)}catch{return De.set(t,!1),!1}});var Ie,De;const Ne="undefined"==typeof window?null:window,Ve=((t,e)=>(n,s)=>{const i=n.createAnalyser();if(Ht(i,s),!(s.maxDecibels>s.minDecibels))throw e();return Zt(i,s,"fftSize"),Zt(i,s,"maxDecibels"),Zt(i,s,"minDecibels"),Zt(i,s,"smoothingTimeConstant"),t($t,(()=>$t(i)))||(t=>{t.getFloatTimeDomainData=e=>{const n=new Uint8Array(e.length);t.getByteTimeDomainData(n);const s=Math.max(n.length,t.fftSize);for(let t=0;t<s;t+=1)e[t]=.0078125*(n[t]-128);return e}})(i),i})(Re,Z),Pe=(t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer})(et),qe=((t,e,n)=>async(s,i,o)=>{const r=t(s);await Promise.all(r.activeInputs.map(((t,r)=>Array.from(t).map((async([t,a])=>{const c=e(t),l=await c.render(t,i),u=s.context.destination;n(t)||s===u&&n(s)||l.connect(o,a,r)})))).reduce(((t,e)=>[...t,...e]),[]))})(et,Pe,vt),Fe=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o){const r=s.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!X(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 s.set(o,r),await n(i,o,r),r})(i,o)}}})(Ve,_t,qe),je=(We=S,t=>{const e=We.get(t);if(void 0===e)throw Lt();return e});var We;const Be=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(Ne),Le=(t=>e=>null!==t&&e instanceof t)(Be),Ue=new WeakMap,ze=(t=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(e,n,s){if(null!==n){let i=this._listeners.get(n);void 0===i&&(i=t(this,n),"function"==typeof n&&this._listeners.set(n,i)),this._nativeEventTarget.addEventListener(e,i,s)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const s=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===s?null:s,n)}})(Ae),Ge=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(Ne),Xe=(t=>e=>null!==t&&e instanceof t)(Ge),Ye=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(Ne),Ze=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(Ne),He=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(Ne),$e=((t,e,n,s,i,o,r,a,c,l,u,h,p,d,f,m)=>class extends l{constructor(e,s,i,o){super(i),this._context=e,this._nativeAudioNode=i;const r=u(e);h(r)&&!0!==n(wt,(()=>wt(r,m)))&&(t=>{const e=new Map;t.connect=(t=>(n,s=0,i=0)=>{const o=xt(n)?t(n,s,i):t(n,s),r=e.get(n);return void 0===r?e.set(n,[{input:i,output:s}]):r.every((t=>t.input!==i||t.output!==s))&&r.push({input:i,output:s}),o})(t.connect.bind(t)),t.disconnect=(n=>(s,i,o)=>{if(n.apply(t),void 0===s)e.clear();else if("number"==typeof s)for(const[t,n]of e){const i=n.filter((t=>t.output!==s));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(s))if(void 0===i)e.delete(s);else{const t=e.get(s);if(void 0!==t){const n=t.filter((t=>t.output!==i&&(t.input!==o||void 0===o)));0===n.length?e.delete(s):e.set(s,n)}}for(const[n,s]of e)s.forEach((e=>{xt(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)}))})(t.disconnect)})(i),C.set(this,i),O.set(this,new Set),"closed"!==e.state&&s&&B(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,n=0,a=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();const l=u(this._context),h=f(l);if(p(t)||d(t))throw o();if(ot(t)){const i=_t(t);try{const e=ht(this._nativeAudioNode,i,n,a),s=yt(this);(h||s)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!s&&yt(t)&&B(t)}catch(t){if(12===t.code)throw o();throw t}if(e(this,t,n,a,h)){const e=c([this],t);Tt(e,s(h))}return t}const m=gt(t);if("playbackRate"===m.name&&1024===m.maxValue)throw r();try{this._nativeAudioNode.connect(m,n),(h||yt(this))&&this._nativeAudioNode.disconnect(m,n)}catch(t){if(12===t.code)throw o();throw t}if(bt(this,t,n,h)){const e=c([this],t);Tt(e,s(h))}}disconnect(t,e,n){let s;const r=u(this._context),l=f(r);if(void 0===t)s=((t,e)=>{const n=et(t),s=[];for(const i of n.outputs)rt(i)?Ct(t,e,...i):At(t,e,...i),s.push(i[0]);return n.outputs.clear(),s})(this,l);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();s=((t,e,n)=>{const s=et(t),i=[];for(const o of s.outputs)o[1]===n&&(rt(o)?Ct(t,e,...o):At(t,e,...o),i.push(o[0]),s.outputs.delete(o));return i})(this,l,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(ot(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(s=((t,e,n,s,i)=>{const o=et(t);return Array.from(o.outputs).filter((t=>!(t[0]!==n||void 0!==s&&t[1]!==s||void 0!==i&&t[2]!==i))).map((n=>(rt(n)?Ct(t,e,...n):At(t,e,...n),o.outputs.delete(n),n[0])))})(this,l,t,e,n),0===s.length)throw o()}for(const t of s){const e=c([this],t);Tt(e,a)}}})((Qe=b,(t,e,n)=>{const s=[];for(let t=0;t<n.numberOfInputs;t+=1)s.push(new Set);Qe.set(t,{activeInputs:s,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,n,s,i,o,r,a,c,l,u,h,p)=>{const d=new WeakMap;return(f,m,_,g,v)=>{const{activeInputs:y,passiveInputs:w}=o(m),{outputs:T}=o(f),x=a(f),b=o=>{const a=c(m),l=c(f);if(o){const e=j(w,f,_,g);t(y,f,e,!1),v||h(f)||n(l,a,_,g),p(m)&&B(m)}else{const t=s(y,f,_,g);e(w,g,t,!1),v||h(f)||i(l,a,_,g);const n=r(m);if(0===n)u(m)&&z(m,y);else{const t=d.get(m);void 0!==t&&clearTimeout(t),d.set(m,setTimeout((()=>{u(m)&&z(m,y)}),1e3*n))}}};return!!l(T,[m,_,g],(t=>t[0]===m&&t[1]===_&&t[2]===g),!0)&&(x.add(b),u(f)?t(y,f,[_,g,b],!0):e(w,g,[f,_,b],!0),!0)}})(ke,Se,ht,Oe,mt,et,Ee,W,_t,at,K,vt,yt),Re,((t,e,n,s,i,o)=>r=>(a,c)=>{const l=t.get(a);if(void 0===l){if(!r&&o(a)){const t=s(a),{outputs:o}=n(a);for(const n of o)if(rt(n)){const i=s(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(a,c)}else t.set(a,l+c)})(M,mt,et,_t,gt,K),Z,Ut,ue,((t,e,n,s,i,o,r,a)=>(c,l)=>{const u=e.get(c);if(void 0===u)throw new Error("Missing the expected cycle count.");const h=o(c.context),p=a(h);if(u===l){if(e.delete(c),!p&&r(c)){const e=s(c),{outputs:o}=n(c);for(const n of o)if(rt(n)){const i=s(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(c,u-l)})(ht,M,et,_t,gt,je,K,Le),((t,e,n)=>function s(i,o){const r=ot(o)?o:n(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=>s([...i,r],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(Ue,et,q),ze,je,Xe,Ye,Ze,Le,He);var Qe;const Je=((t,e,n,s,i,o)=>class extends t{constructor(t,n){const r=i(t),a={...G,...n},c=s(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,n()}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,n()}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)}})($e,Fe,Z,Ve,je,Le),Ke=new WeakSet,tn=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(Ne),en=(nn=new Uint32Array(1),t=>(nn[0]=t,nn[0]));var nn;const sn=((t,e)=>n=>{n.copyFromChannel=(s,i,o=0)=>{const r=t(o),a=t(i);if(a>=n.numberOfChannels)throw e();const c=n.length,l=n.getChannelData(a),u=s.length;for(let t=r<0?-r:0;t+r<c&&t<u;t+=1)s[t]=l[t+r]},n.copyToChannel=(s,i,o=0)=>{const r=t(o),a=t(i);if(a>=n.numberOfChannels)throw e();const c=n.length,l=n.getChannelData(a),u=s.length;for(let t=r<0?-r:0;t+r<c&&t<u;t+=1)l[t+r]=s[t]}})(en,Z),on=(t=>e=>{e.copyFromChannel=(n=>(s,i,o=0)=>{const r=t(o),a=t(i);if(r<e.length)return n.call(e,s,a,r)})(e.copyFromChannel),e.copyToChannel=(n=>(s,i,o=0)=>{const r=t(o),a=t(i);if(r<e.length)return n.call(e,s,a,r)})(e.copyToChannel)})(en),rn=((t,e,n,s,i,o,r,a)=>{let c=null;return class l{constructor(l){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:u,numberOfChannels:h,sampleRate:p}={...$,...l};null===c&&(c=new i(1,1,44100));const d=null!==s&&e(o,o)?new s({length:u,numberOfChannels:h,sampleRate:p}):c.createBuffer(h,u,p);if(0===d.numberOfChannels)throw n();return"function"!=typeof d.copyFromChannel?(r(d),H(d)):e(Y,(()=>Y(d)))||a(d),t.add(d),d}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===l.prototype||t.has(e)}}})(Ke,Re,ue,tn,Be,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(tn),sn,on),an=(t=>(e,n)=>{const s=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.connect(s).connect(e.destination);const i=()=>{n.removeEventListener("ended",i),n.disconnect(s),s.disconnect()};n.addEventListener("ended",i)})(re),cn=((t,e,n)=>async(s,i,o)=>{const r=e(s);await Promise.all(Array.from(r.activeInputs).map((async([e,s])=>{const r=t(e),a=await r.render(e,i);n(e)||a.connect(o,s)})))})(Pe,nt,vt),ln=(t=>(e,n,s)=>t(n,e,s))(cn),un=((t,e,n,s,i,o,r,a,c,l,u)=>(h,p)=>{const d=h.createBufferSource();return Ht(d,p),Qt(d,p,"playbackRate"),Zt(d,p,"buffer"),Zt(d,p,"loop"),Zt(d,p,"loopEnd"),Zt(d,p,"loopStart"),e(n,(()=>n(h)))||(t=>{t.start=(e=>{let n=!1;return(s=0,i=0,o)=>{if(n)throw Lt();e.call(t,s,i,o),n=!0}})(t.start)})(d),e(s,(()=>s(h)))||c(d),e(i,(()=>i(h)))||l(d,h),e(o,(()=>o(h)))||Jt(d),e(r,(()=>r(h)))||u(d,h),e(a,(()=>a(h)))||Kt(d),t(h,d),d})(an,Re,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;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}),Te,xe,be,(t=>{t.start=(e=>(n=0,s=0,i)=>{const o=t.buffer,r=null===o?s:Math.min(o.duration,s);null!==o&&r>o.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,r,i)})(t.start)}),(t=>(e,n)=>{const s=n.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=s),t(e,"buffer",(t=>()=>{const n=t.call(e);return n===s?null:n}),(t=>n=>t.call(e,null===n?s:n)))})(ye),Ce),hn=((t,e)=>(n,s,i)=>(t(s).replay(i),e(s,n,i)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(nt),cn),pn=((t,e,n,s,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(c,l){const u=o.get(l);return void 0!==u?Promise.resolve(u):(async(c,l)=>{let u=n(c);const h=X(u,l);if(!h){const t={buffer:u.buffer,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,loop:u.loop,loopEnd:u.loopEnd,loopStart:u.loopStart,playbackRate:u.playbackRate.value};u=e(l,t),null!==r&&u.start(...r),null!==a&&u.stop(a)}return o.set(l,u),h?await t(l,c.playbackRate,u.playbackRate):await s(l,c.playbackRate,u.playbackRate),await i(c,l,u),u})(c,l)}}})(ln,un,_t,hn,qe),dn=((t,e,n,s,i,o,r,a,c,l,u,h,p)=>(d,f,m,_=null,g=null)=>{const v=m.value,y=new T(v),w=f?s(y):null,x={get defaultValue(){return v},get maxValue(){return null===_?m.maxValue:_},get minValue(){return null===g?m.minValue:g},get value(){return m.value},set value(t){m.value=t,x.setValueAtTime(t,d.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof m.cancelAndHoldAtTime)null===w&&y.flush(d.context.currentTime),y.add(i(t)),m.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===w&&y.flush(d.context.currentTime),y.add(i(t));const n=Array.from(y).pop();m.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?m.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?m.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?m.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&m.setValueCurveAtTime(n.values,n.startTime,n.duration))}return x},cancelScheduledValues:t=>(null===w&&y.flush(d.context.currentTime),y.add(o(t)),m.cancelScheduledValues(t),x),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const n=d.context.currentTime;return null===w&&y.flush(n),0===Array.from(y).length&&(y.add(l(v,n)),m.setValueAtTime(v,n)),y.add(r(t,e)),m.exponentialRampToValueAtTime(t,e),x},linearRampToValueAtTime(t,e){const n=d.context.currentTime;return null===w&&y.flush(n),0===Array.from(y).length&&(y.add(l(v,n)),m.setValueAtTime(v,n)),y.add(a(t,e)),m.linearRampToValueAtTime(t,e),x},setTargetAtTime:(t,e,n)=>(null===w&&y.flush(d.context.currentTime),y.add(c(t,e,n)),m.setTargetAtTime(t,e,n),x),setValueAtTime:(t,e)=>(null===w&&y.flush(d.context.currentTime),y.add(l(t,e)),m.setValueAtTime(t,e),x),setValueCurveAtTime(t,e,n){const s=t instanceof Float32Array?t:new Float32Array(t);if(null!==h&&"webkitAudioContext"===h.name){const t=e+n,i=d.context.sampleRate,o=Math.ceil(e*i),r=Math.floor(t*i),a=r-o,c=new Float32Array(a);for(let t=0;t<a;t+=1){const r=(s.length-1)/n*((o+t)/i-e),a=Math.floor(r),l=Math.ceil(r);c[t]=a===l?s[a]:(1-(r-a))*s[a]+(1-(l-r))*s[l]}null===w&&y.flush(d.context.currentTime),y.add(u(c,e,n)),m.setValueCurveAtTime(c,e,n);const l=r/i;l<t&&p(x,c[c.length-1],l),p(x,s[s.length-1],t)}else null===w&&y.flush(d.context.currentTime),y.add(u(s,e,n)),m.setValueCurveAtTime(s,e,n);return x}};return n.set(x,m),e.set(x,d),t(x,w),x})((fn=A,(t,e)=>{fn.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),Ue,k,(t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:s}=n;e.exponentialRampToValueAtTime(s,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:s}=n;e.linearRampToValueAtTime(s,t)}else if("setTarget"===n.type){const{startTime:t,target:s,timeConstant:i}=n;e.setTargetAtTime(s,t,i)}else if("setValue"===n.type){const{startTime:t,value:s}=n;e.setValueAtTime(s,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:s,values:i}=n;e.setValueCurveAtTime(i,s,t)}}}})),(t=>({cancelTime:t,type:"cancelAndHold"})),(t=>({cancelTime:t,type:"cancelScheduledValues"})),((t,e)=>({endTime:e,type:"exponentialRampToValue",value:t})),((t,e)=>({endTime:e,type:"linearRampToValue",value:t})),((t,e,n)=>({startTime:e,target:t,timeConstant:n,type:"setTarget"})),i,o,Ge,we);var fn;const mn=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,s){const a=o(t),c={...tt,...s},l=i(a,c),u=r(a),h=u?e():null;super(t,!1,l,h),this._audioBufferSourceNodeRenderer=h,this._isBufferNullified=!1,this._isBufferSet=null!==c.buffer,this._nativeAudioBufferSourceNode=l,this._onended=null,this._playbackRate=n(this,u,l.playbackRate,J,Q)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw s();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 n=this._nativeAudioBufferSourceNode.onended;this._onended=null!==n&&n===e?t:n}get playbackRate(){return this._playbackRate}start(t=0,e=0,n){if(this._nativeAudioBufferSourceNode.start(t,e,n),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===n?[t,e]:[t,e,n]),"closed"!==this.context.state){B(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),K(this)&&U(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})($e,pn,dn,Lt,un,je,Le,Ae),_n=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,n){const s=o(t),c=r(s),l=i(s,n,c);super(t,!1,l,c?e(a):null),this._isNodeOfNativeOfflineAudioContext=c,this._nativeAudioDestinationNode=l}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw s();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw s();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})($e,(t=>{const e=new WeakMap;return{render(n,s){const i=e.get(s);return void 0!==i?Promise.resolve(i):(async(n,s)=>{const i=s.destination;return e.set(s,i),await t(n,s,i),i})(n,s)}}}),Z,Lt,((t,e)=>(n,s,i)=>{const o=n.destination;if(o.channelCount!==s)try{o.channelCount=s}catch{}i&&"explicit"!==o.channelCountMode&&(o.channelCountMode="explicit"),0===o.maxChannelCount&&Object.defineProperty(o,"maxChannelCount",{value:s});const r=t(n,{channelCount:s,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})(re,ye),je,Le,qe),gn=((t,e,n,s,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=n(r);const l=X(c,a);if(!l){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),l?(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 s(a,r.Q,c.Q),await s(a,r.detune,c.detune),await s(a,r.frequency,c.frequency),await s(a,r.gain,c.gain)),await i(r,a,c),c})(r,a)}}})(ln,ne,_t,hn,qe),vn=(t=>(e,n)=>t.set(e,n))(Me),yn=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,s){const c=o(t),l={...It,...s},u=i(c,l),h=r(c);super(t,!1,u,h?n():null),this._Q=e(this,h,u.Q,J,Q),this._detune=e(this,h,u.detune,1200*Math.log2(J),-1200*Math.log2(J)),this._frequency=e(this,h,u.frequency,t.sampleRate/2,0),this._gain=e(this,h,u.gain,40*Math.log10(J),Q),this._nativeBiquadFilterNode=u,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,n){try{this._nativeBiquadFilterNode.getFrequencyResponse(t,e,n)}catch(t){if(11===t.code)throw s();throw t}if(t.length!==e.length||e.length!==n.length)throw s()}})($e,dn,gn,Ut,ne,je,Le,vn),wn=((t,e)=>(n,s,i)=>{const o=new Set;return n.connect=(i=>(r,a=0,c=0)=>{const l=0===o.size;if(e(r))return i.call(n,r,a,c),t(o,[r,a,c],(t=>t[0]===r&&t[1]===a&&t[2]===c),!0),l&&s(),r;i.call(n,r,a),t(o,[r,a],(t=>t[0]===r&&t[1]===a),!0),l&&s()})(n.connect),n.disconnect=(t=>(s,r,a)=>{const c=o.size>0;if(void 0===s)t.apply(n),o.clear();else if("number"==typeof s){t.call(n,s);for(const t of o)t[1]===s&&o.delete(t)}else{e(s)?t.call(n,s,r,a):t.call(n,s,r);for(const t of o)t[0]!==s||void 0!==r&&t[1]!==r||void 0!==a&&t[2]!==a||o.delete(t)}const l=0===o.size;c&&l&&i()})(n.disconnect),n})(at,Ye),Tn=((t,e)=>(n,s)=>{s.channelCount=1,s.channelCountMode="explicit",Object.defineProperty(s,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(s,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=n.createBufferSource();e(s,(()=>{const t=s.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(s,0,e)}),(()=>i.disconnect(s)))})(Lt,wn),xn=((t,e)=>(n,s)=>{const i=n.createChannelMerger(s.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(n,i),Ht(i,s),i})(Ge,Tn),bn=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o){const r=s.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!X(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,numberOfInputs:r.numberOfInputs};r=t(o,e)}return s.set(o,r),await n(i,o,r),r})(i,o)}}})(xn,_t,qe),Cn=((t,e,n,s,i)=>class extends t{constructor(t,o){const r=s(t),a={...Dt,...o};super(t,!1,n(r,a),i(r)?e():null)}})($e,bn,xn,je,Le),An=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o){const r=s.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!X(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,numberOfOutputs:r.numberOfOutputs};r=t(o,e)}return s.set(o,r),await n(i,o,r),r})(i,o)}}})(se,_t,qe),kn=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=s(t),c=o({...Nt,...r});super(t,!1,n(a,c),i(a)?e():null)}})($e,An,se,je,Le,(t=>({...t,channelCount:t.numberOfOutputs}))),Sn=((t,e,n,s)=>(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}),l=n(i,{...r,gain:o}),u=a.getChannelData(0);u[0]=1,u[1]=1,c.buffer=a,c.loop=!0;const h={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){l.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){l.channelCountMode=t},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(t){l.channelInterpretation=t},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return c.onended},set onended(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),s(ie(h,l),(()=>c.connect(l)),(()=>c.disconnect(l)))})(an,un,re,wn),On=((t,e,n,s,i)=>(o,r)=>{if(void 0===o.createConstantSource)return n(o,r);const a=o.createConstantSource();return Ht(a,r),Qt(a,r,"offset"),e(s,(()=>s(o)))||Jt(a),e(i,(()=>i(o)))||Kt(a),t(o,a),a})(an,Re,Sn,Te,be),Mn=((t,e,n,s,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(c,l){const u=o.get(l);return void 0!==u?Promise.resolve(u):(async(c,l)=>{let u=n(c);const h=X(u,l);if(!h){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,offset:u.offset.value};u=e(l,t),null!==r&&u.start(r),null!==a&&u.stop(a)}return o.set(l,u),h?await t(l,c.offset,u.offset):await s(l,c.offset,u.offset),await i(c,l,u),u})(c,l)}}})(ln,On,_t,hn,qe),En=((t,e,n,s,i,o,r)=>class extends t{constructor(t,r){const a=i(t),c={...Vt,...r},l=s(a,c),u=o(a),h=u?n():null;super(t,!1,l,h),this._constantSourceNodeRenderer=h,this._nativeConstantSourceNode=l,this._offset=e(this,u,l.offset,J,Q),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 n=this._nativeConstantSourceNode.onended;this._onended=null!==n&&n===e?t:n}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){B(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),K(this)&&U(this)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})($e,dn,Mn,On,je,Le,Ae),Rn=((t,e)=>(n,s)=>{const i=n.createConvolver();if(Ht(i,s),s.disableNormalization===i.normalize&&(i.normalize=!s.disableNormalization),Zt(i,s,"buffer"),s.channelCount>2)throw t();if(e(i,"channelCount",(t=>()=>t.call(i)),(e=>n=>{if(n>2)throw t();return e.call(i,n)})),"max"===s.channelCountMode)throw t();return e(i,"channelCountMode",(t=>()=>t.call(i)),(e=>n=>{if("max"===n)throw t();return e.call(i,n)})),i})(ue,ye),In=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o){const r=s.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!X(r,o)){const e={buffer:r.buffer,channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,disableNormalization:!r.normalize};r=t(o,e)}return s.set(o,r),ut(r)?await n(i,o,r.inputs[0]):await n(i,o,r),r})(i,o)}}})(Rn,_t,qe),Dn=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=s(t),c={...Pt,...r},l=n(a,c);super(t,!1,l,i(a)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=l,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}})($e,In,Rn,je,Le,vn),Nn=((t,e,n,s,i)=>o=>{const r=new WeakMap;return{render(a,c){const l=r.get(c);return void 0!==l?Promise.resolve(l):(async(a,c)=>{let l=n(a);const u=X(l,c);if(!u){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=e(c,t)}return r.set(c,l),u?await t(c,a.delayTime,l.delayTime):await s(c,a.delayTime,l.delayTime),await i(a,c,l),l})(a,c)}}})(ln,oe,_t,hn,qe),Vn=((t,e,n,s,i,o,r)=>class extends t{constructor(t,a){const c=i(t),l={...Ft,...a},u=s(c,l),h=o(c);super(t,!1,u,h?n(l.maxDelayTime):null),this._delayTime=e(this,h,u.delayTime),r(this,l.maxDelayTime)}get delayTime(){return this._delayTime}})($e,dn,Nn,oe,je,Le,vn),Pn=(t=>(e,n)=>{const s=e.createDynamicsCompressor();if(Ht(s,n),n.channelCount>2)throw t();if("max"===n.channelCountMode)throw t();return Qt(s,n,"attack"),Qt(s,n,"knee"),Qt(s,n,"ratio"),Qt(s,n,"release"),Qt(s,n,"threshold"),s})(ue),qn=((t,e,n,s,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=n(r);const l=X(c,a);if(!l){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),l?(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 s(a,r.attack,c.attack),await s(a,r.knee,c.knee),await s(a,r.ratio,c.ratio),await s(a,r.release,c.release),await s(a,r.threshold,c.threshold)),await i(r,a,c),c})(r,a)}}})(ln,Pn,_t,hn,qe),Fn=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,i){const c=o(t),l={...Wt,...i},u=s(c,l),h=r(c);super(t,!1,u,h?n():null),this._attack=e(this,h,u.attack),this._knee=e(this,h,u.knee),this._nativeDynamicsCompressorNode=u,this._ratio=e(this,h,u.ratio),this._release=e(this,h,u.release),this._threshold=e(this,h,u.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}})($e,dn,qn,Pn,ue,je,Le,vn),jn=((t,e,n,s,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=n(r);const l=X(c,a);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(a,t)}return o.set(a,c),l?await t(a,r.gain,c.gain):await s(a,r.gain,c.gain),await i(r,a,c),c})(r,a)}}})(ln,re,_t,hn,qe),Wn=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=i(t),c={...Bt,...r},l=s(a,c),u=o(a);super(t,!1,l,u?n():null),this._gain=e(this,u,l.gain,J,Q)}get gain(){return this._gain}})($e,dn,jn,re,je,Le),Bn=((t,e,n,s)=>(i,o,{channelCount:r,channelCountMode:a,channelInterpretation:c,feedback:l,feedforward:u})=>{const h=te(o,i.sampleRate),p=l instanceof Float64Array?l:new Float64Array(l),d=u instanceof Float64Array?u:new Float64Array(u),f=p.length,m=d.length,_=Math.min(f,m);if(0===f||f>20)throw s();if(0===p[0])throw e();if(0===m||m>20)throw s();if(0===d[0])throw e();if(1!==p[0]){for(let t=0;t<m;t+=1)d[t]/=p[0];for(let t=1;t<f;t+=1)p[t]/=p[0]}const g=n(i,h,r,r);g.channelCount=r,g.channelCountMode=a,g.channelInterpretation=c;const v=[],y=[],w=[];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),w.push(e)}g.onaudioprocess=t=>{const e=t.inputBuffer,n=t.outputBuffer,s=e.numberOfChannels;for(let t=0;t<s;t+=1){const s=e.getChannelData(t),i=n.getChannelData(t);v[t]=Gt(p,f,d,m,_,y[t],w[t],v[t],32,s,i)}};const T=i.sampleRate/2;return ie({get bufferSize(){return h},get channelCount(){return g.channelCount},set channelCount(t){g.channelCount=t},get channelCountMode(){return g.channelCountMode},set channelCountMode(t){g.channelCountMode=t},get channelInterpretation(){return g.channelInterpretation},set channelInterpretation(t){g.channelInterpretation=t},get context(){return g.context},get inputs(){return[g]},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},addEventListener:(...t)=>g.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>g.dispatchEvent(t[0]),getFrequencyResponse(e,n,s){if(e.length!==n.length||n.length!==s.length)throw t();const i=e.length;for(let t=0;t<i;t+=1){const i=-Math.PI*(e[t]/T),o=[Math.cos(i),Math.sin(i)],r=ae(ce(d,o),ce(p,o));n[t]=Math.sqrt(r[0]*r[0]+r[1]*r[1]),s[t]=Math.atan2(r[1],r[0])}},removeEventListener:(...t)=>g.removeEventListener(t[0],t[1],t[2])},g)})(Ut,Lt,le,ue),Ln=((t,e,n,s)=>i=>t(Yt,(()=>Yt(i)))?Promise.resolve(t(s,s)).then((t=>{if(!t){const t=n(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 n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()})))(Re,re,le,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),s=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{n.oncomplete=()=>{s.disconnect(),t(0!==n.currentTime)},n.startRendering()}))})(re,Be)),Un=((t,e,n,s,i)=>(o,r)=>{const a=new WeakMap;let c=null;const l=async(l,u)=>{let h=null,p=e(l);const d=X(p,u);if(void 0===u.createIIRFilter?h=t(u,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(p=u.createIIRFilter(r,o)),a.set(u,null===h?p:h),null!==h){if(null===c){if(null===n)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new n(l.context.destination.channelCount,l.context.length,u.sampleRate);c=(async()=>{await s(l,t,t.destination);return((t,e,n,s)=>{const i=n instanceof Float64Array?n:new Float64Array(n),o=s instanceof Float64Array?s:new Float64Array(s),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 l=new Float32Array(32),u=new Float32Array(32),h=e.createBuffer(t.numberOfChannels,t.length,t.sampleRate),p=t.numberOfChannels;for(let e=0;e<p;e+=1){const n=t.getChannelData(e),s=h.getChannelData(e);l.fill(0),u.fill(0),Gt(i,r,o,a,c,l,u,0,32,n,s)}return h})(await i(t),u,o,r)})()}const t=await c;return h.buffer=t,h.start(0),h}return await s(l,u,p),p};return{render(t,e){const n=a.get(e);return void 0!==n?Promise.resolve(n):l(t,e)}}})(un,_t,Be,qe,Ln),zn=(t=>(e,n,s)=>{if(void 0===e.createIIRFilter)return t(e,n,s);const i=e.createIIRFilter(s.feedforward,s.feedback);return Ht(i,s),i})(Bn),Gn=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=s(t),c=i(a),l={...zt,...r},u=e(a,c?null:t.baseLatency,l);super(t,!1,u,c?n(l.feedback,l.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(n,s,i)=>{if(n.length!==s.length||s.length!==i.length)throw Ut();return e.call(t,n,s,i)})})(u),this._nativeIIRFilterNode=u,o(this,1)}getFrequencyResponse(t,e,n){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,n)}})($e,zn,Un,je,Le,vn),Xn=((t,e,n,s,i,o,r,a)=>(c,l)=>{const u=l.listener,{forwardX:h,forwardY:p,forwardZ:d,positionX:f,positionY:m,positionZ:_,upX:g,upY:v,upZ:y}=void 0===u.forwardX?(()=>{const h=new Float32Array(1),p=e(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),d=r(l);let f=!1,m=[0,0,-1,0,1,0],_=[0,0,0];const g=()=>{if(f)return;f=!0;const t=s(l,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[o(t,h,0),o(t,h,1),o(t,h,2),o(t,h,3),o(t,h,4),o(t,h,5)];e.some(((t,e)=>t!==m[e]))&&(u.setOrientation(...e),m=e);const n=[o(t,h,6),o(t,h,7),o(t,h,8)];n.some(((t,e)=>t!==_[e]))&&(u.setPosition(...n),_=n)},p.connect(t)},v=t=>e=>{e!==m[t]&&(m[t]=e,u.setOrientation(...m))},y=t=>e=>{e!==_[t]&&(_[t]=e,u.setPosition(..._))},w=(e,s,o)=>{const r=n(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:s});r.connect(p,0,e),r.start(),Object.defineProperty(r.offset,"defaultValue",{get:()=>s});const u=t({context:c},d,r.offset,J,Q);var h,f,m,_,v,y,w;return a(u,"value",(t=>()=>t.call(u)),(t=>e=>{try{t.call(u,e)}catch(t){if(9!==t.code)throw t}g(),d&&o(e)})),u.cancelAndHoldAtTime=(h=u.cancelAndHoldAtTime,d?()=>{throw i()}:(...t)=>{const e=h.apply(u,t);return g(),e}),u.cancelScheduledValues=(f=u.cancelScheduledValues,d?()=>{throw i()}:(...t)=>{const e=f.apply(u,t);return g(),e}),u.exponentialRampToValueAtTime=(m=u.exponentialRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=m.apply(u,t);return g(),e}),u.linearRampToValueAtTime=(_=u.linearRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=_.apply(u,t);return g(),e}),u.setTargetAtTime=(v=u.setTargetAtTime,d?()=>{throw i()}:(...t)=>{const e=v.apply(u,t);return g(),e}),u.setValueAtTime=(y=u.setValueAtTime,d?()=>{throw i()}:(...t)=>{const e=y.apply(u,t);return g(),e}),u.setValueCurveAtTime=(w=u.setValueCurveAtTime,d?()=>{throw i()}:(...t)=>{const e=w.apply(u,t);return g(),e}),u};return{forwardX:w(0,0,v(0)),forwardY:w(1,0,v(1)),forwardZ:w(2,-1,v(2)),positionX:w(6,0,y(0)),positionY:w(7,0,y(1)),positionZ:w(8,0,y(2)),upX:w(3,0,v(3)),upY:w(4,1,v(4)),upZ:w(5,0,v(5))}})():u;return{get forwardX(){return h},get forwardY(){return p},get forwardZ(){return d},get positionX(){return f},get positionY(){return m},get positionZ(){return _},get upX(){return g},get upY(){return v},get upZ(){return y}}})(dn,xn,On,le,ue,ge,Le,ye),Yn=new WeakMap,Zn=((t,e,n,s,i,o)=>class extends n{constructor(n,o){super(n),this._nativeContext=n,S.set(this,n),s(n)&&i.set(n,new Set),this._destination=new t(this,o),this._listener=e(this,n),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 n=this._nativeContext.onstatechange;this._onstatechange=null!==n&&n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(_n,Xn,ze,Le,Yn,Ae),Hn=((t,e,n,s,i,o)=>(r,a)=>{const c=r.createOscillator();return Ht(c,a),Qt(c,a,"detune"),Qt(c,a,"frequency"),void 0!==a.periodicWave?c.setPeriodicWave(a.periodicWave):Zt(c,a,"type"),e(n,(()=>n(r)))||Jt(c),e(s,(()=>s(r)))||o(c,r),e(i,(()=>i(r)))||Kt(c),t(r,c),c})(an,Re,Te,xe,be,Ce),$n=((t,e,n,s,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(l,u){const h=o.get(u);return void 0!==h?Promise.resolve(h):(async(l,u)=>{let h=n(l);const p=X(h,u);if(!p){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,detune:h.detune.value,frequency:h.frequency.value,periodicWave:null===r?void 0:r,type:h.type};h=e(u,t),null!==a&&h.start(a),null!==c&&h.stop(c)}return o.set(u,h),p?(await t(u,l.detune,h.detune),await t(u,l.frequency,h.frequency)):(await s(u,l.detune,h.detune),await s(u,l.frequency,h.frequency)),await i(l,u,h),h})(l,u)}}})(ln,Hn,_t,hn,qe),Qn=((t,e,n,s,i,o,r)=>class extends t{constructor(t,r){const a=i(t),c={...pe,...r},l=n(a,c),u=o(a),h=u?s():null,p=t.sampleRate/2;super(t,!1,l,h),this._detune=e(this,u,l.detune,153600,-153600),this._frequency=e(this,u,l.frequency,p,-p),this._nativeOscillatorNode=l,this._onended=null,this._oscillatorNodeRenderer=h,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 n=this._nativeOscillatorNode.onended;this._onended=null!==n&&n===e?t:n}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){B(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),K(this)&&U(this)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})($e,dn,Hn,$n,je,Le,Ae),Jn=(t=>(e,n)=>{const s=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 s.buffer=i,s.loop=!0,s.connect(n),s.start(),()=>{s.stop(),s.disconnect(n)}})(un),Kn=((t,e,n,s,i)=>(o,{curve:r,oversample:a,...c})=>{const l=o.createWaveShaper(),u=o.createWaveShaper();Ht(l,c),Ht(u,c);const h=n(o,{...c,gain:1}),p=n(o,{...c,gain:-1}),d=n(o,{...c,gain:1}),f=n(o,{...c,gain:-1});let m=null,_=!1,g=null;const v={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){h.channelCount=t,p.channelCount=t,l.channelCount=t,d.channelCount=t,u.channelCount=t,f.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){h.channelCountMode=t,p.channelCountMode=t,l.channelCountMode=t,d.channelCountMode=t,u.channelCountMode=t,f.channelCountMode=t},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t,p.channelInterpretation=t,l.channelInterpretation=t,d.channelInterpretation=t,u.channelInterpretation=t,f.channelInterpretation=t},get context(){return l.context},get curve(){return g},set curve(n){if(null!==n&&n.length<2)throw e();if(null===n)l.curve=n,u.curve=n;else{const t=n.length,e=new Float32Array(t+2-t%2),s=new Float32Array(t+2-t%2);e[0]=n[0],s[0]=-n[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),l=Math.ceil(a);e[r]=c===l?n[c]:(1-(a-c))*n[c]+(1-(l-a))*n[l],s[r]=c===l?-n[t-1-c]:-(1-(a-c))*n[t-1-c]-(1-(l-a))*n[t-1-l]}e[i]=t%2==1?n[i-1]:(n[i-2]+n[i-1])/2,l.curve=e,u.curve=s}g=n,_&&(s(g)&&null===m?m=t(o,h):null!==m&&(m(),m=null))},get inputs(){return[h]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(t){l.oversample=t,u.oversample=t},addEventListener:(...t)=>h.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>h.dispatchEvent(t[0]),removeEventListener:(...t)=>h.removeEventListener(t[0],t[1],t[2])};null!==r&&(v.curve=r instanceof Float32Array?r:new Float32Array(r)),a!==v.oversample&&(v.oversample=a);return i(ie(v,d),(()=>{h.connect(l).connect(d),h.connect(p).connect(u).connect(f).connect(d),_=!0,s(g)&&(m=t(o,h))}),(()=>{h.disconnect(l),l.disconnect(d),h.disconnect(p),p.disconnect(u),u.disconnect(f),f.disconnect(d),_=!1,null!==m&&(m(),m=null)}))})(Jn,Lt,re,ve,wn),ts=((t,e,n,s,i,o,r)=>(a,c)=>{const l=a.createWaveShaper();if(null!==o&&"webkitAudioContext"===o.name&&void 0===a.createGain().gain.automationRate)return n(a,c);Ht(l,c);const u=null===c.curve||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(null!==u&&u.length<2)throw e();Zt(l,{curve:u},"curve"),Zt(l,c,"oversample");let h=null,p=!1;r(l,"curve",(t=>()=>t.call(l)),(e=>n=>(e.call(l,n),p&&(s(n)&&null===h?h=t(a,l):s(n)||null===h||(h(),h=null)),n)));return i(l,(()=>{p=!0,s(l.curve)&&(h=t(a,l))}),(()=>{p=!1,null!==h&&(h(),h=null)}))})(Jn,Lt,Kn,ve,wn,Ge,ye),es=((t,e,n,s,i,o,r,a,c,l)=>(u,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:m,orientationX:_,orientationY:g,orientationZ:v,panningModel:y,positionX:w,positionY:T,positionZ:x,refDistance:b,rolloffFactor:C,...A})=>{const k=u.createPanner();if(A.channelCount>2)throw r();if("max"===A.channelCountMode)throw r();Ht(k,A);const S={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},O=n(u,{...S,channelInterpretation:"speakers",numberOfInputs:6}),M=s(u,{...A,gain:1}),E=s(u,{...S,gain:1}),R=s(u,{...S,gain:0}),I=s(u,{...S,gain:0}),D=s(u,{...S,gain:0}),N=s(u,{...S,gain:0}),V=s(u,{...S,gain:0}),P=i(u,256,6,1),q=o(u,{...S,curve:new Float32Array([1,1]),oversample:"none"});let F=[_,g,v],j=[w,T,x];const W=new Float32Array(1);P.onaudioprocess=({inputBuffer:t})=>{const e=[c(t,W,0),c(t,W,1),c(t,W,2)];e.some(((t,e)=>t!==F[e]))&&(k.setOrientation(...e),F=e);const n=[c(t,W,3),c(t,W,4),c(t,W,5)];n.some(((t,e)=>t!==j[e]))&&(k.setPosition(...n),j=n)},Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(I.gain,"defaultValue",{get:()=>0}),Object.defineProperty(D.gain,"defaultValue",{get:()=>0}),Object.defineProperty(N.gain,"defaultValue",{get:()=>0}),Object.defineProperty(V.gain,"defaultValue",{get:()=>0});const B={get bufferSize(){},get channelCount(){return k.channelCount},set channelCount(t){if(t>2)throw r();M.channelCount=t,k.channelCount=t},get channelCountMode(){return k.channelCountMode},set channelCountMode(t){if("max"===t)throw r();M.channelCountMode=t,k.channelCountMode=t},get channelInterpretation(){return k.channelInterpretation},set channelInterpretation(t){M.channelInterpretation=t,k.channelInterpretation=t},get coneInnerAngle(){return k.coneInnerAngle},set coneInnerAngle(t){k.coneInnerAngle=t},get coneOuterAngle(){return k.coneOuterAngle},set coneOuterAngle(t){k.coneOuterAngle=t},get coneOuterGain(){return k.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();k.coneOuterGain=t},get context(){return k.context},get distanceModel(){return k.distanceModel},set distanceModel(t){k.distanceModel=t},get inputs(){return[M]},get maxDistance(){return k.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;k.maxDistance=t},get numberOfInputs(){return k.numberOfInputs},get numberOfOutputs(){return k.numberOfOutputs},get orientationX(){return E.gain},get orientationY(){return R.gain},get orientationZ(){return I.gain},get panningModel(){return k.panningModel},set panningModel(t){k.panningModel=t},get positionX(){return D.gain},get positionY(){return N.gain},get positionZ(){return V.gain},get refDistance(){return k.refDistance},set refDistance(t){if(t<0)throw new RangeError;k.refDistance=t},get rolloffFactor(){return k.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;k.rolloffFactor=t},addEventListener:(...t)=>M.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>M.dispatchEvent(t[0]),removeEventListener:(...t)=>M.removeEventListener(t[0],t[1],t[2])};h!==B.coneInnerAngle&&(B.coneInnerAngle=h),p!==B.coneOuterAngle&&(B.coneOuterAngle=p),d!==B.coneOuterGain&&(B.coneOuterGain=d),f!==B.distanceModel&&(B.distanceModel=f),m!==B.maxDistance&&(B.maxDistance=m),_!==B.orientationX.value&&(B.orientationX.value=_),g!==B.orientationY.value&&(B.orientationY.value=g),v!==B.orientationZ.value&&(B.orientationZ.value=v),y!==B.panningModel&&(B.panningModel=y),w!==B.positionX.value&&(B.positionX.value=w),T!==B.positionY.value&&(B.positionY.value=T),x!==B.positionZ.value&&(B.positionZ.value=x),b!==B.refDistance&&(B.refDistance=b),C!==B.rolloffFactor&&(B.rolloffFactor=C),1===F[0]&&0===F[1]&&0===F[2]||k.setOrientation(...F),0===j[0]&&0===j[1]&&0===j[2]||k.setPosition(...j);return l(ie(B,k),(()=>{M.connect(k),t(M,q,0,0),q.connect(E).connect(O,0,0),q.connect(R).connect(O,0,1),q.connect(I).connect(O,0,2),q.connect(D).connect(O,0,3),q.connect(N).connect(O,0,4),q.connect(V).connect(O,0,5),O.connect(P).connect(u.destination)}),(()=>{M.disconnect(k),a(M,q,0,0),q.disconnect(E),E.disconnect(O),q.disconnect(R),R.disconnect(O),q.disconnect(I),I.disconnect(O),q.disconnect(D),D.disconnect(O),q.disconnect(N),N.disconnect(O),q.disconnect(V),V.disconnect(O),O.disconnect(P),P.disconnect(u.destination)}))})(ht,Lt,xn,re,le,ts,ue,mt,ge,wn),ns=(t=>(e,n)=>{const s=e.createPanner();return void 0===s.orientationX?t(e,n):(Ht(s,n),Qt(s,n,"orientationX"),Qt(s,n,"orientationY"),Qt(s,n,"orientationZ"),Qt(s,n,"positionX"),Qt(s,n,"positionY"),Qt(s,n,"positionZ"),Zt(s,n,"coneInnerAngle"),Zt(s,n,"coneOuterAngle"),Zt(s,n,"coneOuterGain"),Zt(s,n,"distanceModel"),Zt(s,n,"maxDistance"),Zt(s,n,"panningModel"),Zt(s,n,"refDistance"),Zt(s,n,"rolloffFactor"),s)})(es),ss=((t,e,n,s,i,o,r,a,c,l)=>()=>{const u=new WeakMap;let h=null;return{render(p,d){const f=u.get(d);return void 0!==f?Promise.resolve(f):(async(p,d)=>{let f=null,m=o(p);const _={channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation},g={..._,coneInnerAngle:m.coneInnerAngle,coneOuterAngle:m.coneOuterAngle,coneOuterGain:m.coneOuterGain,distanceModel:m.distanceModel,maxDistance:m.maxDistance,panningModel:m.panningModel,refDistance:m.refDistance,rolloffFactor:m.rolloffFactor},v=X(m,d);if("bufferSize"in m)f=s(d,{..._,gain:1});else if(!v){const t={...g,orientationX:m.orientationX.value,orientationY:m.orientationY.value,orientationZ:m.orientationZ.value,positionX:m.positionX.value,positionY:m.positionY.value,positionZ:m.positionZ.value};m=i(d,t)}if(u.set(d,null===f?m:f),null!==f){if(null===h){if(null===r)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new r(6,p.context.length,d.sampleRate),s=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});s.connect(t.destination),h=(async()=>{const e=await Promise.all([p.orientationX,p.orientationY,p.orientationZ,p.positionX,p.positionY,p.positionZ].map((async(e,s)=>{const i=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===s?1:0});return await a(t,e,i.offset),i})));for(let t=0;t<6;t+=1)e[t].connect(s,0,t),e[t].start(0);return l(t)})()}const t=await h,o=s(d,{..._,gain:1});await c(p,d,o);const u=[];for(let e=0;e<t.numberOfChannels;e+=1)u.push(t.getChannelData(e));let m=[u[0][0],u[1][0],u[2][0]],v=[u[3][0],u[4][0],u[5][0]],y=s(d,{..._,gain:1}),w=i(d,{...g,orientationX:m[0],orientationY:m[1],orientationZ:m[2],positionX:v[0],positionY:v[1],positionZ:v[2]});o.connect(y).connect(w.inputs[0]),w.connect(f);for(let e=128;e<t.length;e+=128){const t=[u[0][e],u[1][e],u[2][e]],n=[u[3][e],u[4][e],u[5][e]];if(t.some(((t,e)=>t!==m[e]))||n.some(((t,e)=>t!==v[e]))){m=t,v=n;const r=e/d.sampleRate;y.gain.setValueAtTime(0,r),y=s(d,{..._,gain:0}),w=i(d,{...g,orientationX:m[0],orientationY:m[1],orientationZ:m[2],positionX:v[0],positionY:v[1],positionZ:v[2]}),y.gain.setValueAtTime(1,r),o.connect(y).connect(w.inputs[0]),w.connect(f)}}return f}return v?(await t(d,p.orientationX,m.orientationX),await t(d,p.orientationY,m.orientationY),await t(d,p.orientationZ,m.orientationZ),await t(d,p.positionX,m.positionX),await t(d,p.positionY,m.positionY),await t(d,p.positionZ,m.positionZ)):(await a(d,p.orientationX,m.orientationX),await a(d,p.orientationY,m.orientationY),await a(d,p.orientationZ,m.orientationZ),await a(d,p.positionX,m.positionX),await a(d,p.positionY,m.positionY),await a(d,p.positionZ,m.positionZ)),ut(m)?await c(p,d,m.inputs[0]):await c(p,d,m),m})(p,d)}}})(ln,xn,On,re,ns,_t,Be,hn,qe,Ln),is=((t,e,n,s,i,o,r)=>class extends t{constructor(t,a){const c=i(t),l={...de,...a},u=n(c,l),h=o(c);super(t,!1,u,h?s():null),this._nativePannerNode=u,this._orientationX=e(this,h,u.orientationX,J,Q),this._orientationY=e(this,h,u.orientationY,J,Q),this._orientationZ=e(this,h,u.orientationZ,J,Q),this._positionX=e(this,h,u.positionX,J,Q),this._positionY=e(this,h,u.positionY,J,Q),this._positionZ=e(this,h,u.positionZ,J,Q),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}})($e,dn,ns,ss,je,Le,vn),os=(t=>(e,{disableNormalization:n,imag:s,real:i})=>{const o=s instanceof Float32Array?s:new Float32Array(s),r=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(r,o,{disableNormalization:n});if(Array.from(s).length<2)throw t();return a})(Z),rs=((t,e,n,s)=>class i{constructor(i,o){const r=e(i),a=s({...fe,...o}),c=t(r,a);return n.add(c),c}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===i.prototype||n.has(t)}})(os,je,new WeakSet,(t=>{const{imag:e,real:n}=t;return void 0===e?void 0===n?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(n,(()=>0)),real:n}:void 0===n?{...t,imag:e,real:Array.from(e,(()=>0))}:{...t,imag:e,real:n}})),as=((t,e,n,s,i,o)=>{const r=16385,a=new Float32Array([1,1]),c=Math.PI/2,l={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},u={...l,oversample:"none"},h=(t,o,h,p,d)=>{if(1===o)return((t,e,i,o)=>{const h=new Float32Array(r),p=new Float32Array(r);for(let t=0;t<r;t+=1){const e=t/16384*c;h[t]=Math.cos(e),p[t]=Math.sin(e)}const d=n(t,{...l,gain:0}),f=s(t,{...u,curve:h}),m=s(t,{...u,curve:a}),_=n(t,{...l,gain:0}),g=s(t,{...u,curve:p});return{connectGraph(){e.connect(d),e.connect(void 0===m.inputs?m:m.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(_.gain),d.connect(o,0,0),_.connect(o,0,1)},disconnectGraph(){e.disconnect(d),e.disconnect(void 0===m.inputs?m:m.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(_.gain),d.disconnect(o,0,0),_.disconnect(o,0,1)}}})(t,h,p,d);if(2===o)return((t,i,o,h)=>{const p=new Float32Array(r),d=new Float32Array(r),f=new Float32Array(r),m=new Float32Array(r),_=Math.floor(8192.5);for(let t=0;t<r;t+=1)if(t>_){const e=(t-_)/(16384-_)*c;p[t]=Math.cos(e),d[t]=Math.sin(e),f[t]=0,m[t]=1}else{const e=t/(16384-_)*c;p[t]=1,d[t]=0,f[t]=Math.cos(e),m[t]=Math.sin(e)}const g=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),v=n(t,{...l,gain:0}),y=s(t,{...u,curve:p}),w=n(t,{...l,gain:0}),T=s(t,{...u,curve:d}),x=s(t,{...u,curve:a}),b=n(t,{...l,gain:0}),C=s(t,{...u,curve:f}),A=n(t,{...l,gain:0}),k=s(t,{...u,curve:m});return{connectGraph(){i.connect(g),i.connect(void 0===x.inputs?x:x.inputs[0]),g.connect(v,0),g.connect(w,0),g.connect(b,1),g.connect(A,1),x.connect(o),o.connect(void 0===y.inputs?y:y.inputs[0]),o.connect(void 0===T.inputs?T:T.inputs[0]),o.connect(void 0===C.inputs?C:C.inputs[0]),o.connect(void 0===k.inputs?k:k.inputs[0]),y.connect(v.gain),T.connect(w.gain),C.connect(b.gain),k.connect(A.gain),v.connect(h,0,0),b.connect(h,0,0),w.connect(h,0,1),A.connect(h,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(void 0===x.inputs?x:x.inputs[0]),g.disconnect(v,0),g.disconnect(w,0),g.disconnect(b,1),g.disconnect(A,1),x.disconnect(o),o.disconnect(void 0===y.inputs?y:y.inputs[0]),o.disconnect(void 0===T.inputs?T:T.inputs[0]),o.disconnect(void 0===C.inputs?C:C.inputs[0]),o.disconnect(void 0===k.inputs?k:k.inputs[0]),y.disconnect(v.gain),T.disconnect(w.gain),C.disconnect(b.gain),k.disconnect(A.gain),v.disconnect(h,0,0),b.disconnect(h,0,0),w.disconnect(h,0,1),A.disconnect(h,0,1)}}})(t,h,p,d);throw i()};return(e,{channelCount:s,channelCountMode:r,pan:a,...c})=>{if("max"===r)throw i();const l=t(e,{...c,channelCount:1,channelCountMode:r,numberOfInputs:2}),u=n(e,{...c,channelCount:s,channelCountMode:r,gain:1}),p=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:d,disconnectGraph:f}=h(e,s,u,p,l);Object.defineProperty(p.gain,"defaultValue",{get:()=>0}),Object.defineProperty(p.gain,"maxValue",{get:()=>1}),Object.defineProperty(p.gain,"minValue",{get:()=>-1});const m={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(t){u.channelCount!==t&&(_&&f(),({connectGraph:d,disconnectGraph:f}=h(e,t,u,p,l)),_&&d()),u.channelCount=t},get channelCountMode(){return u.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();u.channelCountMode=t},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t},get context(){return u.context},get inputs(){return[u]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get pan(){return p.gain},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])};let _=!1;return o(ie(m,l),(()=>{d(),_=!0}),(()=>{f(),_=!1}))}})(xn,se,re,ts,ue,wn),cs=((t,e)=>(n,s)=>{const i=s.channelCountMode;if("clamped-max"===i)throw e();if(void 0===n.createStereoPanner)return t(n,s);const o=n.createStereoPanner();return Ht(o,s),Qt(o,s,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),o})(as,ue),ls=((t,e,n,s,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=n(r);const l=X(c,a);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(a,t)}return o.set(a,c),l?await t(a,r.pan,c.pan):await s(a,r.pan,c.pan),ut(c)?await i(r,a,c.inputs[0]):await i(r,a,c),c})(r,a)}}})(ln,cs,_t,hn,qe),us=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=i(t),c={...me,...r},l=n(a,c),u=o(a);super(t,!1,l,u?s():null),this._pan=e(this,u,l.pan)}get pan(){return this._pan}})($e,dn,cs,ls,je,Le),hs=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o){const r=s.get(o);return void 0!==r?Promise.resolve(r):(async(i,o)=>{let r=e(i);if(!X(r,o)){const e={channelCount:r.channelCount,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,curve:r.curve,oversample:r.oversample};r=t(o,e)}return s.set(o,r),ut(r)?await n(i,o,r.inputs[0]):await n(i,o,r),r})(i,o)}}})(ts,_t,qe),ps=((t,e,n,s,i,o,r)=>class extends t{constructor(t,e){const a=i(t),c={..._e,...e},l=n(a,c);super(t,!0,l,o(a)?s():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=l,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}})($e,Lt,ts,hs,je,Le,vn),ds=(t=>null!==t&&t.isSecureContext)(Ne),fs=(t=>(e,n,s)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return s()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(Ne),ms=new WeakMap,_s=((t,e)=>n=>{let s=t.get(n);if(void 0!==s)return s;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return s=new e(1,1,44100),t.set(n,s),s})(ms,Be),gs=ds?((t,e,n,s,i,o,r,a,c,l,u,h,p)=>{let d=0;return(f,m,_={credentials:"omit"})=>{const g=u.get(f);if(void 0!==g&&g.has(m))return Promise.resolve();const v=l.get(f);if(void 0!==v){const t=v.get(m);if(void 0!==t)return t}const y=o(f),w=void 0===y.audioWorklet?i(m).then((([t,e])=>{const[s,i]=N(t,e);return n(`${s};((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;s(y.currentTime,y.sampleRate,(()=>t(class{},void 0,((t,n)=>{if(""===t.trim())throw e();const s=E.get(y);if(void 0!==s){if(s.has(t))throw e();P(n),V(n.parameterDescriptors),s.set(t,n)}else P(n),V(n.parameterDescriptors),E.set(y,new Map([[t,n]]))}),y.sampleRate,void 0,void 0)))})):Promise.all([i(m),Promise.resolve(t(h,h))]).then((([[t,e],n])=>{const s=d+1;d=s;const[i,o]=N(t,e),l=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${o}\n})(${n?"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{${n?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${n?"":"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${s}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),u=URL.createObjectURL(l);return y.audioWorklet.addModule(u,_).then((()=>{if(a(y))return y;const t=r(y);return t.audioWorklet.addModule(u,_).then((()=>t))})).then((t=>{if(null===c)throw new SyntaxError;try{new c(t,`__sac${s}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(u)))}));return void 0===v?l.set(f,new Map([[m,w]])):v.set(m,w),w.then((()=>{const t=u.get(f);void 0===t?u.set(f,new Set([m])):t.add(m)})).finally((()=>{const t=l.get(f);void 0!==t&&t.delete(m)})),w}})(Re,ue,(t=>e=>new Promise(((n,s)=>{if(null===t)return void s(new SyntaxError);const i=t.document.head;if(null===i)s(new SyntaxError);else{const o=t.document.createElement("script"),r=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(r),c=t.onerror,l=()=>{t.onerror=c,URL.revokeObjectURL(a)};t.onerror=(e,n,i,o,r)=>n===a||n===t.location.href&&1===i&&1===o?(l(),s(r),!1):null!==c?c(e,n,i,o,r):void 0,o.onerror=()=>{l(),s(new SyntaxError)},o.onload=()=>{l(),n()},o.src=a,o.type="module",i.appendChild(o)}})))(Ne),fs,(t=>async e=>{try{const t=await fetch(e);if(t.ok)return[await t.text(),t.url]}catch{}throw t()})((()=>new DOMException("","AbortError"))),je,_s,Le,He,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=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"}),s=new e(1,128,44100),i=URL.createObjectURL(n);let o=!1,r=!1;try{await s.audioWorklet.addModule(i);const e=new t(s,"a",{numberOfOutputs:0}),n=s.createOscillator();e.port.onmessage=()=>o=!0,e.onprocessorerror=()=>r=!0,n.connect(e),n.start(0),await s.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return o&&!r})(He,Be),Ne):void 0,vs=((t,e)=>n=>t(n)||e(n))(Xe,Le),ys=((t,e,n,s,i,o,r,a,c,l,u)=>(h,p)=>{const d=r(h)?h:o(h);if(i.has(p)){const t=n();return Promise.reject(t)}try{i.add(p)}catch{}return e(c,(()=>c(d)))?d.decodeAudioData(p).then((n=>(qt(p).catch((()=>{})),e(a,(()=>a(n)))||u(n),t.add(n),n))):new Promise(((e,n)=>{const i=async()=>{try{await qt(p)}catch{}},o=t=>{n(t),i()};try{d.decodeAudioData(p,(n=>{"function"!=typeof n.copyFromChannel&&(l(n),H(n)),t.add(n),i().then((()=>e(n)))}),(t=>{o(null===t?s():t)}))}catch(t){o(t)}}))})(Ke,Re,(()=>new DOMException("","DataCloneError")),(()=>new DOMException("","EncodingError")),new WeakSet,je,vs,Y,Yt,sn,on),ws=((t,e,n,s,i,o,r,a,c,l,u,h,p,d,f,m,_,g,v,y)=>class extends f{constructor(e,n){super(e,n),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,n)=>t(this,e,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,s){return new n({length:e,numberOfChannels:t,sampleRate:s})}createBufferSource(){return new s(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 u(this,{maxDelayTime:t})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(t,e){return new d(this,{feedback:e,feedforward:t})}createOscillator(){return new m(this)}createPanner(){return new _(this)}createPeriodicWave(t,e,n={disableNormalization:!1}){return new g(this,{...n,imag:e,real:t})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(t,e,n){return l(this._nativeContext,t).then((t=>("function"==typeof e&&e(t),t)),(t=>{throw"function"==typeof n&&n(t),t}))}})(gs,Je,rn,mn,yn,Cn,kn,En,Dn,ys,Vn,Fn,Wn,Gn,Zn,Qn,is,rs,us,ps),Ts=((t,e,n,s)=>class extends t{constructor(t,i){const o=n(t),r=e(o,i);if(s(o))throw TypeError();super(t,!0,r,null),this._nativeMediaElementAudioSourceNode=r}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})($e,((t,e)=>t.createMediaElementSource(e.mediaElement)),je,Le),xs=((t,e,n,s)=>class extends t{constructor(t,i){const o=n(t);if(s(o))throw new TypeError;const r={...Xt,...i},a=e(o,r);super(t,!1,a,null),this._nativeMediaStreamAudioDestinationNode=a}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})($e,((t,e)=>{const n=t.createMediaStreamDestination();return Ht(n,e),1===n.numberOfOutputs&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n}),je,Le),bs=((t,e,n,s)=>class extends t{constructor(t,i){const o=n(t),r=e(o,i);if(s(o))throw new TypeError;super(t,!0,r,null),this._nativeMediaStreamAudioSourceNode=r}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})($e,((t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const s=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(s));return Object.defineProperty(i,"mediaStream",{value:e}),i}),je,Le),Cs=((t,e)=>(n,{mediaStreamTrack:s})=>{if("function"==typeof n.createMediaStreamTrackSource)return n.createMediaStreamTrackSource(s);const i=new MediaStream([s]),o=n.createMediaStreamSource(i);if("audio"!==s.kind)throw t();if(e(n))throw new TypeError;return o})(Lt,Le),As=((t,e,n)=>class extends t{constructor(t,s){const i=n(t);super(t,!0,e(i,s),null)}})($e,Cs,je),ks=((t,e,n,s,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 n();throw t}if(null===e)throw s();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 n();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()),it(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 n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)})):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}))}})(ws,Lt,ue,(()=>new DOMException("","UnknownError")),Ts,xs,bs,As,Ge),Ss=(t=>e=>{const n=t.get(e);if(void 0===n)throw new Error("The context has no set of AudioWorkletNodes.");return n})(Yn),Os=(t=>(e,n)=>{t(e).add(n)})(Ss),Ms=(t=>(e,n,s=0,i=0)=>{const o=e[s];if(void 0===o)throw t();return xt(n)?o.connect(n,0,i):o.connect(n,0)})(Z),Es=(t=>(e,n)=>{t(e).delete(n)})(Ss),Rs=(t=>(e,n=void 0,s=void 0,i=0)=>void 0===n?e.forEach((t=>t.disconnect())):"number"==typeof n?jt(t,e,n).disconnect():xt(n)?void 0===s?e.forEach((t=>t.disconnect(n))):void 0===i?jt(t,e,s).disconnect(n,0):jt(t,e,s).disconnect(n,0,i):void 0===s?e.forEach((t=>t.disconnect(n))):jt(t,e,s).disconnect(n,0))(Z),Is=new WeakMap,Ds=((t,e)=>n=>e(t,n))(Is,q),Ns=((t,e,n,s,i,o,r,a,c,l,u,h,p)=>(d,f,m,_)=>{if(0===_.numberOfInputs&&0===_.numberOfOutputs)throw c();const g=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(g.some((t=>t<1)))throw c();if(g.length!==_.numberOfOutputs)throw e();if("explicit"!==_.channelCountMode)throw c();const v=_.channelCount*_.numberOfInputs,y=g.reduce(((t,e)=>t+e),0),w=void 0===m.parameterDescriptors?0:m.parameterDescriptors.length;if(v+w>6||y>6)throw c();const T=new MessageChannel,x=[],b=[];for(let t=0;t<_.numberOfInputs;t+=1)x.push(r(d,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),b.push(i(d,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const C=[];if(void 0!==m.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:s}of m.parameterDescriptors){const i=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==_.parameterData[s]?_.parameterData[s]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?J:e},minValue:{get:()=>void 0===n?Q:n}}),C.push(i)}const A=s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,v+w)}),k=te(f,d.sampleRate),S=a(d,k,v+w,Math.max(1,y)),O=i(d,{channelCount:Math.max(1,y),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,y)}),M=[];for(let t=0;t<_.numberOfOutputs;t+=1)M.push(s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[t]}));for(let t=0;t<_.numberOfInputs;t+=1){x[t].connect(b[t]);for(let e=0;e<_.channelCount;e+=1)b[t].connect(A,e,t*_.channelCount+e)}const E=new kt(void 0===m.parameterDescriptors?[]:m.parameterDescriptors.map((({name:t},e)=>{const n=C[e];return n.connect(A,0,v+e),n.start(0),[t,n.offset]})));A.connect(S);let I=_.channelInterpretation,D=null;const N=0===_.numberOfOutputs?[S]:M,V={get bufferSize(){return k},get channelCount(){return _.channelCount},set channelCount(t){throw n()},get channelCountMode(){return _.channelCountMode},set channelCountMode(t){throw n()},get channelInterpretation(){return I},set channelInterpretation(t){for(const e of x)e.channelInterpretation=t;I=t},get context(){return S.context},get inputs(){return x},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get onprocessorerror(){return D},set onprocessorerror(t){"function"==typeof D&&V.removeEventListener("processorerror",D),D="function"==typeof t?t:null,"function"==typeof D&&V.addEventListener("processorerror",D)},get parameters(){return E},get port(){return T.port2},addEventListener:(...t)=>S.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,N),disconnect:l.bind(null,N),dispatchEvent:(...t)=>S.dispatchEvent(t[0]),removeEventListener:(...t)=>S.removeEventListener(t[0],t[1],t[2])},P=new Map;var q,F;T.port1.addEventListener=(q=T.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 n=P.get(t[1]);void 0!==n?t[1]=n:(t[1]=t=>{u(d.currentTime,d.sampleRate,(()=>e(t)))},P.set(e,t[1]))}}return q.call(T.port1,t[0],t[1],t[2])}),T.port1.removeEventListener=(F=T.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=P.get(t[1]);void 0!==e&&(P.delete(t[1]),t[1]=e)}return F.call(T.port1,t[0],t[1],t[2])});let j=null;Object.defineProperty(T.port1,"onmessage",{get:()=>j,set:t=>{"function"==typeof j&&T.port1.removeEventListener("message",j),j="function"==typeof t?t:null,"function"==typeof j&&(T.port1.addEventListener("message",j),T.port1.start())}}),m.prototype.port=T.port1;let W=null;const B=((t,e,n,s)=>{let i=R.get(t);void 0===i&&(i=new WeakMap,R.set(t,i));const o=ee(n,s);return i.set(e,o),o})(d,V,m,_);B.then((t=>W=t));const L=Et(_.numberOfInputs,_.channelCount),U=Et(_.numberOfOutputs,g),z=void 0===m.parameterDescriptors?[]:m.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let G=!0;const X=()=>{_.numberOfOutputs>0&&S.disconnect(O);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const n=M[t];for(let s=0;s<g[t];s+=1)O.disconnect(n,e+s,s);e+=g[t]}},Y=new Map;S.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==W){const n=h(V);for(let s=0;s<k;s+=128){for(let e=0;e<_.numberOfInputs;e+=1)for(let n=0;n<_.channelCount;n+=1)Ot(t,L[e],n,n,s);void 0!==m.parameterDescriptors&&m.parameterDescriptors.forEach((({name:e},n)=>{Ot(t,z,e,v+n,s)}));for(let t=0;t<_.numberOfInputs;t+=1)for(let e=0;e<g[t];e+=1)0===U[t][e].byteLength&&(U[t][e]=new Float32Array(128));try{const t=L.map(((t,e)=>{if(n[e].size>0)return Y.set(e,k/128),t;const s=Y.get(e);return void 0===s?[]:(t.every((t=>t.every((t=>0===t))))&&(1===s?Y.delete(e):Y.set(e,s-1)),t)})),i=u(d.currentTime+s/d.sampleRate,d.sampleRate,(()=>W.process(t,U,z)));G=i;for(let t=0,n=0;t<_.numberOfOutputs;t+=1){for(let i=0;i<g[t];i+=1)Mt(e,U[t],i,n+i,s);n+=g[t]}}catch(t){G=!1,V.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!G){for(let t=0;t<_.numberOfInputs;t+=1){x[t].disconnect(b[t]);for(let e=0;e<_.channelCount;e+=1)b[s].disconnect(A,e,t*_.channelCount+e)}if(void 0!==m.parameterDescriptors){const t=m.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=C[e];t.disconnect(A,0,v+e),t.stop()}}A.disconnect(S),S.onaudioprocess=null,Z?X():K();break}}}};let Z=!1;const H=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),$=()=>S.connect(H).connect(d.destination),K=()=>{S.disconnect(H),H.disconnect()};return $(),p(V,(()=>{if(G){K(),_.numberOfOutputs>0&&S.connect(O);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const n=M[t];for(let s=0;s<g[t];s+=1)O.connect(n,e+s,s);e+=g[t]}}Z=!0}),(()=>{G&&($(),X()),Z=!1}))})(Ms,Z,Lt,xn,se,On,re,le,ue,Rs,fs,Ds,wn),Vs=((t,e,n,s,i)=>(o,r,a,c,l,u)=>{if(null!==a)try{const e=new a(o,c,u),s=new Map;let r=null;if(Object.defineProperties(e,{channelCount:{get:()=>u.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 n=s.get(t[1]);void 0!==n?t[1]=n:(t[1]=n=>{"error"===n.type?(Object.defineProperties(n,{type:{value:"processorerror"}}),e(n)):e(new ErrorEvent(t[0],{...n}))},s.set(e,t[1]))}}return p.call(e,"error",t[1],t[2]),p.call(e,...t)}),e.removeEventListener=(h=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=s.get(t[1]);void 0!==e&&(s.delete(t[1]),t[1]=e)}return h.call(e,"error",t[1],t[2]),h.call(e,t[0],t[1],t[2])}),0!==u.numberOfOutputs){const t=n(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(t).connect(o.destination);return i(e,(()=>t.disconnect()),(()=>t.connect(o.destination)))}return e}catch(t){if(11===t.code)throw s();throw t}var h,p;if(void 0===l)throw s();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(u),e(o,r,l,u)})(Lt,Ns,re,ue,wn),Ps=((t,e,n,s,i,o,r,a,c,l,u,h,p,d,f,m)=>(_,g,v)=>{const y=new WeakMap;let w=null;return{render(T,x){a(x,T);const b=y.get(x);return void 0!==b?Promise.resolve(b):(async(a,T)=>{let x=u(a),b=null;const C=X(x,T),A=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(null===h){const t=A.reduce(((t,e)=>t+e),0),n=i(T,{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(s(T,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:A[t]}));const l=r(T,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});l.connect=e.bind(null,o),l.disconnect=c.bind(null,o),b=[n,o,l]}else C||(x=new h(T,_));if(y.set(T,null===b?x:b[2]),null!==b){if(null===w){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,n=t+e,c=async()=>{const c=new p(n,128*Math.ceil(a.context.length/128),T.sampleRate),l=[],u=[];for(let t=0;t<g.numberOfInputs;t+=1)l.push(r(c,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),u.push(i(c,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const h=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}))),_=s(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<g.numberOfInputs;t+=1){l[t].connect(u[t]);for(let e=0;e<g.channelCount;e+=1)u[t].connect(_,e,t*g.channelCount+e)}for(const[e,n]of h.entries())n.connect(_,0,t+e),n.start(0);return _.connect(c.destination),await Promise.all(l.map((t=>f(a,c,t)))),m(c)};w=Rt(a,0===n?null:await c(),T,g,A,v,l)}const t=await w,e=n(T,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,u,h]=b;null!==t&&(e.buffer=t,e.start(0)),e.connect(c);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const n=u[t];for(let s=0;s<A[t];s+=1)c.connect(n,e+s,s);e+=A[t]}return h}if(C)for(const[e,n]of a.parameters.entries())await t(T,n,x.parameters.get(e));else for(const[t,e]of a.parameters.entries())await d(T,e,x.parameters.get(t));return await f(a,T,x),x})(T,x)}}})(ln,Ms,un,xn,se,On,re,Es,Rs,fs,_t,He,Be,hn,qe,Ln),qs=(t=>e=>t.get(e))(ms),Fs=(t=>(e,n)=>{t.set(e,n)})(Is),js=ds?((t,e,n,s,i,o,r,a,c,l,u,h,p,d)=>class extends e{constructor(e,d,f){var m;const _=a(e),g=c(_),v=u({...St,...f});p(v);const y=E.get(_),w=null==y?void 0:y.get(d),T=g||"closed"!==_.state?_:null!==(m=r(_))&&void 0!==m?m:_,x=i(T,g?null:e.baseLatency,l,d,w,v);super(e,!0,x,g?s(d,v,w):null);const b=[];x.parameters.forEach(((t,e)=>{const s=n(this,g,t);b.push([e,s])})),this._nativeAudioWorkletNode=x,this._onprocessorerror=null,this._parameters=new kt(b),g&&t(_,this);const{activeInputs:C}=o(this);h(x,C)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?d(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==n&&n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(Os,$e,dn,Ps,Vs,et,qs,je,Le,He,(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))})),Fs,(t=>{const{port1:e,port2:n}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),n.close()}}),Ae):void 0,Ws=((t,e)=>(n,s,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(n,s,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(ue,Be),Bs=((t,e,n,s,i,o,r,a)=>(c,l)=>n(c).render(c,l).then((()=>Promise.all(Array.from(s(l)).map((t=>n(t).render(t,l)))))).then((()=>i(l))).then((n=>("function"!=typeof n.copyFromChannel?(r(n),H(n)):e(o,(()=>o(n)))||a(n),t.add(n),n))))(Ke,Re,Pe,Ss,Ln,Y,sn,on),Ls=((t,e,n,s,i)=>class extends t{constructor(t,n,i){let o;if("number"==typeof t&&void 0!==n&&void 0!==i)o={length:n,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}={...he,...o},l=s(a,r,c);e(Yt,(()=>Yt(l)))||l.addEventListener("statechange",(()=>{let t=0;const e=n=>{"running"===this._state&&(t>0?(l.removeEventListener("statechange",e),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):t+=1)};return e})()),super(l,a),this._length=r,this._nativeOfflineAudioContext=l,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(n()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally((()=>{this._state=null,it(this)})))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout((()=>this._waitForThePromiseToSettle(t)))}})(ws,Re,Lt,Ws,Bs),Us=((t,e)=>n=>{const s=t.get(n);return e(s)||e(n)})(S,Xe),zs=((t,e)=>n=>t.has(n)||e(n))(C,Ye),Gs=((t,e)=>n=>t.has(n)||e(n))(k,Ze),Xs=((t,e)=>n=>{const s=t.get(n);return e(s)||e(n)})(S,Le);function Ys(t){return void 0===t}function Zs(t){return void 0!==t}function Hs(t){return"number"==typeof t}function $s(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object}function Qs(t){return Array.isArray(t)}function Js(t){return"string"==typeof t}function Ks(t){return Js(t)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(t)}function ti(t,e){if(!t)throw new Error(e)}function ei(t,e,n=1/0){if(!(e<=t&&t<=n))throw new RangeError(`Value must be within [${e}, ${n}], got: ${t}`)}function ni(t){t.isOffline||"running"===t.state||ai('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let si=!1,ii=!1;function oi(t){si=t}let ri=console;function ai(...t){ri.warn(...t)}const ci="object"==typeof self?self:null,li=ci&&(ci.hasOwnProperty("AudioContext")||ci.hasOwnProperty("webkitAudioContext"));function ui(t,e,n,s){var i,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,s);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r}function hi(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{c(s.next(t))}catch(t){o(t)}}function a(t){try{c(s.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}c((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class pi{constructor(t,e,n,s){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(s||44100),.001),this.updateInterval=n,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),n=new Worker(e);n.onmessage=this._callback.bind(this),this._worker=n}_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()}}function di(t){return Gs(t)}function fi(t){return zs(t)}function mi(t){return Xs(t)}function _i(t){return Us(t)}function gi(t,e){return"value"===t||di(e)||fi(e)||function(t){return t instanceof rn}(e)}function vi(t,...e){if(!e.length)return t;const n=e.shift();if($s(t)&&$s(n))for(const e in n)gi(e,n[e])?t[e]=n[e]:$s(n[e])?(t[e]||Object.assign(t,{[e]:{}}),vi(t[e],n[e])):Object.assign(t,{[e]:n[e]});return vi(t,...e)}function yi(t,e,n=[],s){const i={},o=Array.from(e);if($s(o[0])&&s&&!Reflect.has(o[0],s)){Object.keys(o[0]).some((e=>Reflect.has(t,e)))||(vi(i,{[s]:o[0]}),n.splice(n.indexOf(s),1),o.shift())}if(1===o.length&&$s(o[0]))vi(i,o[0]);else for(let t=0;t<n.length;t++)Zs(o[t])&&(i[n[t]]=o[t]);return vi(t,i)}function wi(t,e){return Ys(t)?e:t}function Ti(t,e){return e.forEach((e=>{Reflect.has(t,e)&&delete t[e]})),t}
/**
     * Tone.js
     * @author Yotam Mann
     * @license http://opensource.org/licenses/MIT MIT License
     * @copyright 2014-2024 Yotam Mann
     */class xi{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ci&&this.toString()===ci.TONE_DEBUG_CLASS)&&function(...t){ri.log(...t)}(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}xi.version=e;const bi=1e-6;function Ci(t,e){return t>e+bi}function Ai(t,e){return Ci(t,e)||Si(t,e)}function ki(t,e){return t+bi<e}function Si(t,e){return Math.abs(t-e)<bi}class Oi extends xi{constructor(){super(),this.name="Timeline",this._timeline=[];const t=yi(Oi.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(ti(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];ti(Ai(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 n=this._search(t,e);return-1!==n?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const n=this._search(t,e);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const n=this._search(t);return n-1>=0?this._timeline[n-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Si(this._timeline[e].time,t)){for(let n=e;n>=0&&Si(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&Ai(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 n=0;const s=this._timeline.length;let i=s;if(s>0&&this._timeline[s-1][e]<=t)return s-1;for(;n<i;){let s=Math.floor(n+(i-n)/2);const o=this._timeline[s],r=this._timeline[s+1];if(Si(o[e],t)){for(let n=s;n<this._timeline.length;n++){if(!Si(this._timeline[n][e],t))break;s=n}return s}if(ki(o[e],t)&&Ci(r[e],t))return s;Ci(o[e],t)?i=s:n=s+1}return-1}_iterate(t,e=0,n=this._timeline.length-1){this._timeline.slice(e,n+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const n=this._search(t);return-1!==n&&this._iterate(e,0,n),this}forEachAfter(t,e){const n=this._search(t);return this._iterate(e,n+1),this}forEachBetween(t,e,n){let s=this._search(t),i=this._search(e);return-1!==s&&-1!==i?(this._timeline[s].time!==t&&(s+=1),this._timeline[i].time===e&&(i-=1),this._iterate(n,s,i)):-1===s&&this._iterate(n,0,i),this}forEachFrom(t,e){let n=this._search(t);for(;n>=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this}forEachAtTime(t,e){const n=this._search(t);if(-1!==n&&Si(this._timeline[n].time,t)){let s=n;for(let e=n;e>=0&&Si(this._timeline[e].time,t);e--)s=e;this._iterate((t=>{e(t)}),s,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const Mi=[];function Ei(t){Mi.push(t)}const Ri=[];function Ii(t){Ri.push(t)}class Di extends xi{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach((t=>{Ys(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)})),this}once(t,e){const n=(...s)=>{e(...s),this.off(t,n)};return this.on(t,n),this}off(t,e){return t.split(/\W+/).forEach((t=>{if(Ys(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(Ys(e))this._events[t]=[];else{const n=this._events[t];for(let t=n.length-1;t>=0;t--)n[t]===e&&n.splice(t,1)}})),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const n=this._events[t].slice(0);for(let t=0,s=n.length;t<s;t++)n[t].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach((e=>{const n=Object.getOwnPropertyDescriptor(Di.prototype,e);Object.defineProperty(t.prototype,e,n)}))}dispose(){return super.dispose(),this._events=void 0,this}}class Ni extends Di{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}class Vi extends Ni{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Oi,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;const n=yi(Vi.getDefaults(),arguments,["context"]);n.context?(this._context=n.context,this._latencyHint=(null===(t=arguments[0])||void 0===t?void 0:t.latencyHint)||""):(this._context=function(t){return new ks(t)}({latencyHint:n.latencyHint}),this._latencyHint=n.latencyHint),this._ticker=new pi(this.emit.bind(this,"tick"),n.clockSource,n.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[(null===(e=arguments[0])||void 0===e?void 0:e.hasOwnProperty("updateInterval"))?"_lookAhead":"lookAhead"]=n.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){var t;return this._initialized||(t=this,Mi.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,n){return this._context.createBuffer(t,e,n)}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,n){return this._context.createPeriodicWave(t,e,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){ti(_i(this._context),"Not available if OfflineAudioContext");return this._context.createMediaStreamSource(t)}createMediaElementSource(t){ti(_i(this._context),"Not available if OfflineAudioContext");return this._context.createMediaElementSource(t)}createMediaStreamDestination(){ti(_i(this._context),"Not available if OfflineAudioContext");return 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){ti(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){ti(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){ti(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){ti(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,n){return ti(Zs(js),"AudioWorkletNode only works in a secure context (https or localhost)"),new(t instanceof(null==ci?void 0:ci.BaseAudioContext)?null==ci?void 0:ci.AudioWorkletNode:js)(t,e,n)}(this.rawContext,t,e)}addAudioWorkletModule(t){return hi(this,void 0,void 0,(function*(){ti(Zs(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise}))}workletsAreReady(){return hi(this,void 0,void 0,(function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()}))}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 _i(this._context)?this._context.resume():Promise.resolve()}close(){return hi(this,void 0,void 0,(function*(){var t;_i(this._context)&&"closed"!==this.state&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&(t=this,Ri.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),n=e.getChannelData(0);for(let e=0;e<n.length;e++)n[e]=t;const s=this._context.createBufferSource();return s.channelCount=1,s.channelCountMode="explicit",s.buffer=e,s.loop=!0,s.start(0),this._constants.set(t,s),s}}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();let e=this._timeouts.peek();for(;this._timeouts.length&&e&&e.time<=t;)e.callback(),this._timeouts.shift(),e=this._timeouts.peek()}setTimeout(t,e){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:n+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 n=++this._timeoutIds,s=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),s()},id:n,time:i+e})};return s(),n}}function Pi(t,e){Qs(e)?e.forEach((e=>Pi(t,e))):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function qi(t,e){Qs(e)?e.forEach((e=>qi(t,e))):Object.defineProperty(t,e,{writable:!0})}const Fi=()=>{};class ji extends xi{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Fi;const t=yi(ji.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,Js(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:Fi,onload:Fi,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Ui().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 hi(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=Qs(t)&&t[0].length>0,n=e?t.length:1,s=e?t[0].length:t.length,i=Ui(),o=i.createBuffer(n,s,i.sampleRate),r=e||1!==n?t:[t];for(let t=0;t<n;t++)o.copyToChannel(r[t],t);return this._buffer=o,this}toMono(t){if(Hs(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let n=0;n<e;n++){const e=this.toArray(n);for(let n=0;n<e.length;n++)t[n]+=e[n]}t=t.map((t=>t/e)),this.fromArray(t)}return this}toArray(t){if(Hs(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){ti(this.loaded,"Buffer is not loaded");const n=Math.floor(t*this.sampleRate),s=Math.floor(e*this.sampleRate);ti(n<s,"The start time must be less than the end time");const i=s-n,o=Ui().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let t=0;t<this.numberOfChannels;t++)o.copyToChannel(this.getChannelData(t).subarray(n,s),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 hi(this,void 0,void 0,(function*(){const e=new ji;return yield e.load(t)}))}static load(t){return hi(this,void 0,void 0,(function*(){const e=t.match(/\[([^\]\[]+\|.+)\]$/);if(e){const n=e[1].split("|");let s=n[0];for(const t of n)if(ji.supportsType(t)){s=t;break}t=t.replace(e[0],s)}const n=""===ji.baseUrl||ji.baseUrl.endsWith("/")?ji.baseUrl:ji.baseUrl+"/",s=document.createElement("a");s.href=n+t,s.pathname=(s.pathname+s.hash).split("/").map(encodeURIComponent).join("/");const i=yield fetch(s.href);if(!i.ok)throw new Error(`could not load url: ${t}`);const o=yield i.arrayBuffer();return yield Ui().decodeAudioData(o)}))}static supportsType(t){const e=t.split("."),n=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+n)}static loaded(){return hi(this,void 0,void 0,(function*(){for(yield Promise.resolve();ji.downloads.length;)yield ji.downloads[0]}))}}ji.baseUrl="",ji.downloads=[];class Wi extends Vi{constructor(){var t,e,n;super({clockSource:"offline",context:mi(arguments[0])?arguments[0]:(t=arguments[0],e=arguments[1]*arguments[2],n=arguments[2],new Ls(t,e,n)),lookAhead:0,updateInterval:mi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=mi(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return hi(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 n=Math.floor(this.sampleRate/128);t&&e%n==0&&(yield new Promise((t=>setTimeout(t,1))))}}))}render(){return hi(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 Bi=new class extends Ni{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,n){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,n){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 hi(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 Li=Bi;function Ui(){return Li===Bi&&li&&function(t,e=!1){e&&Li.dispose();Li=_i(t)?new Vi(t):mi(t)?new Wi(t):t}(new Vi),Li}if(ci&&!ci.TONE_SILENCE_LOGGING){const t=` * Tone.js ${"v"}${e} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function zi(t){return Math.pow(2,t/12)}let Gi=440;function Xi(t){return Math.round(Yi(t))}function Yi(t){return 69+12*Math.log2(t/Gi)}class Zi extends xi{constructor(t,e,n){super(),this.defaultUnits="s",this._val=e,this._units=n,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 n=parseInt(t,10),s="."===e?1.5:1;return 1===n?this._beatsToUnits(this._getTimeSignature())*s:this._beatsToUnits(4/n)*s},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,n)=>{let s=0;return t&&"0"!==t&&(s+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(s+=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(s+=this._beatsToUnits(parseFloat(n)/4)),s},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof Zi&&this.fromType(this._val),Ys(this._val))return this._noArg();if(Js(this._val)&&Ys(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if($s(this._val)){let t=0;for(const e in this._val)if(Zs(this._val[e])){const n=this._val[e];t+=new this.constructor(this.context,e).valueOf()*n}return t}if(Zs(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 Js(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 Hi extends Zi{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 Hi(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const n=new this.constructor(this.context,t).valueOf(),s=this.valueOf();return s+(Math.round(s/n)*n-s)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const n=Math.pow(2,t);e.push(n+"n."),e.push(n+"n"),e.push(n+"t")}e.push("0");let n=e[0],s=new Hi(this.context,e[0]).toSeconds();return e.forEach((e=>{const i=new Hi(this.context,e).toSeconds();Math.abs(i-t)<Math.abs(s-t)&&(n=e,s=i)})),n}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const n=Math.floor(e/this._getTimeSignature());let s=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=s.toString();i.length>3&&(s=parseFloat(parseFloat(i).toFixed(3)));return[n,e,s].join(":")}toTicks(){const t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Xi(this.toFrequency())}_now(){return this.context.now()}}function $i(t,e){return new Hi(Ui(),t,e)}class Qi extends Hi{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Gi}static set A4(t){!function(t){Gi=t}(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return"midi"===this.defaultUnits?t:Qi.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){const n=Ji[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?n:Qi.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,n){let s=1;return t&&"0"!==t&&(s*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(s*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(s*=this._beatsToUnits(parseFloat(n)/4)),s}}})}transpose(t){return new Qi(this.context,this.valueOf()*zi(t))}harmonize(t){return t.map((t=>this.transpose(t)))}toMidi(){return Xi(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/Qi.A4);let n=Math.round(12*e)+57;const s=Math.floor(n/12);s<0&&(n+=-12*s);return Ki[n%12]+s.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 function(t){return Gi*Math.pow(2,(t-69)/12)}(t)}static ftom(t){return Xi(t)}}const Ji={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},Ki=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];class to extends Hi{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}class eo extends xi{constructor(){super();const t=yi(eo.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Ui()}}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 function(t){Ys(t)&&si&&!ii&&(ii=!0,ai("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}(t),new Hi(this.context,t).toSeconds()}toFrequency(t){return new Qi(this.context,t).toFrequency()}toTicks(t){return new to(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach((n=>{Ys(t[n])&&delete e[n]})),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach((e=>{if(Reflect.has(this,e)){const n=this[e];Zs(n)&&Zs(n.value)&&Zs(n.setValueAtTime)?t[e]=n.value:n instanceof eo?t[e]=n._getPartialProperties(t[e]):Qs(n)||Hs(n)||Js(n)||"boolean"==typeof n?t[e]=n:delete t[e]}})),t}set(t){return Object.keys(t).forEach((e=>{Reflect.has(this,e)&&Zs(this[e])&&(this[e]&&Zs(this[e].value)&&Zs(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 no extends Oi{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,n){return ei(e,0),this.add(Object.assign({},n,{state:t,time:e})),this}getLastState(t,e){for(let n=this._search(e);n>=0;n--){const e=this._timeline[n];if(e.state===t)return e}}getNextState(t,e){const n=this._search(e);if(-1!==n)for(let e=n;e<this._timeline.length;e++){const n=this._timeline[e];if(n.state===t)return n}}}class so extends eo{constructor(){const t=yi(so.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,ti(Zs(t.param)&&(di(t.param)||t.param instanceof so),"param must be an AudioParam");!di(t.param);)t.param=t.param._param;this._swappable=!!Zs(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 Oi(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,Zs(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 Zs(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 Zs(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return Zs(this.maxValue)&&Zs(this.minValue)&&ei(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")?(e=t,Math.pow(10,e/20)):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t;var e}_toType(t){return this.convert&&"decibels"===this.units?(e=t,Math.log(e)/Math.LN10*20):t;var e}setValueAtTime(t,e){const n=this.toSeconds(e),s=this._fromType(t);return ti(isFinite(s)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(s),this.log(this.units,"setValueAtTime",t,n),this._events.add({time:n,type:"setValueAtTime",value:s}),this._param.setValueAtTime(s,n),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),n=this._events.getAfter(e),s=this._events.get(e);let i=this._initialValue;if(null===s)i=this._initialValue;else if("setTargetAtTime"!==s.type||null!==n&&"setValueAtTime"!==n.type)if(null===n)i=s.value;else if("linearRampToValueAtTime"===n.type||"exponentialRampToValueAtTime"===n.type){let t=s.value;if("setTargetAtTime"===s.type){const e=this._events.getBefore(s.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===n.type?this._linearInterpolate(s.time,t,n.time,n.value,e):this._exponentialInterpolate(s.time,t,n.time,n.value,e)}else i=s.value;else{const t=this._events.getBefore(s.time);let n;n=null===t?this._initialValue:t.value,"setTargetAtTime"===s.type&&(i=this._exponentialApproach(s.time,n,s.value,s.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 n=this._fromType(t),s=this.toSeconds(e);return ti(isFinite(n)&&isFinite(s),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this._events.add({time:s,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",t,s),this._param.linearRampToValueAtTime(n,s),this}exponentialRampToValueAtTime(t,e){let n=this._fromType(t);n=Si(n,0)?this._minOutput:n,this._assertRange(n);const s=this.toSeconds(e);return ti(isFinite(n)&&isFinite(s),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:s,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",t,s),this._param.exponentialRampToValueAtTime(n,s),this}exponentialRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(t,n+this.toSeconds(e)),this}linearRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(t,n+this.toSeconds(e)),this}targetRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(t,n,e),this}exponentialApproachValueAtTime(t,e,n){e=this.toSeconds(e),n=this.toSeconds(n);const s=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(t,e,s),this.cancelAndHoldAtTime(e+.9*n),this.linearRampToValueAtTime(t,e+n),this}setTargetAtTime(t,e,n){const s=this._fromType(t);ti(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(s),ti(isFinite(s)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:n,time:i,type:"setTargetAtTime",value:s}),this.log(this.units,"setTargetAtTime",t,i,n),this._param.setTargetAtTime(s,i,n),this}setValueCurveAtTime(t,e,n,s=1){n=this.toSeconds(n),e=this.toSeconds(e);const i=this._fromType(t[0])*s;this.setValueAtTime(this._toType(i),e);const o=n/(t.length-1);for(let n=1;n<t.length;n++){const i=this._fromType(t[n])*s;this.linearRampToValueAtTime(this._toType(i),e+n*o)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return ti(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),n=this._fromType(this.getValueAtTime(e));ti(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+n);const s=this._events.get(e),i=this._events.getAfter(e);return s&&Si(s.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(n),e):"exponentialRampToValueAtTime"===i.type&&this.exponentialRampToValueAtTime(this._toType(n),e)),this._events.add({time:e,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,e),this}rampTo(t,e=.1,n){return"frequency"===this.units||"bpm"===this.units||"decibels"===this.units?this.exponentialRampTo(t,e,n):this.linearRampTo(t,e,n),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const n=this._events.get(e);if(n&&"setTargetAtTime"===n.type){const s=this._events.getAfter(n.time),i=s?s.time:e+2,o=(i-e)/10;for(let n=e;n<i;n+=o)t.linearRampToValueAtTime(this.getValueAtTime(n),n)}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){ti(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,n,s,i){return n+(e-n)*Math.exp(-(i-t)/s)}_linearInterpolate(t,e,n,s,i){return e+(i-t)/(n-t)*(s-e)}_exponentialInterpolate(t,e,n,s,i){return e*Math.pow(s/e,(i-t)/(n-t))}}class io extends eo{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return Zs(this.input)?di(this.input)||this.input instanceof so?1:this.input.numberOfInputs:0}get numberOfOutputs(){return Zs(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return Zs(t)&&(t instanceof io||fi(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();ti(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,n=0){return ro(this,t,e,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return ai("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,n=0){return function(t,e,n=0,s=0){if(Zs(e))for(;e instanceof io;)e=e.input;for(;!fi(t);)Zs(t.output)&&(t=t.output);di(e)?t.disconnect(e,n):fi(e)?t.disconnect(e,n,s):t.disconnect()}(this,t,e,n),this}chain(...t){return oo(this,...t),this}fan(...t){return t.forEach((t=>this.connect(t))),this}dispose(){return super.dispose(),Zs(this.input)&&(this.input instanceof io?this.input.dispose():fi(this.input)&&this.input.disconnect()),Zs(this.output)&&(this.output instanceof io?this.output.dispose():fi(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function oo(...t){const e=t.shift();t.reduce(((t,e)=>(t instanceof io?t.connect(e):fi(t)&&ro(t,e),e)),e)}function ro(t,e,n=0,s=0){for(ti(Zs(t),"Cannot connect from undefined node"),ti(Zs(e),"Cannot connect to undefined node"),(e instanceof io||fi(e))&&ti(e.numberOfInputs>0,"Cannot connect to node with no inputs"),ti(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof io||e instanceof so;)Zs(e.input)&&(e=e.input);for(;t instanceof io;)Zs(t.output)&&(t=t.output);di(e)?t.connect(e,n):t.connect(e,n,s)}class ao extends io{constructor(){const t=yi(ao.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}),Pi(this,"gain")}static getDefaults(){return Object.assign(io.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class co extends io{constructor(t){super(t),this.onended=Fi,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new ao({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(io.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Fi})}_startGain(t,e=1){ti(-1===this._startTime,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=t+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+n):this._gainNode.gain.exponentialApproachValueAtTime(e,t,n)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){ti(-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!==Fi&&(this.onended(this),this.onended=Fi,!this.context.isOffline)){const t=()=>this.dispose();void 0!==window.requestIdleCallback?window.requestIdleCallback(t):setTimeout(t,1e3)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),ti(-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=Fi,this}}class lo extends co{constructor(){const t=yi(lo.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),ro(this._source,this._gainNode),this.offset=new so({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}static getDefaults(){return Object.assign(co.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),"started"===this.state&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}}class uo extends io{constructor(){const t=yi(uo.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new lo({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(io.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,n=0){return ho(this,t,e,n),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,n){return this._param.exponentialRampTo(t,e,n),this}linearRampTo(t,e,n){return this._param.linearRampTo(t,e,n),this}targetRampTo(t,e,n){return this._param.targetRampTo(t,e,n),this}exponentialApproachValueAtTime(t,e,n){return this._param.exponentialApproachValueAtTime(t,e,n),this}setTargetAtTime(t,e,n){return this._param.setTargetAtTime(t,e,n),this}setValueCurveAtTime(t,e,n,s){return this._param.setValueCurveAtTime(t,e,n,s),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,n){return this._param.rampTo(t,e,n),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}}function ho(t,e,n,s){(e instanceof so||di(e)||e instanceof uo&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof uo&&(e.overridden=!0)),ro(t,e,n,s)}class po extends so{constructor(){const t=yi(po.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Oi(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,n){e=this.toSeconds(e),this.setRampPoint(e);const s=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max(1/n,1));for(let t=0;t<=o;t++){const o=n*t+e,r=this._exponentialApproach(i.time,i.value,s,n,o);this.linearRampToValueAtTime(this._toType(r),o)}return this}setValueAtTime(t,e){const n=this.toSeconds(e);super.setValueAtTime(t,e);const s=this._events.get(n),i=this._events.previousEvent(s),o=this._getTicksUntilEvent(i,n);return s.ticks=Math.max(o,0),this}linearRampToValueAtTime(t,e){const n=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const s=this._events.get(n),i=this._events.previousEvent(s),o=this._getTicksUntilEvent(i,n);return s.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const n=this._fromType(t),s=this._events.get(e),i=Math.round(Math.max(10*(e-s.time),1)),o=(e-s.time)/i;for(let t=0;t<=i;t++){const i=o*t+s.time,r=this._exponentialInterpolate(s.time,s.value,e,n,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(Ys(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const n=this._fromType(this.getValueAtTime(t.time));let s=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(s=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(n+s)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),n=this._events.get(e);return Math.max(this._getTicksUntilEvent(n,e),0)}getDurationOfTicks(t,e){const n=this.toSeconds(e),s=this.getTicksAtTime(e);return this.getTimeOfTick(s+t)-n}getTimeOfTick(t){const e=this._events.get(t,"ticks"),n=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&n&&"linearRampToValueAtTime"===n.type&&e.value!==n.value){const s=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(n.time))-s)/(n.time-e.time),o=Math.sqrt(Math.pow(s,2)-2*i*(e.ticks-t)),r=(-s+o)/i;return(r>0?r:(-s-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 n=this.toSeconds(e),s=this.toSeconds(t),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+s)-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 fo extends uo{constructor(){const t=yi(fo.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new po({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(uo.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 mo extends eo{constructor(){const t=yi(mo.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new no,this._tickOffset=new Oi,this._ticksAtTime=new Oi,this._secondsAtTime=new Oi,this.frequency=new fo({context:this.context,units:t.units,value:t.frequency}),Pi(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 n=this.toSeconds(t);return"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),Zs(e)&&this.setTicksAtTime(e,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),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),n=this._state.getLastState("stopped",e),s=this._ticksAtTime.get(e),i={state:"paused",time:e};this._state.add(i);let o=s||n,r=s?s.ticks:0,a=null;return this._state.forEachBetween(o.time,e+this.sampleTime,(t=>{let e=o.time;const n=this._tickOffset.get(t.time);n&&n.time>=o.time&&(r=n.ticks,e=n.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(),n=this.frequency.timeToTicks(t,e);this.setTicksAtTime(n,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),n={state:"paused",time:t};this._state.add(n);const s=this._secondsAtTime.get(t);let i=s||e,o=s?s.seconds:0,r=null;return this._state.forEachBetween(i.time,t+this.sampleTime,(t=>{let e=i.time;const s=this._tickOffset.get(t.time);s&&s.time>=i.time&&(o=s.seconds,e=s.time),"started"===i.state&&"started"!==t.state&&(o+=t.time-e,t.time!==n.time&&(r={state:t.state,time:t.time,seconds:o})),i=t})),this._state.remove(n),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 n=this._tickOffset.get(e),s=this._state.get(e),i=Math.max(n.time,s.time),o=this.frequency.getTicksAtTime(i)+t-n.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(t,e,n){let s=this._state.get(t);this._state.forEachBetween(t,e,(e=>{s&&"started"===s.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(s.time,t),e.time-this.sampleTime,n),s=e}));let i=null;if(s&&"started"===s.state){const o=Math.max(s.time,t),r=this.frequency.getTicksAtTime(o),a=r-this.frequency.getTicksAtTime(s.time);let c=Math.ceil(a)-a;c=Si(c,1)?0:c;let l=this.frequency.getTimeOfTick(r+c);for(;l<e;){try{n(l,Math.round(this.getTicksAtTime(l)))}catch(t){i=t;break}l+=this.frequency.getDurationOfTicks(1,l)}}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 _o extends eo{constructor(){const t=yi(_o.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=Fi,this._lastUpdate=0,this._state=new no("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new mo({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,Pi(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(eo.getDefaults(),{callback:Fi,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){ni(this.context);const n=this.toSeconds(t);return this.log("start",n),"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,e),n<this._lastUpdate&&this.emit("start",n,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 n=this.toSeconds(e),s=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(s+t,n)}_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(_o);class go extends io{constructor(){const t=yi(go.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new ao({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,Pi(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(io.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 vo extends io{constructor(){const t=yi(vo.getDefaults(),arguments);super(t),this.name="Destination",this.input=new go({context:this.context}),this.output=new ao({context:this.context}),this.volume=this.input.volume,oo(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(io.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),oo(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}Ei((t=>{t.destination=new vo({context:t})})),Ii((t=>{t.destination.dispose()}));class yo extends io{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(io.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}}Ei((t=>{t.listener=new yo({context:t})})),Ii((t=>{t.listener.dispose()}));class wo extends xi{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=yi(wo.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach((e=>{this._loadingCount++;const n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)}))}static getDefaults(){return{baseUrl:"",onerror:Fi,onload:Fi,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return ti(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,n=Fi,s=Fi){return Js(e)?(this.baseUrl&&"data:audio/"===e.trim().substring(0,11).toLowerCase()&&(this.baseUrl=""),this._buffers.set(t.toString(),new ji(this.baseUrl+e,n,s))):this._buffers.set(t.toString(),new ji(e,n,s)),this}dispose(){return super.dispose(),this._buffers.forEach((t=>t.dispose())),this._buffers.clear(),this}}class To extends to{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())}}class xo extends eo{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Oi,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;for(;this._events.length&&this._events.peek().time-this.anticipation<=t;){const e=this._events.shift();e&&t-e.time<=this.expiration&&e.callback()}this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}Ei((t=>{t.draw=new xo({context:t})})),Ii((t=>{t.draw.dispose()}));class bo extends xi{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){ti(Zs(t.time),"Events must have a time property"),ti(Zs(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Co(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 n of e)if(n.event===t){this._removeNode(n),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,n=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,n=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,n=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,n=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,n=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),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){const e=t.parent,n=t.isLeftChild(),s=t.right;s&&(t.right=s.left,s.left=t),null!==e?n?e.left=s:e.right=s:this._setRoot(s)}_rotateRight(t){const e=t.parent,n=t.isLeftChild(),s=t.left;s&&(t.left=s.right,s.right=t),null!==e?n?e.left=s:e.right=s:this._setRoot(s)}_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 n=1;n<e.length;n++)e[n].low>t.low&&(t=e[n]);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 n=[];this._root.search(t,n),n.forEach((t=>{t.event&&e(t.event)}))}return this}forEachFrom(t,e){if(null!==this._root){const n=[];this._root.searchAfter(t,n),n.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 Co{constructor(t,e,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,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 Ao extends xi{constructor(t){super(),this.name="TimelineValue",this._timeline=new Oi({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 ko extends io{constructor(){super(yi(ko.getDefaults(),arguments,["context"]))}connect(t,e=0,n=0){return ho(this,t,e,n),this}}class So extends ko{constructor(){const t=yi(So.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Qs(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):"function"==typeof t.mapping&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(uo.getDefaults(),{length:1024})}setMap(t,e=1024){const n=new Float32Array(e);for(let s=0,i=e;s<i;s++){const e=s/(i-1)*2-1;n[s]=t(e,s)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){ti(["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 Oo extends ko{constructor(){const t=yi(Oo.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new So({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ko.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 Mo{constructor(t,e){this.id=Mo._eventId++,this._remainderTime=0;const n=Object.assign(Mo.getDefaults(),e);this.transport=t,this.callback=n.callback,this._once=n.once,this.time=Math.floor(n.time),this._remainderTime=n.time-this.time}static getDefaults(){return{callback:Fi,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}}Mo._eventId=0;class Eo extends Mo{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(Eo.getDefaults(),e);this.duration=n.duration,this._interval=n.interval,this._nextTick=n.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.transport.on("ticks",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Mo.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return ki(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new To(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){ki(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 To(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);Ci(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 Ro extends eo{constructor(){const t=yi(Ro.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Ao(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Oi,this._repeatedEvents=new bo,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new _o({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),Pi(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 n=e%(2*this._swingTicks)/(2*this._swingTicks),s=Math.sin(n*Math.PI)*this._swingAmount;t+=new To(this.context,2*this._swingTicks/3).toSeconds()*s}oi(!0),this._timeline.forEachAtTime(e,(e=>e.invoke(t))),oi(!1)}schedule(t,e){const n=new Mo(this,{callback:t,time:new to(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(t,e,n,s=1/0){const i=new Eo(this,{callback:t,duration:new Hi(this.context,s).toTicks(),interval:new Hi(this.context,e).toTicks(),time:new to(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const n=new Mo(this,{callback:t,once:!0,time:new to(this.context,e).toTicks()});return this._addEvent(n,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 To(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 n;return this.context.resume(),Zs(e)&&(n=this.toTicks(e)),this._clock.start(t,n),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){Qs(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Hi(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Hi(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 To(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 To(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(),n=this._clock.frequency.timeToTicks(t,e);this.ticks=n}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(this._clock.ticks!==t){const e=this.now();if("started"===this.state){const n=this._clock.getTicksAtTime(e),s=e+this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,e);this.emit("stop",s),this._clock.setTicksAtTime(t,s),this.emit("start",s,this._clock.getSecondsAtTime(s))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}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(),n=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){const n=this.now();let s=this.bpm,i=1/(60/s.getValueAtTime(n)/this.PPQ),o=[];if("time"===t.units){const t=1/64/i,e=new ao(t),n=new Oo(-1),r=new ao(t);s.chain(e,n,r),s=r,i=1/i,o=[e,n,r]}e||(e=0!==t.getValueAtTime(n)?t.getValueAtTime(n)/i:0);const r=new ao(e);return s.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 n=this._syncedSignals[e];n.signal===t&&(n.nodes.forEach((t=>t.dispose())),n.signal.value=n.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),qi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Di.mixin(Ro),Ei((t=>{t.transport=new Ro({context:t})})),Ii((t=>{t.transport.dispose()}));class Io extends io{constructor(t){super(t),this.input=void 0,this._state=new no("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Fi,this._syncedStop=Fi,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new go({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,Pi(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(io.getDefaults(),{mute:!1,onstop:Fi,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,n){let s=Ys(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(s=this._clampToCurrentTime(s),this._synced||"started"!==this._state.getValueAtTime(s))if(this.log("start",s),this._state.setStateAtTime("started",s),this._synced){const t=this._state.get(s);t&&(t.offset=this.toSeconds(wi(e,0)),t.duration=n?this.toSeconds(n):void 0);const i=this.context.transport.schedule((t=>{this._start(t,e,n)}),s);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>s&&this._syncedStart(this.now(),this.context.transport.seconds)}else ni(this.context),this._start(s,e,n);else ti(Ci(s,this._state.get(s).time),"Start time must be strictly greater than previous start time"),this._state.cancel(s),this._state.setStateAtTime("started",s),this.log("restart",s),this.restart(s,e,n);return this}stop(t){let e=Ys(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||Zs(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,n){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(Ci(e,0)){const n=this._state.get(e);if(n&&"started"===n.state&&n.time!==e){const s=e-this.toSeconds(n.time);let i;n.duration&&(i=this.toSeconds(n.duration)-s),this._start(t,this.toSeconds(n.offset)+s,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=Fi,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Do extends co{constructor(){const t=yi(Do.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,ro(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(co.getDefaults(),{url:new ji,loop:!1,loopEnd:0,loopStart:0,onload:Fi,onerror:Fi,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,n,s=1){ti(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,s),e=this.loop?wi(e,this.loopStart):wi(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),n=t-e;Ai(o,t)&&(o=(o-e)%n+e),Si(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,ki(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,o)),Zs(n)){let t=this.toSeconds(n);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 No extends Io{constructor(){const t=yi(No.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(Io.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(ti(t in qo,"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=qo[this._type];this._source=new Do({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 Vo=220500,Po={brown:null,pink:null,white:null},qo={get brown(){if(!Po.brown){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(Vo);t[e]=n;let s=0;for(let t=0;t<Vo;t++){const e=2*Math.random()-1;n[t]=(s+.02*e)/1.02,s=n[t],n[t]*=3.5}}Po.brown=(new ji).fromArray(t)}return Po.brown},get pink(){if(!Po.pink){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(Vo);let s,i,o,r,a,c,l;t[e]=n,s=i=o=r=a=c=l=0;for(let t=0;t<Vo;t++){const e=2*Math.random()-1;s=.99886*s+.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,n[t]=s+i+o+r+a+c+l+.5362*e,n[t]*=.11,l=.115926*e}}Po.pink=(new ji).fromArray(t)}return Po.pink},get white(){if(!Po.white){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(Vo);t[e]=n;for(let t=0;t<Vo;t++)n[t]=2*Math.random()-1}Po.white=(new ji).fromArray(t)}return Po.white}};function Fo(t,e){return hi(this,void 0,void 0,(function*(){const n=e/t.context.sampleRate,s=new Wi(1,n,t.context.sampleRate);new t.constructor(Object.assign(t.get(),{frequency:2/n,detune:0,context:s})).toDestination().start(0);return(yield s.render()).getChannelData(0)}))}class jo extends co{constructor(){const t=yi(jo.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],ro(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}),Pi(this,["frequency","detune"])}static getDefaults(){return Object.assign(co.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 Wo extends Io{constructor(){const t=yi(Wo.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new uo({context:this.context,units:"frequency",value:t.frequency}),Pi(this,"frequency"),this.detune=new uo({context:this.context,units:"cents",value:t.detune}),Pi(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(Io.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),n=new jo({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_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 Wo._periodicWaveCache.find((t=>{return t.phase===this._phase&&(e=t.partials,n=this._partials,e.length===n.length&&e.every(((t,e)=>n[e]===t)));var e,n}))}{const t=Wo._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(Zs(e)){const{partials:t,wave:n}=e;this._wave=n,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[e,n]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(e,n);this._wave=s,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),Wo._periodicWaveCache.push({imag:n,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:e,type:this._type,wave:this._wave}),Wo._periodicWaveCache.length>100&&Wo._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){ei(t,0);let e=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(e=n[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach(((t,n)=>e[n]=t)),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let n=2048;const s=new Float32Array(n),i=new Float32Array(n);let o=1;if("custom"===t){if(o=this._partials.length+1,this._partialCount=this._partials.length,n=o,0===this._partials.length)return[s,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),n=o):this._partialCount=0,this._partials=[]}for(let r=1;r<n;++r){const n=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*n:0,this._partials[r-1]=a;break;case"sawtooth":a=n*(1&r?1:-1),this._partials[r-1]=a;break;case"triangle":a=1&r?n*n*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?(s[r]=-a*Math.sin(e*r),i[r]=a*Math.cos(e*r)):(s[r]=0,i[r]=0)}return[s,i]}_inverseFFT(t,e,n){let s=0;const i=t.length;for(let o=0;o<i;o++)s+=t[o]*Math.cos(o*n)+e[o]*Math.sin(o*n);return s}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let n=0;const s=2*Math.PI;for(let i=0;i<32;i++)n=Math.max(this._inverseFFT(t,e,i/32*s),n);return i=-this._inverseFFT(t,e,this._phase)/n,o=-1,r=1,Math.max(Math.min(i,r),o);var i,o,r}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 hi(this,arguments,void 0,(function*(t=1024){return Fo(this,t)}))}dispose(){return super.dispose(),null!==this._oscillator&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}}Wo._periodicWaveCache=[];class Bo extends ko{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new So({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 Lo extends uo{constructor(){const t=yi(Lo.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new ao({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(uo.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class Uo extends Io{constructor(){const t=yi(Uo.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new Bo({context:this.context}),this._modulationNode=new ao({context:this.context}),this._carrier=new Wo({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 Wo({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Lo({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),Pi(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Wo.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 hi(this,arguments,void 0,(function*(t=1024){return Fo(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 zo extends Io{constructor(){const t=yi(zo.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new ao({context:this.context,gain:0}),this._carrier=new Wo({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 uo({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Wo({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Lo({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Lo({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),Pi(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Wo.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 hi(this,arguments,void 0,(function*(t=1024){return Fo(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 Go extends Io{constructor(){const t=yi(Go.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new ao({context:this.context,gain:0}),this._thresh=new So({context:this.context,mapping:t=>t<=0?-1:1}),this.width=new uo({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Wo({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),Pi(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Io.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 hi(this,arguments,void 0,(function*(t=1024){return Fo(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class Xo extends Io{constructor(){const t=yi(Xo.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new uo({context:this.context,units:"frequency",value:t.frequency}),this.detune=new uo({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,Pi(this,["frequency","detune"])}static getDefaults(){return Object.assign(Wo.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,n=t/(this._oscillators.length-1);this._forEach(((t,s)=>t.detune.value=e+n*s))}}get count(){return this._oscillators.length}set count(t){if(ei(t,1),this._oscillators.length!==t){this._forEach((t=>t.dispose())),this._oscillators=[];for(let e=0;e<t;e++){const n=new Wo({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):Fi});"custom"===this.type&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[e]=n}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 hi(this,arguments,void 0,(function*(t=1024){return Fo(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach((t=>t.dispose())),this}}class Yo extends Io{constructor(){const t=yi(Yo.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Lo({context:this.context,value:2}),this._pulse=new Go({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Wo({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),Pi(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Io.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 hi(this,arguments,void 0,(function*(t=1024){return Fo(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Zo={am:Uo,fat:Xo,fm:zo,oscillator:Wo,pulse:Go,pwm:Yo};class Ho extends Io{constructor(){const t=yi(Ho.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new uo({context:this.context,units:"frequency",value:t.frequency}),this.detune=new uo({context:this.context,units:"cents",value:t.detune}),Pi(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Wo.getDefaults(),zo.getDefaults(),Uo.getDefaults(),Xo.getDefaults(),Go.getDefaults(),Yo.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=Zo[t],n=this.now();if(this._oscillator){const t=this._oscillator;t.stop(n),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(n)}}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 Zo[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")&&Hs(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")&&Hs(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"))&&Js(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 hi(this,arguments,void 0,(function*(t=1024){return Fo(this,t)}))}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}function $o(t,e=1/0){const n=new WeakMap;return function(s,i){Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(s){ei(s,t,e),n.set(this,s)}})}}function Qo(t,e=1/0){const n=new WeakMap;return function(s,i){Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(s){ei(this.toSeconds(s),t,e),n.set(this,s)}})}}class Jo extends Io{constructor(){const t=yi(Jo.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,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(Io.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Fi,onerror:Fi,playbackRate:1,reverse:!1})}load(t){return hi(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_onload(t=Fi){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,n){return super.start(t,e,n),this}_start(t,e,n){e=this._loop?wi(e,this._loopStart):wi(e,0);const s=this.toSeconds(e),i=n;n=wi(n,Math.max(this._buffer.duration-s,0));let o=this.toSeconds(n);o/=this._playbackRate,t=this.toSeconds(t);const r=new Do({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),this._loop&&Ys(i)?r.start(t,s):r.start(t,s,o-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach((t=>t.stop(e)))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){var s;null===(s=[...this._activeSources].pop())||void 0===s||s.stop(t),this._start(t,e,n)}seek(t,e){const n=this.toSeconds(e);if("started"===this._state.getValueAtTime(n)){const e=this.toSeconds(t);this._stop(n),this._start(n,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&&ei(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&&ei(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(),n=this._state.getNextState("stopped",e);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach((t=>t.cancelStop()))),this._activeSources.forEach((n=>{n.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}}ui([Qo(0)],Jo.prototype,"fadeIn",void 0),ui([Qo(0)],Jo.prototype,"fadeOut",void 0);class Ko extends io{constructor(){const t=yi(Ko.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new uo({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(io.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(Js(t))return t;{let n;for(n in tr)if(tr[n][e]===t)return n;return t}}_setCurve(t,e,n){if(Js(n)&&Reflect.has(tr,n)){const s=tr[n];$s(s)?"_decayCurve"!==t&&(this[t]=s[e]):this[t]=s}else{if(!Qs(n)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+n);this[t]=n}}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 n=this.toSeconds(this.attack);const s=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0){n=(1-i)/(1/n)}if(n<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if("linear"===this._attackCurve)this._sig.linearRampTo(e,n,t);else if("exponential"===this._attackCurve)this._sig.targetRampTo(e,n,t);else{this._sig.cancelAndHoldAtTime(t);let s=this._attackCurve;for(let t=1;t<s.length;t++)if(s[t-1]<=i&&i<=s[t]){s=this._attackCurve.slice(t),s[0]=i;break}this._sig.setValueCurveAtTime(s,t,n,e)}if(s&&this.sustain<1){const i=e*this.sustain,o=t+n;this.log("decay",o),"linear"===this._decayCurve?this._sig.linearRampToValueAtTime(i,s+o):this._sig.exponentialApproachValueAtTime(i,o,s)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,t):"linear"===this._releaseCurve?this._sig.linearRampTo(0,n,t):"exponential"===this._releaseCurve?this._sig.targetRampTo(0,n,t):(ti(Qs(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,n,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,n=1){return e=this.toSeconds(e),this.triggerAttack(e,n),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,n=0){return ho(this,t,e,n),this}asArray(){return hi(this,arguments,void 0,(function*(t=1024){const e=t/this.context.sampleRate,n=new Wi(1,e,this.context.sampleRate),s=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=s+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:n}));a._sig.toDestination(),a.triggerAttackRelease(e*(s+o)/r,0);return(yield n.render()).getChannelData(0)}))}dispose(){return super.dispose(),this._sig.dispose(),this}}ui([Qo(0)],Ko.prototype,"attack",void 0),ui([Qo(0)],Ko.prototype,"decay",void 0),ui([$o(0,1)],Ko.prototype,"sustain",void 0),ui([Qo(0)],Ko.prototype,"release",void 0);const tr=(()=>{const t=128;let e,n;const s=[];for(e=0;e<t;e++)s[e]=Math.sin(e/127*(Math.PI/2));const i=[];for(e=0;e<127;e++){n=e/127;const t=Math.sin(n*(2*Math.PI)*6.4-Math.PI/2)+1;i[e]=t/10+.83*n}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++)n=e/127,r[e]=.5*(1-Math.cos(Math.PI*n));const a=[];for(e=0;e<t;e++){n=e/127;const t=4*Math.pow(n,3)+.2,s=Math.cos(t*Math.PI*2*n);a[e]=Math.abs(s*(1-n))}function c(t){const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=1-t[n];return e}return{bounce:{In:c(a),Out:a},cosine:{In:s,Out:(l=s,l.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 l})();class er extends io{constructor(){const t=yi(er.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 go({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Pi(this,"volume")}static getDefaults(){return Object.assign(io.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 n=this["_original_"+t]=this[t];this[t]=(...t)=>{const s=t[e],i=this.context.transport.schedule((s=>{t[e]=s,n.apply(this,t)}),s);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,n,s){const i=this.toSeconds(n),o=this.toSeconds(e);return this.triggerAttack(t,i,s),this.triggerRelease(i+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class nr extends er{constructor(){const t=yi(nr.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(er.getDefaults(),{detune:0,onsilence:Fi,portamento:0})}triggerAttack(t,e,n=1){this.log("triggerAttack",t,e,n);const s=this.toSeconds(e);return this._triggerEnvelopeAttack(s,n),this.setNote(t,s),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const n=this.toSeconds(e),s=t instanceof Qi?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(s,t,n)}else this.frequency.setValueAtTime(s,n);return this}}ui([Qo(0)],nr.prototype,"portamento",void 0);class sr extends Ko{constructor(){super(yi(sr.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new ao({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 ir extends nr{constructor(){const t=yi(ir.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new Ho(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 sr(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),Pi(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(nr.getDefaults(),{envelope:Object.assign(Ti(Ko.getDefaults(),Object.keys(io.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ti(Ho.getDefaults(),[...Object.keys(Io.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),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+n)}}_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 or extends ir{constructor(){const t=yi(or.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Pi(this,["oscillator","envelope"])}static getDefaults(){return vi(nr.getDefaults(),ir.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const n=this.toSeconds(e),s=this.toFrequency(t instanceof Qi?t.toFrequency():t),i=s*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(s,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}ui([$o(0)],or.prototype,"octaves",void 0),ui([Qo(0)],or.prototype,"pitchDecay",void 0);class rr extends er{constructor(){const t=yi(rr.getDefaults(),arguments);super(t),this.name="NoiseSynth",this.noise=new No(Object.assign({context:this.context},t.noise)),this.envelope=new sr(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(er.getDefaults(),{envelope:Object.assign(Ti(Ko.getDefaults(),Object.keys(io.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(Ti(No.getDefaults(),Object.keys(Io.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,n=1){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,n),this.triggerRelease(e+t),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}const ar=new Set;function cr(t){ar.add(t)}function lr(t,e){const n=`registerProcessor("${t}", ${e})`;ar.add(n)}cr('\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 it\'s 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');cr("\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");cr("\n\t/**\n\t * A multichannel buffer for use within an AudioWorkletProcessor as a delay line\n\t */\n\tclass DelayLine {\n\t\t\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\t}\n");lr("feedback-comb-filter",'\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 ur extends er{constructor(){const t=yi(ur.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map;const e={};Object.keys(t.urls).forEach((n=>{const s=parseInt(n,10);if(ti(Ks(n)||Hs(s)&&isFinite(s),`url key is neither a note or midi pitch: ${n}`),Ks(n)){const s=new Qi(this.context,n).toMidi();e[s]=t.urls[n]}else Hs(s)&&isFinite(s)&&(e[s]=t.urls[s])})),this._buffers=new wo({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(er.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Fi,onerror:Fi,release:.1,urls:{}})}_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,n=1){return this.log("triggerAttack",t,e,n),Array.isArray(t)||(t=[t]),t.forEach((t=>{const s=Yi(new Qi(this.context,t).toFrequency()),i=Math.round(s),o=s-i,r=this._findClosest(i),a=i-r,c=this._buffers.get(a),l=zi(r+o),u=new Do({url:c,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:l}).connect(this.output);u.start(e,0,c.duration/l,n),Qs(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(u),u.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){const t=this._activeSources.get(i),e=t.indexOf(u);-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 n=new Qi(this.context,t).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){const t=this._activeSources.get(n);e=this.toSeconds(e),t.forEach((t=>{t.stop(e)})),this._activeSources.set(n,[])}})),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,n,s=1){const i=this.toSeconds(n);return this.triggerAttack(t,i,s),Qs(e)?(ti(Qs(t),"notes must be an array when duration is array"),t.forEach(((t,n)=>{const s=e[Math.min(n,e.length-1)];this.triggerRelease(t,i+this.toSeconds(s))}))):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,n){if(ti(Ks(t)||isFinite(t),`note must be a pitch or midi: ${t}`),Ks(t)){const s=new Qi(this.context,t).toMidi();this._buffers.add(s,e,n)}else this._buffers.add(t,e,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach((t=>{t.forEach((t=>t.dispose()))})),this._activeSources.clear(),this}}ui([Qo(0)],ur.prototype,"attack",void 0),ui([Qo(0)],ur.prototype,"release",void 0);class hr extends io{constructor(){const t=yi(hr.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",Pi(this,"pan")}static getDefaults(){return Object.assign(io.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}lr("bit-crusher","\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 pr extends io{constructor(){const t=yi(pr.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new ao({context:this.context}),pr._allSolos.has(this.context)||pr._allSolos.set(this.context,new Set),pr._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(io.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),pr._allSolos.get(this.context).forEach((t=>t._updateSolo()))}get muted(){return 0===this.input.gain.value}_addSolo(){pr._soloed.has(this.context)||pr._soloed.set(this.context,new Set),pr._soloed.get(this.context).add(this)}_removeSolo(){pr._soloed.has(this.context)&&pr._soloed.get(this.context).delete(this)}_isSoloed(){return pr._soloed.has(this.context)&&pr._soloed.get(this.context).has(this)}_noSolos(){return!pr._soloed.has(this.context)||pr._soloed.has(this.context)&&0===pr._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),pr._allSolos.get(this.context).delete(this),this._removeSolo(),this}}pr._allSolos=new Map,pr._soloed=new Map;class dr extends io{constructor(){const t=yi(dr.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new hr({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new go({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,Pi(this,["pan","volume"])}static getDefaults(){return Object.assign(io.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 fr extends io{constructor(){const t=yi(fr.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new pr({solo:t.solo,context:this.context}),this._panVol=this.output=new dr({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),Pi(this,["pan","volume"])}static getDefaults(){return Object.assign(io.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 fr.buses.has(t)||fr.buses.set(t,new ao({context:this.context})),fr.buses.get(t)}send(t,e=0){const n=this._getBus(t),s=new ao({context:this.context,units:"decibels",gain:e});return this.connect(s),s.connect(n),s}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}}function mr(){return Ui().now()}fr.buses=new Map,Ui().transport,Ui().destination,Ui().destination,Ui().listener,Ui().draw,Ui();let _r=!1;async function gr(){const t=Ui();_r||"running"===t.state||("suspended"===t.state&&await t.resume(),"running"!==t.state&&await Li.resume(),_r=!0,console.log("Audio Context started."))}function vr(t={}){const e={oscillator:{type:"triangle",...t.oscillator},envelope:{attack:.005,decay:.1,sustain:.3,release:.5,...t.envelope},volume:-10,...t},n=new ir(e).toDestination();return n.createdAt=mr(),n.totalDuration=0,n}function yr(t={}){const e={noise:{type:"white",...t.noise},envelope:{attack:.005,decay:.1,sustain:.05,release:.1,...t.envelope},volume:-15,...t},n=new rr(e).toDestination();return n.createdAt=mr(),n.totalDuration=0,n}function wr(t,e=0){const n=t.envelope?$i(t.envelope.release).toSeconds():.5,s=Math.max(e,n)+1;setTimeout((()=>{t&&!t.disposed&&t.dispose()}),1e3*s)}const Tr=function(t="medium"){gr().then((()=>{const e=vr({oscillator:{type:"triangle8"},envelope:{attack:.01,decay:.2,sustain:.1,release:.5},volume:-8});if("short"===t){const t=mr();e.triggerAttackRelease("C5","16n",t),wr(e,.5)}else if("medium"===t){const t=mr();e.triggerAttackRelease("C5","16n",t),e.triggerAttackRelease("E5","8n",t+.15),wr(e,.65)}else if("long"===t){const t=mr(),n=2,s=vr({oscillator:{type:"triangle"},envelope:{attack:.01,decay:.3,sustain:.2,release:.6},volume:-15});e.triggerAttackRelease("C5","8n",t),e.triggerAttackRelease("E5","8n",t+.2),e.triggerAttackRelease("G5","8n",t+.4),e.triggerAttackRelease("C6","4n",t+.7),s.triggerAttackRelease("E4","8n",t+.4),s.triggerAttackRelease("G4","8n",t+.6),s.triggerAttackRelease("C5","4n",t+.7),wr(e,n),wr(s,n)}}))},xr=function(t="medium"){gr().then((()=>{const e=vr({oscillator:{type:"sine4"},envelope:{attack:.03,decay:.3,sustain:.2,release:.4},volume:-8});if("short"===t)e.triggerAttackRelease("G4","8n",mr()),wr(e,.5);else if("medium"===t){const t=mr();e.triggerAttackRelease("G4","8n",t),e.triggerAttackRelease("C5","8n",t+.25),wr(e,.75)}else if("long"===t){const t=mr(),n=["G4","A4","C5","E5","G5","E5","C5","A4","G4"],s=.12,i=n.length*s+1.2;n.forEach(((n,i)=>{e.triggerAttackRelease(n,"16n",t+i*s)}));const o=yr({noise:{type:"white"},envelope:{attack:.01,decay:1.2,sustain:0,release:.2},volume:-30});o.triggerAttackRelease("8n",t),wr(e,i),wr(o,i)}}))},br=function(t="medium"){gr().then((()=>{const e=vr({oscillator:{type:"square8"},envelope:{attack:.01,decay:.2,sustain:.2,release:.4},volume:-10});if("short"===t)e.triggerAttackRelease("D5","8n",mr()),wr(e,.5);else if("medium"===t){const t=mr();e.triggerAttackRelease("D5","16n",t),e.triggerAttackRelease("D5","16n",t+.15),wr(e,.5)}else if("long"===t){const t=["D5","D5","D5","A4","A4","A4","D5","D5","D5"],n=Array(9).fill("32n"),s=["32n","32n","8n","32n","32n","8n","32n","32n","8n"];let i=mr(),o=0;for(let t=0;t<s.length;t++)o+=$i(s[t]).toSeconds();for(let o=0;o<t.length;o++)e.triggerAttackRelease(t[o],n[o],i),i+=$i(s[o]).toSeconds();wr(e,o)}}))},Cr=function(t="medium"){gr().then((()=>{const e=vr({oscillator:{type:"sawtooth4"},envelope:{attack:.01,decay:.2,sustain:.2,release:.3},volume:-12});if("short"===t){const t=mr();e.triggerAttackRelease("F4","8n",t),wr(e,.5)}else if("medium"===t){const t=mr();e.triggerAttackRelease("F4","8n",t),e.triggerAttackRelease("D4","8n",t+.25),wr(e,.75)}else if("long"===t){const t=mr(),n=2.5;e.triggerAttackRelease("F4","8n",t),e.triggerAttackRelease("D4","8n",t+.25),e.triggerAttackRelease("Bb3","8n",t+.5),e.triggerAttackRelease("F4","8n",t+.9),e.triggerAttackRelease("D4","8n",t+1.15),e.triggerAttackRelease("Bb3","4n",t+1.4);const s=yr({noise:{type:"pink"},envelope:{attack:.01,decay:.1,sustain:0,release:.1},volume:-25});s.triggerAttackRelease("16n",t),s.triggerAttackRelease("16n",t+.9),wr(e,n),wr(s,n)}}))},Ar=function(t="medium"){gr().then((()=>{const e=vr({oscillator:{type:"fmsquare"},envelope:{attack:.005,decay:.2,sustain:.3,release:.2},volume:-9});if("short"===t){const t=mr();e.triggerAttackRelease("Eb4","8n",t),wr(e,.5)}else if("medium"===t){const t=mr();e.triggerAttackRelease("Eb4","8n",t),e.triggerAttackRelease("D4","8n",t+.2),wr(e,.7)}else if("long"===t){const t=mr(),n=2,s=vr({oscillator:{type:"square"},envelope:{attack:.01,decay:.3,sustain:.2,release:.3},volume:-12});e.triggerAttackRelease("Eb4","8n",t),e.triggerAttackRelease("D4","8n",t+.25),e.triggerAttackRelease("Eb4","8n",t+.5),e.triggerAttackRelease("D4","8n",t+.75),e.triggerAttackRelease("Bb3","4n",t+1.1),s.triggerAttackRelease("Eb3","2n",t),wr(e,n),wr(s,n)}}))},kr={playSuccess:Tr,playAttention:xr,playAlert:br,playWarning:Cr,playError:Ar,ensureAudioContextStarted:gr};"undefined"!=typeof window&&(window.SimpleNotificationSounds=kr),t.ensureAudioContextStarted=gr,t.playAlert=br,t.playAttention=xr,t.playError=Ar,t.playSuccess=Tr,t.playWarning=Cr,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=simple-notification-sounds.umd.js.map
