@blibliki/engine 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19484 -0
- package/dist/index.umd.cjs +227 -0
- package/dist/{build → src}/Engine.d.ts +10 -9
- package/dist/{build → src}/core/IO/AudioNode.d.ts +6 -5
- package/dist/{build → src}/core/IO/Collection.d.ts +5 -4
- package/dist/{build → src}/core/IO/ForwardNode/Base.d.ts +6 -5
- package/dist/{build → src}/core/IO/ForwardNode/index.d.ts +6 -5
- package/dist/{build → src}/core/IO/MidiNode.d.ts +5 -4
- package/dist/{build → src}/core/IO/Node.d.ts +3 -2
- package/dist/{build → src}/core/IO/index.d.ts +6 -5
- package/dist/{build → src}/core/Module/MonoModule.d.ts +9 -8
- package/dist/{build → src}/core/Module/PolyModule.d.ts +8 -7
- package/dist/src/core/Module/index.d.ts +7 -0
- package/dist/{build → src}/core/midi/ComputerKeyboardInput.d.ts +3 -2
- package/dist/{build → src}/core/midi/MidiDevice.d.ts +2 -1
- package/dist/{build → src}/core/midi/MidiDeviceManager.d.ts +2 -1
- package/dist/{build → src}/core/midi/MidiEvent.d.ts +3 -2
- package/dist/src/core/midi/index.d.ts +5 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/main.d.ts +0 -0
- package/dist/{build → src}/modules/BitCrusher.d.ts +3 -2
- package/dist/{build → src}/modules/Delay.d.ts +3 -2
- package/dist/{build → src}/modules/Distortion.d.ts +3 -2
- package/dist/{build → src}/modules/Effect.d.ts +3 -2
- package/dist/{build → src}/modules/Envelope/AmpEnvelope.d.ts +3 -2
- package/dist/{build → src}/modules/Envelope/Base.d.ts +4 -3
- package/dist/{build → src}/modules/Envelope/FreqEnvelope.d.ts +4 -3
- package/dist/src/modules/Envelope/index.d.ts +3 -0
- package/dist/{build → src}/modules/Filter.d.ts +4 -3
- package/dist/{build → src}/modules/LFO.d.ts +5 -4
- package/dist/{build → src}/modules/Master.d.ts +3 -2
- package/dist/{build → src}/modules/MidiSelector.d.ts +3 -2
- package/dist/{build → src}/modules/Oscillator.d.ts +7 -6
- package/dist/{build → src}/modules/Reverb.d.ts +3 -2
- package/dist/{build → src}/modules/Sequencer.d.ts +4 -3
- package/dist/{build → src}/modules/VirtualMidi.d.ts +7 -6
- package/dist/{build → src}/modules/VoiceScheduler.d.ts +6 -5
- package/dist/{build → src}/modules/Volume.d.ts +4 -3
- package/dist/src/modules/index.d.ts +18 -0
- package/dist/{build → src}/routes.d.ts +3 -2
- package/dist/test/MockingModules.d.ts +22 -0
- package/dist/test/Module/Oscillator.test.d.ts +1 -0
- package/dist/test/core/IO.test.d.ts +1 -0
- package/package.json +15 -16
- package/src/main.ts +1 -0
- package/src/modules/Oscillator.ts +14 -5
- package/src/modules/index.ts +2 -2
- package/src/vite-env.d.ts +1 -0
- package/dist/build/core/IO/ForwardNode.d.ts +0 -38
- package/dist/build/core/Module/index.d.ts +0 -6
- package/dist/build/core/midi/index.d.ts +0 -5
- package/dist/build/index.d.ts +0 -9
- package/dist/build/modules/Envelope/index.d.ts +0 -3
- package/dist/build/modules/index.d.ts +0 -17
- package/dist/main.cjs.js +0 -25
- package/dist/main.cjs.js.map +0 -1
- package/dist/main.esm.js +0 -25
- package/dist/main.esm.js.map +0 -1
- /package/dist/{build → src}/core/Note/frequencyTable.d.ts +0 -0
- /package/dist/{build → src}/core/Note/index.d.ts +0 -0
- /package/dist/{build → src}/types.d.ts +0 -0
- /package/dist/{build → src}/utils.d.ts +0 -0
package/dist/main.cjs.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t="14.7.77",e=(t,e,s)=>({endTime:e,insertTime:s,type:"exponentialRampToValue",value:t}),s=(t,e,s)=>({endTime:e,insertTime:s,type:"linearRampToValue",value:t}),n=(t,e)=>({startTime:e,type:"setValue",value:t}),i=(t,e,s)=>({duration:s,startTime:e,type:"setValueCurve",values:t}),r=(t,e,{startTime:s,target:n,timeConstant:i})=>n+(e-n)*Math.exp((s-t)/i),o=t=>"exponentialRampToValue"===t.type,a=t=>"linearRampToValue"===t.type,c=t=>o(t)||a(t),u=t=>"setValue"===t.type,h=t=>"setValueCurve"===t.type,l=(t,e,s,n)=>{const i=t[e];return void 0===i?n:c(i)||u(i)?i.value:h(i)?i.values[i.values.length-1]:r(s,l(t,e-1,i.startTime,n),i)},p=(t,e,s,n,i)=>void 0===s?[n.insertTime,i]:c(s)?[s.endTime,s.value]:u(s)?[s.startTime,s.value]:h(s)?[s.startTime+s.duration,s.values[s.values.length-1]]:[s.startTime,l(t,e-1,s.startTime,i)],d=t=>"cancelAndHold"===t.type,f=t=>"cancelScheduledValues"===t.type,m=t=>d(t)||f(t)?t.cancelTime:o(t)||a(t)?t.endTime:t.startTime,_=(t,e,s,{endTime:n,value:i})=>s===i?i:0<s&&0<i||s<0&&i<0?s*(i/s)**((t-e)/(n-e)):0,g=(t,e,s,{endTime:n,value:i})=>s+(t-e)/(n-e)*(i-s),v=(t,{duration:e,startTime:s,values:n})=>((t,e)=>{const s=Math.floor(e),n=Math.ceil(e);return s===n?t[s]:(1-(e-s))*t[s]+(1-(n-e))*t[n]})(n,(t-s)/e*(n.length-1)),y=t=>"setTarget"===t.type;class w{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){const r=m(t);if(d(t)||f(t)){const a=this._automationEvents.findIndex((e=>f(t)&&h(e)?e.startTime+e.duration>=r:m(e)>=r)),u=this._automationEvents[a];if(-1!==a&&(this._automationEvents=this._automationEvents.slice(0,a)),d(t)){const t=this._automationEvents[this._automationEvents.length-1];if(void 0!==u&&c(u)){if(void 0!==t&&y(t))throw new Error("The internal list is malformed.");const n=void 0===t?u.insertTime:h(t)?t.startTime+t.duration:m(t),i=void 0===t?this._defaultValue:h(t)?t.values[t.values.length-1]:t.value,a=o(u)?_(r,n,i,u):g(r,n,i,u),c=o(u)?e(a,r,this._currenTime):s(a,r,this._currenTime);this._automationEvents.push(c)}if(void 0!==t&&y(t)&&this._automationEvents.push(n(this.getValue(r),r)),void 0!==t&&h(t)&&t.startTime+t.duration>r){const e=r-t.startTime,s=(t.values.length-1)/t.duration,n=Math.max(2,1+Math.ceil(e*s)),o=e/(n-1)*s,a=t.values.slice(0,n);if(o<1)for(let e=1;e<n;e+=1){const s=o*e%1;a[e]=t.values[e-1]*(1-s)+t.values[e]*s}this._automationEvents[this._automationEvents.length-1]=i(a,t.startTime,e)}}}else{const n=this._automationEvents.findIndex((t=>m(t)>r)),i=-1===n?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[n-1];if(void 0!==i&&h(i)&&m(i)+i.duration>r)return!1;const c=o(t)?e(t.value,t.endTime,this._currenTime):a(t)?s(t.value,r,this._currenTime):t;if(-1===n)this._automationEvents.push(c);else{if(h(t)&&r+t.duration>m(this._automationEvents[n]))return!1;this._automationEvents.splice(n,0,c)}}return!0}flush(t){const e=this._automationEvents.findIndex((e=>m(e)>t));if(e>1){const t=this._automationEvents.slice(e-1),s=t[0];y(s)&&t.unshift(n(l(this._automationEvents,e-2,s.startTime,this._defaultValue),s.startTime)),this._automationEvents=t}}getValue(t){if(0===this._automationEvents.length)return this._defaultValue;const e=this._automationEvents.findIndex((e=>m(e)>t)),s=this._automationEvents[e],n=(-1===e?this._automationEvents.length:e)-1,i=this._automationEvents[n];if(void 0!==i&&y(i)&&(void 0===s||!c(s)||s.insertTime>t))return r(t,l(this._automationEvents,n-1,i.startTime,this._defaultValue),i);if(void 0!==i&&u(i)&&(void 0===s||!c(s)))return i.value;if(void 0!==i&&h(i)&&(void 0===s||!c(s)||i.startTime+i.duration>t))return t<i.startTime+i.duration?v(t,i):i.values[i.values.length-1];if(void 0!==i&&c(i)&&(void 0===s||!c(s)))return i.value;if(void 0!==s&&o(s)){const[e,r]=p(this._automationEvents,n,i,s,this._defaultValue);return _(t,e,r,s)}if(void 0!==s&&a(s)){const[e,r]=p(this._automationEvents,n,i,s,this._defaultValue);return g(t,e,r,s)}return this._defaultValue}}const x=new WeakSet,b=new WeakMap,T=new WeakMap,A=new WeakMap,k=new WeakMap,C=new WeakMap,S=new WeakMap,O=new WeakMap,M=new WeakMap,E=new WeakMap,D={construct:()=>D},I=/^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]*);?/,R=(t,e)=>{const s=[];let n=t.replace(/^[\s]+/,""),i=n.match(I);for(;null!==i;){const t=i[1].slice(1,-1),r=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());s.push(r),n=n.slice(i[0].length).replace(/^[\s]+/,""),i=n.match(I)}return[s.join(";"),n]},N=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},B=t=>{if(!(t=>{try{new new Proxy(t,D)}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.")},V=(t,e)=>{const s=t.get(e);if(void 0===s)throw new Error("A value with the given key could not be found.");return s},P=(t,e)=>{const s=Array.from(t).filter(e);if(s.length>1)throw Error("More than one element was found.");if(0===s.length)throw Error("No element was found.");const[n]=s;return t.delete(n),n},q=(t,e,s,n)=>{const i=V(t,e),r=P(i,(t=>t[0]===s&&t[1]===n));return 0===i.size&&t.delete(e),r},F=t=>V(S,t),j=t=>{if(x.has(t))throw new Error("The AudioNode is already stored.");x.add(t),F(t).forEach((t=>t(!0)))},z=t=>"port"in t,W=t=>{if(!x.has(t))throw new Error("The AudioNode is not stored.");x.delete(t),F(t).forEach((t=>t(!1)))},L=(t,e)=>{!z(t)&&e.every((t=>0===t.size))&&W(t)},H={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},U=(t,e)=>t.context===e,G=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},$=()=>new DOMException("","IndexSizeError"),X=t=>{var e;t.getChannelData=(e=t.getChannelData,s=>{try{return e.call(t,s)}catch(t){if(12===t.code)throw $();throw t}})},Z={numberOfChannels:1},Y=-34028234663852886e22,Q=-Y,K=t=>x.has(t),J={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},tt=t=>V(b,t),et=t=>V(A,t),st=(t,e)=>{const{activeInputs:s}=tt(t);s.forEach((s=>s.forEach((([s])=>{e.includes(t)||st(s,[...e,t])}))));const n=(t=>"playbackRate"in t)(t)?[t.playbackRate]:z(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)(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of n){const s=et(t);void 0!==s&&s.activeInputs.forEach((([t])=>st(t,e)))}K(t)&&W(t)},nt=t=>{st(t.destination,[])},it=t=>"context"in t,rt=t=>it(t[0]),ot=(t,e,s,n)=>{for(const e of t)if(s(e)){if(n)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},at=(t,e,[s,n],i)=>{ot(t,[e,s,n],(t=>t[0]===e&&t[1]===s),i)},ct=(t,[e,s,n],i)=>{const r=t.get(e);void 0===r?t.set(e,new Set([[s,n]])):ot(r,[s,n],(t=>t[0]===s),i)},ut=t=>"inputs"in t,ht=(t,e,s,n)=>{if(ut(e)){const i=e.inputs[n];return t.connect(i,s,0),[i,s,0]}return t.connect(e,s,n),[e,s,n]},lt=(t,e,s)=>{for(const n of t)if(n[0]===e&&n[1]===s)return t.delete(n),n;return null},pt=(t,e)=>{if(!F(t).delete(e))throw new Error("Missing the expected event listener.")},dt=(t,e,s)=>{const n=V(t,e),i=P(n,(t=>t[0]===s));return 0===n.size&&t.delete(e),i},ft=(t,e,s,n)=>{ut(e)?t.disconnect(e.inputs[n],s,0):t.disconnect(e,s,n)},mt=t=>V(T,t),_t=t=>V(k,t),gt=t=>O.has(t),vt=t=>!x.has(t),yt=(t,e)=>new Promise((s=>{if(null!==e)s(!0);else{const e=t.createScriptProcessor(256,1,1),n=t.createGain(),i=t.createBuffer(1,2,44100),r=i.getChannelData(0);r[0]=1,r[1]=1;const o=t.createBufferSource();o.buffer=i,o.loop=!0,o.connect(e).connect(t.destination),o.connect(n),o.disconnect(n),e.onaudioprocess=n=>{const i=n.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?s(!0):s(!1),o.stop(),e.onaudioprocess=null,o.disconnect(e),e.disconnect(t.destination)},o.start()}})),wt=(t,e)=>{const s=new Map;for(const e of t)for(const t of e){const e=s.get(t);s.set(t,void 0===e?1:e+1)}s.forEach(((t,s)=>e(s,t)))},xt=t=>"context"in t,bt=(t,e,s,n)=>{const{activeInputs:i,passiveInputs:r}=et(e),{outputs:o}=tt(t),a=F(t),c=o=>{const a=mt(t),c=_t(e);if(o){const e=dt(r,t,s);at(i,t,e,!1),n||gt(t)||a.connect(c,s)}else{const e=((t,e,s)=>P(t,(t=>t[0]===e&&t[1]===s)))(i,t,s);ct(r,e,!1),n||gt(t)||a.disconnect(c,s)}};return!!ot(o,[e,s],(t=>t[0]===e&&t[1]===s),!0)&&(a.add(c),K(t)?at(i,t,[s,c],!0):ct(r,[t,s,c],!0),!0)},Tt=(t,e,s,n,i)=>{const[r,o]=((t,e,s,n)=>{const{activeInputs:i,passiveInputs:r}=tt(e),o=lt(i[n],t,s);if(null===o)return[q(r,t,s,n)[2],!1];return[o[2],!0]})(t,s,n,i);if(null!==r&&(pt(t,r),!o||e||gt(t)||ft(mt(t),mt(s),n,i)),K(s)){const{activeInputs:t}=tt(s);L(s,t)}},At=(t,e,s,n)=>{const[i,r]=((t,e,s)=>{const{activeInputs:n,passiveInputs:i}=et(e),r=lt(n,t,s);if(null===r)return[dt(i,t,s)[1],!1];return[r[2],!0]})(t,s,n);null!==i&&(pt(t,i),!r||e||gt(t)||mt(t).disconnect(_t(s),n))};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(((s,n)=>t.call(e,s,n,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const Ct={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function St(t,e,s,n,i){if("function"==typeof t.copyFromChannel)0===e[s].byteLength&&(e[s]=new Float32Array(128)),t.copyFromChannel(e[s],n,i);else{const r=t.getChannelData(n);if(0===e[s].byteLength)e[s]=r.slice(i,i+128);else{const t=new Float32Array(r.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[s].set(t)}}}const Ot=(t,e,s,n,i)=>{"function"==typeof t.copyToChannel?0!==e[s].byteLength&&t.copyToChannel(e[s],n,i):0!==e[s].byteLength&&t.getChannelData(n).set(e[s],i)},Mt=(t,e)=>{const s=[];for(let n=0;n<t;n+=1){const t=[],i="number"==typeof e?e:e[n];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));s.push(t)}return s},Et=async(t,e,s,n,i,r,o)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,c=n.channelCount*n.numberOfInputs,u=i.reduce(((t,e)=>t+e),0),h=0===u?null:s.createBuffer(u,a,s.sampleRate);if(void 0===r)throw new Error("Missing the processor constructor.");const l=tt(t),p=await((t,e)=>{const s=V(E,t),n=mt(e);return V(s,n)})(s,t),d=Mt(n.numberOfInputs,n.channelCount),f=Mt(n.numberOfOutputs,i),m=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let u=0;u<a;u+=128){if(n.numberOfInputs>0&&null!==e)for(let t=0;t<n.numberOfInputs;t+=1)for(let s=0;s<n.channelCount;s+=1)St(e,d[t],s,s,u);void 0!==r.parameterDescriptors&&null!==e&&r.parameterDescriptors.forEach((({name:t},s)=>{St(e,m,t,c+s,u)}));for(let t=0;t<n.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===f[t][e].byteLength&&(f[t][e]=new Float32Array(128));try{const t=d.map(((t,e)=>0===l.activeInputs[e].size?[]:t)),e=o(u/s.sampleRate,s.sampleRate,(()=>p.process(t,f,m)));if(null!==h)for(let t=0,e=0;t<n.numberOfOutputs;t+=1){for(let s=0;s<i[t];s+=1)Ot(h,f[t],s,e+s,u);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 h},Dt={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},It={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Rt={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Nt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},Bt={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Vt=t=>{const{port1:e,port2:s}=new MessageChannel;return new Promise((n=>{const i=()=>{s.onmessage=null,e.close(),s.close(),n()};s.onmessage=()=>i();try{e.postMessage(t,[t])}catch{}finally{i()}}))},Pt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},qt=(t,e,s)=>{const n=e[s];if(void 0===n)throw t();return n},Ft={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},jt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},zt=()=>new DOMException("","InvalidStateError"),Wt=()=>new DOMException("","InvalidAccessError"),Lt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Ht=(t,e,s,n,i,r,o,a,c,u,h)=>{const l=u.length;let p=a;for(let a=0;a<l;a+=1){let l=s[0]*u[a];for(let e=1;e<i;e+=1){const n=p-e&c-1;l+=s[e]*r[n],l-=t[e]*o[n]}for(let t=i;t<n;t+=1)l+=s[t]*r[p-t&c-1];for(let s=i;s<e;s+=1)l-=t[s]*o[p-s&c-1];r[p]=u[a],o[p]=l,p=p+1&c-1,h[a]=l}return p},Ut={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Gt=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const s=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==s&&(s.catch((()=>{})),!0)}catch{}return!1},$t=(t,e,s)=>{const n=e[s];void 0!==n&&n!==t[s]&&(t[s]=n)},Xt=(t,e)=>{$t(t,e,"channelCount"),$t(t,e,"channelCountMode"),$t(t,e,"channelInterpretation")},Zt=t=>"function"==typeof t.getFloatTimeDomainData,Yt=(t,e,s)=>{const n=e[s];void 0!==n&&n!==t[s].value&&(t[s].value=n)},Qt=t=>{var e;t.start=(e=t.start,(s=0,n=0,i)=>{if("number"==typeof i&&i<0||n<0||s<0)throw new RangeError("The parameters can't be negative.");e.call(t,s,n,i)})},Kt=t=>{var e;t.stop=(e=t.stop,(s=0)=>{if(s<0)throw new RangeError("The parameter can't be negative.");e.call(t,s)})},Jt=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),te=async(t,e)=>{const s=await(t=>new Promise(((e,s)=>{const{port1:n,port2:i}=new MessageChannel;n.onmessage=({data:t})=>{n.close(),i.close(),e(t)},n.onmessageerror=({data:t})=>{n.close(),i.close(),s(t)},i.postMessage(t)})))(e);return new t(s)},ee=(t,e)=>{const s=t.createBiquadFilter();return Xt(s,e),Yt(s,e,"Q"),Yt(s,e,"detune"),Yt(s,e,"frequency"),Yt(s,e,"gain"),$t(s,e,"type"),s},se=(t,e)=>{const s=t.createChannelSplitter(e.numberOfOutputs);return Xt(s,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw zt()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw zt()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw zt()}})})(s),s},ne=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),ie=(t,e)=>{const s=t.createDelay(e.maxDelayTime);return Xt(s,e),Yt(s,e,"delayTime"),s},re=(t,e)=>{const s=t.createGain();return Xt(s,e),Yt(s,e,"gain"),s};function oe(t,e){const s=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/s,(t[1]*e[0]-t[0]*e[1])/s]}function ae(t,e){let s=[0,0];for(let r=t.length-1;r>=0;r-=1)i=e,s=[(n=s)[0]*i[0]-n[1]*i[1],n[0]*i[1]+n[1]*i[0]],s[0]+=t[r];var n,i;return s}const ce=(t,e,s,n)=>t.createScriptProcessor(e,s,n),ue=()=>new DOMException("","NotSupportedError"),he={numberOfChannels:1},le={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},pe={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},de={disableNormalization:!1},fe={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},me={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},_e=(t,e,s)=>void 0===t.copyFromChannel?t.getChannelData(s)[0]:(t.copyFromChannel(e,s),e[0]),ge=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},ve=(t,e,s,n)=>{let i=t;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:r,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:s(r),set:n(o)})},ye=(t,e,s)=>{try{t.setValueAtTime(e,s)}catch(n){if(9!==n.code)throw n;ye(t,e,s+1e-7)}},we=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),s=t.createBufferSource();s.buffer=e,s.start(),s.stop();try{return s.stop(),!0}catch{return!1}},be=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},Te=(t,e)=>{const s=e.createGain();t.connect(s);const n=(e=>()=>{e.call(t,s),t.removeEventListener("ended",n)})(t.disconnect);t.addEventListener("ended",n),ne(t,s),t.stop=(e=>{let n=!1;return(i=0)=>{if(n)try{e.call(t,i)}catch{s.gain.setValueAtTime(0,i)}else e.call(t,i),n=!0}})(t.stop)},Ae=(t,e)=>s=>{const n={value:t};return Object.defineProperties(s,{currentTarget:n,target:n}),"function"==typeof e?e.call(t,s):e.handleEvent.call(t,s)},ke=(t=>(e,s,[n,i,r],o)=>{t(e[i],[s,n,r],(t=>t[0]===s&&t[1]===n),o)})(ot),Ce=(t=>(e,s,[n,i,r],o)=>{const a=e.get(n);void 0===a?e.set(n,new Set([[i,s,r]])):t(a,[i,s,r],(t=>t[0]===i&&t[1]===s),o)})(ot),Se=(t=>(e,s,n,i)=>t(e[i],(t=>t[0]===s&&t[1]===n)))(P),Oe=new WeakMap,Me=(t=>e=>{var s;return null!==(s=t.get(e))&&void 0!==s?s:0})(Oe),Ee=(De=new Map,Ie=new WeakMap,(t,e)=>{const s=Ie.get(t);if(void 0!==s)return s;const n=De.get(t);if(void 0!==n)return n;try{const s=e();return s instanceof Promise?(De.set(t,s),s.catch((()=>!1)).then((e=>(De.delete(t),Ie.set(t,e),e)))):(Ie.set(t,s),s)}catch{return Ie.set(t,!1),!1}});var De,Ie;const Re="undefined"==typeof window?null:window,Ne=((t,e)=>(s,n)=>{const i=s.createAnalyser();if(Xt(i,n),!(n.maxDecibels>n.minDecibels))throw e();return $t(i,n,"fftSize"),$t(i,n,"maxDecibels"),$t(i,n,"minDecibels"),$t(i,n,"smoothingTimeConstant"),t(Zt,(()=>Zt(i)))||(t=>{t.getFloatTimeDomainData=e=>{const s=new Uint8Array(e.length);t.getByteTimeDomainData(s);const n=Math.max(s.length,t.fftSize);for(let t=0;t<n;t+=1)e[t]=.0078125*(s[t]-128);return e}})(i),i})(Ee,$),Be=(t=>e=>{const s=t(e);if(null===s.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return s.renderer})(tt),Ve=((t,e,s)=>async(n,i,r)=>{const o=t(n);await Promise.all(o.activeInputs.map(((t,o)=>Array.from(t).map((async([t,a])=>{const c=e(t),u=await c.render(t,i),h=n.context.destination;s(t)||n===h&&s(n)||u.connect(r,a,o)})))).reduce(((t,e)=>[...t,...e]),[]))})(tt,Be,gt),Pe=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,r){const o=n.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!U(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,fftSize:o.fftSize,maxDecibels:o.maxDecibels,minDecibels:o.minDecibels,smoothingTimeConstant:o.smoothingTimeConstant};o=t(r,e)}return n.set(r,o),await s(i,r,o),o})(i,r)}}})(Ne,mt,Ve),qe=(Fe=C,t=>{const e=Fe.get(t);if(void 0===e)throw zt();return e});var Fe;const je=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(Re),ze=(t=>e=>null!==t&&e instanceof t)(je),We=new WeakMap,Le=(t=>class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(e,s,n){if(null!==s){let i=this._listeners.get(s);void 0===i&&(i=t(this,s),"function"==typeof s&&this._listeners.set(s,i)),this._nativeEventTarget.addEventListener(e,i,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,s){const n=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===n?null:n,s)}})(Ae),He=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(Re),Ue=(t=>e=>null!==t&&e instanceof t)(He),Ge=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(Re),$e=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(Re),Xe=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(Re),Ze=((t,e,s,n,i,r,o,a,c,u,h,l,p,d,f,m)=>class extends u{constructor(e,n,i,r){super(i),this._context=e,this._nativeAudioNode=i;const o=h(e);l(o)&&!0!==s(yt,(()=>yt(o,m)))&&(t=>{const e=new Map;t.connect=(t=>(s,n=0,i=0)=>{const r=xt(s)?t(s,n,i):t(s,n),o=e.get(s);return void 0===o?e.set(s,[{input:i,output:n}]):o.every((t=>t.input!==i||t.output!==n))&&o.push({input:i,output:n}),r})(t.connect.bind(t)),t.disconnect=(s=>(n,i,r)=>{if(s.apply(t),void 0===n)e.clear();else if("number"==typeof n)for(const[t,s]of e){const i=s.filter((t=>t.output!==n));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(n))if(void 0===i)e.delete(n);else{const t=e.get(n);if(void 0!==t){const s=t.filter((t=>t.output!==i&&(t.input!==r||void 0===r)));0===s.length?e.delete(n):e.set(n,s)}}for(const[s,n]of e)n.forEach((e=>{xt(s)?t.connect(s,e.output,e.input):t.connect(s,e.output)}))})(t.disconnect)})(i),T.set(this,i),S.set(this,new Set),"closed"!==e.state&&n&&j(this),t(this,r,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,s=0,a=0){if(s<0||s>=this._nativeAudioNode.numberOfOutputs)throw i();const u=h(this._context),l=f(u);if(p(t)||d(t))throw r();if(it(t)){const i=mt(t);try{const e=ht(this._nativeAudioNode,i,s,a),n=vt(this);(l||n)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!n&&vt(t)&&j(t)}catch(t){if(12===t.code)throw r();throw t}if(e(this,t,s,a,l)){const e=c([this],t);wt(e,n(l))}return t}const m=_t(t);if("playbackRate"===m.name&&1024===m.maxValue)throw o();try{this._nativeAudioNode.connect(m,s),(l||vt(this))&&this._nativeAudioNode.disconnect(m,s)}catch(t){if(12===t.code)throw r();throw t}if(bt(this,t,s,l)){const e=c([this],t);wt(e,n(l))}}disconnect(t,e,s){let n;const o=h(this._context),u=f(o);if(void 0===t)n=((t,e)=>{const s=tt(t),n=[];for(const i of s.outputs)rt(i)?Tt(t,e,...i):At(t,e,...i),n.push(i[0]);return s.outputs.clear(),n})(this,u);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();n=((t,e,s)=>{const n=tt(t),i=[];for(const r of n.outputs)r[1]===s&&(rt(r)?Tt(t,e,...r):At(t,e,...r),i.push(r[0]),n.outputs.delete(r));return i})(this,u,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(it(t)&&void 0!==s&&(s<0||s>=t.numberOfInputs))throw i();if(n=((t,e,s,n,i)=>{const r=tt(t);return Array.from(r.outputs).filter((t=>!(t[0]!==s||void 0!==n&&t[1]!==n||void 0!==i&&t[2]!==i))).map((s=>(rt(s)?Tt(t,e,...s):At(t,e,...s),r.outputs.delete(s),s[0])))})(this,u,t,e,s),0===n.length)throw r()}for(const t of n){const e=c([this],t);wt(e,a)}}})((Ye=b,(t,e,s)=>{const n=[];for(let t=0;t<s.numberOfInputs;t+=1)n.push(new Set);Ye.set(t,{activeInputs:n,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,s,n,i,r,o,a,c,u,h,l,p)=>{const d=new WeakMap;return(f,m,_,g,v)=>{const{activeInputs:y,passiveInputs:w}=r(m),{outputs:x}=r(f),b=a(f),T=r=>{const a=c(m),u=c(f);if(r){const e=q(w,f,_,g);t(y,f,e,!1),v||l(f)||s(u,a,_,g),p(m)&&j(m)}else{const t=n(y,f,_,g);e(w,g,t,!1),v||l(f)||i(u,a,_,g);const s=o(m);if(0===s)h(m)&&L(m,y);else{const t=d.get(m);void 0!==t&&clearTimeout(t),d.set(m,setTimeout((()=>{h(m)&&L(m,y)}),1e3*s))}}};return!!u(x,[m,_,g],(t=>t[0]===m&&t[1]===_&&t[2]===g),!0)&&(b.add(T),h(f)?t(y,f,[_,g,T],!0):e(w,g,[f,_,T],!0),!0)}})(ke,Ce,ht,Se,ft,tt,Me,F,mt,ot,K,gt,vt),Ee,((t,e,s,n,i,r)=>o=>(a,c)=>{const u=t.get(a);if(void 0===u){if(!o&&r(a)){const t=n(a),{outputs:r}=s(a);for(const s of r)if(rt(s)){const i=n(s[0]);e(t,i,s[1],s[2])}else{const e=i(s[0]);t.disconnect(e,s[1])}}t.set(a,c)}else t.set(a,u+c)})(O,ft,tt,mt,_t,K),$,Wt,ue,((t,e,s,n,i,r,o,a)=>(c,u)=>{const h=e.get(c);if(void 0===h)throw new Error("Missing the expected cycle count.");const l=r(c.context),p=a(l);if(h===u){if(e.delete(c),!p&&o(c)){const e=n(c),{outputs:r}=s(c);for(const s of r)if(rt(s)){const i=n(s[0]);t(e,i,s[1],s[2])}else{const t=i(s[0]);e.connect(t,s[1])}}}else e.set(c,h-u)})(ht,O,tt,mt,_t,qe,K,ze),((t,e,s)=>function n(i,r){const o=it(r)?r:s(t,r);if((t=>"delayTime"in t)(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map((t=>n([...i,o],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(We,tt,V),Le,qe,Ue,Ge,$e,ze,Xe);var Ye;const Qe=((t,e,s,n,i,r)=>class extends t{constructor(t,s){const o=i(t),a={...H,...s},c=n(o,a);super(t,!1,c,r(o)?e():null),this._nativeAnalyserNode=c}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,s()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,s()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(Ze,Pe,$,Ne,qe,ze),Ke=new WeakSet,Je=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(Re),ts=(es=new Uint32Array(1),t=>(es[0]=t,es[0]));var es;const ss=((t,e)=>s=>{s.copyFromChannel=(n,i,r=0)=>{const o=t(r),a=t(i);if(a>=s.numberOfChannels)throw e();const c=s.length,u=s.getChannelData(a),h=n.length;for(let t=o<0?-o:0;t+o<c&&t<h;t+=1)n[t]=u[t+o]},s.copyToChannel=(n,i,r=0)=>{const o=t(r),a=t(i);if(a>=s.numberOfChannels)throw e();const c=s.length,u=s.getChannelData(a),h=n.length;for(let t=o<0?-o:0;t+o<c&&t<h;t+=1)u[t+o]=n[t]}})(ts,$),ns=(t=>e=>{e.copyFromChannel=(s=>(n,i,r=0)=>{const o=t(r),a=t(i);if(o<e.length)return s.call(e,n,a,o)})(e.copyFromChannel),e.copyToChannel=(s=>(n,i,r=0)=>{const o=t(r),a=t(i);if(o<e.length)return s.call(e,n,a,o)})(e.copyToChannel)})(ts),is=((t,e,s,n,i,r,o,a)=>{let c=null;return class u{constructor(u){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:h,numberOfChannels:l,sampleRate:p}={...Z,...u};null===c&&(c=new i(1,1,44100));const d=null!==n&&e(r,r)?new n({length:h,numberOfChannels:l,sampleRate:p}):c.createBuffer(l,h,p);if(0===d.numberOfChannels)throw s();return"function"!=typeof d.copyFromChannel?(o(d),X(d)):e(G,(()=>G(d)))||a(d),t.add(d),d}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===u.prototype||t.has(e)}}})(Ke,Ee,ue,Je,je,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(Je),ss,ns),rs=(t=>(e,s)=>{const n=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});s.connect(n).connect(e.destination);const i=()=>{s.removeEventListener("ended",i),s.disconnect(n),n.disconnect()};s.addEventListener("ended",i)})(re),os=((t,e,s)=>async(n,i,r)=>{const o=e(n);await Promise.all(Array.from(o.activeInputs).map((async([e,n])=>{const o=t(e),a=await o.render(e,i);s(e)||a.connect(r,n)})))})(Be,et,gt),as=(t=>(e,s,n)=>t(s,e,n))(os),cs=((t,e,s,n,i,r,o,a,c,u,h)=>(l,p)=>{const d=l.createBufferSource();return Xt(d,p),Yt(d,p,"playbackRate"),$t(d,p,"buffer"),$t(d,p,"loop"),$t(d,p,"loopEnd"),$t(d,p,"loopStart"),e(s,(()=>s(l)))||(t=>{t.start=(e=>{let s=!1;return(n=0,i=0,r)=>{if(s)throw zt();e.call(t,n,i,r),s=!0}})(t.start)})(d),e(n,(()=>n(l)))||c(d),e(i,(()=>i(l)))||u(d,l),e(r,(()=>r(l)))||Qt(d),e(o,(()=>o(l)))||h(d,l),e(a,(()=>a(l)))||Kt(d),t(l,d),d})(rs,Ee,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),s=t.createBuffer(1,1,44100);e.buffer=s;try{e.start(0,1)}catch{return!1}return!0}),(t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0}),we,xe,be,(t=>{var e;t.start=(e=t.start,(s=0,n=0,i)=>{const r=t.buffer,o=null===r?n:Math.min(r.duration,n);null!==r&&o>r.duration-.5/t.context.sampleRate?e.call(t,s,0,0):e.call(t,s,o,i)})}),(t=>(e,s)=>{const n=s.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=n),t(e,"buffer",(t=>()=>{const s=t.call(e);return s===n?null:s}),(t=>s=>t.call(e,null===s?n:s)))})(ve),Te),us=((t,e)=>(s,n,i)=>(t(n).replay(i),e(n,s,i)))((t=>e=>{const s=t(e);if(null===s.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return s.renderer})(et),os),hs=((t,e,s,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;return{set start(t){o=t},set stop(t){a=t},render(c,u){const h=r.get(u);return void 0!==h?Promise.resolve(h):(async(c,u)=>{let h=s(c);const l=U(h,u);if(!l){const t={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=e(u,t),null!==o&&h.start(...o),null!==a&&h.stop(a)}return r.set(u,h),l?await t(u,c.playbackRate,h.playbackRate):await n(u,c.playbackRate,h.playbackRate),await i(c,u,h),h})(c,u)}}})(as,cs,mt,us,Ve),ls=((t,e,s,n,i,r,o,a,c,u,h,l,p)=>(d,f,m,_=null,g=null)=>{const v=m.value,y=new w(v),x=f?n(y):null,b={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,b.setValueAtTime(t,d.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof m.cancelAndHoldAtTime)null===x&&y.flush(d.context.currentTime),y.add(i(t)),m.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===x&&y.flush(d.context.currentTime),y.add(i(t));const s=Array.from(y).pop();m.cancelScheduledValues(t),e!==s&&void 0!==s&&("exponentialRampToValue"===s.type?m.exponentialRampToValueAtTime(s.value,s.endTime):"linearRampToValue"===s.type?m.linearRampToValueAtTime(s.value,s.endTime):"setValue"===s.type?m.setValueAtTime(s.value,s.startTime):"setValueCurve"===s.type&&m.setValueCurveAtTime(s.values,s.startTime,s.duration))}return b},cancelScheduledValues:t=>(null===x&&y.flush(d.context.currentTime),y.add(r(t)),m.cancelScheduledValues(t),b),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const s=d.context.currentTime;return null===x&&y.flush(s),0===Array.from(y).length&&(y.add(u(v,s)),m.setValueAtTime(v,s)),y.add(o(t,e)),m.exponentialRampToValueAtTime(t,e),b},linearRampToValueAtTime(t,e){const s=d.context.currentTime;return null===x&&y.flush(s),0===Array.from(y).length&&(y.add(u(v,s)),m.setValueAtTime(v,s)),y.add(a(t,e)),m.linearRampToValueAtTime(t,e),b},setTargetAtTime:(t,e,s)=>(null===x&&y.flush(d.context.currentTime),y.add(c(t,e,s)),m.setTargetAtTime(t,e,s),b),setValueAtTime:(t,e)=>(null===x&&y.flush(d.context.currentTime),y.add(u(t,e)),m.setValueAtTime(t,e),b),setValueCurveAtTime(t,e,s){const n=t instanceof Float32Array?t:new Float32Array(t);if(null!==l&&"webkitAudioContext"===l.name){const t=e+s,i=d.context.sampleRate,r=Math.ceil(e*i),o=Math.floor(t*i),a=o-r,c=new Float32Array(a);for(let t=0;t<a;t+=1){const o=(n.length-1)/s*((r+t)/i-e),a=Math.floor(o),u=Math.ceil(o);c[t]=a===u?n[a]:(1-(o-a))*n[a]+(1-(u-o))*n[u]}null===x&&y.flush(d.context.currentTime),y.add(h(c,e,s)),m.setValueCurveAtTime(c,e,s);const u=o/i;u<t&&p(b,c[c.length-1],u),p(b,n[n.length-1],t)}else null===x&&y.flush(d.context.currentTime),y.add(h(n,e,s)),m.setValueCurveAtTime(n,e,s);return b}};return s.set(b,m),e.set(b,d),t(b,x),b})((ps=A,(t,e)=>{ps.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),We,k,(t=>({replay(e){for(const s of t)if("exponentialRampToValue"===s.type){const{endTime:t,value:n}=s;e.exponentialRampToValueAtTime(n,t)}else if("linearRampToValue"===s.type){const{endTime:t,value:n}=s;e.linearRampToValueAtTime(n,t)}else if("setTarget"===s.type){const{startTime:t,target:n,timeConstant:i}=s;e.setTargetAtTime(n,t,i)}else if("setValue"===s.type){const{startTime:t,value:n}=s;e.setValueAtTime(n,t)}else{if("setValueCurve"!==s.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:n,values:i}=s;e.setValueCurveAtTime(i,n,t)}}}})),(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,s)=>({startTime:e,target:t,timeConstant:s,type:"setTarget"})),n,i,He,ye);var ps;const ds=((t,e,s,n,i,r,o,a)=>class extends t{constructor(t,n){const a=r(t),c={...J,...n},u=i(a,c),h=o(a),l=h?e():null;super(t,!1,u,l),this._audioBufferSourceNodeRenderer=l,this._isBufferNullified=!1,this._isBufferSet=null!==c.buffer,this._nativeAudioBufferSourceNode=u,this._onended=null,this._playbackRate=s(this,h,u.playbackRate,Q,Y)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw n();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const s=this._nativeAudioBufferSourceNode.onended;this._onended=null!==s&&s===e?t:s}get playbackRate(){return this._playbackRate}start(t=0,e=0,s){if(this._nativeAudioBufferSourceNode.start(t,e,s),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===s?[t,e]:[t,e,s]),"closed"!==this.context.state){j(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),K(this)&&W(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(Ze,hs,ls,zt,cs,qe,ze,Ae),fs=((t,e,s,n,i,r,o,a)=>class extends t{constructor(t,s){const n=r(t),c=o(n),u=i(n,s,c);super(t,!1,u,c?e(a):null),this._isNodeOfNativeOfflineAudioContext=c,this._nativeAudioDestinationNode=u}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw n();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw s();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw n();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(Ze,(t=>{const e=new WeakMap;return{render(s,n){const i=e.get(n);return void 0!==i?Promise.resolve(i):(async(s,n)=>{const i=n.destination;return e.set(n,i),await t(s,n,i),i})(s,n)}}}),$,zt,((t,e)=>(s,n,i)=>{const r=s.destination;if(r.channelCount!==n)try{r.channelCount=n}catch{}i&&"explicit"!==r.channelCountMode&&(r.channelCountMode="explicit"),0===r.maxChannelCount&&Object.defineProperty(r,"maxChannelCount",{value:n});const o=t(s,{channelCount:n,channelCountMode:r.channelCountMode,channelInterpretation:r.channelInterpretation,gain:1});return e(o,"channelCount",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e);try{r.channelCount=e}catch(t){if(e>r.maxChannelCount)throw t}})),e(o,"channelCountMode",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e),r.channelCountMode=e})),e(o,"channelInterpretation",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e),r.channelInterpretation=e})),Object.defineProperty(o,"maxChannelCount",{get:()=>r.maxChannelCount}),o.connect(r),o})(re,ve),qe,ze,Ve),ms=((t,e,s,n,i)=>()=>{const r=new WeakMap;return{render(o,a){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(o,a)=>{let c=s(o);const u=U(c,a);if(!u){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 r.set(a,c),u?(await t(a,o.Q,c.Q),await t(a,o.detune,c.detune),await t(a,o.frequency,c.frequency),await t(a,o.gain,c.gain)):(await n(a,o.Q,c.Q),await n(a,o.detune,c.detune),await n(a,o.frequency,c.frequency),await n(a,o.gain,c.gain)),await i(o,a,c),c})(o,a)}}})(as,ee,mt,us,Ve),_s=(t=>(e,s)=>t.set(e,s))(Oe),gs=((t,e,s,n,i,r,o,a)=>class extends t{constructor(t,n){const c=r(t),u={...Dt,...n},h=i(c,u),l=o(c);super(t,!1,h,l?s():null),this._Q=e(this,l,h.Q,Q,Y),this._detune=e(this,l,h.detune,1200*Math.log2(Q),-1200*Math.log2(Q)),this._frequency=e(this,l,h.frequency,t.sampleRate/2,0),this._gain=e(this,l,h.gain,40*Math.log10(Q),Y),this._nativeBiquadFilterNode=h,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,s){try{this._nativeBiquadFilterNode.getFrequencyResponse(t,e,s)}catch(t){if(11===t.code)throw n();throw t}if(t.length!==e.length||e.length!==s.length)throw n()}})(Ze,ls,ms,Wt,ee,qe,ze,_s),vs=((t,e)=>(s,n,i)=>{const r=new Set;return s.connect=(i=>(o,a=0,c=0)=>{const u=0===r.size;if(e(o))return i.call(s,o,a,c),t(r,[o,a,c],(t=>t[0]===o&&t[1]===a&&t[2]===c),!0),u&&n(),o;i.call(s,o,a),t(r,[o,a],(t=>t[0]===o&&t[1]===a),!0),u&&n()})(s.connect),s.disconnect=(t=>(n,o,a)=>{const c=r.size>0;if(void 0===n)t.apply(s),r.clear();else if("number"==typeof n){t.call(s,n);for(const t of r)t[1]===n&&r.delete(t)}else{e(n)?t.call(s,n,o,a):t.call(s,n,o);for(const t of r)t[0]!==n||void 0!==o&&t[1]!==o||void 0!==a&&t[2]!==a||r.delete(t)}const u=0===r.size;c&&u&&i()})(s.disconnect),s})(ot,Ge),ys=((t,e)=>(s,n)=>{n.channelCount=1,n.channelCountMode="explicit",Object.defineProperty(n,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=s.createBufferSource();e(n,(()=>{const t=n.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(n,0,e)}),(()=>i.disconnect(n)))})(zt,vs),ws=((t,e)=>(s,n)=>{const i=s.createChannelMerger(n.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(s,i),Xt(i,n),i})(He,ys),xs=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,r){const o=n.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!U(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfInputs:o.numberOfInputs};o=t(r,e)}return n.set(r,o),await s(i,r,o),o})(i,r)}}})(ws,mt,Ve),bs=((t,e,s,n,i)=>class extends t{constructor(t,r){const o=n(t),a={...It,...r};super(t,!1,s(o,a),i(o)?e():null)}})(Ze,xs,ws,qe,ze),Ts=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,r){const o=n.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!U(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfOutputs:o.numberOfOutputs};o=t(r,e)}return n.set(r,o),await s(i,r,o),o})(i,r)}}})(se,mt,Ve),As=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=n(t),c=r({...Rt,...o});super(t,!1,s(a,c),i(a)?e():null)}})(Ze,Ts,se,qe,ze,(t=>({...t,channelCount:t.numberOfOutputs}))),ks=((t,e,s,n)=>(i,{offset:r,...o})=>{const a=i.createBuffer(1,2,44100),c=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),u=s(i,{...o,gain:r}),h=a.getChannelData(0);h[0]=1,h[1]=1,c.buffer=a,c.loop=!0;const l={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(t){u.channelCount=t},get channelCountMode(){return u.channelCountMode},set channelCountMode(t){u.channelCountMode=t},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t},get context(){return u.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get offset(){return u.gain},get onended(){return c.onended},set onended(t){c.onended=t},addEventListener:(...t)=>c.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>c.dispatchEvent(t[0]),removeEventListener:(...t)=>c.removeEventListener(t[0],t[1],t[2]),start(t=0){c.start.call(c,t)},stop(t=0){c.stop.call(c,t)}};return t(i,c),n(ne(l,u),(()=>c.connect(u)),(()=>c.disconnect(u)))})(rs,cs,re,vs),Cs=((t,e,s,n,i)=>(r,o)=>{if(void 0===r.createConstantSource)return s(r,o);const a=r.createConstantSource();return Xt(a,o),Yt(a,o,"offset"),e(n,(()=>n(r)))||Qt(a),e(i,(()=>i(r)))||Kt(a),t(r,a),a})(rs,Ee,ks,we,be),Ss=((t,e,s,n,i)=>()=>{const r=new WeakMap;let o=null,a=null;return{set start(t){o=t},set stop(t){a=t},render(c,u){const h=r.get(u);return void 0!==h?Promise.resolve(h):(async(c,u)=>{let h=s(c);const l=U(h,u);if(!l){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=e(u,t),null!==o&&h.start(o),null!==a&&h.stop(a)}return r.set(u,h),l?await t(u,c.offset,h.offset):await n(u,c.offset,h.offset),await i(c,u,h),h})(c,u)}}})(as,Cs,mt,us,Ve),Os=((t,e,s,n,i,r,o)=>class extends t{constructor(t,o){const a=i(t),c={...Nt,...o},u=n(a,c),h=r(a),l=h?s():null;super(t,!1,u,l),this._constantSourceNodeRenderer=l,this._nativeConstantSourceNode=u,this._offset=e(this,h,u.offset,Q,Y),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(t){const e="function"==typeof t?o(this,t):null;this._nativeConstantSourceNode.onended=e;const s=this._nativeConstantSourceNode.onended;this._onended=null!==s&&s===e?t:s}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){j(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),K(this)&&W(this)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})(Ze,ls,Ss,Cs,qe,ze,Ae),Ms=((t,e)=>(s,n)=>{const i=s.createConvolver();if(Xt(i,n),n.disableNormalization===i.normalize&&(i.normalize=!n.disableNormalization),$t(i,n,"buffer"),n.channelCount>2)throw t();if(e(i,"channelCount",(t=>()=>t.call(i)),(e=>s=>{if(s>2)throw t();return e.call(i,s)})),"max"===n.channelCountMode)throw t();return e(i,"channelCountMode",(t=>()=>t.call(i)),(e=>s=>{if("max"===s)throw t();return e.call(i,s)})),i})(ue,ve),Es=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,r){const o=n.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!U(o,r)){const e={buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize};o=t(r,e)}return n.set(r,o),ut(o)?await s(i,r,o.inputs[0]):await s(i,r,o),o})(i,r)}}})(Ms,mt,Ve),Ds=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=n(t),c={...Bt,...o},u=s(a,c);super(t,!1,u,i(a)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=u,null!==c.buffer&&r(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,r(this,0)}else this._isBufferNullified=!1,r(this,null===this._nativeConvolverNode.buffer?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(t){this._nativeConvolverNode.normalize=t}})(Ze,Es,Ms,qe,ze,_s),Is=((t,e,s,n,i)=>r=>{const o=new WeakMap;return{render(a,c){const u=o.get(c);return void 0!==u?Promise.resolve(u):(async(a,c)=>{let u=s(a);const h=U(u,c);if(!h){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,delayTime:u.delayTime.value,maxDelayTime:r};u=e(c,t)}return o.set(c,u),h?await t(c,a.delayTime,u.delayTime):await n(c,a.delayTime,u.delayTime),await i(a,c,u),u})(a,c)}}})(as,ie,mt,us,Ve),Rs=((t,e,s,n,i,r,o)=>class extends t{constructor(t,a){const c=i(t),u={...Pt,...a},h=n(c,u),l=r(c);super(t,!1,h,l?s(u.maxDelayTime):null),this._delayTime=e(this,l,h.delayTime),o(this,u.maxDelayTime)}get delayTime(){return this._delayTime}})(Ze,ls,Is,ie,qe,ze,_s),Ns=(t=>(e,s)=>{const n=e.createDynamicsCompressor();if(Xt(n,s),s.channelCount>2)throw t();if("max"===s.channelCountMode)throw t();return Yt(n,s,"attack"),Yt(n,s,"knee"),Yt(n,s,"ratio"),Yt(n,s,"release"),Yt(n,s,"threshold"),n})(ue),Bs=((t,e,s,n,i)=>()=>{const r=new WeakMap;return{render(o,a){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(o,a)=>{let c=s(o);const u=U(c,a);if(!u){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 r.set(a,c),u?(await t(a,o.attack,c.attack),await t(a,o.knee,c.knee),await t(a,o.ratio,c.ratio),await t(a,o.release,c.release),await t(a,o.threshold,c.threshold)):(await n(a,o.attack,c.attack),await n(a,o.knee,c.knee),await n(a,o.ratio,c.ratio),await n(a,o.release,c.release),await n(a,o.threshold,c.threshold)),await i(o,a,c),c})(o,a)}}})(as,Ns,mt,us,Ve),Vs=((t,e,s,n,i,r,o,a)=>class extends t{constructor(t,i){const c=r(t),u={...Ft,...i},h=n(c,u),l=o(c);super(t,!1,h,l?s():null),this._attack=e(this,l,h.attack),this._knee=e(this,l,h.knee),this._nativeDynamicsCompressorNode=h,this._ratio=e(this,l,h.ratio),this._release=e(this,l,h.release),this._threshold=e(this,l,h.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}})(Ze,ls,Bs,Ns,ue,qe,ze,_s),Ps=((t,e,s,n,i)=>()=>{const r=new WeakMap;return{render(o,a){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(o,a)=>{let c=s(o);const u=U(c,a);if(!u){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(a,t)}return r.set(a,c),u?await t(a,o.gain,c.gain):await n(a,o.gain,c.gain),await i(o,a,c),c})(o,a)}}})(as,re,mt,us,Ve),qs=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=i(t),c={...jt,...o},u=n(a,c),h=r(a);super(t,!1,u,h?s():null),this._gain=e(this,h,u.gain,Q,Y)}get gain(){return this._gain}})(Ze,ls,Ps,re,qe,ze),Fs=((t,e,s,n)=>(i,r,{channelCount:o,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:h})=>{const l=Jt(r,i.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),d=h instanceof Float64Array?h:new Float64Array(h),f=p.length,m=d.length,_=Math.min(f,m);if(0===f||f>20)throw n();if(0===p[0])throw e();if(0===m||m>20)throw n();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=s(i,l,o,o);g.channelCount=o,g.channelCountMode=a,g.channelInterpretation=c;const v=[],y=[],w=[];for(let t=0;t<o;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,s=t.outputBuffer,n=e.numberOfChannels;for(let t=0;t<n;t+=1){const n=e.getChannelData(t),i=s.getChannelData(t);v[t]=Ht(p,f,d,m,_,y[t],w[t],v[t],32,n,i)}};const x=i.sampleRate/2,b={get bufferSize(){return l},get channelCount(){return g.channelCount},set channelCount(t){g.channelCount=t},get channelCountMode(){return g.channelCountMode},set channelCountMode(t){g.channelCountMode=t},get channelInterpretation(){return g.channelInterpretation},set channelInterpretation(t){g.channelInterpretation=t},get context(){return g.context},get inputs(){return[g]},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},addEventListener:(...t)=>g.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>g.dispatchEvent(t[0]),getFrequencyResponse(e,s,n){if(e.length!==s.length||s.length!==n.length)throw t();const i=e.length;for(let t=0;t<i;t+=1){const i=-Math.PI*(e[t]/x),r=[Math.cos(i),Math.sin(i)],o=oe(ae(d,r),ae(p,r));s[t]=Math.sqrt(o[0]*o[0]+o[1]*o[1]),n[t]=Math.atan2(o[1],o[0])}},removeEventListener:(...t)=>g.removeEventListener(t[0],t[1],t[2])};return ne(b,g)})(Wt,zt,ce,ue),js=((t,e,s,n)=>i=>t(Gt,(()=>Gt(i)))?Promise.resolve(t(n,n)).then((t=>{if(!t){const t=s(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const s=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{s.disconnect(),t(e.renderedBuffer)},s.connect(i.destination),i.startRendering()})))(Ee,re,ce,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const s=new e(1,1,44100),n=t(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{s.oncomplete=()=>{n.disconnect(),t(0!==s.currentTime)},s.startRendering()}))})(re,je)),zs=((t,e,s,n,i)=>(r,o)=>{const a=new WeakMap;let c=null;const u=async(u,h)=>{let l=null,p=e(u);const d=U(p,h);if(void 0===h.createIIRFilter?l=t(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(p=h.createIIRFilter(o,r)),a.set(h,null===l?p:l),null!==l){if(null===c){if(null===s)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new s(u.context.destination.channelCount,u.context.length,h.sampleRate);c=(async()=>{await n(u,t,t.destination);return((t,e,s,n)=>{const i=s instanceof Float64Array?s:new Float64Array(s),r=n instanceof Float64Array?n:new Float64Array(n),o=i.length,a=r.length,c=Math.min(o,a);if(1!==i[0]){for(let t=0;t<o;t+=1)r[t]/=i[0];for(let t=1;t<a;t+=1)i[t]/=i[0]}const u=new Float32Array(32),h=new Float32Array(32),l=e.createBuffer(t.numberOfChannels,t.length,t.sampleRate),p=t.numberOfChannels;for(let e=0;e<p;e+=1){const s=t.getChannelData(e),n=l.getChannelData(e);u.fill(0),h.fill(0),Ht(i,o,r,a,c,u,h,0,32,s,n)}return l})(await i(t),h,r,o)})()}const t=await c;return l.buffer=t,l.start(0),l}return await n(u,h,p),p};return{render(t,e){const s=a.get(e);return void 0!==s?Promise.resolve(s):u(t,e)}}})(cs,mt,je,Ve,js),Ws=(t=>(e,s,n)=>{if(void 0===e.createIIRFilter)return t(e,s,n);const i=e.createIIRFilter(n.feedforward,n.feedback);return Xt(i,n),i})(Fs),Ls=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=n(t),c=i(a),u={...Lt,...o},h=e(a,c?null:t.baseLatency,u);super(t,!1,h,c?s(u.feedback,u.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(s,n,i)=>{if(s.length!==n.length||n.length!==i.length)throw Wt();return e.call(t,s,n,i)})})(h),this._nativeIIRFilterNode=h,r(this,1)}getFrequencyResponse(t,e,s){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,s)}})(Ze,Ws,zs,qe,ze,_s),Hs=((t,e,s,n,i,r,o,a)=>(c,u)=>{const h=u.listener,{forwardX:l,forwardY:p,forwardZ:d,positionX:f,positionY:m,positionZ:_,upX:g,upY:v,upZ:y}=void 0===h.forwardX?(()=>{const l=new Float32Array(1),p=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),d=o(u);let f=!1,m=[0,0,-1,0,1,0],_=[0,0,0];const g=()=>{if(f)return;f=!0;const t=n(u,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[r(t,l,0),r(t,l,1),r(t,l,2),r(t,l,3),r(t,l,4),r(t,l,5)];e.some(((t,e)=>t!==m[e]))&&(h.setOrientation(...e),m=e);const s=[r(t,l,6),r(t,l,7),r(t,l,8)];s.some(((t,e)=>t!==_[e]))&&(h.setPosition(...s),_=s)},p.connect(t)},v=t=>e=>{e!==m[t]&&(m[t]=e,h.setOrientation(...m))},y=t=>e=>{e!==_[t]&&(_[t]=e,h.setPosition(..._))},w=(e,n,r)=>{const o=s(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:n});o.connect(p,0,e),o.start(),Object.defineProperty(o.offset,"defaultValue",{get:()=>n});const h=t({context:c},d,o.offset,Q,Y);var l,f,m,_,v,y,w;return a(h,"value",(t=>()=>t.call(h)),(t=>e=>{try{t.call(h,e)}catch(t){if(9!==t.code)throw t}g(),d&&r(e)})),h.cancelAndHoldAtTime=(l=h.cancelAndHoldAtTime,d?()=>{throw i()}:(...t)=>{const e=l.apply(h,t);return g(),e}),h.cancelScheduledValues=(f=h.cancelScheduledValues,d?()=>{throw i()}:(...t)=>{const e=f.apply(h,t);return g(),e}),h.exponentialRampToValueAtTime=(m=h.exponentialRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=m.apply(h,t);return g(),e}),h.linearRampToValueAtTime=(_=h.linearRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=_.apply(h,t);return g(),e}),h.setTargetAtTime=(v=h.setTargetAtTime,d?()=>{throw i()}:(...t)=>{const e=v.apply(h,t);return g(),e}),h.setValueAtTime=(y=h.setValueAtTime,d?()=>{throw i()}:(...t)=>{const e=y.apply(h,t);return g(),e}),h.setValueCurveAtTime=(w=h.setValueCurveAtTime,d?()=>{throw i()}:(...t)=>{const e=w.apply(h,t);return g(),e}),h};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))}})():h;return{get forwardX(){return l},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}}})(ls,ws,Cs,ce,ue,_e,ze,ve),Us=new WeakMap,Gs=((t,e,s,n,i,r)=>class extends s{constructor(s,r){super(s),this._nativeContext=s,C.set(this,s),n(s)&&i.set(s,new Set),this._destination=new t(this,r),this._listener=e(this,s),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e="function"==typeof t?r(this,t):null;this._nativeContext.onstatechange=e;const s=this._nativeContext.onstatechange;this._onstatechange=null!==s&&s===e?t:s}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(fs,Hs,Le,ze,Us,Ae),$s=((t,e,s,n,i,r)=>(o,a)=>{const c=o.createOscillator();return Xt(c,a),Yt(c,a,"detune"),Yt(c,a,"frequency"),void 0!==a.periodicWave?c.setPeriodicWave(a.periodicWave):$t(c,a,"type"),e(s,(()=>s(o)))||Qt(c),e(n,(()=>n(o)))||r(c,o),e(i,(()=>i(o)))||Kt(c),t(o,c),c})(rs,Ee,we,xe,be,Te),Xs=((t,e,s,n,i)=>()=>{const r=new WeakMap;let o=null,a=null,c=null;return{set periodicWave(t){o=t},set start(t){a=t},set stop(t){c=t},render(u,h){const l=r.get(h);return void 0!==l?Promise.resolve(l):(async(u,h)=>{let l=s(u);const p=U(l,h);if(!p){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,detune:l.detune.value,frequency:l.frequency.value,periodicWave:null===o?void 0:o,type:l.type};l=e(h,t),null!==a&&l.start(a),null!==c&&l.stop(c)}return r.set(h,l),p?(await t(h,u.detune,l.detune),await t(h,u.frequency,l.frequency)):(await n(h,u.detune,l.detune),await n(h,u.frequency,l.frequency)),await i(u,h,l),l})(u,h)}}})(as,$s,mt,us,Ve),Zs=((t,e,s,n,i,r,o)=>class extends t{constructor(t,o){const a=i(t),c={...le,...o},u=s(a,c),h=r(a),l=h?n():null,p=t.sampleRate/2;super(t,!1,u,l),this._detune=e(this,h,u.detune,153600,-153600),this._frequency=e(this,h,u.frequency,p,-p),this._nativeOscillatorNode=u,this._onended=null,this._oscillatorNodeRenderer=l,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?o(this,t):null;this._nativeOscillatorNode.onended=e;const s=this._nativeOscillatorNode.onended;this._onended=null!==s&&s===e?t:s}get type(){return this._nativeOscillatorNode.type}set type(t){this._nativeOscillatorNode.type=t,null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.start=t),"closed"!==this.context.state){j(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),K(this)&&W(this)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})(Ze,ls,$s,Xs,qe,ze,Ae),Ys=(t=>(e,s)=>{const n=t(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return n.buffer=i,n.loop=!0,n.connect(s),n.start(),()=>{n.stop(),n.disconnect(s)}})(cs),Qs=((t,e,s,n,i)=>(r,{curve:o,oversample:a,...c})=>{const u=r.createWaveShaper(),h=r.createWaveShaper();Xt(u,c),Xt(h,c);const l=s(r,{...c,gain:1}),p=s(r,{...c,gain:-1}),d=s(r,{...c,gain:1}),f=s(r,{...c,gain:-1});let m=null,_=!1,g=null;const v={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(t){l.channelCount=t,p.channelCount=t,u.channelCount=t,d.channelCount=t,h.channelCount=t,f.channelCount=t},get channelCountMode(){return u.channelCountMode},set channelCountMode(t){l.channelCountMode=t,p.channelCountMode=t,u.channelCountMode=t,d.channelCountMode=t,h.channelCountMode=t,f.channelCountMode=t},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(t){l.channelInterpretation=t,p.channelInterpretation=t,u.channelInterpretation=t,d.channelInterpretation=t,h.channelInterpretation=t,f.channelInterpretation=t},get context(){return u.context},get curve(){return g},set curve(s){if(null!==s&&s.length<2)throw e();if(null===s)u.curve=s,h.curve=s;else{const t=s.length,e=new Float32Array(t+2-t%2),n=new Float32Array(t+2-t%2);e[0]=s[0],n[0]=-s[t-1];const i=Math.ceil((t+1)/2),r=(t+1)/2-1;for(let o=1;o<i;o+=1){const a=o/i*r,c=Math.floor(a),u=Math.ceil(a);e[o]=c===u?s[c]:(1-(a-c))*s[c]+(1-(u-a))*s[u],n[o]=c===u?-s[t-1-c]:-(1-(a-c))*s[t-1-c]-(1-(u-a))*s[t-1-u]}e[i]=t%2==1?s[i-1]:(s[i-2]+s[i-1])/2,u.curve=e,h.curve=n}g=s,_&&(n(g)&&null===m?m=t(r,l):null!==m&&(m(),m=null))},get inputs(){return[l]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get oversample(){return u.oversample},set oversample(t){u.oversample=t,h.oversample=t},addEventListener:(...t)=>l.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>l.dispatchEvent(t[0]),removeEventListener:(...t)=>l.removeEventListener(t[0],t[1],t[2])};null!==o&&(v.curve=o instanceof Float32Array?o:new Float32Array(o)),a!==v.oversample&&(v.oversample=a);return i(ne(v,d),(()=>{l.connect(u).connect(d),l.connect(p).connect(h).connect(f).connect(d),_=!0,n(g)&&(m=t(r,l))}),(()=>{l.disconnect(u),u.disconnect(d),l.disconnect(p),p.disconnect(h),h.disconnect(f),f.disconnect(d),_=!1,null!==m&&(m(),m=null)}))})(Ys,zt,re,ge,vs),Ks=((t,e,s,n,i,r,o)=>(a,c)=>{const u=a.createWaveShaper();if(null!==r&&"webkitAudioContext"===r.name&&void 0===a.createGain().gain.automationRate)return s(a,c);Xt(u,c);const h=null===c.curve||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(null!==h&&h.length<2)throw e();$t(u,{curve:h},"curve"),$t(u,c,"oversample");let l=null,p=!1;o(u,"curve",(t=>()=>t.call(u)),(e=>s=>(e.call(u,s),p&&(n(s)&&null===l?l=t(a,u):n(s)||null===l||(l(),l=null)),s)));return i(u,(()=>{p=!0,n(u.curve)&&(l=t(a,u))}),(()=>{p=!1,null!==l&&(l(),l=null)}))})(Ys,zt,Qs,ge,vs,He,ve),Js=((t,e,s,n,i,r,o,a,c,u)=>(h,{coneInnerAngle:l,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:m,orientationX:_,orientationY:g,orientationZ:v,panningModel:y,positionX:w,positionY:x,positionZ:b,refDistance:T,rolloffFactor:A,...k})=>{const C=h.createPanner();if(k.channelCount>2)throw o();if("max"===k.channelCountMode)throw o();Xt(C,k);const S={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},O=s(h,{...S,channelInterpretation:"speakers",numberOfInputs:6}),M=n(h,{...k,gain:1}),E=n(h,{...S,gain:1}),D=n(h,{...S,gain:0}),I=n(h,{...S,gain:0}),R=n(h,{...S,gain:0}),N=n(h,{...S,gain:0}),B=n(h,{...S,gain:0}),V=i(h,256,6,1),P=r(h,{...S,curve:new Float32Array([1,1]),oversample:"none"});let q=[_,g,v],F=[w,x,b];const j=new Float32Array(1);V.onaudioprocess=({inputBuffer:t})=>{const e=[c(t,j,0),c(t,j,1),c(t,j,2)];e.some(((t,e)=>t!==q[e]))&&(C.setOrientation(...e),q=e);const s=[c(t,j,3),c(t,j,4),c(t,j,5)];s.some(((t,e)=>t!==F[e]))&&(C.setPosition(...s),F=s)},Object.defineProperty(D.gain,"defaultValue",{get:()=>0}),Object.defineProperty(I.gain,"defaultValue",{get:()=>0}),Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(N.gain,"defaultValue",{get:()=>0}),Object.defineProperty(B.gain,"defaultValue",{get:()=>0});const z={get bufferSize(){},get channelCount(){return C.channelCount},set channelCount(t){if(t>2)throw o();M.channelCount=t,C.channelCount=t},get channelCountMode(){return C.channelCountMode},set channelCountMode(t){if("max"===t)throw o();M.channelCountMode=t,C.channelCountMode=t},get channelInterpretation(){return C.channelInterpretation},set channelInterpretation(t){M.channelInterpretation=t,C.channelInterpretation=t},get coneInnerAngle(){return C.coneInnerAngle},set coneInnerAngle(t){C.coneInnerAngle=t},get coneOuterAngle(){return C.coneOuterAngle},set coneOuterAngle(t){C.coneOuterAngle=t},get coneOuterGain(){return C.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();C.coneOuterGain=t},get context(){return C.context},get distanceModel(){return C.distanceModel},set distanceModel(t){C.distanceModel=t},get inputs(){return[M]},get maxDistance(){return C.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;C.maxDistance=t},get numberOfInputs(){return C.numberOfInputs},get numberOfOutputs(){return C.numberOfOutputs},get orientationX(){return E.gain},get orientationY(){return D.gain},get orientationZ(){return I.gain},get panningModel(){return C.panningModel},set panningModel(t){C.panningModel=t},get positionX(){return R.gain},get positionY(){return N.gain},get positionZ(){return B.gain},get refDistance(){return C.refDistance},set refDistance(t){if(t<0)throw new RangeError;C.refDistance=t},get rolloffFactor(){return C.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;C.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])};l!==z.coneInnerAngle&&(z.coneInnerAngle=l),p!==z.coneOuterAngle&&(z.coneOuterAngle=p),d!==z.coneOuterGain&&(z.coneOuterGain=d),f!==z.distanceModel&&(z.distanceModel=f),m!==z.maxDistance&&(z.maxDistance=m),_!==z.orientationX.value&&(z.orientationX.value=_),g!==z.orientationY.value&&(z.orientationY.value=g),v!==z.orientationZ.value&&(z.orientationZ.value=v),y!==z.panningModel&&(z.panningModel=y),w!==z.positionX.value&&(z.positionX.value=w),x!==z.positionY.value&&(z.positionY.value=x),b!==z.positionZ.value&&(z.positionZ.value=b),T!==z.refDistance&&(z.refDistance=T),A!==z.rolloffFactor&&(z.rolloffFactor=A),1===q[0]&&0===q[1]&&0===q[2]||C.setOrientation(...q),0===F[0]&&0===F[1]&&0===F[2]||C.setPosition(...F);return u(ne(z,C),(()=>{M.connect(C),t(M,P,0,0),P.connect(E).connect(O,0,0),P.connect(D).connect(O,0,1),P.connect(I).connect(O,0,2),P.connect(R).connect(O,0,3),P.connect(N).connect(O,0,4),P.connect(B).connect(O,0,5),O.connect(V).connect(h.destination)}),(()=>{M.disconnect(C),a(M,P,0,0),P.disconnect(E),E.disconnect(O),P.disconnect(D),D.disconnect(O),P.disconnect(I),I.disconnect(O),P.disconnect(R),R.disconnect(O),P.disconnect(N),N.disconnect(O),P.disconnect(B),B.disconnect(O),O.disconnect(V),V.disconnect(h.destination)}))})(ht,zt,ws,re,ce,Ks,ue,ft,_e,vs),tn=(t=>(e,s)=>{const n=e.createPanner();return void 0===n.orientationX?t(e,s):(Xt(n,s),Yt(n,s,"orientationX"),Yt(n,s,"orientationY"),Yt(n,s,"orientationZ"),Yt(n,s,"positionX"),Yt(n,s,"positionY"),Yt(n,s,"positionZ"),$t(n,s,"coneInnerAngle"),$t(n,s,"coneOuterAngle"),$t(n,s,"coneOuterGain"),$t(n,s,"distanceModel"),$t(n,s,"maxDistance"),$t(n,s,"panningModel"),$t(n,s,"refDistance"),$t(n,s,"rolloffFactor"),n)})(Js),en=((t,e,s,n,i,r,o,a,c,u)=>()=>{const h=new WeakMap;let l=null;return{render(p,d){const f=h.get(d);return void 0!==f?Promise.resolve(f):(async(p,d)=>{let f=null,m=r(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=U(m,d);if("bufferSize"in m)f=n(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(h.set(d,null===f?m:f),null!==f){if(null===l){if(null===o)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new o(6,p.context.length,d.sampleRate),n=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});n.connect(t.destination),l=(async()=>{const e=await Promise.all([p.orientationX,p.orientationY,p.orientationZ,p.positionX,p.positionY,p.positionZ].map((async(e,n)=>{const i=s(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===n?1:0});return await a(t,e,i.offset),i})));for(let t=0;t<6;t+=1)e[t].connect(n,0,t),e[t].start(0);return u(t)})()}const t=await l,r=n(d,{..._,gain:1});await c(p,d,r);const h=[];for(let e=0;e<t.numberOfChannels;e+=1)h.push(t.getChannelData(e));let m=[h[0][0],h[1][0],h[2][0]],v=[h[3][0],h[4][0],h[5][0]],y=n(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]});r.connect(y).connect(w.inputs[0]),w.connect(f);for(let e=128;e<t.length;e+=128){const t=[h[0][e],h[1][e],h[2][e]],s=[h[3][e],h[4][e],h[5][e]];if(t.some(((t,e)=>t!==m[e]))||s.some(((t,e)=>t!==v[e]))){m=t,v=s;const o=e/d.sampleRate;y.gain.setValueAtTime(0,o),y=n(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,o),r.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)}}})(as,ws,Cs,re,tn,mt,je,us,Ve,js),sn=((t,e,s,n,i,r,o)=>class extends t{constructor(t,a){const c=i(t),u={...pe,...a},h=s(c,u),l=r(c);super(t,!1,h,l?n():null),this._nativePannerNode=h,this._orientationX=e(this,l,h.orientationX,Q,Y),this._orientationY=e(this,l,h.orientationY,Q,Y),this._orientationZ=e(this,l,h.orientationZ,Q,Y),this._positionX=e(this,l,h.positionX,Q,Y),this._positionY=e(this,l,h.positionY,Q,Y),this._positionZ=e(this,l,h.positionZ,Q,Y),o(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}})(Ze,ls,tn,en,qe,ze,_s),nn=(t=>(e,{disableNormalization:s,imag:n,real:i})=>{const r=n instanceof Float32Array?n:new Float32Array(n),o=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(o,r,{disableNormalization:s});if(Array.from(n).length<2)throw t();return a})($),rn=((t,e,s,n)=>class i{constructor(i,r){const o=e(i),a=n({...de,...r}),c=t(o,a);return s.add(c),c}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===i.prototype||s.has(t)}})(nn,qe,new WeakSet,(t=>{const{imag:e,real:s}=t;return void 0===e?void 0===s?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(s,(()=>0)),real:s}:void 0===s?{...t,imag:e,real:Array.from(e,(()=>0))}:{...t,imag:e,real:s}})),on=((t,e,s,n,i,r)=>{const o=16385,a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},h={...u,oversample:"none"},l=(t,r,l,p,d)=>{if(1===r)return((t,e,i,r)=>{const l=new Float32Array(o),p=new Float32Array(o);for(let t=0;t<o;t+=1){const e=t/16384*c;l[t]=Math.cos(e),p[t]=Math.sin(e)}const d=s(t,{...u,gain:0}),f=n(t,{...h,curve:l}),m=n(t,{...h,curve:a}),_=s(t,{...u,gain:0}),g=n(t,{...h,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(r,0,0),_.connect(r,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(r,0,0),_.disconnect(r,0,1)}}})(t,l,p,d);if(2===r)return((t,i,r,l)=>{const p=new Float32Array(o),d=new Float32Array(o),f=new Float32Array(o),m=new Float32Array(o),_=Math.floor(8192.5);for(let t=0;t<o;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=s(t,{...u,gain:0}),y=n(t,{...h,curve:p}),w=s(t,{...u,gain:0}),x=n(t,{...h,curve:d}),b=n(t,{...h,curve:a}),T=s(t,{...u,gain:0}),A=n(t,{...h,curve:f}),k=s(t,{...u,gain:0}),C=n(t,{...h,curve:m});return{connectGraph(){i.connect(g),i.connect(void 0===b.inputs?b:b.inputs[0]),g.connect(v,0),g.connect(w,0),g.connect(T,1),g.connect(k,1),b.connect(r),r.connect(void 0===y.inputs?y:y.inputs[0]),r.connect(void 0===x.inputs?x:x.inputs[0]),r.connect(void 0===A.inputs?A:A.inputs[0]),r.connect(void 0===C.inputs?C:C.inputs[0]),y.connect(v.gain),x.connect(w.gain),A.connect(T.gain),C.connect(k.gain),v.connect(l,0,0),T.connect(l,0,0),w.connect(l,0,1),k.connect(l,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(void 0===b.inputs?b:b.inputs[0]),g.disconnect(v,0),g.disconnect(w,0),g.disconnect(T,1),g.disconnect(k,1),b.disconnect(r),r.disconnect(void 0===y.inputs?y:y.inputs[0]),r.disconnect(void 0===x.inputs?x:x.inputs[0]),r.disconnect(void 0===A.inputs?A:A.inputs[0]),r.disconnect(void 0===C.inputs?C:C.inputs[0]),y.disconnect(v.gain),x.disconnect(w.gain),A.disconnect(T.gain),C.disconnect(k.gain),v.disconnect(l,0,0),T.disconnect(l,0,0),w.disconnect(l,0,1),k.disconnect(l,0,1)}}})(t,l,p,d);throw i()};return(e,{channelCount:n,channelCountMode:o,pan:a,...c})=>{if("max"===o)throw i();const u=t(e,{...c,channelCount:1,channelCountMode:o,numberOfInputs:2}),h=s(e,{...c,channelCount:n,channelCountMode:o,gain:1}),p=s(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:d,disconnectGraph:f}=l(e,n,h,p,u);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 h.channelCount},set channelCount(t){h.channelCount!==t&&(_&&f(),({connectGraph:d,disconnectGraph:f}=l(e,t,h,p,u)),_&&d()),h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[h]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get pan(){return p.gain},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])};let _=!1;return r(ne(m,u),(()=>{d(),_=!0}),(()=>{f(),_=!1}))}})(ws,se,re,Ks,ue,vs),an=((t,e)=>(s,n)=>{const i=n.channelCountMode;if("clamped-max"===i)throw e();if(void 0===s.createStereoPanner)return t(s,n);const r=s.createStereoPanner();return Xt(r,n),Yt(r,n,"pan"),Object.defineProperty(r,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),r})(on,ue),cn=((t,e,s,n,i)=>()=>{const r=new WeakMap;return{render(o,a){const c=r.get(a);return void 0!==c?Promise.resolve(c):(async(o,a)=>{let c=s(o);const u=U(c,a);if(!u){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(a,t)}return r.set(a,c),u?await t(a,o.pan,c.pan):await n(a,o.pan,c.pan),ut(c)?await i(o,a,c.inputs[0]):await i(o,a,c),c})(o,a)}}})(as,an,mt,us,Ve),un=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=i(t),c={...fe,...o},u=s(a,c),h=r(a);super(t,!1,u,h?n():null),this._pan=e(this,h,u.pan)}get pan(){return this._pan}})(Ze,ls,an,cn,qe,ze),hn=((t,e,s)=>()=>{const n=new WeakMap;return{render(i,r){const o=n.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!U(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample};o=t(r,e)}return n.set(r,o),ut(o)?await s(i,r,o.inputs[0]):await s(i,r,o),o})(i,r)}}})(Ks,mt,Ve),ln=((t,e,s,n,i,r,o)=>class extends t{constructor(t,e){const a=i(t),c={...me,...e},u=s(a,c);super(t,!0,u,r(a)?n():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=u,o(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}})(Ze,zt,Ks,hn,qe,ze,_s),pn=(t=>null!==t&&t.isSecureContext)(Re),dn=(t=>(e,s,n)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*s)},currentTime:{configurable:!0,get:()=>e}});try{return n()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(Re),fn=new WeakMap,mn=((t,e)=>s=>{let n=t.get(s);if(void 0!==n)return n;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return n=new e(1,1,44100),t.set(s,n),n})(fn,je),_n=pn?((t,e,s,n,i,r,o,a,c,u,h,l,p)=>{let d=0;return(f,m,_={credentials:"omit"})=>{const g=h.get(f);if(void 0!==g&&g.has(m))return Promise.resolve();const v=u.get(f);if(void 0!==v){const t=v.get(m);if(void 0!==t)return t}const y=r(f),w=void 0===y.audioWorklet?i(m).then((([t,e])=>{const[n,i]=R(t,e);return s(`${n};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}\n})})(window,'_AWGS')`)})).then((()=>{const t=p._AWGS.pop();if(void 0===t)throw new SyntaxError;n(y.currentTime,y.sampleRate,(()=>t(class{},void 0,((t,s)=>{if(""===t.trim())throw e();const n=M.get(y);if(void 0!==n){if(n.has(t))throw e();B(s),N(s.parameterDescriptors),n.set(t,s)}else B(s),N(s.parameterDescriptors),M.set(y,new Map([[t,s]]))}),y.sampleRate,void 0,void 0)))})):Promise.all([i(m),Promise.resolve(t(l,l))]).then((([[t,e],s])=>{const n=d+1;d=n;const[i,r]=R(t,e),u=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${r}\n})(${s?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${s?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${s?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${n}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),h=URL.createObjectURL(u);return y.audioWorklet.addModule(h,_).then((()=>{if(a(y))return y;const t=o(y);return t.audioWorklet.addModule(h,_).then((()=>t))})).then((t=>{if(null===c)throw new SyntaxError;try{new c(t,`__sac${n}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(h)))}));return void 0===v?u.set(f,new Map([[m,w]])):v.set(m,w),w.then((()=>{const t=h.get(f);void 0===t?h.set(f,new Set([m])):t.add(m)})).finally((()=>{const t=u.get(f);void 0!==t&&t.delete(m)})),w}})(Ee,ue,(t=>e=>new Promise(((s,n)=>{if(null===t)return void n(new SyntaxError);const i=t.document.head;if(null===i)n(new SyntaxError);else{const r=t.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),c=t.onerror,u=()=>{t.onerror=c,URL.revokeObjectURL(a)};t.onerror=(e,s,i,r,o)=>s===a||s===t.location.href&&1===i&&1===r?(u(),n(o),!1):null!==c?c(e,s,i,r,o):void 0,r.onerror=()=>{u(),n(new SyntaxError)},r.onload=()=>{u(),s()},r.src=a,r.type="module",i.appendChild(r)}})))(Re),dn,(t=>async e=>{try{const t=await fetch(e);if(t.ok)return[await t.text(),t.url]}catch{}throw t()})((()=>new DOMException("","AbortError"))),qe,mn,ze,Xe,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const s=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),n=new e(1,128,44100),i=URL.createObjectURL(s);let r=!1,o=!1;try{await n.audioWorklet.addModule(i);const e=new t(n,"a",{numberOfOutputs:0}),s=n.createOscillator();e.port.onmessage=()=>r=!0,e.onprocessorerror=()=>o=!0,s.connect(e),s.start(0),await n.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return r&&!o})(Xe,je),Re):void 0,gn=((t,e)=>s=>t(s)||e(s))(Ue,ze),vn=((t,e,s,n,i,r,o,a,c,u,h)=>(l,p)=>{const d=o(l)?l:r(l);if(i.has(p)){const t=s();return Promise.reject(t)}try{i.add(p)}catch{}return e(c,(()=>c(d)))?d.decodeAudioData(p).then((s=>(Vt(p).catch((()=>{})),e(a,(()=>a(s)))||h(s),t.add(s),s))):new Promise(((e,s)=>{const i=async()=>{try{await Vt(p)}catch{}},r=t=>{s(t),i()};try{d.decodeAudioData(p,(s=>{"function"!=typeof s.copyFromChannel&&(u(s),X(s)),t.add(s),i().then((()=>e(s)))}),(t=>{r(null===t?n():t)}))}catch(t){r(t)}}))})(Ke,Ee,(()=>new DOMException("","DataCloneError")),(()=>new DOMException("","EncodingError")),new WeakSet,qe,gn,G,Gt,ss,ns),yn=((t,e,s,n,i,r,o,a,c,u,h,l,p,d,f,m,_,g,v,y)=>class extends f{constructor(e,s){super(e,s),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,s)=>t(this,e,s)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,n){return new s({length:e,numberOfChannels:t,sampleRate:n})}createBufferSource(){return new n(this)}createChannelMerger(t=6){return new r(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new o(this,{numberOfOutputs:t})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(t=1){return new h(this,{maxDelayTime:t})}createDynamicsCompressor(){return new l(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,s={disableNormalization:!1}){return new g(this,{...s,imag:e,real:t})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(t,e,s){return u(this._nativeContext,t).then((t=>("function"==typeof e&&e(t),t)),(t=>{throw"function"==typeof s&&s(t),t}))}})(_n,Qe,is,ds,gs,bs,As,Os,Ds,vn,Rs,Vs,qs,Ls,Gs,Zs,sn,rn,un,ln),wn=((t,e,s,n)=>class extends t{constructor(t,i){const r=s(t),o=e(r,i);if(n(r))throw TypeError();super(t,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})(Ze,((t,e)=>t.createMediaElementSource(e.mediaElement)),qe,ze),xn=((t,e,s,n)=>class extends t{constructor(t,i){const r=s(t);if(n(r))throw new TypeError;const o={...Ut,...i},a=e(r,o);super(t,!1,a,null),this._nativeMediaStreamAudioDestinationNode=a}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})(Ze,((t,e)=>{const s=t.createMediaStreamDestination();return Xt(s,e),1===s.numberOfOutputs&&Object.defineProperty(s,"numberOfOutputs",{get:()=>0}),s}),qe,ze),bn=((t,e,s,n)=>class extends t{constructor(t,i){const r=s(t),o=e(r,i);if(n(r))throw new TypeError;super(t,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(Ze,((t,{mediaStream:e})=>{const s=e.getAudioTracks();s.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const n=s.slice(0,1),i=t.createMediaStreamSource(new MediaStream(n));return Object.defineProperty(i,"mediaStream",{value:e}),i}),qe,ze),Tn=((t,e)=>(s,{mediaStreamTrack:n})=>{if("function"==typeof s.createMediaStreamTrackSource)return s.createMediaStreamTrackSource(n);const i=new MediaStream([n]),r=s.createMediaStreamSource(i);if("audio"!==n.kind)throw t();if(e(s))throw new TypeError;return r})(zt,ze),An=((t,e,s)=>class extends t{constructor(t,n){const i=s(t);super(t,!0,e(i,n),null)}})(Ze,Tn,qe),kn=((t,e,s,n,i,r,o,a,c)=>class extends t{constructor(t={}){if(null===c)throw new Error("Missing the native AudioContext constructor.");let e;try{e=new c(t)}catch(t){if(12===t.code&&"sampleRate is not in range"===t.message)throw s();throw t}if(null===e)throw n();if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw s();super(e,2);const{latencyHint:i}=t,{sampleRate:r}=e;if(this._baseLatency="number"==typeof e.baseLatency?e.baseLatency:"balanced"===i?512/r:"interactive"===i||void 0===i?256/r:"playback"===i?1024/r:128*Math.max(2,Math.min(128,Math.round(i*r/128)))/r,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()),nt(this)})))}createMediaElementSource(t){return new i(this,{mediaElement:t})}createMediaStreamDestination(){return new r(this)}createMediaStreamSource(t){return new o(this,{mediaStream:t})}createMediaStreamTrackSource(t){return new a(this,{mediaStreamTrack:t})}resume(){return"suspended"===this._state?new Promise(((t,e)=>{const s=()=>{this._nativeAudioContext.removeEventListener("statechange",s),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",s)})):this._nativeAudioContext.resume().catch((t=>{if(void 0===t||15===t.code)throw e();throw t}))}suspend(){return this._nativeAudioContext.suspend().catch((t=>{if(void 0===t)throw e();throw t}))}})(yn,zt,ue,(()=>new DOMException("","UnknownError")),wn,xn,bn,An,He),Cn=(t=>e=>{const s=t.get(e);if(void 0===s)throw new Error("The context has no set of AudioWorkletNodes.");return s})(Us),Sn=(t=>(e,s)=>{t(e).add(s)})(Cn),On=(t=>(e,s,n=0,i=0)=>{const r=e[n];if(void 0===r)throw t();return xt(s)?r.connect(s,0,i):r.connect(s,0)})($),Mn=(t=>(e,s)=>{t(e).delete(s)})(Cn),En=(t=>(e,s=void 0,n=void 0,i=0)=>void 0===s?e.forEach((t=>t.disconnect())):"number"==typeof s?qt(t,e,s).disconnect():xt(s)?void 0===n?e.forEach((t=>t.disconnect(s))):void 0===i?qt(t,e,n).disconnect(s,0):qt(t,e,n).disconnect(s,0,i):void 0===n?e.forEach((t=>t.disconnect(s))):qt(t,e,n).disconnect(s,0))($),Dn=new WeakMap,In=((t,e)=>s=>e(t,s))(Dn,V),Rn=((t,e,s,n,i,r,o,a,c,u,h,l,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 x=new MessageChannel,b=[],T=[];for(let t=0;t<_.numberOfInputs;t+=1)b.push(o(d,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),T.push(i(d,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const A=[];if(void 0!==m.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:s,name:n}of m.parameterDescriptors){const i=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==_.parameterData[n]?_.parameterData[n]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?Q:e},minValue:{get:()=>void 0===s?Y:s}}),A.push(i)}const k=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,v+w)}),C=Jt(f,d.sampleRate),S=a(d,C,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(n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[t]}));for(let t=0;t<_.numberOfInputs;t+=1){b[t].connect(T[t]);for(let e=0;e<_.channelCount;e+=1)T[t].connect(k,e,t*_.channelCount+e)}const D=new kt(void 0===m.parameterDescriptors?[]:m.parameterDescriptors.map((({name:t},e)=>{const s=A[e];return s.connect(k,0,v+e),s.start(0),[t,s.offset]})));k.connect(S);let I=_.channelInterpretation,R=null;const N=0===_.numberOfOutputs?[S]:M,B={get bufferSize(){return C},get channelCount(){return _.channelCount},set channelCount(t){throw s()},get channelCountMode(){return _.channelCountMode},set channelCountMode(t){throw s()},get channelInterpretation(){return I},set channelInterpretation(t){for(const e of b)e.channelInterpretation=t;I=t},get context(){return S.context},get inputs(){return b},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get onprocessorerror(){return R},set onprocessorerror(t){"function"==typeof R&&B.removeEventListener("processorerror",R),R="function"==typeof t?t:null,"function"==typeof R&&B.addEventListener("processorerror",R)},get parameters(){return D},get port(){return x.port2},addEventListener:(...t)=>S.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,N),disconnect:u.bind(null,N),dispatchEvent:(...t)=>S.dispatchEvent(t[0]),removeEventListener:(...t)=>S.removeEventListener(t[0],t[1],t[2])},V=new Map;var P,q;x.port1.addEventListener=(P=x.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const s=V.get(t[1]);void 0!==s?t[1]=s:(t[1]=t=>{h(d.currentTime,d.sampleRate,(()=>e(t)))},V.set(e,t[1]))}}return P.call(x.port1,t[0],t[1],t[2])}),x.port1.removeEventListener=(q=x.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=V.get(t[1]);void 0!==e&&(V.delete(t[1]),t[1]=e)}return q.call(x.port1,t[0],t[1],t[2])});let F=null;Object.defineProperty(x.port1,"onmessage",{get:()=>F,set:t=>{"function"==typeof F&&x.port1.removeEventListener("message",F),F="function"==typeof t?t:null,"function"==typeof F&&(x.port1.addEventListener("message",F),x.port1.start())}}),m.prototype.port=x.port1;let j=null;const z=((t,e,s,n)=>{let i=E.get(t);void 0===i&&(i=new WeakMap,E.set(t,i));const r=te(s,n);return i.set(e,r),r})(d,B,m,_);z.then((t=>j=t));const W=Mt(_.numberOfInputs,_.channelCount),L=Mt(_.numberOfOutputs,g),H=void 0===m.parameterDescriptors?[]:m.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let U=!0;const G=()=>{_.numberOfOutputs>0&&S.disconnect(O);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const s=M[t];for(let n=0;n<g[t];n+=1)O.disconnect(s,e+n,n);e+=g[t]}},$=new Map;S.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==j){const s=l(B);for(let n=0;n<C;n+=128){for(let e=0;e<_.numberOfInputs;e+=1)for(let s=0;s<_.channelCount;s+=1)St(t,W[e],s,s,n);void 0!==m.parameterDescriptors&&m.parameterDescriptors.forEach((({name:e},s)=>{St(t,H,e,v+s,n)}));for(let t=0;t<_.numberOfInputs;t+=1)for(let e=0;e<g[t];e+=1)0===L[t][e].byteLength&&(L[t][e]=new Float32Array(128));try{const t=W.map(((t,e)=>{if(s[e].size>0)return $.set(e,C/128),t;const n=$.get(e);return void 0===n?[]:(t.every((t=>t.every((t=>0===t))))&&(1===n?$.delete(e):$.set(e,n-1)),t)})),i=h(d.currentTime+n/d.sampleRate,d.sampleRate,(()=>j.process(t,L,H)));U=i;for(let t=0,s=0;t<_.numberOfOutputs;t+=1){for(let i=0;i<g[t];i+=1)Ot(e,L[t],i,s+i,n);s+=g[t]}}catch(t){U=!1,B.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!U){for(let t=0;t<_.numberOfInputs;t+=1){b[t].disconnect(T[t]);for(let e=0;e<_.channelCount;e+=1)T[n].disconnect(k,e,t*_.channelCount+e)}if(void 0!==m.parameterDescriptors){const t=m.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=A[e];t.disconnect(k,0,v+e),t.stop()}}k.disconnect(S),S.onaudioprocess=null,X?G():J();break}}}};let X=!1;const Z=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),K=()=>S.connect(Z).connect(d.destination),J=()=>{S.disconnect(Z),Z.disconnect()};return K(),p(B,(()=>{if(U){J(),_.numberOfOutputs>0&&S.connect(O);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const s=M[t];for(let n=0;n<g[t];n+=1)O.connect(s,e+n,n);e+=g[t]}}X=!0}),(()=>{U&&(K(),G()),X=!1}))})(On,$,zt,ws,se,Cs,re,ce,ue,En,dn,In,vs),Nn=((t,e,s,n,i)=>(r,o,a,c,u,h)=>{if(null!==a)try{const e=new a(r,c,h),n=new Map;let o=null;if(Object.defineProperties(e,{channelCount:{get:()=>h.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>o,set:t=>{"function"==typeof o&&e.removeEventListener("processorerror",o),o="function"==typeof t?t:null,"function"==typeof o&&e.addEventListener("processorerror",o)}}}),e.addEventListener=(p=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const s=n.get(t[1]);void 0!==s?t[1]=s:(t[1]=s=>{"error"===s.type?(Object.defineProperties(s,{type:{value:"processorerror"}}),e(s)):e(new ErrorEvent(t[0],{...s}))},n.set(e,t[1]))}}return p.call(e,"error",t[1],t[2]),p.call(e,...t)}),e.removeEventListener=(l=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=n.get(t[1]);void 0!==e&&(n.delete(t[1]),t[1]=e)}return l.call(e,"error",t[1],t[2]),l.call(e,t[0],t[1],t[2])}),0!==h.numberOfOutputs){const t=s(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(t).connect(r.destination);return i(e,(()=>t.disconnect()),(()=>t.connect(r.destination)))}return e}catch(t){if(11===t.code)throw n();throw t}var l,p;if(void 0===u)throw n();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(h),e(r,o,u,h)})(zt,Rn,re,ue,vs),Bn=((t,e,s,n,i,r,o,a,c,u,h,l,p,d,f,m)=>(_,g,v)=>{const y=new WeakMap;let w=null;return{render(x,b){a(b,x);const T=y.get(b);return void 0!==T?Promise.resolve(T):(async(a,x)=>{let b=h(a),T=null;const A=U(b,x),k=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(null===l){const t=k.reduce(((t,e)=>t+e),0),s=i(x,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),r=[];for(let t=0;t<a.numberOfOutputs;t+=1)r.push(n(x,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:k[t]}));const u=o(x,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});u.connect=e.bind(null,r),u.disconnect=c.bind(null,r),T=[s,r,u]}else A||(b=new l(x,_));if(y.set(x,null===T?b:T[2]),null!==T){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,s=t+e,c=async()=>{const c=new p(s,128*Math.ceil(a.context.length/128),x.sampleRate),u=[],h=[];for(let t=0;t<g.numberOfInputs;t+=1)u.push(o(c,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),h.push(i(c,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const l=await Promise.all(Array.from(a.parameters.values()).map((async t=>{const e=r(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await d(c,t,e.offset),e}))),_=n(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<g.numberOfInputs;t+=1){u[t].connect(h[t]);for(let e=0;e<g.channelCount;e+=1)h[t].connect(_,e,t*g.channelCount+e)}for(const[e,s]of l.entries())s.connect(_,0,t+e),s.start(0);return _.connect(c.destination),await Promise.all(u.map((t=>f(a,c,t)))),m(c)};w=Et(a,0===s?null:await c(),x,g,k,v,u)}const t=await w,e=s(x,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,h,l]=T;null!==t&&(e.buffer=t,e.start(0)),e.connect(c);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const s=h[t];for(let n=0;n<k[t];n+=1)c.connect(s,e+n,n);e+=k[t]}return l}if(A)for(const[e,s]of a.parameters.entries())await t(x,s,b.parameters.get(e));else for(const[t,e]of a.parameters.entries())await d(x,e,b.parameters.get(t));return await f(a,x,b),b})(x,b)}}})(as,On,cs,ws,se,Cs,re,Mn,En,dn,mt,Xe,je,us,Ve,js),Vn=(t=>e=>t.get(e))(fn),Pn=(t=>(e,s)=>{t.set(e,s)})(Dn),qn=pn?((t,e,s,n,i,r,o,a,c,u,h,l,p,d)=>class extends e{constructor(e,d,f){var m;const _=a(e),g=c(_),v=h({...Ct,...f});p(v);const y=M.get(_),w=null==y?void 0:y.get(d),x=g||"closed"!==_.state?_:null!==(m=o(_))&&void 0!==m?m:_,b=i(x,g?null:e.baseLatency,u,d,w,v);super(e,!0,b,g?n(d,v,w):null);const T=[];b.parameters.forEach(((t,e)=>{const n=s(this,g,t);T.push([e,n])})),this._nativeAudioWorkletNode=b,this._onprocessorerror=null,this._parameters=new kt(T),g&&t(_,this);const{activeInputs:A}=r(this);l(b,A)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?d(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const s=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==s&&s===e?t:s}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(Sn,Ze,ls,Bn,Nn,tt,Vn,qe,ze,Xe,(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))})),Pn,(t=>{const{port1:e,port2:s}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),s.close()}}),Ae):void 0,Fn=((t,e)=>(s,n,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(s,n,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(ue,je),jn=((t,e,s,n,i,r,o,a)=>(c,u)=>s(c).render(c,u).then((()=>Promise.all(Array.from(n(u)).map((t=>s(t).render(t,u)))))).then((()=>i(u))).then((s=>("function"!=typeof s.copyFromChannel?(o(s),X(s)):e(r,(()=>r(s)))||a(s),t.add(s),s))))(Ke,Ee,Be,Cn,js,G,ss,ns),zn=((t,e,s,n,i)=>class extends t{constructor(t,s,i){let r;if("number"==typeof t&&void 0!==s&&void 0!==i)r={length:s,numberOfChannels:t,sampleRate:i};else{if("object"!=typeof t)throw new Error("The given parameters are not valid.");r=t}const{length:o,numberOfChannels:a,sampleRate:c}={...he,...r},u=n(a,o,c);e(Gt,(()=>Gt(u)))||u.addEventListener("statechange",(()=>{let t=0;const e=s=>{"running"===this._state&&(t>0?(u.removeEventListener("statechange",e),s.stopImmediatePropagation(),this._waitForThePromiseToSettle(s)):t+=1)};return e})()),super(u,a),this._length=o,this._nativeOfflineAudioContext=u,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(s()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally((()=>{this._state=null,nt(this)})))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout((()=>this._waitForThePromiseToSettle(t)))}})(yn,Ee,zt,Fn,jn),Wn=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(C,Ue),Ln=((t,e)=>s=>t.has(s)||e(s))(T,Ge),Hn=((t,e)=>s=>t.has(s)||e(s))(k,$e),Un=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(C,ze);function Gn(t,e){if(!t)throw new Error(e)}function $n(t,e,s=1/0){if(!(e<=t&&t<=s))throw new RangeError(`Value must be within [${e}, ${s}], got: ${t}`)}function Xn(t){t.isOffline||"running"===t.state||Yn('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Zn=console;function Yn(...t){Zn.warn(...t)}function Qn(t){return void 0===t}function Kn(t){return!Qn(t)}function Jn(t){return"number"==typeof t}function ti(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object}function ei(t){return"boolean"==typeof t}function si(t){return Array.isArray(t)}function ni(t){return"string"==typeof t}function ii(t){return ni(t)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(t)}const ri="object"==typeof self?self:null,oi=ri&&(ri.hasOwnProperty("AudioContext")||ri.hasOwnProperty("webkitAudioContext"));function ai(t,e,s,n){var i,r=arguments.length,o=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r<3?i(o):r>3?i(e,s,o):i(e,s))||o);return r>3&&o&&Object.defineProperty(e,s,o),o}function ci(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{c(n.next(t))}catch(t){r(t)}}function a(t){try{c(n.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class ui{constructor(t,e,s){this._callback=t,this._type=e,this._updateInterval=s,this._createClock()}_createWorker(){const t=new Blob([`\n\t\t\t// the initial timeout time\n\t\t\tlet timeoutTime = ${(1e3*this._updateInterval).toFixed(1)};\n\t\t\t// onmessage callback\n\t\t\tself.onmessage = function(msg){\n\t\t\t\ttimeoutTime = parseInt(msg.data);\n\t\t\t};\n\t\t\t// the tick function which posts a message\n\t\t\t// and schedules a new tick\n\t\t\tfunction tick(){\n\t\t\t\tsetTimeout(tick, timeoutTime);\n\t\t\t\tself.postMessage('tick');\n\t\t\t}\n\t\t\t// call tick initially\n\t\t\ttick();\n\t\t\t`],{type:"text/javascript"}),e=URL.createObjectURL(t),s=new Worker(e);s.onmessage=this._callback.bind(this),this._worker=s}_createTimeout(){this._timeout=setTimeout((()=>{this._createTimeout(),this._callback()}),1e3*this._updateInterval)}_createClock(){if("worker"===this._type)try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else"timeout"===this._type&&this._createTimeout()}_disposeClock(){this._timeout&&(clearTimeout(this._timeout),this._timeout=0),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){this._updateInterval=Math.max(t,128/44100),"worker"===this._type&&this._worker.postMessage(Math.max(1e3*t,1))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}}function hi(t){return Hn(t)}function li(t){return Ln(t)}function pi(t){return Un(t)}function di(t){return Wn(t)}function fi(t){return t instanceof AudioBuffer}function mi(t,e){return"value"===t||hi(e)||li(e)||fi(e)}function _i(t,...e){if(!e.length)return t;const s=e.shift();if(ti(t)&&ti(s))for(const e in s)mi(e,s[e])?t[e]=s[e]:ti(s[e])?(t[e]||Object.assign(t,{[e]:{}}),_i(t[e],s[e])):Object.assign(t,{[e]:s[e]});return _i(t,...e)}function gi(t,e,s=[],n){const i={},r=Array.from(e);if(ti(r[0])&&n&&!Reflect.has(r[0],n)){Object.keys(r[0]).some((e=>Reflect.has(t,e)))||(_i(i,{[n]:r[0]}),s.splice(s.indexOf(n),1),r.shift())}if(1===r.length&&ti(r[0]))_i(i,r[0]);else for(let t=0;t<s.length;t++)Kn(r[t])&&(i[s[t]]=r[t]);return _i(t,i)}function vi(t,e){return Qn(t)?e:t}function yi(t,e){return e.forEach((e=>{Reflect.has(t,e)&&delete t[e]})),t}
|
|
2
|
-
/**
|
|
3
|
-
* Tone.js
|
|
4
|
-
* @author Yotam Mann
|
|
5
|
-
* @license http://opensource.org/licenses/MIT MIT License
|
|
6
|
-
* @copyright 2014-2019 Yotam Mann
|
|
7
|
-
*/class wi{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ri&&this.toString()===ri.TONE_DEBUG_CLASS)&&function(...t){Zn.log(...t)}(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}wi.version=t;const xi=1e-6;function bi(t,e){return t>e+xi}function Ti(t,e){return bi(t,e)||ki(t,e)}function Ai(t,e){return t+xi<e}function ki(t,e){return Math.abs(t-e)<xi}class Ci extends wi{constructor(){super(),this.name="Timeline",this._timeline=[];const t=gi(Ci.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(Gn(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];Gn(Ti(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{const e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(t){const e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this}get(t,e="time"){const s=this._search(t,e);return-1!==s?this._timeline[s]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const s=this._search(t,e);return s+1<this._timeline.length?this._timeline[s+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const s=this._search(t);return s-1>=0?this._timeline[s-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(ki(this._timeline[e].time,t)){for(let s=e;s>=0&&ki(this._timeline[s].time,t);s--)e=s;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&Ti(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(0===this._timeline.length)return-1;let s=0;const n=this._timeline.length;let i=n;if(n>0&&this._timeline[n-1][e]<=t)return n-1;for(;s<i;){let n=Math.floor(s+(i-s)/2);const r=this._timeline[n],o=this._timeline[n+1];if(ki(r[e],t)){for(let s=n;s<this._timeline.length;s++){if(!ki(this._timeline[s][e],t))break;n=s}return n}if(Ai(r[e],t)&&bi(o[e],t))return n;bi(r[e],t)?i=n:s=n+1}return-1}_iterate(t,e=0,s=this._timeline.length-1){this._timeline.slice(e,s+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const s=this._search(t);return-1!==s&&this._iterate(e,0,s),this}forEachAfter(t,e){const s=this._search(t);return this._iterate(e,s+1),this}forEachBetween(t,e,s){let n=this._search(t),i=this._search(e);return-1!==n&&-1!==i?(this._timeline[n].time!==t&&(n+=1),this._timeline[i].time===e&&(i-=1),this._iterate(s,n,i)):-1===n&&this._iterate(s,0,i),this}forEachFrom(t,e){let s=this._search(t);for(;s>=0&&this._timeline[s].time>=t;)s--;return this._iterate(e,s+1),this}forEachAtTime(t,e){const s=this._search(t);if(-1!==s&&ki(this._timeline[s].time,t)){let n=s;for(let e=s;e>=0&&ki(this._timeline[e].time,t);e--)n=e;this._iterate((t=>{e(t)}),n,s)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const Si=[];function Oi(t){Si.push(t)}const Mi=[];function Ei(t){Mi.push(t)}class Di extends wi{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach((t=>{Qn(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)})),this}once(t,e){const s=(...n)=>{e(...n),this.off(t,s)};return this.on(t,s),this}off(t,e){return t.split(/\W+/).forEach((s=>{if(Qn(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(Qn(e))this._events[t]=[];else{const s=this._events[t];for(let t=s.length-1;t>=0;t--)s[t]===e&&s.splice(t,1)}})),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const s=this._events[t].slice(0);for(let t=0,n=s.length;t<n;t++)s[t].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach((e=>{const s=Object.getOwnPropertyDescriptor(Di.prototype,e);Object.defineProperty(t.prototype,e,s)}))}dispose(){return super.dispose(),this._events=void 0,this}}class Ii extends Di{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}}class Ri extends Ii{constructor(){super(),this.name="Context",this._constants=new Map,this._timeouts=new Ci,this._timeoutIds=0,this._initialized=!1,this.isOffline=!1,this._workletModules=new Map;const t=gi(Ri.getDefaults(),arguments,["context"]);t.context?this._context=t.context:this._context=function(t){return new kn(t)}({latencyHint:t.latencyHint}),this._ticker=new ui(this.emit.bind(this,"tick"),t.clockSource,t.updateInterval),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this._setLatencyHint(t.latencyHint),this.lookAhead=t.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){var t;return this._initialized||(t=this,Si.forEach((e=>e(t))),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,s){return this._context.createBuffer(t,e,s)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,s){return this._context.createPeriodicWave(t,e,s)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){Gn(di(this._context),"Not available if OfflineAudioContext");return this._context.createMediaStreamSource(t)}createMediaElementSource(t){Gn(di(this._context),"Not available if OfflineAudioContext");return this._context.createMediaElementSource(t)}createMediaStreamDestination(){Gn(di(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){Gn(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Gn(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Gn(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Gn(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,s){return Gn(Kn(qn),"This node only works in a secure context (https or localhost)"),new qn(t,e,s)}(this.rawContext,t,e)}addAudioWorkletModule(t,e){return ci(this,void 0,void 0,(function*(){Gn(Kn(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletModules.has(e)||this._workletModules.set(e,this.rawContext.audioWorklet.addModule(t)),yield this._workletModules.get(e)}))}workletsAreReady(){return ci(this,void 0,void 0,(function*(){const t=[];this._workletModules.forEach((e=>t.push(e))),yield Promise.all(t)}))}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 latencyHint(){return this._latencyHint}_setLatencyHint(t){let e=0;if(this._latencyHint=t,ni(t))switch(t){case"interactive":e=.1;break;case"playback":e=.5;break;case"balanced":e=.25}this.lookAhead=e,this.updateInterval=e/2}get rawContext(){return this._context}now(){return this._context.currentTime+this.lookAhead}immediate(){return this._context.currentTime}resume(){return di(this._context)?this._context.resume():Promise.resolve()}close(){return ci(this,void 0,void 0,(function*(){var t;di(this._context)&&(yield this._context.close()),this._initialized&&(t=this,Mi.forEach((e=>e(t))))}))}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),s=e.getChannelData(0);for(let e=0;e<s.length;e++)s[e]=t;const n=this._context.createBufferSource();return n.channelCount=1,n.channelCountMode="explicit",n.buffer=e,n.loop=!0,n.start(0),this._constants.set(t,n),n}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map((t=>this._constants[t].disconnect())),this}_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 s=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:s+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach((e=>{e.id===t&&this._timeouts.remove(e)})),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const s=++this._timeoutIds,n=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),n()},id:s,time:i+e})};return n(),s}}function Ni(t,e){si(e)?e.forEach((e=>Ni(t,e))):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function Bi(t,e){si(e)?e.forEach((e=>Bi(t,e))):Object.defineProperty(t,e,{writable:!0})}const Vi=()=>{};class Pi extends wi{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Vi;const t=gi(Pi.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,t.url&&fi(t.url)||t.url instanceof Pi?this.set(t.url):ni(t.url)&&this.load(t.url).catch(t.onerror)}static getDefaults(){return{onerror:Vi,onload:Vi,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:zi().sampleRate}set(t){return t instanceof Pi?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return ci(this,void 0,void 0,(function*(){const e=Pi.load(t).then((t=>{this.set(t),this.onload(this)}));Pi.downloads.push(e);try{yield e}finally{const t=Pi.downloads.indexOf(e);Pi.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=si(t)&&t[0].length>0,s=e?t.length:1,n=e?t[0].length:t.length,i=zi(),r=i.createBuffer(s,n,i.sampleRate),o=e||1!==s?t:[t];for(let t=0;t<s;t++)r.copyToChannel(o[t],t);return this._buffer=r,this}toMono(t){if(Jn(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let s=0;s<e;s++){const e=this.toArray(s);for(let s=0;s<e.length;s++)t[s]+=e[s]}t=t.map((t=>t/e)),this.fromArray(t)}return this}toArray(t){if(Jn(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){const s=Math.floor(t*this.sampleRate),n=Math.floor(e*this.sampleRate);Gn(s<n,"The start time must be less than the end time");const i=n-s,r=zi().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let t=0;t<this.numberOfChannels;t++)r.copyToChannel(this.getChannelData(t).subarray(s,n),t);return new Pi(r)}_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 Pi).fromArray(t)}static fromUrl(t){return ci(this,void 0,void 0,(function*(){const e=new Pi;return yield e.load(t)}))}static load(t){return ci(this,void 0,void 0,(function*(){const e=t.match(/\[([^\]\[]+\|.+)\]$/);if(e){const s=e[1].split("|");let n=s[0];for(const t of s)if(Pi.supportsType(t)){n=t;break}t=t.replace(e[0],n)}const s=""===Pi.baseUrl||Pi.baseUrl.endsWith("/")?Pi.baseUrl:Pi.baseUrl+"/",n=yield fetch(s+t);if(!n.ok)throw new Error(`could not load url: ${t}`);const i=yield n.arrayBuffer();return yield zi().decodeAudioData(i)}))}static supportsType(t){const e=t.split("."),s=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+s)}static loaded(){return ci(this,void 0,void 0,(function*(){for(yield Promise.resolve();Pi.downloads.length;)yield Pi.downloads[0]}))}}Pi.baseUrl="",Pi.downloads=[];class qi extends Ri{constructor(){var t,e,s;super({clockSource:"offline",context:pi(arguments[0])?arguments[0]:(t=arguments[0],e=arguments[1]*arguments[2],s=arguments[2],new zn(t,e,s)),lookAhead:0,updateInterval:pi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=pi(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return ci(this,void 0,void 0,(function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const s=Math.floor(this.sampleRate/128);t&&e%s==0&&(yield new Promise((t=>setTimeout(t,1))))}}))}render(t=!0){return ci(this,void 0,void 0,(function*(){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new Pi(e)}))}close(){return Promise.resolve()}}const Fi=new class extends Ii{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,s){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,s){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t,e){return ci(this,void 0,void 0,(function*(){return Promise.resolve()}))}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};let ji=Fi;function zi(){return ji===Fi&&oi&&Wi(new Ri),ji}function Wi(t){ji=di(t)?new Ri(t):pi(t)?new qi(t):t}if(ri&&!ri.TONE_SILENCE_LOGGING){const e=` * Tone.js ${"v"}${t} * `;console.log(`%c${e}`,"background: #000; color: #fff")}function Li(t){return Math.pow(2,t/12)}let Hi=440;function Ui(t){return Math.round(Gi(t))}function Gi(t){return 69+12*Math.log2(t/Hi)}class $i extends wi{constructor(t,e,s){super(),this.defaultUnits="s",this._val=e,this._units=s,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const s=parseInt(t,10),n="."===e?1.5:1;return 1===s?this._beatsToUnits(this._getTimeSignature())*n:this._beatsToUnits(4/s)*n},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(3*Math.floor(e)))},regexp:/^(\d+)t$/i},tr:{method:(t,e,s)=>{let n=0;return t&&"0"!==t&&(n+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n+=this._beatsToUnits(parseFloat(e))),s&&"0"!==s&&(n+=this._beatsToUnits(parseFloat(s)/4)),n},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof $i&&this.fromType(this._val),Qn(this._val))return this._noArg();if(ni(this._val)&&Qn(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(ti(this._val)){let t=0;for(const e in this._val)if(Kn(this._val[e])){const s=this._val[e];t+=new this.constructor(this.context,e).valueOf()*s}return t}if(Kn(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 ni(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 Xi extends $i{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 Xi(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const s=new this.constructor(this.context,t).valueOf(),n=this.valueOf();return n+(Math.round(n/s)*s-n)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const s=Math.pow(2,t);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let s=e[0],n=new Xi(this.context,e[0]).toSeconds();return e.forEach((e=>{const i=new Xi(this.context,e).toSeconds();Math.abs(i-t)<Math.abs(n-t)&&(s=e,n=i)})),s}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const s=Math.floor(e/this._getTimeSignature());let n=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=n.toString();i.length>3&&(n=parseFloat(parseFloat(i).toFixed(3)));return[s,e,n].join(":")}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.round(e*this._getPPQ())}toSeconds(){return this.valueOf()}toMidi(){return Ui(this.toFrequency())}_now(){return this.context.now()}}class Zi extends Xi{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Hi}static set A4(t){!function(t){Hi=t}(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return"midi"===this.defaultUnits?t:Zi.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method(t,e){const s=Yi[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?s:Zi.mtof(s)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,s){let n=1;return t&&"0"!==t&&(n*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(n*=this._beatsToUnits(parseFloat(e))),s&&"0"!==s&&(n*=this._beatsToUnits(parseFloat(s)/4)),n}}})}transpose(t){return new Zi(this.context,this.valueOf()*Li(t))}harmonize(t){return t.map((t=>this.transpose(t)))}toMidi(){return Ui(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/Zi.A4);let s=Math.round(12*e)+57;const n=Math.floor(s/12);n<0&&(s+=-12*n);return Qi[s%12]+n.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return function(t){return Hi*Math.pow(2,(t-69)/12)}(t)}static ftom(t){return Ui(t)}}const Yi={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},Qi=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];class Ki extends Xi{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}class Ji extends wi{constructor(){super();const t=gi(Ji.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:zi()}}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 new Xi(this.context,t).toSeconds()}toFrequency(t){return new Zi(this.context,t).toFrequency()}toTicks(t){return new Ki(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach((s=>{Qn(t[s])&&delete e[s]})),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach((e=>{if(Reflect.has(this,e)){const s=this[e];Kn(s)&&Kn(s.value)&&Kn(s.setValueAtTime)?t[e]=s.value:s instanceof Ji?t[e]=s._getPartialProperties(t[e]):si(s)||Jn(s)||ni(s)||ei(s)?t[e]=s:delete t[e]}})),t}set(t){return Object.keys(t).forEach((e=>{Reflect.has(this,e)&&Kn(this[e])&&(this[e]&&Kn(this[e].value)&&Kn(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof Ji?this[e].set(t[e]):this[e]=t[e])})),this}}class tr extends Ci{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){const e=this.get(t);return null!==e?e.state:this._initial}setStateAtTime(t,e,s){return $n(e,0),this.add(Object.assign({},s,{state:t,time:e})),this}getLastState(t,e){for(let s=this._search(e);s>=0;s--){const e=this._timeline[s];if(e.state===t)return e}}getNextState(t,e){const s=this._search(e);if(-1!==s)for(let e=s;e<this._timeline.length;e++){const s=this._timeline[e];if(s.state===t)return s}}}class er extends Ji{constructor(){super(gi(er.getDefaults(),arguments,["param","units","convert"])),this.name="Param",this.overridden=!1,this._minOutput=1e-7;const t=gi(er.getDefaults(),arguments,["param","units","convert"]);for(Gn(Kn(t.param)&&(hi(t.param)||t.param instanceof er),"param must be an AudioParam");!hi(t.param);)t.param=t.param._param;this._swappable=!!Kn(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 Ci(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,Kn(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Ji.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 Kn(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 Kn(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return Kn(this.maxValue)&&Kn(this.minValue)&&$n(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 s=this.toSeconds(e),n=this._fromType(t);return Gn(isFinite(n)&&isFinite(s),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this.log(this.units,"setValueAtTime",t,s),this._events.add({time:s,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,s),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),s=this._events.getAfter(e),n=this._events.get(e);let i=this._initialValue;if(null===n)i=this._initialValue;else if("setTargetAtTime"!==n.type||null!==s&&"setValueAtTime"!==s.type)if(null===s)i=n.value;else if("linearRampToValueAtTime"===s.type||"exponentialRampToValueAtTime"===s.type){let t=n.value;if("setTargetAtTime"===n.type){const e=this._events.getBefore(n.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===s.type?this._linearInterpolate(n.time,t,s.time,s.value,e):this._exponentialInterpolate(n.time,t,s.time,s.value,e)}else i=n.value;else{const t=this._events.getBefore(n.time);let s;s=null===t?this._initialValue:t.value,"setTargetAtTime"===n.type&&(i=this._exponentialApproach(n.time,s,n.value,n.constant,e))}return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===this._fromType(e)&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const s=this._fromType(t),n=this.toSeconds(e);return Gn(isFinite(s)&&isFinite(n),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(s),this._events.add({time:n,type:"linearRampToValueAtTime",value:s}),this.log(this.units,"linearRampToValueAtTime",t,n),this._param.linearRampToValueAtTime(s,n),this}exponentialRampToValueAtTime(t,e){let s=this._fromType(t);s=ki(s,0)?this._minOutput:s,this._assertRange(s);const n=this.toSeconds(e);return Gn(isFinite(s)&&isFinite(n),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:n,type:"exponentialRampToValueAtTime",value:s}),this.log(this.units,"exponentialRampToValueAtTime",t,n),this._param.exponentialRampToValueAtTime(s,n),this}exponentialRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.exponentialRampToValueAtTime(t,s+this.toSeconds(e)),this}linearRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.linearRampToValueAtTime(t,s+this.toSeconds(e)),this}targetRampTo(t,e,s){return s=this.toSeconds(s),this.setRampPoint(s),this.exponentialApproachValueAtTime(t,s,e),this}exponentialApproachValueAtTime(t,e,s){e=this.toSeconds(e),s=this.toSeconds(s);const n=Math.log(s+1)/Math.log(200);return this.setTargetAtTime(t,e,n),this.cancelAndHoldAtTime(e+.9*s),this.linearRampToValueAtTime(t,e+s),this}setTargetAtTime(t,e,s){const n=this._fromType(t);Gn(isFinite(s)&&s>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(n),Gn(isFinite(n)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:s,time:i,type:"setTargetAtTime",value:n}),this.log(this.units,"setTargetAtTime",t,i,s),this._param.setTargetAtTime(n,i,s),this}setValueCurveAtTime(t,e,s,n=1){s=this.toSeconds(s),e=this.toSeconds(e);const i=this._fromType(t[0])*n;this.setValueAtTime(this._toType(i),e);const r=s/(t.length-1);for(let s=1;s<t.length;s++){const i=this._fromType(t[s])*n;this.linearRampToValueAtTime(this._toType(i),e+s*r)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return Gn(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){const e=this.toSeconds(t),s=this._fromType(this.getValueAtTime(e));Gn(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+s);const n=this._events.get(e),i=this._events.getAfter(e);return n&&ki(n.time,e)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),"linearRampToValueAtTime"===i.type?this.linearRampToValueAtTime(this._toType(s),e):"exponentialRampToValueAtTime"===i.type&&this.exponentialRampToValueAtTime(this._toType(s),e)),this._events.add({time:e,type:"setValueAtTime",value:s}),this._param.setValueAtTime(s,e),this}rampTo(t,e=.1,s){return"frequency"===this.units||"bpm"===this.units||"decibels"===this.units?this.exponentialRampTo(t,e,s):this.linearRampTo(t,e,s),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const s=this._events.get(e);if(s&&"setTargetAtTime"===s.type){const n=this._events.getAfter(s.time),i=n?n.time:e+2,r=(i-e)/10;for(let s=e;s<i;s+=r)t.linearRampToValueAtTime(this.getValueAtTime(s),s)}return this._events.forEachAfter(this.context.currentTime,(e=>{"cancelScheduledValues"===e.type?t.cancelScheduledValues(e.time):"setTargetAtTime"===e.type?t.setTargetAtTime(e.value,e.time,e.constant):t[e.type](e.value,e.time)})),this}setParam(t){Gn(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,s,n,i){return s+(e-s)*Math.exp(-(i-t)/n)}_linearInterpolate(t,e,s,n,i){return e+(i-t)/(s-t)*(n-e)}_exponentialInterpolate(t,e,s,n,i){return e*Math.pow(n/e,(i-t)/(s-t))}}class sr extends Ji{constructor(){super(...arguments),this.name="ToneAudioNode",this._internalChannels=[]}get numberOfInputs(){return Kn(this.input)?hi(this.input)||this.input instanceof er?1:this.input.numberOfInputs:0}get numberOfOutputs(){return Kn(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return Kn(t)&&(t instanceof sr||li(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();Gn(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,s=0){return ir(this,t,e,s),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Yn("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,s=0){return rr(this,t,e,s),this}chain(...t){return nr(this,...t),this}fan(...t){return t.forEach((t=>this.connect(t))),this}dispose(){return super.dispose(),Kn(this.input)&&(this.input instanceof sr?this.input.dispose():li(this.input)&&this.input.disconnect()),Kn(this.output)&&(this.output instanceof sr?this.output.dispose():li(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function nr(...t){const e=t.shift();t.reduce(((t,e)=>(t instanceof sr?t.connect(e):li(t)&&ir(t,e),e)),e)}function ir(t,e,s=0,n=0){for(Gn(Kn(t),"Cannot connect from undefined node"),Gn(Kn(e),"Cannot connect to undefined node"),(e instanceof sr||li(e))&&Gn(e.numberOfInputs>0,"Cannot connect to node with no inputs"),Gn(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof sr||e instanceof er;)Kn(e.input)&&(e=e.input);for(;t instanceof sr;)Kn(t.output)&&(t=t.output);hi(e)?t.connect(e,s):t.connect(e,s,n)}function rr(t,e,s=0,n=0){if(Kn(e))for(;e instanceof sr;)e=e.input;for(;!li(t);)Kn(t.output)&&(t=t.output);hi(e)?t.disconnect(e,s):li(e)?t.disconnect(e,s,n):t.disconnect()}class or extends sr{constructor(){super(gi(or.getDefaults(),arguments,["gain","units"])),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode;const t=gi(or.getDefaults(),arguments,["gain","units"]);this.gain=new er({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),Ni(this,"gain")}static getDefaults(){return Object.assign(sr.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class ar extends sr{constructor(t){super(t),this.onended=Vi,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new or({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(sr.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Vi})}_startGain(t,e=1){Gn(-1===this._startTime,"Source cannot be started more than once");const s=this.toSeconds(this._fadeIn);return this._startTime=t+s,this._startTime=Math.max(this._startTime,this.context.currentTime),s>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+s):this._gainNode.gain.exponentialApproachValueAtTime(e,t,s)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Gn(-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.context.currentTime),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!==Vi&&(this.onended(this),this.onended=Vi,!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"),Gn(-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.disconnect(),this}}class cr extends ar{constructor(){super(gi(cr.getDefaults(),arguments,["offset"])),this.name="ToneConstantSource",this._source=this.context.createConstantSource();const t=gi(cr.getDefaults(),arguments,["offset"]);ir(this._source,this._gainNode),this.offset=new er({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(ar.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 ur extends sr{constructor(){super(gi(ur.getDefaults(),arguments,["value","units"])),this.name="Signal",this.override=!0;const t=gi(ur.getDefaults(),arguments,["value","units"]);this.output=this._constantSource=new cr({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(sr.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,s=0){return hr(this,t,e,s),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,s){return this._param.exponentialRampTo(t,e,s),this}linearRampTo(t,e,s){return this._param.linearRampTo(t,e,s),this}targetRampTo(t,e,s){return this._param.targetRampTo(t,e,s),this}exponentialApproachValueAtTime(t,e,s){return this._param.exponentialApproachValueAtTime(t,e,s),this}setTargetAtTime(t,e,s){return this._param.setTargetAtTime(t,e,s),this}setValueCurveAtTime(t,e,s,n){return this._param.setValueCurveAtTime(t,e,s,n),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,s){return this._param.rampTo(t,e,s),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}function hr(t,e,s,n){(e instanceof er||hi(e)||e instanceof ur&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof ur&&(e.overridden=!0)),ir(t,e,s,n)}class lr extends er{constructor(){super(gi(lr.getDefaults(),arguments,["value"])),this.name="TickParam",this._events=new Ci(1/0),this._multiplier=1;const t=gi(lr.getDefaults(),arguments,["value"]);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(er.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,s){e=this.toSeconds(e),this.setRampPoint(e);const n=this._fromType(t),i=this._events.get(e),r=Math.round(Math.max(1/s,1));for(let t=0;t<=r;t++){const r=s*t+e,o=this._exponentialApproach(i.time,i.value,n,s,r);this.linearRampToValueAtTime(this._toType(o),r)}return this}setValueAtTime(t,e){const s=this.toSeconds(e);super.setValueAtTime(t,e);const n=this._events.get(s),i=this._events.previousEvent(n),r=this._getTicksUntilEvent(i,s);return n.ticks=Math.max(r,0),this}linearRampToValueAtTime(t,e){const s=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const n=this._events.get(s),i=this._events.previousEvent(n),r=this._getTicksUntilEvent(i,s);return n.ticks=Math.max(r,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const s=this._fromType(t),n=this._events.get(e),i=Math.round(Math.max(10*(e-n.time),1)),r=(e-n.time)/i;for(let t=0;t<=i;t++){const i=r*t+n.time,o=this._exponentialInterpolate(n.time,n.value,e,s,i);this.linearRampToValueAtTime(this._toType(o),i)}return this}_getTicksUntilEvent(t,e){if(null===t)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Qn(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const s=this._fromType(this.getValueAtTime(t.time));let n=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(n=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(s+n)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),s=this._events.get(e);return Math.max(this._getTicksUntilEvent(s,e),0)}getDurationOfTicks(t,e){const s=this.toSeconds(e),n=this.getTicksAtTime(e);return this.getTimeOfTick(n+t)-s}getTimeOfTick(t){const e=this._events.get(t,"ticks"),s=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&s&&"linearRampToValueAtTime"===s.type&&e.value!==s.value){const n=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(s.time))-n)/(s.time-e.time),r=Math.sqrt(Math.pow(n,2)-2*i*(e.ticks-t)),o=(-n+r)/i;return(o>0?o:(-n-r)/i)+e.time}return e?0===e.value?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){const s=this.toSeconds(e),n=this.toSeconds(t),i=this.getTicksAtTime(s);return this.getTicksAtTime(s+n)-i}_fromType(t){return"bpm"===this.units&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return"bpm"===this.units&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class pr extends ur{constructor(){super(gi(pr.getDefaults(),arguments,["value"])),this.name="TickSignal";const t=gi(pr.getDefaults(),arguments,["value"]);this.input=this._param=new lr({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(ur.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 dr extends Ji{constructor(){super(gi(dr.getDefaults(),arguments,["frequency"])),this.name="TickSource",this._state=new tr,this._tickOffset=new Ci;const t=gi(dr.getDefaults(),arguments,["frequency"]);this.frequency=new pr({context:this.context,units:t.units,value:t.frequency}),Ni(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Ji.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){const s=this.toSeconds(t);return"started"!==this._state.getValueAtTime(s)&&(this._state.setStateAtTime("started",s),Kn(e)&&this.setTicksAtTime(e,s)),this}stop(t){const e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){const t=this._state.get(e);t&&t.time>0&&(this._tickOffset.cancel(t.time),this._state.cancel(t.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&this._state.setStateAtTime("paused",e),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this}getTicksAtTime(t){const e=this.toSeconds(t),s=this._state.getLastState("stopped",e),n={state:"paused",time:e};this._state.add(n);let i=s,r=0;return this._state.forEachBetween(s.time,e+this.sampleTime,(t=>{let e=i.time;const s=this._tickOffset.get(t.time);s&&s.time>=i.time&&(r=s.ticks,e=s.time),"started"===i.state&&"started"!==t.state&&(r+=this.frequency.getTicksAtTime(t.time)-this.frequency.getTicksAtTime(e)),i=t})),this._state.remove(n),r}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),s=this.frequency.timeToTicks(t,e);this.setTicksAtTime(s,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),s={state:"paused",time:t};this._state.add(s);let n=e,i=0;return this._state.forEachBetween(e.time,t+this.sampleTime,(t=>{let e=n.time;const s=this._tickOffset.get(t.time);s&&s.time>=n.time&&(i=s.seconds,e=s.time),"started"===n.state&&"started"!==t.state&&(i+=t.time-e),n=t})),this._state.remove(s),i}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}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){const s=this._tickOffset.get(e),n=this._state.get(e),i=Math.max(s.time,n.time),r=this.frequency.getTicksAtTime(i)+t-s.ticks;return this.frequency.getTimeOfTick(r)}forEachTickBetween(t,e,s){let n=this._state.get(t);this._state.forEachBetween(t,e,(e=>{n&&"started"===n.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(n.time,t),e.time-this.sampleTime,s),n=e}));let i=null;if(n&&"started"===n.state){const r=Math.max(n.time,t),o=this.frequency.getTicksAtTime(r),a=o-this.frequency.getTicksAtTime(n.time);let c=Math.ceil(a)-a;c=ki(c,1)?0:c;let u=this.frequency.getTimeOfTick(o+c);for(;u<e;){try{s(u,Math.round(this.getTicksAtTime(u)))}catch(t){i=t;break}u+=this.frequency.getDurationOfTicks(1,u)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this.frequency.dispose(),this}}class fr extends Ji{constructor(){super(gi(fr.getDefaults(),arguments,["callback","frequency"])),this.name="Clock",this.callback=Vi,this._lastUpdate=0,this._state=new tr("stopped"),this._boundLoop=this._loop.bind(this);const t=gi(fr.getDefaults(),arguments,["callback","frequency"]);this.callback=t.callback,this._tickSource=new dr({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,Ni(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Ji.getDefaults(),{callback:Vi,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){Xn(this.context);const s=this.toSeconds(t);return this.log("start",s),"started"!==this._state.getValueAtTime(s)&&(this._state.setStateAtTime("started",s),this._tickSource.start(s,e),s<this._lastUpdate&&this.emit("start",s,e)),this}stop(t){const e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){const s=this.toSeconds(e),n=this.getTicksAtTime(s);return this._tickSource.getTimeOfTick(n+t,s)}_loop(){const t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,(t=>{switch(t.state){case"started":const e=this._tickSource.getTicksAtTime(t.time);this.emit("start",t.time,e);break;case"stopped":0!==t.time&&this.emit("stop",t.time);break;case"paused":this.emit("pause",t.time)}})),this._tickSource.forEachTickBetween(t,e,((t,e)=>{this.callback(t,e)})))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Di.mixin(fr);let mr=class t extends sr{constructor(){super(gi(t.getDefaults(),arguments,["delayTime","maxDelay"])),this.name="Delay";const e=gi(t.getDefaults(),arguments,["delayTime","maxDelay"]),s=this.toSeconds(e.maxDelay);this._maxDelay=Math.max(s,this.toSeconds(e.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(s),this.delayTime=new er({context:this.context,param:this._delayNode.delayTime,units:"time",value:e.delayTime,minValue:0,maxValue:this.maxDelay}),Ni(this,"delayTime")}static getDefaults(){return Object.assign(sr.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}};class _r extends wi{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=gi(_r.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach((e=>{this._loadingCount++;const s=t.urls[e];this.add(e,s,this._bufferLoaded.bind(this,t.onload),t.onerror)}))}static getDefaults(){return{baseUrl:"",onerror:Vi,onload:Vi,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Gn(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,0===this._loadingCount&&t&&t()}get loaded(){return Array.from(this._buffers).every((([t,e])=>e.loaded))}add(t,e,s=Vi,n=Vi){return ni(e)?this._buffers.set(t.toString(),new Pi(this.baseUrl+e,s,n)):this._buffers.set(t.toString(),new Pi(e,s,n)),this}dispose(){return super.dispose(),this._buffers.forEach((t=>t.dispose())),this._buffers.clear(),this}}class gr extends Ki{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}class vr extends Ji{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Ci,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}}Oi((t=>{t.draw=new vr({context:t})})),Ei((t=>{t.draw.dispose()}));class yr extends wi{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Gn(Kn(t.time),"Events must have a time property"),Gn(Kn(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new wr(t.time,t.time+t.duration,t);for(null===this._root?this._root=e:this._root.insert(e),this._length++;null!==e;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(null!==this._root){const e=[];this._root.search(t.time,e);for(const s of e)if(s.event===t){this._removeNode(s),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,(t=>this.remove(t))),this}_setRoot(t){this._root=t,null!==this._root&&(this._root.parent=null)}_replaceNodeInParent(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{let e,s=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,s=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,s=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,s=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,s=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),s&&this._rebalance(s)}t.dispose()}_rotateLeft(t){const e=t.parent,s=t.isLeftChild(),n=t.right;n&&(t.right=n.left,n.left=t),null!==e?s?e.left=n:e.right=n:this._setRoot(n)}_rotateRight(t){const e=t.parent,s=t.isLeftChild(),n=t.left;n&&(t.left=n.right,n.right=t),null!==e?s?e.left=n:e.right=n:this._setRoot(n)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(null!==this._root){const e=[];if(this._root.search(t,e),e.length>0){let t=e[0];for(let s=1;s<e.length;s++)e[s].low>t.low&&(t=e[s]);return t.event}}return null}forEach(t){if(null!==this._root){const e=[];this._root.traverse((t=>e.push(t))),e.forEach((e=>{e.event&&t(e.event)}))}return this}forEachAtTime(t,e){if(null!==this._root){const s=[];this._root.search(t,s),s.forEach((t=>{t.event&&e(t.event)}))}return this}forEachFrom(t,e){if(null!==this._root){const s=[];this._root.searchAfter(t,s),s.forEach((t=>{t.event&&e(t.event)}))}return this}dispose(){return super.dispose(),null!==this._root&&this._root.traverse((t=>t.dispose())),this._root=null,this}}class wr{constructor(t,e,s){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=s,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)}traverse(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)}updateHeight(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t}isLeftChild(){return null!==this.parent&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}let xr=class t extends sr{constructor(){super(gi(t.getDefaults(),arguments,["volume"])),this.name="Volume";const e=gi(t.getDefaults(),arguments,["volume"]);this.input=this.output=new or({context:this.context,gain:e.volume,units:"decibels"}),this.volume=this.output.gain,Ni(this,"volume"),this._unmutedVolume=e.volume,this.mute=e.mute}static getDefaults(){return Object.assign(sr.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 br extends sr{constructor(){super(gi(br.getDefaults(),arguments)),this.name="Destination",this.input=new xr({context:this.context}),this.output=new or({context:this.context}),this.volume=this.input.volume;const t=gi(br.getDefaults(),arguments);nr(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(sr.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),nr(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}Oi((t=>{t.destination=new br({context:t})})),Ei((t=>{t.destination.dispose()}));class Tr extends wi{constructor(t){super(),this.name="TimelineValue",this._timeline=new Ci({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 Ar{constructor(t,e){this.id=Ar._eventId++;const s=Object.assign(Ar.getDefaults(),e);this.transport=t,this.callback=s.callback,this._once=s.once,this.time=s.time}static getDefaults(){return{callback:Vi,once:!1,time:0}}invoke(t){this.callback&&(this.callback(t),this._once&&this.transport.clear(this.id))}dispose(){return this.callback=void 0,this}}Ar._eventId=0;class kr extends Ar{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const s=Object.assign(kr.getDefaults(),e);this.duration=new gr(t.context,s.duration).valueOf(),this._interval=new gr(t.context,s.interval).valueOf(),this._nextTick=s.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Ar.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvents(t){const e=this.transport.getTicksAtTime(t);e>=this.time&&e>=this._nextTick&&this._nextTick+this._interval<this.time+this.duration&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new gr(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.time;const e=this.transport.getTicksAtTime(t);e>this.time&&(this._nextTick=this.time+Math.ceil((e-this.time)/this._interval)*this._interval),this._currentId=this.transport.scheduleOnce(this.invoke.bind(this),new gr(this.context,this._nextTick).toSeconds()),this._nextTick+=this._interval,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new gr(this.context,this._nextTick).toSeconds())}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}}class Cr extends Ji{constructor(){super(gi(Cr.getDefaults(),arguments)),this.name="Transport",this._loop=new Tr(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Ci,this._repeatedEvents=new yr,this._syncedSignals=[],this._swingAmount=0;const t=gi(Cr.getDefaults(),arguments);this._ppq=t.ppq,this._clock=new fr({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),Ni(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(Ji.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!=0&&e%(2*this._swingTicks)!=0){const s=e%(2*this._swingTicks)/(2*this._swingTicks),n=Math.sin(s*Math.PI)*this._swingAmount;t+=new gr(this.context,2*this._swingTicks/3).toSeconds()*n}this._timeline.forEachAtTime(e,(e=>e.invoke(t)))}schedule(t,e){const s=new Ar(this,{callback:t,time:new Ki(this.context,e).toTicks()});return this._addEvent(s,this._timeline)}scheduleRepeat(t,e,s,n=1/0){const i=new kr(this,{callback:t,duration:new Xi(this.context,n).toTicks(),interval:new Xi(this.context,e).toTicks(),time:new Ki(this.context,s).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const s=new Ar(this,{callback:t,once:!0,time:new Ki(this.context,e).toTicks()});return this._addEvent(s,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,(t=>this.clear(t.id))),this._repeatedEvents.forEachFrom(e,(t=>this.clear(t.id))),this}_bindClockEvents(){this._clock.on("start",((t,e)=>{e=new gr(this.context,e).toSeconds(),this.emit("start",t,e)})),this._clock.on("stop",(t=>{this.emit("stop",t)})),this._clock.on("pause",(t=>{this.emit("pause",t)}))}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){let s;return Kn(e)&&(s=this.toTicks(e)),this._clock.start(t,s),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){si(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Xi(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Xi(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 gr(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 gr(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),s=this._clock.frequency.timeToTicks(t,e);this.ticks=s}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){const e=this.now();if("started"===this.state){const s=this._clock.getTicksAtTime(e),n=e+this._clock.frequency.getDurationOfTicks(Math.ceil(s)-s,e);this.emit("stop",n),this._clock.setTicksAtTime(t,n),this.emit("start",n,this._clock.getSecondsAtTime(n))}else this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return Math.round(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(),s=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(s,e)}}syncSignal(t,e){if(!e){const s=this.now();if(0!==t.getValueAtTime(s)){const n=1/(60/this.bpm.getValueAtTime(s)/this.PPQ);e=t.getValueAtTime(s)/n}else e=0}const s=new or(e);return this.bpm.connect(s),s.connect(t._param),this._syncedSignals.push({initial:t.value,ratio:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const s=this._syncedSignals[e];s.signal===t&&(s.ratio.dispose(),s.signal.value=s.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Bi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Di.mixin(Cr),Oi((t=>{t.transport=new Cr({context:t})})),Ei((t=>{t.transport.dispose()}));class Sr extends sr{constructor(t){super(t),this.input=void 0,this._state=new tr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Vi,this._syncedStop=Vi,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new xr({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,Ni(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(sr.getDefaults(),{mute:!1,onstop:Vi,volume:0})}get state(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,s){let n=Qn(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(n=this._clampToCurrentTime(n),this._synced||"started"!==this._state.getValueAtTime(n))if(this.log("start",n),this._state.setStateAtTime("started",n),this._synced){const t=this._state.get(n);t&&(t.offset=this.toSeconds(vi(e,0)),t.duration=s?this.toSeconds(s):void 0);const i=this.context.transport.schedule((t=>{this._start(t,e,s)}),n);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>n&&this._syncedStart(this.now(),this.context.transport.seconds)}else Xn(this.context),this._start(n,e,s);else Gn(bi(n,this._state.get(n).time),"Start time must be strictly greater than previous start time"),this._state.cancel(n),this._state.setStateAtTime("started",n),this.log("restart",n),this.restart(n,e,s);return this}stop(t){let e=Qn(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||Kn(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){const t=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(t)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,s){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,s)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(e>0){const s=this._state.get(e);if(s&&"started"===s.state&&s.time!==e){const n=e-this.toSeconds(s.time);let i;s.duration&&(i=this.toSeconds(s.duration)-n),this._start(t,this.toSeconds(s.offset)+n,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));"started"===this._state.getValueAtTime(e)&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach((t=>this.context.transport.clear(t))),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=Vi,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Or extends ar{constructor(){super(gi(Or.getDefaults(),arguments,["url","onload"])),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1;const t=gi(Or.getDefaults(),arguments,["url","onload"]);ir(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new er({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 Pi(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(ar.getDefaults(),{url:new Pi,loop:!1,loopEnd:0,loopStart:0,onload:Vi,onerror:Vi,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,s,n=1){Gn(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,n),e=this.loop?vi(e,this.loopStart):vi(e,0);let r=Math.max(this.toSeconds(e),0);if(this.loop){const t=this.toSeconds(this.loopEnd)||this.buffer.duration,e=this.toSeconds(this.loopStart),s=t-e;Ti(r,t)&&(r=(r-e)%s+e),ki(r,this.buffer.duration)&&(r=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Ai(r,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,r)),Kn(s)){let t=this.toSeconds(s);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class Mr extends Sr{constructor(){super(gi(Mr.getDefaults(),arguments,["type"])),this.name="Noise",this._source=null;const t=gi(Mr.getDefaults(),arguments,["type"]);this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Sr.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Gn(t in Ir,"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=Ir[this._type];this._source=new Or({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 Er=220500,Dr={brown:null,pink:null,white:null},Ir={get brown(){if(!Dr.brown){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Er);t[e]=s;let n=0;for(let t=0;t<Er;t++){const e=2*Math.random()-1;s[t]=(n+.02*e)/1.02,n=s[t],s[t]*=3.5}}Dr.brown=(new Pi).fromArray(t)}return Dr.brown},get pink(){if(!Dr.pink){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Er);let n,i,r,o,a,c,u;t[e]=s,n=i=r=o=a=c=u=0;for(let t=0;t<Er;t++){const e=2*Math.random()-1;n=.99886*n+.0555179*e,i=.99332*i+.0750759*e,r=.969*r+.153852*e,o=.8665*o+.3104856*e,a=.55*a+.5329522*e,c=-.7616*c-.016898*e,s[t]=n+i+r+o+a+c+u+.5362*e,s[t]*=.11,u=.115926*e}}Dr.pink=(new Pi).fromArray(t)}return Dr.pink},get white(){if(!Dr.white){const t=[];for(let e=0;e<2;e++){const s=new Float32Array(Er);t[e]=s;for(let t=0;t<Er;t++)s[t]=2*Math.random()-1}Dr.white=(new Pi).fromArray(t)}return Dr.white}};function Rr(t,e){return ci(this,void 0,void 0,(function*(){const s=e/t.context.sampleRate,n=new qi(1,s,t.context.sampleRate);new t.constructor(Object.assign(t.get(),{frequency:2/s,detune:0,context:n})).toDestination().start(0);return(yield n.render()).getChannelData(0)}))}class Nr extends ar{constructor(){super(gi(Nr.getDefaults(),arguments,["frequency","type"])),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator];const t=gi(Nr.getDefaults(),arguments,["frequency","type"]);ir(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new er({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new er({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),Ni(this,["frequency","detune"])}static getDefaults(){return Object.assign(ar.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}}let Br=class t extends Sr{constructor(){super(gi(t.getDefaults(),arguments,["frequency","type"])),this.name="Oscillator",this._oscillator=null;const e=gi(t.getDefaults(),arguments,["frequency","type"]);this.frequency=new ur({context:this.context,units:"frequency",value:e.frequency}),Ni(this,"frequency"),this.detune=new ur({context:this.context,units:"cents",value:e.detune}),Ni(this,"detune"),this._partials=e.partials,this._partialCount=e.partialCount,this._type=e.type,e.partialCount&&"custom"!==e.type&&(this._type=this.baseType+e.partialCount.toString()),this.phase=e.phase}static getDefaults(){return Object.assign(Sr.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),s=new Nr({context:this.context,onended:()=>this.onstop(this)});this._oscillator=s,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_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 t._periodicWaveCache.find((t=>{return t.phase===this._phase&&(e=t.partials,s=this._partials,e.length===s.length&&e.every(((t,e)=>s[e]===t)));var e,s}))}{const e=t._periodicWaveCache.find((t=>t.type===this._type&&t.phase===this._phase));return this._partialCount=e?e.partialCount:this._partialCount,e}}get type(){return this._type}set type(e){this._type=e;const s=-1!==["sine","square","sawtooth","triangle"].indexOf(e);if(0===this._phase&&s)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=e);else{const s=this._getCachedPeriodicWave();if(Kn(s)){const{partials:t,wave:e}=s;this._wave=e,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[s,n]=this._getRealImaginary(e,this._phase),i=this.context.createPeriodicWave(s,n);this._wave=i,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),t._periodicWaveCache.push({imag:n,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:s,type:this._type,wave:this._wave}),t._periodicWaveCache.length>100&&t._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){$n(t,0);let e=this._type;const s=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(s&&(e=s[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach(((t,s)=>e[s]=t)),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let s=2048;const n=new Float32Array(s),i=new Float32Array(s);let r=1;if("custom"===t){if(r=this._partials.length+1,this._partialCount=this._partials.length,s=r,0===this._partials.length)return[n,i]}else{const e=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);e?(r=parseInt(e[2],10)+1,this._partialCount=parseInt(e[2],10),t=e[1],r=Math.max(r,2),s=r):this._partialCount=0,this._partials=[]}for(let o=1;o<s;++o){const s=2/(o*Math.PI);let a;switch(t){case"sine":a=o<=r?1:0,this._partials[o-1]=a;break;case"square":a=1&o?2*s:0,this._partials[o-1]=a;break;case"sawtooth":a=s*(1&o?1:-1),this._partials[o-1]=a;break;case"triangle":a=1&o?s*s*2*(o-1>>1&1?-1:1):0,this._partials[o-1]=a;break;case"custom":a=this._partials[o-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}0!==a?(n[o]=-a*Math.sin(e*o),i[o]=a*Math.cos(e*o)):(n[o]=0,i[o]=0)}return[n,i]}_inverseFFT(t,e,s){let n=0;const i=t.length;for(let r=0;r<i;r++)n+=t[r]*Math.cos(r*s)+e[r]*Math.sin(r*s);return n}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let s=0;const n=2*Math.PI;for(let i=0;i<32;i++)s=Math.max(this._inverseFFT(t,e,i/32*n),s);return i=-this._inverseFFT(t,e,this._phase)/s,r=-1,o=1,Math.max(Math.min(i,o),r);var i,r,o}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(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(this,t)}))}dispose(){return super.dispose(),null!==this._oscillator&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Br._periodicWaveCache=[];class Vr extends sr{constructor(){super(Object.assign(gi(Vr.getDefaults(),arguments,["context"])))}connect(t,e=0,s=0){return hr(this,t,e,s),this}}class Pr extends Vr{constructor(){super(Object.assign(gi(Pr.getDefaults(),arguments,["mapping","length"]))),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper;const t=gi(Pr.getDefaults(),arguments,["mapping","length"]);si(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(ur.getDefaults(),{length:1024})}setMap(t,e=1024){const s=new Float32Array(e);for(let n=0,i=e;n<i;n++){const e=n/(i-1)*2-1;s[n]=t(e,n)}return this.curve=s,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){Gn(["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 qr extends Vr{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Pr({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 Fr extends ur{constructor(){super(Object.assign(gi(Fr.getDefaults(),arguments,["value"]))),this.name="Multiply",this.override=!1;const t=gi(Fr.getDefaults(),arguments,["value"]);this._mult=this.input=this.output=new or({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(ur.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class jr extends Sr{constructor(){super(gi(jr.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="AMOscillator",this._modulationScale=new qr({context:this.context}),this._modulationNode=new or({context:this.context});const t=gi(jr.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new Br({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 Br({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Fr({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),Ni(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Br.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(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(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 zr extends Sr{constructor(){super(gi(zr.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="FMOscillator",this._modulationNode=new or({context:this.context,gain:0});const t=gi(zr.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new Br({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 ur({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Br({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Fr({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Fr({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),Ni(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Br.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(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(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 Wr extends Sr{constructor(){super(gi(Wr.getDefaults(),arguments,["frequency","width"])),this.name="PulseOscillator",this._widthGate=new or({context:this.context,gain:0}),this._thresh=new Pr({context:this.context,mapping:t=>t<=0?-1:1});const t=gi(Wr.getDefaults(),arguments,["frequency","width"]);this.width=new ur({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Br({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),Ni(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Sr.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(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class Lr extends Sr{constructor(){super(gi(Lr.getDefaults(),arguments,["frequency","type","spread"])),this.name="FatOscillator",this._oscillators=[];const t=gi(Lr.getDefaults(),arguments,["frequency","type","spread"]);this.frequency=new ur({context:this.context,units:"frequency",value:t.frequency}),this.detune=new ur({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,Ni(this,["frequency","detune"])}static getDefaults(){return Object.assign(Br.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach((e=>e.start(t)))}_stop(t){t=this.toSeconds(t),this._forEach((e=>e.stop(t)))}_restart(t){this._forEach((e=>e.restart(t)))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach((e=>e.type=t))}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,s=t/(this._oscillators.length-1);this._forEach(((t,n)=>t.detune.value=e+s*n))}}get count(){return this._oscillators.length}set count(t){if($n(t,1),this._oscillators.length!==t){this._forEach((t=>t.dispose())),this._oscillators=[];for(let e=0;e<t;e++){const s=new Br({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):Vi});"custom"===this.type&&(s.partials=this._partials),this.frequency.connect(s.frequency),this.detune.connect(s.detune),s.detune.overridden=!1,s.connect(this.output),this._oscillators[e]=s}this.spread=this._spread,"started"===this.state&&this._forEach((t=>t.start()))}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach(((t,e)=>t.phase=this._phase+e/this.count*360))}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach((e=>e.baseType=t)),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach((e=>e.partials=t)))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach((e=>e.partialCount=t)),this._type=this._oscillators[0].type}asArray(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach((t=>t.dispose())),this}}class Hr extends Sr{constructor(){super(gi(Hr.getDefaults(),arguments,["frequency","modulationFrequency"])),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Fr({context:this.context,value:2});const t=gi(Hr.getDefaults(),arguments,["frequency","modulationFrequency"]);this._pulse=new Wr({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Br({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),Ni(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Sr.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(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Ur={am:jr,fat:Lr,fm:zr,oscillator:Br,pulse:Wr,pwm:Hr};class Gr extends Sr{constructor(){super(gi(Gr.getDefaults(),arguments,["frequency","type"])),this.name="OmniOscillator";const t=gi(Gr.getDefaults(),arguments,["frequency","type"]);this.frequency=new ur({context:this.context,units:"frequency",value:t.frequency}),this.detune=new ur({context:this.context,units:"cents",value:t.detune}),Ni(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Br.getDefaults(),zr.getDefaults(),jr.getDefaults(),Lr.getDefaults(),Wr.getDefaults(),Hr.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=Ur[t],s=this.now();if(this._oscillator){const t=this._oscillator;t.stop(s),this.context.setTimeout((()=>t.dispose()),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),"started"===this.state&&this._oscillator.start(s)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";"pwm"!==this._oscillator.type&&"pulse"!==this._oscillator.type&&(e=this._oscillator.type),"fm"===t?this.type="fm"+e:"am"===t?this.type="am"+e:"fat"===t?this.type="fat"+e:"oscillator"===t?this.type=e:"pulse"===t?this.type="pulse":"pwm"===t&&(this.type="pwm")}_getOscType(t,e){return t instanceof Ur[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")&&Jn(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")&&Jn(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"))&&ni(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(t=1024){return ci(this,void 0,void 0,(function*(){return Rr(this,t)}))}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class $r extends ur{constructor(){super(Object.assign(gi($r.getDefaults(),arguments,["value"]))),this.override=!1,this.name="Add",this._sum=new or({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,nr(this._constantSource,this._sum)}static getDefaults(){return Object.assign(ur.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class Xr extends Vr{constructor(){super(Object.assign(gi(Xr.getDefaults(),arguments,["min","max"]))),this.name="Scale";const t=gi(Xr.getDefaults(),arguments,["min","max"]);this._mult=this.input=new Fr({context:this.context,value:t.max-t.min}),this._add=this.output=new $r({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(Vr.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(t){this._min=t,this._setRange()}get max(){return this._max}set max(t){this._max=t,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}}class Zr extends Vr{constructor(){super(Object.assign(gi(Zr.getDefaults(),arguments))),this.name="Zero",this._gain=new or({context:this.context}),this.output=this._gain,this.input=void 0,ir(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),rr(this.context.getConstant(0),this._gain),this}}let Yr=class t extends sr{constructor(){super(gi(t.getDefaults(),arguments,["frequency","min","max"])),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=er.prototype._fromType,this._toType=er.prototype._toType,this._is=er.prototype._is,this._clampValue=er.prototype._clampValue;const e=gi(t.getDefaults(),arguments,["frequency","min","max"]);this._oscillator=new Br(e),this.frequency=this._oscillator.frequency,this._amplitudeGain=new or({context:this.context,gain:e.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new ur({context:this.context,units:"audioRange",value:0}),this._zeros=new Zr({context:this.context}),this._a2g=new qr({context:this.context}),this._scaler=this.output=new Xr({context:this.context,max:e.max,min:e.min}),this.units=e.units,this.min=e.min,this.max=e.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),Ni(this,["amplitude","frequency"]),this.phase=e.phase}static getDefaults(){return Object.assign(Br.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,type:"sine",units:"number"})}start(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this}stop(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}_setStoppedValue(){this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get min(){return this._toType(this._scaler.min)}set min(t){t=this._fromType(t),this._scaler.min=t}get max(){return this._toType(this._scaler.max)}set max(t){t=this._fromType(t),this._scaler.max=t}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(t){this._oscillator.partials=t,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t,this._setStoppedValue()}get units(){return this._units}set units(t){const e=this.min,s=this.max;this._units=t,this.min=e,this.max=s}get state(){return this._oscillator.state}connect(t,e,s){return(t instanceof er||t instanceof ur)&&(this.convert=t.convert,this.units=t.units),hr(this,t,e,s),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}};function Qr(t,e=1/0){const s=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return s.get(this)},set:function(n){$n(n,t,e),s.set(this,n)}})}}function Kr(t,e=1/0){const s=new WeakMap;return function(n,i){Reflect.defineProperty(n,i,{configurable:!0,enumerable:!0,get:function(){return s.get(this)},set:function(n){$n(this.toSeconds(n),t,e),s.set(this,n)}})}}class Jr extends Sr{constructor(){super(gi(Jr.getDefaults(),arguments,["url","onload"])),this.name="Player",this._activeSources=new Set;const t=gi(Jr.getDefaults(),arguments,["url","onload"]);this._buffer=new Pi({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(Sr.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Vi,onerror:Vi,playbackRate:1,reverse:!1})}load(t){return ci(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_onload(t=Vi){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),0!==this._activeSources.size||this._synced||"started"!==this._state.getValueAtTime(this.now())||(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,s){return super.start(t,e,s),this}_start(t,e,s){e=this._loop?vi(e,this._loopStart):vi(e,0);const n=this.toSeconds(e),i=s;s=vi(s,Math.max(this._buffer.duration-n,0));let r=this.toSeconds(s);r/=this._playbackRate,t=this.toSeconds(t);const o=new Or({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+r),this._state.setStateAtTime("stopped",t+r,{implicitEnd:!0})),this._activeSources.add(o),this._loop&&Qn(i)?o.start(t,n):o.start(t,n,r-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach((t=>t.stop(e)))}restart(t,e,s){return super.restart(t,e,s),this}_restart(t,e,s){this._stop(t),this._start(t,e,s)}seek(t,e){const s=this.toSeconds(e);if("started"===this._state.getValueAtTime(s)){const e=this.toSeconds(t);this._stop(s),this._start(s,e)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&$n(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&&$n(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(),s=this._state.getNextState("stopped",e);s&&s.implicitEnd&&(this._state.cancel(s.time),this._activeSources.forEach((t=>t.cancelStop()))),this._activeSources.forEach((s=>{s.playbackRate.setValueAtTime(t,e)}))}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach((t=>t.dispose())),this._activeSources.clear(),this._buffer.dispose(),this}}ai([Kr(0)],Jr.prototype,"fadeIn",void 0),ai([Kr(0)],Jr.prototype,"fadeOut",void 0);class to extends Vr{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Pr({context:this.context,mapping:t=>2*Math.abs(t)-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class eo extends Vr{constructor(){super(Object.assign(gi(eo.getDefaults(),arguments,["value"]))),this.name="Pow";const t=gi(eo.getDefaults(),arguments,["value"]);this._exponentScaler=this.input=this.output=new Pr({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(Vr.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}}let so=class t extends sr{constructor(){super(gi(t.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="Envelope",this._sig=new ur({context:this.context,value:0}),this.output=this._sig,this.input=void 0;const e=gi(t.getDefaults(),arguments,["attack","decay","sustain","release"]);this.attack=e.attack,this.decay=e.decay,this.sustain=e.sustain,this.release=e.release,this.attackCurve=e.attackCurve,this.releaseCurve=e.releaseCurve,this.decayCurve=e.decayCurve}static getDefaults(){return Object.assign(sr.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(ni(t))return t;{let s;for(s in no)if(no[s][e]===t)return s;return t}}_setCurve(t,e,s){if(ni(s)&&Reflect.has(no,s)){const n=no[s];ti(n)?"_decayCurve"!==t&&(this[t]=n[e]):this[t]=n}else{if(!si(s)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+s);this[t]=s}}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._decayCurve}set decayCurve(t){Gn(["linear","exponential"].some((e=>e===t)),`Invalid envelope curve: ${t}`),this._decayCurve=t}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let s=this.toSeconds(this.attack);const n=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0){s=(1-i)/(1/s)}if(s<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if("linear"===this._attackCurve)this._sig.linearRampTo(e,s,t);else if("exponential"===this._attackCurve)this._sig.targetRampTo(e,s,t);else{this._sig.cancelAndHoldAtTime(t);let n=this._attackCurve;for(let t=1;t<n.length;t++)if(n[t-1]<=i&&i<=n[t]){n=this._attackCurve.slice(t),n[0]=i;break}this._sig.setValueCurveAtTime(n,t,s,e)}if(n&&this.sustain<1){const i=e*this.sustain,r=t+s;this.log("decay",r),"linear"===this._decayCurve?this._sig.linearRampToValueAtTime(i,n+r):this._sig.exponentialApproachValueAtTime(i,r,n)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const s=this.toSeconds(this.release);s<this.sampleTime?this._sig.setValueAtTime(0,t):"linear"===this._releaseCurve?this._sig.linearRampTo(0,s,t):"exponential"===this._releaseCurve?this._sig.targetRampTo(0,s,t):(Gn(si(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,s,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,s=1){return e=this.toSeconds(e),this.triggerAttack(e,s),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,s=0){return hr(this,t,e,s),this}asArray(t=1024){return ci(this,void 0,void 0,(function*(){const e=t/this.context.sampleRate,s=new qi(1,e,this.context.sampleRate),n=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=n+this.toSeconds(this.release),r=.1*i,o=i+r,a=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/o,decay:e*this.toSeconds(this.decay)/o,release:e*this.toSeconds(this.release)/o,context:s}));a._sig.toDestination(),a.triggerAttackRelease(e*(n+r)/o,0);return(yield s.render()).getChannelData(0)}))}dispose(){return super.dispose(),this._sig.dispose(),this}};ai([Kr(0)],so.prototype,"attack",void 0),ai([Kr(0)],so.prototype,"decay",void 0),ai([Qr(0,1)],so.prototype,"sustain",void 0),ai([Kr(0)],so.prototype,"release",void 0);const no=(()=>{const t=128;let e,s;const n=[];for(e=0;e<t;e++)n[e]=Math.sin(e/127*(Math.PI/2));const i=[];for(e=0;e<127;e++){s=e/127;const t=Math.sin(s*(2*Math.PI)*6.4-Math.PI/2)+1;i[e]=t/10+.83*s}i[127]=1;const r=[];for(e=0;e<t;e++)r[e]=Math.ceil(e/127*5)/5;const o=[];for(e=0;e<t;e++)s=e/127,o[e]=.5*(1-Math.cos(Math.PI*s));const a=[];for(e=0;e<t;e++){s=e/127;const t=4*Math.pow(s,3)+.2,n=Math.cos(t*Math.PI*2*s);a[e]=Math.abs(n*(1-s))}function c(t){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=1-t[s];return e}return{bounce:{In:c(a),Out:a},cosine:{In:n,Out:(u=n,u.slice(0).reverse())},exponential:"exponential",linear:"linear",ripple:{In:i,Out:c(i)},sine:{In:o,Out:c(o)},step:{In:r,Out:c(r)}};var u})();class io extends sr{constructor(){super(gi(io.getDefaults(),arguments)),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease;const t=gi(io.getDefaults(),arguments);this._volume=this.output=new xr({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Ni(this,"volume")}static getDefaults(){return Object.assign(sr.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){const s=this["_original_"+t]=this[t];this[t]=(...t)=>{const n=t[e],i=this.context.transport.schedule((n=>{t[e]=n,s.apply(this,t)}),n);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach((t=>this.context.transport.clear(t))),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease),this}triggerAttackRelease(t,e,s,n){const i=this.toSeconds(s),r=this.toSeconds(e);return this.triggerAttack(t,i,n),this.triggerRelease(i+r),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class ro extends io{constructor(){super(gi(ro.getDefaults(),arguments));const t=gi(ro.getDefaults(),arguments);this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(io.getDefaults(),{detune:0,onsilence:Vi,portamento:0})}triggerAttack(t,e,s=1){this.log("triggerAttack",t,e,s);const n=this.toSeconds(e);return this._triggerEnvelopeAttack(n,s),this.setNote(t,n),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const s=this.toSeconds(e),n=t instanceof Zi?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(s)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(n,t,s)}else this.frequency.setValueAtTime(n,s);return this}}ai([Kr(0)],ro.prototype,"portamento",void 0);class oo extends so{constructor(){super(gi(oo.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new or({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 ao extends ro{constructor(){super(gi(ao.getDefaults(),arguments)),this.name="Synth";const t=gi(ao.getDefaults(),arguments);this.oscillator=new Gr(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 oo(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),Ni(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ro.getDefaults(),{envelope:Object.assign(yi(so.getDefaults(),Object.keys(sr.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(yi(Gr.getDefaults(),[...Object.keys(Sr.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),s=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+s)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class co extends sr{constructor(){super(gi(co.getDefaults(),arguments,["frequency","type"])),this.name="BiquadFilter";const t=gi(co.getDefaults(),arguments,["frequency","type"]);this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new er({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new er({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new er({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new er({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(sr.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Gn(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let s=0;s<t;s++){const n=19980*Math.pow(s/t,2)+20;e[s]=n}const s=new Float32Array(t),n=new Float32Array(t),i=this.context.createBiquadFilter();return i.type=this.type,i.Q.value=this.Q.value,i.frequency.value=this.frequency.value,i.gain.value=this.gain.value,i.getFrequencyResponse(e,s,n),s}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}let uo=class t extends sr{constructor(){super(gi(t.getDefaults(),arguments,["frequency","type","rolloff"])),this.name="Filter",this.input=new or({context:this.context}),this.output=new or({context:this.context}),this._filters=[];const e=gi(t.getDefaults(),arguments,["frequency","type","rolloff"]);this._filters=[],this.Q=new ur({context:this.context,units:"positive",value:e.Q}),this.frequency=new ur({context:this.context,units:"frequency",value:e.frequency}),this.detune=new ur({context:this.context,units:"cents",value:e.detune}),this.gain=new ur({context:this.context,units:"decibels",convert:!1,value:e.gain}),this._type=e.type,this.rolloff=e.rolloff,Ni(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(sr.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){Gn(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),`Invalid filter type: ${t}`),this._type=t,this._filters.forEach((e=>e.type=t))}get rolloff(){return this._rolloff}set rolloff(t){const e=Jn(t)?t:parseInt(t,10),s=[-12,-24,-48,-96];let n=s.indexOf(e);Gn(-1!==n,`rolloff can only be ${s.join(", ")}`),n+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach((t=>t.disconnect())),this._filters=new Array(n);for(let t=0;t<n;t++){const e=new co({context:this.context});e.type=this._type,this.frequency.connect(e.frequency),this.detune.connect(e.detune),this.Q.connect(e.Q),this.gain.connect(e.gain),this._filters[t]=e}this._internalChannels=this._filters,nr(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){const e=new co({frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),s=new Float32Array(t).map((()=>1));return this._filters.forEach((()=>{e.getFrequencyResponse(t).forEach(((t,e)=>s[e]*=t))})),e.dispose(),s}dispose(){return super.dispose(),this._filters.forEach((t=>{t.dispose()})),Bi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};class ho extends so{constructor(){super(gi(ho.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="FrequencyEnvelope";const t=gi(ho.getDefaults(),arguments,["attack","decay","sustain","release"]);this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new eo({context:this.context,value:t.exponent}),this._scale=this.output=new Xr({context:this.context,min:this._baseFrequency,max:this._baseFrequency*Math.pow(2,this._octaves)}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(so.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){const e=this.toFrequency(t);$n(e,0),this._baseFrequency=e,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._scale.max=this._baseFrequency*Math.pow(2,t)}get exponent(){return this._exponent.value}set exponent(t){this._exponent.value=t}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class lo extends ao{constructor(){super(gi(lo.getDefaults(),arguments)),this.name="MembraneSynth",this.portamento=0;const t=gi(lo.getDefaults(),arguments);this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Ni(this,["oscillator","envelope"])}static getDefaults(){return _i(ro.getDefaults(),ao.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const s=this.toSeconds(e),n=this.toFrequency(t instanceof Zi?t.toFrequency():t),i=n*this.octaves;return this.oscillator.frequency.setValueAtTime(i,s),this.oscillator.frequency.exponentialRampToValueAtTime(n,s+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}ai([Qr(0)],lo.prototype,"octaves",void 0),ai([Kr(0)],lo.prototype,"pitchDecay",void 0);const po=new Set;function fo(t){po.add(t)}function mo(t,e){const s=`registerProcessor("${t}", ${e})`;po.add(s)}class _o extends sr{constructor(t){super(t),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=Vi;const e=URL.createObjectURL(new Blob([Array.from(po).join("\n")],{type:"text/javascript"})),s=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(e,s).then((()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(s,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))}))}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage("dispose"),this._worklet.disconnect()),this}}fo('\n\t/**\n\t * The base AudioWorkletProcessor for use in Tone.js. Works with the [[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');fo("\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");fo("\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");mo("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 go extends io{constructor(){super(gi(go.getDefaults(),arguments,["urls","onload","baseUrl"],"urls")),this.name="Sampler",this._activeSources=new Map;const t=gi(go.getDefaults(),arguments,["urls","onload","baseUrl"],"urls"),e={};Object.keys(t.urls).forEach((s=>{const n=parseInt(s,10);if(Gn(ii(s)||Jn(n)&&isFinite(n),`url key is neither a note or midi pitch: ${s}`),ii(s)){const n=new Zi(this.context,s).toMidi();e[n]=t.urls[s]}else Jn(n)&&isFinite(n)&&(e[n]=t.urls[n])})),this._buffers=new _r({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(io.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Vi,onerror:Vi,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,s=1){return this.log("triggerAttack",t,e,s),Array.isArray(t)||(t=[t]),t.forEach((t=>{const n=Gi(new Zi(this.context,t).toFrequency()),i=Math.round(n),r=n-i,o=this._findClosest(i),a=i-o,c=this._buffers.get(a),u=Li(o+r),h=new Or({url:c,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:u}).connect(this.output);h.start(e,0,c.duration/u,s),si(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(h),h.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){const t=this._activeSources.get(i),e=t.indexOf(h);-1!==e&&t.splice(e,1)}}})),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach((t=>{const s=new Zi(this.context,t).toMidi();if(this._activeSources.has(s)&&this._activeSources.get(s).length){const t=this._activeSources.get(s);e=this.toSeconds(e),t.forEach((t=>{t.stop(e)})),this._activeSources.set(s,[])}})),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach((t=>{for(;t.length;){t.shift().stop(e)}})),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,s,n=1){const i=this.toSeconds(s);return this.triggerAttack(t,i,n),si(e)?(Gn(si(t),"notes must be an array when duration is array"),t.forEach(((t,s)=>{const n=e[Math.min(s,e.length-1)];this.triggerRelease(t,i+this.toSeconds(n))}))):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,s){if(Gn(ii(t)||isFinite(t),`note must be a pitch or midi: ${t}`),ii(t)){const n=new Zi(this.context,t).toMidi();this._buffers.add(n,e,s)}else this._buffers.add(t,e,s);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach((t=>{t.forEach((t=>t.dispose()))})),this._activeSources.clear(),this}}ai([Kr(0)],go.prototype,"attack",void 0),ai([Kr(0)],go.prototype,"release",void 0);class vo extends Ji{constructor(){super(gi(vo.getDefaults(),arguments,["callback","value"])),this.name="ToneEvent",this._state=new tr("stopped"),this._startOffset=0;const t=gi(vo.getDefaults(),arguments,["callback","value"]);this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(Ji.getDefaults(),{callback:Vi,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(t=-1){this._state.forEachFrom(t,(t=>{let e;if("started"===t.state){-1!==t.id&&this.context.transport.clear(t.id);const s=t.time+Math.round(this.startOffset/this._playbackRate);if(!0===this._loop||Jn(this._loop)&&this._loop>1){e=1/0,Jn(this._loop)&&(e=this._loop*this._getLoopDuration());const n=this._state.getAfter(s);null!==n&&(e=Math.min(e,n.time-s)),e!==1/0&&(this._state.setStateAtTime("stopped",s+e+1,{id:-1}),e=new gr(this.context,e));const i=new gr(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new gr(this.context,s),e)}else t.id=this.context.transport.schedule(this._tick.bind(this),new gr(this.context,s))}}))}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t}get probability(){return this._probability}set probability(t){this._probability=t}get humanize(){return this._humanize}set humanize(t){this._humanize=t}start(t){const e=this.toTicks(t);return"stopped"===this._state.getValueAtTime(e)&&(this._state.add({id:-1,state:"started",time:e}),this._rescheduleEvents(e)),this}stop(t){this.cancel(t);const e=this.toTicks(t);if("started"===this._state.getValueAtTime(e)){this._state.setStateAtTime("stopped",e,{id:-1});const t=this._state.getBefore(e);let s=e;null!==t&&(s=t.time),this._rescheduleEvents(s)}return this}cancel(t){t=vi(t,-1/0);const e=this.toTicks(t);return this._state.forEachFrom(e,(t=>{this.context.transport.clear(t.id)})),this._state.cancel(e),this}_tick(t){const e=this.context.transport.getTicksAtTime(t);if(!this.mute&&"started"===this._state.getValueAtTime(e)){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let e=.02;ei(this.humanize)||(e=this.toSeconds(this.humanize)),t+=(2*Math.random()-1)*e}this.callback(t,this.value)}}_getLoopDuration(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)}get loop(){return this._loop}set loop(t){this._loop=t,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._rescheduleEvents()}get loopEnd(){return new gr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}get loopStart(){return new gr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){const s=this._getLoopDuration();return(t-e.time)%s/s}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class yo extends vo{constructor(){super(gi(yo.getDefaults(),arguments,["callback","events"])),this.name="Part",this._state=new tr("stopped"),this._events=new Set;const t=gi(yo.getDefaults(),arguments,["callback","events"]);this._state.increasing=!0,t.events.forEach((t=>{si(t)?this.add(t[0],t[1]):this.add(t)}))}static getDefaults(){return Object.assign(vo.getDefaults(),{events:[]})}start(t,e){const s=this.toTicks(t);if("started"!==this._state.getValueAtTime(s)){e=vi(e,this._loop?this._loopStart:0),e=this._loop?vi(e,this._loopStart):vi(e,0);const t=this.toTicks(e);this._state.add({id:-1,offset:t,state:"started",time:s}),this._forEach((e=>{this._startNote(e,s,t)}))}return this}_startNote(t,e,s){e-=s,this._loop?t.startOffset>=this._loopStart&&t.startOffset<this._loopEnd?(t.startOffset<s&&(e+=this._getLoopDuration()),t.start(new gr(this.context,e))):t.startOffset<this._loopStart&&t.startOffset>=s&&(t.loop=!1,t.start(new gr(this.context,e))):t.startOffset>=s&&t.start(new gr(this.context,e))}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t,this._forEach((t=>{t.startOffset+=this._startOffset}))}stop(t){const e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach((e=>{e.stop(t)})),this}at(t,e){const s=new Ki(this.context,t).toTicks(),n=new gr(this.context,1).toSeconds(),i=this._events.values();let r=i.next();for(;!r.done;){const t=r.value;if(Math.abs(s-t.startOffset)<n)return Kn(e)&&(t.value=e),t;r=i.next()}return Kn(e)?(this.add(t,e),this.at(t)):null}add(t,e){t instanceof Object&&Reflect.has(t,"time")&&(t=(e=t).time);const s=this.toTicks(t);let n;return e instanceof vo?(n=e,n.callback=this._tick.bind(this)):n=new vo({callback:this._tick.bind(this),context:this.context,value:e}),n.startOffset=s,n.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(n),this._restartEvent(n),this}_restartEvent(t){this._state.forEach((e=>{"started"===e.state?this._startNote(t,e.time,e.offset):t.stop(new gr(this.context,e.time))}))}remove(t,e){return ti(t)&&t.hasOwnProperty("time")&&(t=(e=t).time),t=this.toTicks(t),this._events.forEach((s=>{s.startOffset===t&&(Qn(e)||Kn(e)&&s.value===e)&&(this._events.delete(s),s.dispose())})),this}clear(){return this._forEach((t=>t.dispose())),this._events.clear(),this}cancel(t){return this._forEach((e=>e.cancel(t))),this._state.cancel(this.toTicks(t)),this}_forEach(t){return this._events&&this._events.forEach((e=>{e instanceof yo?e._forEach(t):t(e)})),this}_setAll(t,e){this._forEach((s=>{s[t]=e}))}_tick(t,e){this.mute||this.callback(t,e)}_testLoopBoundries(t){this._loop&&(t.startOffset<this._loopStart||t.startOffset>=this._loopEnd)?t.cancel(0):"stopped"===t.state&&this._restartEvent(t)}get probability(){return this._probability}set probability(t){this._probability=t,this._setAll("probability",t)}get humanize(){return this._humanize}set humanize(t){this._humanize=t,this._setAll("humanize",t)}get loop(){return this._loop}set loop(t){this._loop=t,this._forEach((e=>{e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.loop=t,this._testLoopBoundries(e)}))}get loopEnd(){return new gr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach((e=>{e.loopEnd=t,this._testLoopBoundries(e)}))}get loopStart(){return new gr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach((t=>{t.loopStart=this.loopStart,this._testLoopBoundries(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._setAll("playbackRate",t)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}class wo extends sr{constructor(){super(Object.assign(gi(wo.getDefaults(),arguments,["fade"]))),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new to({context:this.context}),this.a=new or({context:this.context,gain:0}),this.b=new or({context:this.context,gain:0}),this.output=new or({context:this.context}),this._internalChannels=[this.a,this.b];const t=gi(wo.getDefaults(),arguments,["fade"]);this.fade=new ur({context:this.context,units:"normalRange",value:t.fade}),Ni(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",ir(this._split,this.a.gain,0),ir(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign(sr.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}}let xo=class extends sr{constructor(t){super(t),this.name="Effect",this._dryWet=new wo({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new or({context:this.context}),this.effectReturn=new or({context:this.context}),this.input=new or({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],Ni(this,"wet")}static getDefaults(){return Object.assign(sr.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};class bo extends sr{constructor(){super(Object.assign(gi(bo.getDefaults(),arguments,["pan"]))),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner;const t=gi(bo.getDefaults(),arguments,["pan"]);this.pan=new er({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",Ni(this,"pan")}static getDefaults(){return Object.assign(sr.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}const To="bit-crusher";mo(To,"\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");let Ao=class t extends xo{constructor(){super(gi(t.getDefaults(),arguments,["bits"])),this.name="BitCrusher";const e=gi(t.getDefaults(),arguments,["bits"]);this._bitCrusherWorklet=new ko({context:this.context,bits:e.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(xo.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}};class ko extends _o{constructor(){super(gi(ko.getDefaults(),arguments)),this.name="BitCrusherWorklet";const t=gi(ko.getDefaults(),arguments);this.input=new or({context:this.context}),this.output=new or({context:this.context}),this.bits=new er({context:this.context,value:t.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(_o.getDefaults(),{bits:12})}_audioWorkletName(){return To}onReady(t){nr(this.input,t,this.output);const e=t.parameters.get("bits");this.bits.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class Co extends sr{constructor(){super(gi(Co.getDefaults(),arguments,["channels"])),this.name="Merge";const t=gi(Co.getDefaults(),arguments,["channels"]);this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(sr.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}let So=class t extends xo{constructor(){super(gi(t.getDefaults(),arguments,["distortion"])),this.name="Distortion";const e=gi(t.getDefaults(),arguments,["distortion"]);this._shaper=new Pr({context:this.context,length:4096}),this._distortion=e.distortion,this.connectEffect(this._shaper),this.distortion=e.distortion,this.oversample=e.oversample}static getDefaults(){return Object.assign(xo.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(t){this._distortion=t;const e=100*t,s=Math.PI/180;this._shaper.setMap((t=>Math.abs(t)<.001?0:(3+e)*t*20*s/(Math.PI+e*Math.abs(t))))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}};class Oo extends xo{constructor(t){super(t),this.name="FeedbackEffect",this._feedbackGain=new or({context:this.context,gain:t.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,Ni(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(xo.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class Mo extends Oo{constructor(){super(gi(Mo.getDefaults(),arguments,["delayTime","feedback"])),this.name="FeedbackDelay";const t=gi(Mo.getDefaults(),arguments,["delayTime","feedback"]);this._delayNode=new mr({context:this.context,delayTime:t.delayTime,maxDelay:t.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),Ni(this,"delayTime")}static getDefaults(){return Object.assign(Oo.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}let Eo=class t extends xo{constructor(){super(gi(t.getDefaults(),arguments,["decay"])),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const e=gi(t.getDefaults(),arguments,["decay"]);this._decay=e.decay,this._preDelay=e.preDelay,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(xo.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){$n(t=this.toSeconds(t),.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){$n(t=this.toSeconds(t),0),this._preDelay=t,this.generate()}generate(){return ci(this,void 0,void 0,(function*(){const t=this.ready,e=new qi(2,this._decay+this._preDelay,this.context.sampleRate),s=new Mr({context:e}),n=new Mr({context:e}),i=new Co({context:e});s.connect(i,0,0),n.connect(i,0,1);const r=new or({context:e}).toDestination();i.connect(r),s.start(0),n.start(0),r.gain.setValueAtTime(0,0),r.gain.setValueAtTime(1,this._preDelay),r.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const o=e.render();return this.ready=o.then(Vi),yield t,this._convolver.buffer=(yield o).get(),this}))}dispose(){return super.dispose(),this._convolver.disconnect(),this}};class Do extends sr{constructor(){super(gi(Do.getDefaults(),arguments,["solo"])),this.name="Solo";const t=gi(Do.getDefaults(),arguments,["solo"]);this.input=this.output=new or({context:this.context}),Do._allSolos.has(this.context)||Do._allSolos.set(this.context,new Set),Do._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(sr.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),Do._allSolos.get(this.context).forEach((t=>t._updateSolo()))}get muted(){return 0===this.input.gain.value}_addSolo(){Do._soloed.has(this.context)||Do._soloed.set(this.context,new Set),Do._soloed.get(this.context).add(this)}_removeSolo(){Do._soloed.has(this.context)&&Do._soloed.get(this.context).delete(this)}_isSoloed(){return Do._soloed.has(this.context)&&Do._soloed.get(this.context).has(this)}_noSolos(){return!Do._soloed.has(this.context)||Do._soloed.has(this.context)&&0===Do._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),Do._allSolos.get(this.context).delete(this),this._removeSolo(),this}}Do._allSolos=new Map,Do._soloed=new Map;class Io extends sr{constructor(){super(gi(Io.getDefaults(),arguments,["pan","volume"])),this.name="PanVol";const t=gi(Io.getDefaults(),arguments,["pan","volume"]);this._panner=this.input=new bo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new xr({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,Ni(this,["pan","volume"])}static getDefaults(){return Object.assign(sr.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 Ro extends sr{constructor(){super(gi(Ro.getDefaults(),arguments,["volume","pan"])),this.name="Channel";const t=gi(Ro.getDefaults(),arguments,["volume","pan"]);this._solo=this.input=new Do({solo:t.solo,context:this.context}),this._panVol=this.output=new Io({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),Ni(this,["pan","volume"])}static getDefaults(){return Object.assign(sr.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return Ro.buses.has(t)||Ro.buses.set(t,new or({context:this.context})),Ro.buses.get(t)}send(t,e=0){const s=this._getBus(t),n=new or({context:this.context,units:"decibels",gain:e});return this.connect(n),n.connect(s),n}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}Ro.buses=new Map;class No extends sr{constructor(){super(...arguments),this.name="Listener",this.positionX=new er({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new er({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new er({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new er({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new er({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new er({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new er({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new er({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new er({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(sr.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}}function Bo(){return zi().now()}Oi((t=>{t.listener=new No({context:t})})),Ei((t=>{t.listener.dispose()})),zi().transport,zi().destination,zi().destination,zi().listener,zi().draw,zi();const Vo={C0:16.35,"C#0":17.32,Db0:17.32,D0:18.35,"D#0":19.45,Eb0:19.45,E0:20.6,F0:21.83,"F#0":23.12,Gb0:23.12,G0:24.5,"G#0":25.96,Ab0:25.96,A0:27.5,"A#0":29.14,Bb0:29.14,B0:30.87,C1:32.7,"C#1":34.65,Db1:34.65,D1:36.71,"D#1":38.89,Eb1:38.89,E1:41.2,F1:43.65,"F#1":46.25,Gb1:46.25,G1:49,"G#1":51.91,Ab1:51.91,A1:55,"A#1":58.27,Bb1:58.27,B1:61.74,C2:65.41,"C#2":69.3,Db2:69.3,D2:73.42,"D#2":77.78,Eb2:77.78,E2:82.41,F2:87.31,"F#2":92.5,Gb2:92.5,G2:98,"G#2":103.83,Ab2:103.83,A2:110,"A#2":116.54,Bb2:116.54,B2:123.47,C3:130.81,"C#3":138.59,Db3:138.59,D3:146.83,"D#3":155.56,Eb3:155.56,E3:164.81,F3:174.61,"F#3":185,Gb3:185,G3:196,"G#3":207.65,Ab3:207.65,A3:220,"A#3":233.08,Bb3:233.08,B3:246.94,C4:261.63,"C#4":277.18,Db4:277.18,D4:293.66,"D#4":311.13,Eb4:311.13,E4:329.63,F4:349.23,"F#4":369.99,Gb4:369.99,G4:392,"G#4":415.3,Ab4:415.3,A4:440,"A#4":466.16,Bb4:466.16,B4:493.88,C5:523.25,"C#5":554.37,Db5:554.37,D5:587.33,"D#5":622.25,Eb5:622.25,E5:659.26,F5:698.46,"F#5":739.99,Gb5:739.99,G5:783.99,"G#5":830.61,Ab5:830.61,A5:880,"A#5":932.33,Bb5:932.33,B5:987.77,C6:1046.5,"C#6":1108.73,Db6:1108.73,D6:1174.66,"D#6":1244.51,Eb6:1244.51,E6:1318.51,F6:1396.91,"F#6":1479.98,Gb6:1479.98,G6:1567.98,"G#6":1661.22,Ab6:1661.22,A6:1760,"A#6":1864.66,Bb6:1864.66,B6:1975.53,C7:2093,"C#7":2217.46,Db7:2217.46,D7:2349.32,"D#7":2489.02,Eb7:2489.02,E7:2637.02,F7:2793.83,"F#7":2959.96,Gb7:2959.96,G7:3135.96,"G#7":3322.44,Ab7:3322.44,A7:3520,"A#7":3729.31,Bb7:3729.31,B7:3951.07,C8:4186.01,"C#8":4434.92,Db8:4434.92,D8:4698.64,"D#8":4978.03,Eb8:4978.03},Po=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],qo=Po.length;class Fo{static _notes;name;octave;velocity=1;duration;frequency;constructor(t){"number"==typeof t?this.fromFrequency(t):"string"==typeof t?this.fromString(t):t instanceof MIDIMessageEvent?this.fromEvent(t):this.fromProps(t)}static notes(t=3){return Po.map((e=>new Fo(`${e}${t}`)))}get isSemi(){return"#"===this.name.slice(-1)}get fullName(){return`${this.name}${this.octave}`}midiData(t=!0){return new Uint8Array([t?144:128,0,100*this.velocity])}get midiNumber(){return 12*(this.octave+2)+this.noteIndex}get noteIndex(){return Po.indexOf(this.name)}adjustFrequency(t=0,e=0){if(this.frequency)return this.frequency;let s=this.octave+t;const n=Po.indexOf(this.name)+e;let i=n;n>=qo?(s++,i=n%qo):n<0&&(s--,i=qo+i);const r=Po[i];return Vo[`${r}${s}`]}valueOf(){return this.fullName}serialize(){return{note:this.fullName,frequency:this.frequency,velocity:this.velocity,duration:this.duration}}fromFrequency(t){this.frequency=t}fromString(t){const e=t.match(/(\w#?)(\d)?/)||[];this.name=e[1],this.octave=e[2]?parseInt(e[2]):1}fromEvent(t){this.name=Po[t.data[1]%12],this.octave=Math.floor(t.data[1]/12)-2}fromProps(t){if(Object.assign(this,t),!t.note)throw Error("note props is mandatory");this.fromString(t.note)}}const jo={128:"noteOff",144:"noteOn",176:"cc"};class zo{note;voiceNo;triggeredAt;_type;data;event;static fromSequence(t,e){return t.notes.map((t=>this.fromNote(t,!0,e)))}static fromNote(t,e=!0,s){const n=t instanceof Fo?t:new Fo(t),i=new zo(new MIDIMessageEvent("",{data:n.midiData(e)}),s);return i.note=n,i}static fromCC(t,e,s){return new zo(new MIDIMessageEvent("",{data:new Uint8Array([176,t,e])}),s)}constructor(t,e){this.event=t,this.triggeredAt=e||Bo(),this.data=t.data,this.defineNotes()}get statusByte(){return this.data[0]}get firstData(){return this.data[1]}get secondData(){return this.data[2]}get type(){if(this._type)return this._type;let t=jo[240&this.statusByte];return"noteOn"===t&&0===this.secondData&&(t="noteOff"),this._type=t}get isNote(){return"noteOn"===this.type||"noteOff"===this.type}defineNotes(){this.isNote&&(this.note||(this.note=new Fo(this.event)))}}class Wo{id;name;state;eventListerCallbacks=[];_midi;constructor(t){this.id=t.id,this.name=t.name||`Device ${t.id}`,this.state=t.state,this._midi=t,this.connect()}connect(){this._midi.onmidimessage=t=>{(t instanceof MIDIMessageEvent||t instanceof zo)&&this.processEvent(t)}}disconnect(){this._midi.onmidimessage=null}serialize(){const{id:t,name:e,state:s}=this;return{id:t,name:e,state:s}}addEventListener(t){this.eventListerCallbacks.push(t)}removeEventListener(t){this.eventListerCallbacks=this.eventListerCallbacks.filter((e=>e!==t))}processEvent(t){const e=t instanceof zo?t:new zo(t);switch(e.type){case"noteOn":case"noteOff":this.eventListerCallbacks.forEach((t=>t(e)))}}}const Lo={a:new Fo("C3"),s:new Fo("D3"),d:new Fo("E3"),f:new Fo("F3"),g:new Fo("G3"),h:new Fo("A3"),j:new Fo("B3"),k:new Fo("C4"),l:new Fo("D4"),w:new Fo("C#3"),e:new Fo("D#3"),t:new Fo("F#3"),y:new Fo("G#3"),u:new Fo("A#3"),o:new Fo("C#4"),p:new Fo("D#4")},Ho={id:"computer_keyboard",name:"Computer Keyboard",state:"connected"};class Uo{id;name;state;onmidimessage;constructor(){Object.assign(this,Ho),document.addEventListener("keydown",this.onKeyTrigger(!0)),document.addEventListener("keyup",this.onKeyTrigger(!1))}onKeyTrigger=t=>e=>{if(!this.onmidimessage)return;const s=this.extractNote(e);if(!s)return;const n=zo.fromNote(s,t);this.onmidimessage(n)};extractNote(t){if(!t.repeat)return Lo[t.key]}}class Go{devices={};initialized=!1;computerKeyboardInput;constructor(){this.computerKeyboardInput=new Uo,this.initializeDevices().then((()=>{this.listenChanges(),this.initialized=!0})).catch((()=>{}))}find(t){const e=this.devices[t];return e||null}onStateChange(t){navigator.requestMIDIAccess().then((e=>{e.onstatechange=e=>{if(!(e instanceof MIDIConnectionEvent))return;if(e.port instanceof MIDIOutput)return;const s=e.port,n=new Wo(s);t(n)}})).catch((()=>{}))}listenChanges(){this.onStateChange((t=>{"disconnected"===t.state?(t.disconnect(),delete this.devices[t.id]):this.devices[t.id]=t}))}async initializeDevices(){return this.initialized||(await this.inputs()).forEach((t=>{this.devices[t.id]||(this.devices[t.id]=new Wo(t))})),Object.values(this.devices)}async inputs(){const t=[this.computerKeyboardInput];return(await navigator.requestMIDIAccess()).inputs.forEach((e=>t.push(e))),t}}var $o,Xo=new Uint8Array(16);function Zo(){if(!$o&&!($o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $o(Xo)}var Yo=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var Qo=[],Ko=0;Ko<256;++Ko)Qo.push((Ko+256).toString(16).substr(1));function Jo(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=(Qo[t[e+0]]+Qo[t[e+1]]+Qo[t[e+2]]+Qo[t[e+3]]+"-"+Qo[t[e+4]]+Qo[t[e+5]]+"-"+Qo[t[e+6]]+Qo[t[e+7]]+"-"+Qo[t[e+8]]+Qo[t[e+9]]+"-"+Qo[t[e+10]]+Qo[t[e+11]]+Qo[t[e+12]]+Qo[t[e+13]]+Qo[t[e+14]]+Qo[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Yo.test(t)}(s))throw TypeError("Stringified UUID is invalid");return s}function ta(t,e,s){var n=(t=t||{}).random||(t.rng||Zo)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){s=s||0;for(var i=0;i<16;++i)e[s+i]=n[i];return e}return Jo(n)}var ea="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function sa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var na={exports:{}};var ia,ra={exports:{}};function oa(){return ia||(ia=1,ra.exports=function(){var t=t||function(t,e){var s;if("undefined"!=typeof window&&window.crypto&&(s=window.crypto),"undefined"!=typeof self&&self.crypto&&(s=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(s=globalThis.crypto),!s&&"undefined"!=typeof window&&window.msCrypto&&(s=window.msCrypto),!s&&void 0!==ea&&ea.crypto&&(s=ea.crypto),!s)try{s=require("crypto")}catch(t){}var n=function(){if(s){if("function"==typeof s.getRandomValues)try{return s.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof s.randomBytes)try{return s.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function t(){}return function(e){var s;return t.prototype=e,s=new t,t.prototype=null,s}}(),r={},o=r.lib={},a=o.Base={extend:function(t){var e=i(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},c=o.WordArray=a.extend({init:function(t,s){t=this.words=t||[],this.sigBytes=s!=e?s:4*t.length},toString:function(t){return(t||h).stringify(this)},concat:function(t){var e=this.words,s=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var r=0;r<i;r++){var o=s[r>>>2]>>>24-r%4*8&255;e[n+r>>>2]|=o<<24-(n+r)%4*8}else for(var a=0;a<i;a+=4)e[n+a>>>2]=s[a>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,s=this.sigBytes;e[s>>>2]&=4294967295<<32-s%4*8,e.length=t.ceil(s/4)},clone:function(){var t=a.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],s=0;s<t;s+=4)e.push(n());return new c.init(e,t)}}),u=r.enc={},h=u.Hex={stringify:function(t){for(var e=t.words,s=t.sigBytes,n=[],i=0;i<s;i++){var r=e[i>>>2]>>>24-i%4*8&255;n.push((r>>>4).toString(16)),n.push((15&r).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,s=[],n=0;n<e;n+=2)s[n>>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new c.init(s,e/2)}},l=u.Latin1={stringify:function(t){for(var e=t.words,s=t.sigBytes,n=[],i=0;i<s;i++){var r=e[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(r))}return n.join("")},parse:function(t){for(var e=t.length,s=[],n=0;n<e;n++)s[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new c.init(s,e)}},p=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},d=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=p.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var s,n=this._data,i=n.words,r=n.sigBytes,o=this.blockSize,a=r/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,h=t.min(4*u,r);if(u){for(var l=0;l<u;l+=o)this._doProcessBlock(i,l);s=i.splice(0,u),n.sigBytes-=h}return new c.init(s,h)},clone:function(){var t=a.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});o.Hasher=d.extend({cfg:a.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,s){return new t.init(s).finalize(e)}},_createHmacHelper:function(t){return function(e,s){return new f.HMAC.init(t,s).finalize(e)}}});var f=r.algo={};return r}(Math);return t}()),ra.exports}var aa,ca={exports:{}};function ua(){return aa||(aa=1,ca.exports=function(t){return n=(s=t).lib,i=n.Base,r=n.WordArray,(o=s.x64={}).Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),o.WordArray=i.extend({init:function(t,s){t=this.words=t||[],this.sigBytes=s!=e?s:8*t.length},toX32:function(){for(var t=this.words,e=t.length,s=[],n=0;n<e;n++){var i=t[n];s.push(i.high),s.push(i.low)}return r.create(s,this.sigBytes)},clone:function(){for(var t=i.clone.call(this),e=t.words=this.words.slice(0),s=e.length,n=0;n<s;n++)e[n]=e[n].clone();return t}}),t;var e,s,n,i,r,o}(oa())),ca.exports}var ha,la={exports:{}};function pa(){return ha||(ha=1,la.exports=function(t){return function(){if("function"==typeof ArrayBuffer){var e=t.lib.WordArray,s=e.init,n=e.init=function(t){if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),(t instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),t instanceof Uint8Array){for(var e=t.byteLength,n=[],i=0;i<e;i++)n[i>>>2]|=t[i]<<24-i%4*8;s.call(this,n,e)}else s.apply(this,arguments)};n.prototype=e}}(),t.lib.WordArray}(oa())),la.exports}var da,fa={exports:{}};function ma(){return da||(da=1,fa.exports=function(t){return function(){var e=t,s=e.lib.WordArray,n=e.enc;function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,s=t.sigBytes,n=[],i=0;i<s;i+=2){var r=e[i>>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(r))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i<e;i++)n[i>>>1]|=t.charCodeAt(i)<<16-i%2*16;return s.create(n,2*e)}},n.Utf16LE={stringify:function(t){for(var e=t.words,s=t.sigBytes,n=[],r=0;r<s;r+=2){var o=i(e[r>>>2]>>>16-r%4*8&65535);n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>1]|=i(t.charCodeAt(r)<<16-r%2*16);return s.create(n,2*e)}}}(),t.enc.Utf16}(oa())),fa.exports}var _a,ga={exports:{}};function va(){return _a||(_a=1,ga.exports=function(t){return function(){var e=t,s=e.lib.WordArray;function n(t,e,n){for(var i=[],r=0,o=0;o<e;o++)if(o%4){var a=n[t.charCodeAt(o-1)]<<o%4*2|n[t.charCodeAt(o)]>>>6-o%4*2;i[r>>>2]|=a<<24-r%4*8,r++}return s.create(i,r)}e.enc.Base64={stringify:function(t){var e=t.words,s=t.sigBytes,n=this._map;t.clamp();for(var i=[],r=0;r<s;r+=3)for(var o=(e[r>>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,a=0;a<4&&r+.75*a<s;a++)i.push(n.charAt(o>>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(t){var e=t.length,s=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var r=0;r<s.length;r++)i[s.charCodeAt(r)]=r}var o=s.charAt(64);if(o){var a=t.indexOf(o);-1!==a&&(e=a)}return n(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64}(oa())),ga.exports}var ya,wa={exports:{}};function xa(){return ya||(ya=1,wa.exports=function(t){return function(){var e=t,s=e.lib.WordArray;function n(t,e,n){for(var i=[],r=0,o=0;o<e;o++)if(o%4){var a=n[t.charCodeAt(o-1)]<<o%4*2|n[t.charCodeAt(o)]>>>6-o%4*2;i[r>>>2]|=a<<24-r%4*8,r++}return s.create(i,r)}e.enc.Base64url={stringify:function(t,e){void 0===e&&(e=!0);var s=t.words,n=t.sigBytes,i=e?this._safe_map:this._map;t.clamp();for(var r=[],o=0;o<n;o+=3)for(var a=(s[o>>>2]>>>24-o%4*8&255)<<16|(s[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|s[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c<n;c++)r.push(i.charAt(a>>>6*(3-c)&63));var u=i.charAt(64);if(u)for(;r.length%4;)r.push(u);return r.join("")},parse:function(t,e){void 0===e&&(e=!0);var s=t.length,i=e?this._safe_map:this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<i.length;o++)r[i.charCodeAt(o)]=o}var a=i.charAt(64);if(a){var c=t.indexOf(a);-1!==c&&(s=c)}return n(t,s,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),t.enc.Base64url}(oa())),wa.exports}var ba,Ta={exports:{}};function Aa(){return ba||(ba=1,Ta.exports=function(t){return function(e){var s=t,n=s.lib,i=n.WordArray,r=n.Hasher,o=s.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=o.MD5=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var s=0;s<16;s++){var n=e+s,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var r=this._hash.words,o=t[e+0],c=t[e+1],d=t[e+2],f=t[e+3],m=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],y=t[e+8],w=t[e+9],x=t[e+10],b=t[e+11],T=t[e+12],A=t[e+13],k=t[e+14],C=t[e+15],S=r[0],O=r[1],M=r[2],E=r[3];S=u(S,O,M,E,o,7,a[0]),E=u(E,S,O,M,c,12,a[1]),M=u(M,E,S,O,d,17,a[2]),O=u(O,M,E,S,f,22,a[3]),S=u(S,O,M,E,m,7,a[4]),E=u(E,S,O,M,_,12,a[5]),M=u(M,E,S,O,g,17,a[6]),O=u(O,M,E,S,v,22,a[7]),S=u(S,O,M,E,y,7,a[8]),E=u(E,S,O,M,w,12,a[9]),M=u(M,E,S,O,x,17,a[10]),O=u(O,M,E,S,b,22,a[11]),S=u(S,O,M,E,T,7,a[12]),E=u(E,S,O,M,A,12,a[13]),M=u(M,E,S,O,k,17,a[14]),S=h(S,O=u(O,M,E,S,C,22,a[15]),M,E,c,5,a[16]),E=h(E,S,O,M,g,9,a[17]),M=h(M,E,S,O,b,14,a[18]),O=h(O,M,E,S,o,20,a[19]),S=h(S,O,M,E,_,5,a[20]),E=h(E,S,O,M,x,9,a[21]),M=h(M,E,S,O,C,14,a[22]),O=h(O,M,E,S,m,20,a[23]),S=h(S,O,M,E,w,5,a[24]),E=h(E,S,O,M,k,9,a[25]),M=h(M,E,S,O,f,14,a[26]),O=h(O,M,E,S,y,20,a[27]),S=h(S,O,M,E,A,5,a[28]),E=h(E,S,O,M,d,9,a[29]),M=h(M,E,S,O,v,14,a[30]),S=l(S,O=h(O,M,E,S,T,20,a[31]),M,E,_,4,a[32]),E=l(E,S,O,M,y,11,a[33]),M=l(M,E,S,O,b,16,a[34]),O=l(O,M,E,S,k,23,a[35]),S=l(S,O,M,E,c,4,a[36]),E=l(E,S,O,M,m,11,a[37]),M=l(M,E,S,O,v,16,a[38]),O=l(O,M,E,S,x,23,a[39]),S=l(S,O,M,E,A,4,a[40]),E=l(E,S,O,M,o,11,a[41]),M=l(M,E,S,O,f,16,a[42]),O=l(O,M,E,S,g,23,a[43]),S=l(S,O,M,E,w,4,a[44]),E=l(E,S,O,M,T,11,a[45]),M=l(M,E,S,O,C,16,a[46]),S=p(S,O=l(O,M,E,S,d,23,a[47]),M,E,o,6,a[48]),E=p(E,S,O,M,v,10,a[49]),M=p(M,E,S,O,k,15,a[50]),O=p(O,M,E,S,_,21,a[51]),S=p(S,O,M,E,T,6,a[52]),E=p(E,S,O,M,f,10,a[53]),M=p(M,E,S,O,x,15,a[54]),O=p(O,M,E,S,c,21,a[55]),S=p(S,O,M,E,y,6,a[56]),E=p(E,S,O,M,C,10,a[57]),M=p(M,E,S,O,g,15,a[58]),O=p(O,M,E,S,A,21,a[59]),S=p(S,O,M,E,m,6,a[60]),E=p(E,S,O,M,b,10,a[61]),M=p(M,E,S,O,d,15,a[62]),O=p(O,M,E,S,w,21,a[63]),r[0]=r[0]+S|0,r[1]=r[1]+O|0,r[2]=r[2]+M|0,r[3]=r[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;s[i>>>5]|=128<<24-i%32;var r=e.floor(n/4294967296),o=n;s[15+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),s[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(s.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});function u(t,e,s,n,i,r,o){var a=t+(e&s|~e&n)+i+o;return(a<<r|a>>>32-r)+e}function h(t,e,s,n,i,r,o){var a=t+(e&n|s&~n)+i+o;return(a<<r|a>>>32-r)+e}function l(t,e,s,n,i,r,o){var a=t+(e^s^n)+i+o;return(a<<r|a>>>32-r)+e}function p(t,e,s,n,i,r,o){var a=t+(s^(e|~n))+i+o;return(a<<r|a>>>32-r)+e}s.MD5=r._createHelper(c),s.HmacMD5=r._createHmacHelper(c)}(Math),t.MD5}(oa())),Ta.exports}var ka,Ca={exports:{}};function Sa(){return ka||(ka=1,Ca.exports=function(t){return s=(e=t).lib,n=s.WordArray,i=s.Hasher,r=e.algo,o=[],a=r.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var s=this._hash.words,n=s[0],i=s[1],r=s[2],a=s[3],c=s[4],u=0;u<80;u++){if(u<16)o[u]=0|t[e+u];else{var h=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=h<<1|h>>>31}var l=(n<<5|n>>>27)+c+o[u];l+=u<20?1518500249+(i&r|~i&a):u<40?1859775393+(i^r^a):u<60?(i&r|i&a|r&a)-1894007588:(i^r^a)-899497514,c=a,a=r,r=i<<30|i>>>2,i=n,n=l}s[0]=s[0]+n|0,s[1]=s[1]+i|0,s[2]=s[2]+r|0,s[3]=s[3]+a|0,s[4]=s[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,s=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(s/4294967296),e[15+(n+64>>>9<<4)]=s,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(a),e.HmacSHA1=i._createHmacHelper(a),t.SHA1;var e,s,n,i,r,o,a}(oa())),Ca.exports}var Oa,Ma={exports:{}};function Ea(){return Oa||(Oa=1,Ma.exports=function(t){return function(e){var s=t,n=s.lib,i=n.WordArray,r=n.Hasher,o=s.algo,a=[],c=[];!function(){function t(t){for(var s=e.sqrt(t),n=2;n<=s;n++)if(!(t%n))return!1;return!0}function s(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=s(e.pow(n,.5))),c[i]=s(e.pow(n,1/3)),i++),n++}();var u=[],h=o.SHA256=r.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var s=this._hash.words,n=s[0],i=s[1],r=s[2],o=s[3],a=s[4],h=s[5],l=s[6],p=s[7],d=0;d<64;d++){if(d<16)u[d]=0|t[e+d];else{var f=u[d-15],m=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,_=u[d-2],g=(_<<15|_>>>17)^(_<<13|_>>>19)^_>>>10;u[d]=m+u[d-7]+g+u[d-16]}var v=n&i^n&r^i&r,y=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=p+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&h^~a&l)+c[d]+u[d];p=l,l=h,h=a,a=o+w|0,o=r,r=i,i=n,n=w+(y+v)|0}s[0]=s[0]+n|0,s[1]=s[1]+i|0,s[2]=s[2]+r|0,s[3]=s[3]+o|0,s[4]=s[4]+a|0,s[5]=s[5]+h|0,s[6]=s[6]+l|0,s[7]=s[7]+p|0},_doFinalize:function(){var t=this._data,s=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return s[i>>>5]|=128<<24-i%32,s[14+(i+64>>>9<<4)]=e.floor(n/4294967296),s[15+(i+64>>>9<<4)]=n,t.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});s.SHA256=r._createHelper(h),s.HmacSHA256=r._createHmacHelper(h)}(Math),t.SHA256}(oa())),Ma.exports}var Da,Ia={exports:{}};var Ra,Na={exports:{}};function Ba(){return Ra||(Ra=1,Na.exports=function(t){return function(){var e=t,s=e.lib.Hasher,n=e.x64,i=n.Word,r=n.WordArray,o=e.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var t=0;t<80;t++)u[t]=a()}();var h=o.SHA512=s.extend({_doReset:function(){this._hash=new r.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var s=this._hash.words,n=s[0],i=s[1],r=s[2],o=s[3],a=s[4],h=s[5],l=s[6],p=s[7],d=n.high,f=n.low,m=i.high,_=i.low,g=r.high,v=r.low,y=o.high,w=o.low,x=a.high,b=a.low,T=h.high,A=h.low,k=l.high,C=l.low,S=p.high,O=p.low,M=d,E=f,D=m,I=_,R=g,N=v,B=y,V=w,P=x,q=b,F=T,j=A,z=k,W=C,L=S,H=O,U=0;U<80;U++){var G,$,X=u[U];if(U<16)$=X.high=0|t[e+2*U],G=X.low=0|t[e+2*U+1];else{var Z=u[U-15],Y=Z.high,Q=Z.low,K=(Y>>>1|Q<<31)^(Y>>>8|Q<<24)^Y>>>7,J=(Q>>>1|Y<<31)^(Q>>>8|Y<<24)^(Q>>>7|Y<<25),tt=u[U-2],et=tt.high,st=tt.low,nt=(et>>>19|st<<13)^(et<<3|st>>>29)^et>>>6,it=(st>>>19|et<<13)^(st<<3|et>>>29)^(st>>>6|et<<26),rt=u[U-7],ot=rt.high,at=rt.low,ct=u[U-16],ut=ct.high,ht=ct.low;$=($=($=K+ot+((G=J+at)>>>0<J>>>0?1:0))+nt+((G+=it)>>>0<it>>>0?1:0))+ut+((G+=ht)>>>0<ht>>>0?1:0),X.high=$,X.low=G}var lt,pt=P&F^~P&z,dt=q&j^~q&W,ft=M&D^M&R^D&R,mt=E&I^E&N^I&N,_t=(M>>>28|E<<4)^(M<<30|E>>>2)^(M<<25|E>>>7),gt=(E>>>28|M<<4)^(E<<30|M>>>2)^(E<<25|M>>>7),vt=(P>>>14|q<<18)^(P>>>18|q<<14)^(P<<23|q>>>9),yt=(q>>>14|P<<18)^(q>>>18|P<<14)^(q<<23|P>>>9),wt=c[U],xt=wt.high,bt=wt.low,Tt=L+vt+((lt=H+yt)>>>0<H>>>0?1:0),At=gt+mt;L=z,H=W,z=F,W=j,F=P,j=q,P=B+(Tt=(Tt=(Tt=Tt+pt+((lt+=dt)>>>0<dt>>>0?1:0))+xt+((lt+=bt)>>>0<bt>>>0?1:0))+$+((lt+=G)>>>0<G>>>0?1:0))+((q=V+lt|0)>>>0<V>>>0?1:0)|0,B=R,V=N,R=D,N=I,D=M,I=E,M=Tt+(_t+ft+(At>>>0<gt>>>0?1:0))+((E=lt+At|0)>>>0<lt>>>0?1:0)|0}f=n.low=f+E,n.high=d+M+(f>>>0<E>>>0?1:0),_=i.low=_+I,i.high=m+D+(_>>>0<I>>>0?1:0),v=r.low=v+N,r.high=g+R+(v>>>0<N>>>0?1:0),w=o.low=w+V,o.high=y+B+(w>>>0<V>>>0?1:0),b=a.low=b+q,a.high=x+P+(b>>>0<q>>>0?1:0),A=h.low=A+j,h.high=T+F+(A>>>0<j>>>0?1:0),C=l.low=C+W,l.high=k+z+(C>>>0<W>>>0?1:0),O=p.low=O+H,p.high=S+L+(O>>>0<H>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,s=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(s/4294967296),e[31+(n+128>>>10<<5)]=s,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=s.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=s._createHelper(h),e.HmacSHA512=s._createHmacHelper(h)}(),t.SHA512}(oa(),ua())),Na.exports}var Va,Pa={exports:{}};var qa,Fa={exports:{}};function ja(){return qa||(qa=1,Fa.exports=function(t){return function(e){var s=t,n=s.lib,i=n.WordArray,r=n.Hasher,o=s.x64.Word,a=s.algo,c=[],u=[],h=[];!function(){for(var t=1,e=0,s=0;s<24;s++){c[t+5*e]=(s+1)*(s+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)u[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,r=0;r<24;r++){for(var a=0,l=0,p=0;p<7;p++){if(1&i){var d=(1<<p)-1;d<32?l^=1<<d:a^=1<<d-32}128&i?i=i<<1^113:i<<=1}h[r]=o.create(a,l)}}();var l=[];!function(){for(var t=0;t<25;t++)l[t]=o.create()}();var p=a.SHA3=r.extend({cfg:r.cfg.extend({outputLength:512}),_doReset:function(){for(var t=this._state=[],e=0;e<25;e++)t[e]=new o.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(t,e){for(var s=this._state,n=this.blockSize/2,i=0;i<n;i++){var r=t[e+2*i],o=t[e+2*i+1];r=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),(O=s[i]).high^=o,O.low^=r}for(var a=0;a<24;a++){for(var p=0;p<5;p++){for(var d=0,f=0,m=0;m<5;m++)d^=(O=s[p+5*m]).high,f^=O.low;var _=l[p];_.high=d,_.low=f}for(p=0;p<5;p++){var g=l[(p+4)%5],v=l[(p+1)%5],y=v.high,w=v.low;for(d=g.high^(y<<1|w>>>31),f=g.low^(w<<1|y>>>31),m=0;m<5;m++)(O=s[p+5*m]).high^=d,O.low^=f}for(var x=1;x<25;x++){var b=(O=s[x]).high,T=O.low,A=c[x];A<32?(d=b<<A|T>>>32-A,f=T<<A|b>>>32-A):(d=T<<A-32|b>>>64-A,f=b<<A-32|T>>>64-A);var k=l[u[x]];k.high=d,k.low=f}var C=l[0],S=s[0];for(C.high=S.high,C.low=S.low,p=0;p<5;p++)for(m=0;m<5;m++){var O=s[x=p+5*m],M=l[x],E=l[(p+1)%5+5*m],D=l[(p+2)%5+5*m];O.high=M.high^~E.high&D.high,O.low=M.low^~E.low&D.low}O=s[0];var I=h[a];O.high^=I.high,O.low^=I.low}},_doFinalize:function(){var t=this._data,s=t.words;this._nDataBytes;var n=8*t.sigBytes,r=32*this.blockSize;s[n>>>5]|=1<<24-n%32,s[(e.ceil((n+1)/r)*r>>>5)-1]|=128,t.sigBytes=4*s.length,this._process();for(var o=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],h=0;h<c;h++){var l=o[h],p=l.high,d=l.low;p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),u.push(d),u.push(p)}return new i.init(u,a)},clone:function(){for(var t=r.clone.call(this),e=t._state=this._state.slice(0),s=0;s<25;s++)e[s]=e[s].clone();return t}});s.SHA3=r._createHelper(p),s.HmacSHA3=r._createHmacHelper(p)}(Math),t.SHA3}(oa(),ua())),Fa.exports}var za,Wa={exports:{}};var La,Ha={exports:{}};function Ua(){return La||(La=1,Ha.exports=function(t){var e,s,n;s=(e=t).lib.Base,n=e.enc.Utf8,e.algo.HMAC=s.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=n.parse(e));var s=t.blockSize,i=4*s;e.sigBytes>i&&(e=t.finalize(e)),e.clamp();for(var r=this._oKey=e.clone(),o=this._iKey=e.clone(),a=r.words,c=o.words,u=0;u<s;u++)a[u]^=1549556828,c[u]^=909522486;r.sigBytes=o.sigBytes=i,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,s=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(s))}})}(oa())),Ha.exports}var Ga,$a={exports:{}};var Xa,Za={exports:{}};function Ya(){return Xa||(Xa=1,Za.exports=function(t){return s=(e=t).lib,n=s.Base,i=s.WordArray,r=e.algo,o=r.MD5,a=r.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var s,n=this.cfg,r=n.hasher.create(),o=i.create(),a=o.words,c=n.keySize,u=n.iterations;a.length<c;){s&&r.update(s),s=r.update(t).finalize(e),r.reset();for(var h=1;h<u;h++)s=r.finalize(s),r.reset();o.concat(s)}return o.sigBytes=4*c,o}}),e.EvpKDF=function(t,e,s){return a.create(s).compute(t,e)},t.EvpKDF;var e,s,n,i,r,o,a}(oa(),Sa(),Ua())),Za.exports}var Qa,Ka={exports:{}};function Ja(){return Qa||(Qa=1,Ka.exports=function(t){t.lib.Cipher||function(e){var s=t,n=s.lib,i=n.Base,r=n.WordArray,o=n.BufferedBlockAlgorithm,a=s.enc;a.Utf8;var c=a.Base64,u=s.algo.EvpKDF,h=n.Cipher=o.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,s){this.cfg=this.cfg.extend(s),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?y:g}return function(e){return{encrypt:function(s,n,i){return t(n).encrypt(e,s,n,i)},decrypt:function(s,n,i){return t(n).decrypt(e,s,n,i)}}}}()});n.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=s.mode={},p=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=l.CBC=function(){var t=p.extend();function s(t,s,n){var i,r=this._iv;r?(i=r,this._iv=e):i=this._prevBlock;for(var o=0;o<n;o++)t[s+o]^=i[o]}return t.Encryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize;s.call(this,t,e,i),n.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),t.Decryptor=t.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,r=t.slice(e,e+i);n.decryptBlock(t,e),s.call(this,t,e,i),this._prevBlock=r}}),t}(),f=(s.pad={}).Pkcs7={pad:function(t,e){for(var s=4*e,n=s-t.sigBytes%s,i=n<<24|n<<16|n<<8|n,o=[],a=0;a<n;a+=4)o.push(i);var c=r.create(o,n);t.concat(c)},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}};n.BlockCipher=h.extend({cfg:h.cfg.extend({mode:d,padding:f}),reset:function(){var t;h.reset.call(this);var e=this.cfg,s=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,s&&s.words):(this._mode=t.call(n,this,s&&s.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4});var m=n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),_=(s.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,s=t.salt;return(s?r.create([1398893684,1701076831]).concat(s).concat(e):e).toString(c)},parse:function(t){var e,s=c.parse(t),n=s.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=r.create(n.slice(2,4)),n.splice(0,4),s.sigBytes-=16),m.create({ciphertext:s,salt:e})}},g=n.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(t,e,s,n){n=this.cfg.extend(n);var i=t.createEncryptor(s,n),r=i.finalize(e),o=i.cfg;return m.create({ciphertext:r,key:s,iv:o.iv,algorithm:t,mode:o.mode,padding:o.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,s,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(s,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(s.kdf={}).OpenSSL={execute:function(t,e,s,n,i){if(n||(n=r.random(8)),i)o=u.create({keySize:e+s,hasher:i}).compute(t,n);else var o=u.create({keySize:e+s}).compute(t,n);var a=r.create(o.words.slice(e),4*s);return o.sigBytes=4*e,m.create({key:o,iv:a,salt:n})}},y=n.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(t,e,s,n){var i=(n=this.cfg.extend(n)).kdf.execute(s,t.keySize,t.ivSize,n.salt,n.hasher);n.iv=i.iv;var r=g.encrypt.call(this,t,e,i.key,n);return r.mixIn(i),r},decrypt:function(t,e,s,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(s,t.keySize,t.ivSize,e.salt,n.hasher);return n.iv=i.iv,g.decrypt.call(this,t,e,i.key,n)}})}()}(oa(),Ya())),Ka.exports}var tc,ec={exports:{}};function sc(){return tc||(tc=1,ec.exports=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function s(t,e,s,n){var i,r=this._iv;r?(i=r.slice(0),this._iv=void 0):i=this._prevBlock,n.encryptBlock(i,0);for(var o=0;o<s;o++)t[e+o]^=i[o]}return e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize;s.call(this,t,e,i,n),this._prevBlock=t.slice(e,e+i)}}),e.Decryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,r=t.slice(e,e+i);s.call(this,t,e,i,n),this._prevBlock=r}}),e}(),t.mode.CFB}(oa(),Ja())),ec.exports}var nc,ic={exports:{}};function rc(){return nc||(nc=1,ic.exports=function(t){return t.mode.CTR=(e=t.lib.BlockCipherMode.extend(),s=e.Encryptor=e.extend({processBlock:function(t,e){var s=this._cipher,n=s.blockSize,i=this._iv,r=this._counter;i&&(r=this._counter=i.slice(0),this._iv=void 0);var o=r.slice(0);s.encryptBlock(o,0),r[n-1]=r[n-1]+1|0;for(var a=0;a<n;a++)t[e+a]^=o[a]}}),e.Decryptor=s,e),t.mode.CTR;var e,s}(oa(),Ja())),ic.exports}var oc,ac={exports:{}};function cc(){return oc||(oc=1,ac.exports=function(t){
|
|
8
|
-
/** @preserve
|
|
9
|
-
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
|
10
|
-
* derived from CryptoJS.mode.CTR
|
|
11
|
-
* Jan Hruby jhruby.web@gmail.com
|
|
12
|
-
*/
|
|
13
|
-
return t.mode.CTRGladman=function(){var e=t.lib.BlockCipherMode.extend();function s(t){if(255==(t>>24&255)){var e=t>>16&255,s=t>>8&255,n=255&t;255===e?(e=0,255===s?(s=0,255===n?n=0:++n):++s):++e,t=0,t+=e<<16,t+=s<<8,t+=n}else t+=1<<24;return t}function n(t){return 0===(t[0]=s(t[0]))&&(t[1]=s(t[1])),t}var i=e.Encryptor=e.extend({processBlock:function(t,e){var s=this._cipher,i=s.blockSize,r=this._iv,o=this._counter;r&&(o=this._counter=r.slice(0),this._iv=void 0),n(o);var a=o.slice(0);s.encryptBlock(a,0);for(var c=0;c<i;c++)t[e+c]^=a[c]}});return e.Decryptor=i,e}(),t.mode.CTRGladman}(oa(),Ja())),ac.exports}var uc,hc={exports:{}};function lc(){return uc||(uc=1,hc.exports=function(t){return t.mode.OFB=(e=t.lib.BlockCipherMode.extend(),s=e.Encryptor=e.extend({processBlock:function(t,e){var s=this._cipher,n=s.blockSize,i=this._iv,r=this._keystream;i&&(r=this._keystream=i.slice(0),this._iv=void 0),s.encryptBlock(r,0);for(var o=0;o<n;o++)t[e+o]^=r[o]}}),e.Decryptor=s,e),t.mode.OFB;var e,s}(oa(),Ja())),hc.exports}var pc,dc={exports:{}};var fc,mc={exports:{}};var _c,gc={exports:{}};var vc,yc={exports:{}};var wc,xc={exports:{}};var bc,Tc={exports:{}};var Ac,kc={exports:{}};var Cc,Sc={exports:{}};var Oc,Mc={exports:{}};function Ec(){return Oc||(Oc=1,Mc.exports=function(t){return function(){var e=t,s=e.lib,n=s.WordArray,i=s.BlockCipher,r=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],h=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=r.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],s=0;s<56;s++){var n=o[s]-1;e[s]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],r=0;r<16;r++){var u=i[r]=[],h=c[r];for(s=0;s<24;s++)u[s/6|0]|=e[(a[s]-1+h)%28]<<31-s%6,u[4+(s/6|0)]|=e[28+(a[s+24]-1+h)%28]<<31-s%6;for(u[0]=u[0]<<1|u[0]>>>31,s=1;s<7;s++)u[s]=u[s]>>>4*(s-1)+3;u[7]=u[7]<<5|u[7]>>>27}var l=this._invSubKeys=[];for(s=0;s<16;s++)l[s]=i[15-s]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,s){this._lBlock=t[e],this._rBlock=t[e+1],p.call(this,4,252645135),p.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),p.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=s[n],r=this._lBlock,o=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((o^i[c])&h[c])>>>0];this._lBlock=o,this._rBlock=r^a}var l=this._lBlock;this._lBlock=this._rBlock,this._rBlock=l,p.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),p.call(this,16,65535),p.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function p(t,e){var s=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=s,this._lBlock^=s<<t}function d(t,e){var s=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=s,this._rBlock^=s<<t}e.DES=i._createHelper(l);var f=r.TripleDES=i.extend({_doReset:function(){var t=this._key.words;if(2!==t.length&&4!==t.length&&t.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var e=t.slice(0,2),s=t.length<4?t.slice(0,2):t.slice(2,4),i=t.length<6?t.slice(0,2):t.slice(4,6);this._des1=l.createEncryptor(n.create(e)),this._des2=l.createEncryptor(n.create(s)),this._des3=l.createEncryptor(n.create(i))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(f)}(),t.TripleDES}(oa(),va(),Aa(),Ya(),Ja())),Mc.exports}var Dc,Ic={exports:{}};var Rc,Nc={exports:{}};var Bc,Vc={exports:{}};var Pc,qc={exports:{}};function Fc(){return Pc||(Pc=1,qc.exports=function(t){return function(){var e=t,s=e.lib.BlockCipher,n=e.algo;const i=16,r=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],o=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]];var a={pbox:[],sbox:[]};function c(t,e){let s=e>>24&255,n=e>>16&255,i=e>>8&255,r=255&e,o=t.sbox[0][s]+t.sbox[1][n];return o^=t.sbox[2][i],o+=t.sbox[3][r],o}function u(t,e,s){let n,r=e,o=s;for(let e=0;e<i;++e)r^=t.pbox[e],o=c(t,r)^o,n=r,r=o,o=n;return n=r,r=o,o=n,o^=t.pbox[i],r^=t.pbox[i+1],{left:r,right:o}}function h(t,e,s){let n,r=e,o=s;for(let e=i+1;e>1;--e)r^=t.pbox[e],o=c(t,r)^o,n=r,r=o,o=n;return n=r,r=o,o=n,o^=t.pbox[1],r^=t.pbox[0],{left:r,right:o}}function l(t,e,s){for(let e=0;e<4;e++){t.sbox[e]=[];for(let s=0;s<256;s++)t.sbox[e][s]=o[e][s]}let n=0;for(let o=0;o<i+2;o++)t.pbox[o]=r[o]^e[n],n++,n>=s&&(n=0);let a=0,c=0,h=0;for(let e=0;e<i+2;e+=2)h=u(t,a,c),a=h.left,c=h.right,t.pbox[e]=a,t.pbox[e+1]=c;for(let e=0;e<4;e++)for(let s=0;s<256;s+=2)h=u(t,a,c),a=h.left,c=h.right,t.sbox[e][s]=a,t.sbox[e][s+1]=c;return!0}var p=n.Blowfish=s.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var t=this._keyPriorReset=this._key,e=t.words,s=t.sigBytes/4;l(a,e,s)}},encryptBlock:function(t,e){var s=u(a,t[e],t[e+1]);t[e]=s.left,t[e+1]=s.right},decryptBlock:function(t,e){var s=h(a,t[e],t[e+1]);t[e]=s.left,t[e+1]=s.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=s._createHelper(p)}(),t.Blowfish}(oa(),va(),Aa(),Ya(),Ja())),qc.exports}na.exports=function(t){return t}(oa(),ua(),pa(),ma(),va(),xa(),Aa(),Sa(),Ea(),Da||(Da=1,Ia.exports=function(t){return s=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,r=n.SHA224=i.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(r),e.HmacSHA224=i._createHmacHelper(r),t.SHA224;var e,s,n,i,r}(oa(),Ea())),Ba(),Va||(Va=1,Pa.exports=function(t){return s=(e=t).x64,n=s.Word,i=s.WordArray,r=e.algo,o=r.SHA512,a=r.SHA384=o.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=o._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=o._createHelper(a),e.HmacSHA384=o._createHmacHelper(a),t.SHA384;var e,s,n,i,r,o,a}(oa(),ua(),Ba())),ja(),za||(za=1,Wa.exports=function(t){
|
|
14
|
-
/** @preserve
|
|
15
|
-
(c) 2012 by Cédric Mesnil. All rights reserved.
|
|
16
|
-
|
|
17
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
18
|
-
|
|
19
|
-
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
20
|
-
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
21
|
-
|
|
22
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
-
*/
|
|
24
|
-
return function(e){var s=t,n=s.lib,i=n.WordArray,r=n.Hasher,o=s.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),h=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=i.create([0,1518500249,1859775393,2400959708,2840853838]),p=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=o.RIPEMD160=r.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var s=0;s<16;s++){var n=e+s,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var r,o,d,w,x,b,T,A,k,C,S,O=this._hash.words,M=l.words,E=p.words,D=a.words,I=c.words,R=u.words,N=h.words;for(b=r=O[0],T=o=O[1],A=d=O[2],k=w=O[3],C=x=O[4],s=0;s<80;s+=1)S=r+t[e+D[s]]|0,S+=s<16?f(o,d,w)+M[0]:s<32?m(o,d,w)+M[1]:s<48?_(o,d,w)+M[2]:s<64?g(o,d,w)+M[3]:v(o,d,w)+M[4],S=(S=y(S|=0,R[s]))+x|0,r=x,x=w,w=y(d,10),d=o,o=S,S=b+t[e+I[s]]|0,S+=s<16?v(T,A,k)+E[0]:s<32?g(T,A,k)+E[1]:s<48?_(T,A,k)+E[2]:s<64?m(T,A,k)+E[3]:f(T,A,k)+E[4],S=(S=y(S|=0,N[s]))+C|0,b=C,C=k,k=y(A,10),A=T,T=S;S=O[1]+d+k|0,O[1]=O[2]+w+C|0,O[2]=O[3]+x+b|0,O[3]=O[4]+r+T|0,O[4]=O[0]+o+A|0,O[0]=S},_doFinalize:function(){var t=this._data,e=t.words,s=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,r=i.words,o=0;o<5;o++){var a=r[o];r[o]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});function f(t,e,s){return t^e^s}function m(t,e,s){return t&e|~t&s}function _(t,e,s){return(t|~e)^s}function g(t,e,s){return t&s|e&~s}function v(t,e,s){return t^(e|~s)}function y(t,e){return t<<e|t>>>32-e}s.RIPEMD160=r._createHelper(d),s.HmacRIPEMD160=r._createHmacHelper(d)}(),t.RIPEMD160}(oa())),Ua(),Ga||(Ga=1,$a.exports=function(t){return n=(s=(e=t).lib).Base,i=s.WordArray,o=(r=e.algo).SHA256,a=r.HMAC,c=r.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:o,iterations:25e4}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var s=this.cfg,n=a.create(s.hasher,t),r=i.create(),o=i.create([1]),c=r.words,u=o.words,h=s.keySize,l=s.iterations;c.length<h;){var p=n.update(e).finalize(o);n.reset();for(var d=p.words,f=d.length,m=p,_=1;_<l;_++){m=n.finalize(m),n.reset();for(var g=m.words,v=0;v<f;v++)d[v]^=g[v]}r.concat(p),u[0]++}return r.sigBytes=4*h,r}}),e.PBKDF2=function(t,e,s){return c.create(s).compute(t,e)},t.PBKDF2;var e,s,n,i,r,o,a,c}(oa(),Ea(),Ua())),Ya(),Ja(),sc(),rc(),cc(),lc(),pc||(pc=1,dc.exports=function(t){return t.mode.ECB=((e=t.lib.BlockCipherMode.extend()).Encryptor=e.extend({processBlock:function(t,e){this._cipher.encryptBlock(t,e)}}),e.Decryptor=e.extend({processBlock:function(t,e){this._cipher.decryptBlock(t,e)}}),e),t.mode.ECB;var e}(oa(),Ja())),fc||(fc=1,mc.exports=function(t){return t.pad.AnsiX923={pad:function(t,e){var s=t.sigBytes,n=4*e,i=n-s%n,r=s+i-1;t.clamp(),t.words[r>>>2]|=i<<24-r%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923}(oa(),Ja())),_c||(_c=1,gc.exports=function(t){return t.pad.Iso10126={pad:function(e,s){var n=4*s,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126}(oa(),Ja())),vc||(vc=1,yc.exports=function(t){return t.pad.Iso97971={pad:function(e,s){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,s)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971}(oa(),Ja())),wc||(wc=1,xc.exports=function(t){return t.pad.ZeroPadding={pad:function(t,e){var s=4*e;t.clamp(),t.sigBytes+=s-(t.sigBytes%s||s)},unpad:function(t){var e=t.words,s=t.sigBytes-1;for(s=t.sigBytes-1;s>=0;s--)if(e[s>>>2]>>>24-s%4*8&255){t.sigBytes=s+1;break}}},t.pad.ZeroPadding}(oa(),Ja())),bc||(bc=1,Tc.exports=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding}(oa(),Ja())),Ac||(Ac=1,kc.exports=function(t){return s=(e=t).lib.CipherParams,n=e.enc.Hex,e.format.Hex={stringify:function(t){return t.ciphertext.toString(n)},parse:function(t){var e=n.parse(t);return s.create({ciphertext:e})}},t.format.Hex;var e,s,n}(oa(),Ja())),Cc||(Cc=1,Sc.exports=function(t){return function(){var e=t,s=e.lib.BlockCipher,n=e.algo,i=[],r=[],o=[],a=[],c=[],u=[],h=[],l=[],p=[],d=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var s=0,n=0;for(e=0;e<256;e++){var f=n^n<<1^n<<2^n<<3^n<<4;f=f>>>8^255&f^99,i[s]=f,r[f]=s;var m=t[s],_=t[m],g=t[_],v=257*t[f]^16843008*f;o[s]=v<<24|v>>>8,a[s]=v<<16|v>>>16,c[s]=v<<8|v>>>24,u[s]=v,v=16843009*g^65537*_^257*m^16843008*s,h[f]=v<<24|v>>>8,l[f]=v<<16|v>>>16,p[f]=v<<8|v>>>24,d[f]=v,s?(s=m^t[t[t[g^m]]],n^=t[t[n]]):s=n=1}}();var f=[0,1,2,4,8,16,32,64,128,27,54],m=n.AES=s.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,s=t.sigBytes/4,n=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],o=0;o<n;o++)o<s?r[o]=e[o]:(u=r[o-1],o%s?s>6&&o%s==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=f[o/s|0]<<24),r[o]=r[o-s]^u);for(var a=this._invKeySchedule=[],c=0;c<n;c++){if(o=n-c,c%4)var u=r[o];else u=r[o-4];a[c]=c<4||o<=4?u:h[i[u>>>24]]^l[i[u>>>16&255]]^p[i[u>>>8&255]]^d[i[255&u]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,u,i)},decryptBlock:function(t,e){var s=t[e+1];t[e+1]=t[e+3],t[e+3]=s,this._doCryptBlock(t,e,this._invKeySchedule,h,l,p,d,r),s=t[e+1],t[e+1]=t[e+3],t[e+3]=s},_doCryptBlock:function(t,e,s,n,i,r,o,a){for(var c=this._nRounds,u=t[e]^s[0],h=t[e+1]^s[1],l=t[e+2]^s[2],p=t[e+3]^s[3],d=4,f=1;f<c;f++){var m=n[u>>>24]^i[h>>>16&255]^r[l>>>8&255]^o[255&p]^s[d++],_=n[h>>>24]^i[l>>>16&255]^r[p>>>8&255]^o[255&u]^s[d++],g=n[l>>>24]^i[p>>>16&255]^r[u>>>8&255]^o[255&h]^s[d++],v=n[p>>>24]^i[u>>>16&255]^r[h>>>8&255]^o[255&l]^s[d++];u=m,h=_,l=g,p=v}m=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],_=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&u])^s[d++],g=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^s[d++],v=(a[p>>>24]<<24|a[u>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],t[e]=m,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});e.AES=s._createHelper(m)}(),t.AES}(oa(),va(),Aa(),Ya(),Ja())),Ec(),Dc||(Dc=1,Ic.exports=function(t){return function(){var e=t,s=e.lib.StreamCipher,n=e.algo,i=n.RC4=s.extend({_doReset:function(){for(var t=this._key,e=t.words,s=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var r=0;i<256;i++){var o=i%s,a=e[o>>>2]>>>24-o%4*8&255;r=(r+n[i]+a)%256;var c=n[i];n[i]=n[r],n[r]=c}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=r.call(this)},keySize:8,ivSize:0});function r(){for(var t=this._S,e=this._i,s=this._j,n=0,i=0;i<4;i++){s=(s+t[e=(e+1)%256])%256;var r=t[e];t[e]=t[s],t[s]=r,n|=t[(t[e]+t[s])%256]<<24-8*i}return this._i=e,this._j=s,n}e.RC4=s._createHelper(i);var o=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)r.call(this)}});e.RC4Drop=s._createHelper(o)}(),t.RC4}(oa(),va(),Aa(),Ya(),Ja())),Rc||(Rc=1,Nc.exports=function(t){return function(){var e=t,s=e.lib.StreamCipher,n=e.algo,i=[],r=[],o=[],a=n.Rabbit=s.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,s=0;s<4;s++)t[s]=16711935&(t[s]<<8|t[s]>>>24)|4278255360&(t[s]<<24|t[s]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(this._b=0,s=0;s<4;s++)c.call(this);for(s=0;s<8;s++)i[s]^=n[s+4&7];if(e){var r=e.words,o=r[0],a=r[1],u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),h=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),l=u>>>16|4294901760&h,p=h<<16|65535&u;for(i[0]^=u,i[1]^=l,i[2]^=h,i[3]^=p,i[4]^=u,i[5]^=l,i[6]^=h,i[7]^=p,s=0;s<4;s++)c.call(this)}},_doProcessBlock:function(t,e){var s=this._X;c.call(this),i[0]=s[0]^s[5]>>>16^s[3]<<16,i[1]=s[2]^s[7]>>>16^s[5]<<16,i[2]=s[4]^s[1]>>>16^s[7]<<16,i[3]=s[6]^s[3]>>>16^s[1]<<16;for(var n=0;n<4;n++)i[n]=16711935&(i[n]<<8|i[n]>>>24)|4278255360&(i[n]<<24|i[n]>>>8),t[e+n]^=i[n]},blockSize:4,ivSize:2});function c(){for(var t=this._X,e=this._C,s=0;s<8;s++)r[s]=e[s];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<r[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<r[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<r[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<r[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<r[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<r[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<r[6]>>>0?1:0)|0,this._b=e[7]>>>0<r[7]>>>0?1:0,s=0;s<8;s++){var n=t[s]+e[s],i=65535&n,a=n>>>16,c=((i*i>>>17)+i*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[s]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=s._createHelper(a)}(),t.Rabbit}(oa(),va(),Aa(),Ya(),Ja())),Bc||(Bc=1,Vc.exports=function(t){return function(){var e=t,s=e.lib.StreamCipher,n=e.algo,i=[],r=[],o=[],a=n.RabbitLegacy=s.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,s=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)n[i]^=s[i+4&7];if(e){var r=e.words,o=r[0],a=r[1],u=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),h=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),l=u>>>16|4294901760&h,p=h<<16|65535&u;for(n[0]^=u,n[1]^=l,n[2]^=h,n[3]^=p,n[4]^=u,n[5]^=l,n[6]^=h,n[7]^=p,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(t,e){var s=this._X;c.call(this),i[0]=s[0]^s[5]>>>16^s[3]<<16,i[1]=s[2]^s[7]>>>16^s[5]<<16,i[2]=s[4]^s[1]>>>16^s[7]<<16,i[3]=s[6]^s[3]>>>16^s[1]<<16;for(var n=0;n<4;n++)i[n]=16711935&(i[n]<<8|i[n]>>>24)|4278255360&(i[n]<<24|i[n]>>>8),t[e+n]^=i[n]},blockSize:4,ivSize:2});function c(){for(var t=this._X,e=this._C,s=0;s<8;s++)r[s]=e[s];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<r[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<r[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<r[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<r[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<r[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<r[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<r[6]>>>0?1:0)|0,this._b=e[7]>>>0<r[7]>>>0?1:0,s=0;s<8;s++){var n=t[s]+e[s],i=65535&n,a=n>>>16,c=((i*i>>>17)+i*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[s]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=s._createHelper(a)}(),t.RabbitLegacy}(oa(),va(),Aa(),Ya(),Ja())),Fc());var jc,zc=sa(na.exports);function Wc(t,e){const s=`${t}:${e}`,n=zc.SHA256(s).toString(zc.enc.Hex);return`${n.substring(0,8)}-${n.substring(8,12)}-4${n.substring(13,16)}-${"89AB"[parseInt(n.substring(17,18),16)%4]}${n.substring(18,21)}-${n.substring(21,33)}`}!function(t){t.AudioInput="audioInput",t.AudioOutput="audioOutput",t.MidiInput="midiInput",t.MidiOutput="midiOutput",t.ForwardAudioInput="forwardAudioInput",t.ForwardAudioOutput="forwardAudioOutput"}(jc||(jc={}));const Lc=[jc.AudioInput,jc.AudioOutput,jc.ForwardAudioInput,jc.ForwardAudioOutput],Hc=[jc.MidiInput,jc.MidiOutput],Uc=[jc.AudioInput,jc.MidiInput,jc.ForwardAudioInput],Gc=[jc.AudioOutput,jc.MidiOutput,jc.ForwardAudioOutput];function $c(t,e){t.plug(e)}function Xc(t,e){t.connections.some((t=>t.id===e.id))&&t.unPlug(e)}class Zc{id;ioType;name;plugableModule;connections=[];static unPlugAll(t){t.connections.forEach((e=>t.unPlug(e)))}constructor(t,e){this.plugableModule=t,this.id=Wc(t.id,e.name),Object.assign(this,e)}plug(t,e=!0){this.connections.push(t),e&&t.plug(this,!1)}unPlug(t,e=!0){this.connections=this.connections.filter((e=>e.id!==t.id)),e&&t.unPlug(this,!1)}get isInput(){return Uc.indexOf(this.ioType)>-1}get isOutput(){return Gc.indexOf(this.ioType)>-1}get isAudio(){return Lc.indexOf(this.ioType)>-1}get isMidi(){return Hc.indexOf(this.ioType)>-1}serialize(){return{id:this.id,name:this.name,moduleId:this.plugableModule.id,moduleName:this.plugableModule.name,ioType:this.ioType}}}class Yc extends Zc{constructor(t,e){super(t,e),this.checkNameValidity()}get voices(){return this.subModules.length}get subModules(){return this.plugableModule.audioModules}subModule(t){const e=t%this.voices,s=this.subModules.find((t=>t.voiceNo===e));if(!s)throw Error(`Submodule with voiceNo ${t} not found`);return s}get subIOs(){const t=[];for(let e=0;e<this.voices;e++)t.push(this.subIO(e));return t}subIO(t){const e=(this.ioType.includes("Input")?this.subModule(t).inputs:this.subModule(t).outputs).findByName(this.name);if(!e)throw Error(`Could not forward io ${this.name}`);return e}plug(t,e=!0){this.plugUnplug(t,e,!0)}unPlug(t,e=!0){this.plugUnplug(t,e,!1)}unPlugAll(){Zc.unPlugAll(this)}plugUnplug(t,e,s){if(s?super.plug(t,e):super.unPlug(t,e),!e&&(t instanceof Kc||t instanceof Qc))return;const n=s?$c:Xc;if(t instanceof Kc||t instanceof Qc){const e=Math.max(this.voices,t.voices);for(let s=0;s<e;s++){n(this.subIO(s),t.subIO(s))}}else for(let e=0;e<this.voices;e++){n(this.subIO(e),t)}}checkNameValidity(){if(!this.subIO(0))throw Error("You should forward to existing input")}}class Qc extends Yc{constructor(t,e){super(t,e)}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}}class Kc extends Yc{constructor(t,e){super(t,e)}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}}class Jc extends Zc{internalModule;constructor(t,e){super(t,e),this.internalModule=e.internalModule}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}unPlugAll(){Zc.unPlugAll(this)}}class tu extends Zc{internalModule;constructor(t,e){super(t,e),this.internalModule=e.internalModule}plug(t,e=!0){super.plug(t,e),t instanceof Qc||this.internalModule.connect(t.internalModule)}unPlug(t,e=!0){if(super.unPlug(t,e),!(t instanceof Qc))try{this.internalModule.disconnect(t.internalModule)}catch(t){console.error(t)}}unPlugAll(){Zc.unPlugAll(this)}}class eu extends Zc{onMidiEvent;constructor(t,e){super(t,e),this.onMidiEvent=e.onMidiEvent}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}unPlugAll(){Zc.unPlugAll(this)}}class su extends Zc{constructor(t,e){super(t,e)}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}unPlugAll(){Zc.unPlugAll(this)}onMidiEvent=t=>{this.midiConnections.forEach((e=>{e.onMidiEvent(t)}))};get midiConnections(){return this.connections.filter((t=>t instanceof eu))}}class nu{plugableModule;collection=[];constructor(t){this.plugableModule=t}add(t){let e;switch(t.ioType){case jc.AudioInput:if(this.plugableModule instanceof au)throw Error("PolyModule is not supported");e=new Jc(this.plugableModule,t);break;case jc.AudioOutput:if(this.plugableModule instanceof au)throw Error("PolyModule is not supported");e=new tu(this.plugableModule,t);break;case jc.MidiInput:e=new eu(this.plugableModule,t);break;case jc.MidiOutput:e=new su(this.plugableModule,t);break;case jc.ForwardAudioInput:if(this.plugableModule instanceof ou)throw Error("MonoModule is not supported");e=new Qc(this.plugableModule,t);break;case jc.ForwardAudioOutput:if(this.plugableModule instanceof ou)throw Error("MonoModule is not supported");e=new Kc(this.plugableModule,t);break;default:throw Error("Unknown IOType")}return this.collection.push(e),e}unPlugAll(){this.collection.forEach((t=>t.unPlugAll()))}find(t){return this.collection.find((e=>e.id===t))}findByName(t){return this.collection.find((e=>e.name===t))}serialize(){return this.collection.map((t=>t.serialize()))}}class iu{connect(){throw Error("This module is not connectable")}disconnect(){throw Error("This module is not connectable")}dispose(){}}var ru,ou=class{static moduleName;id;name;internalModule;inputs;outputs;voiceNo;updatedAt;_props={};constructor(t,e){this.internalModule=t,this.id=e.id||ta(),delete e.id,this.inputs=new nu(this),this.outputs=new nu(this),Object.assign(this,e)}set props(t){t&&(this.updatedAt=new Date,Object.assign(this,t))}get props(){return this._props}plug(t,e,s){const n=this.outputs.findByName(e);if(!n)throw Error(`Output ${e} not exist`);const i=t.inputs.findByName(s);if(!i)throw Error(`Input ${s} not exist`);$c(i,n)}unPlugAll(){this.outputs.unPlugAll()}dispose(){this.inputs.unPlugAll(),this.outputs.unPlugAll(),this.internalModule.dispose()}triggerAttack=(t,e)=>{throw Error("triggerAttack not implemented")};triggerRelease=(t,e)=>{throw Error("triggerRelease not implemented")};onMidiEvent=t=>{if(void 0!==t.voiceNo&&t.voiceNo!==this.voiceNo)return;const{note:e,triggeredAt:s}=t;switch(t.type){case"noteOn":{const{duration:t}=e;if(this.triggerer(this.triggerAttack,e,s),t){const r=s+(n=t,new Xi(zi(),n,i)).toSeconds();this.triggerer(this.triggerRelease,e,r)}break}case"noteOff":this.triggerer(this.triggerRelease,e,s);break;default:throw Error("This type is not a note")}var n,i};triggerer(t,e,s){t(e,s)}serialize(){const t=this.constructor;return{id:this.id,name:this.name,type:t.moduleName,props:this.props,inputs:this.inputs.serialize(),outputs:this.outputs.serialize()}}registerMidiInput(t){return this.inputs.add({...t,ioType:jc.MidiInput})}registerAudioInput(t){return this.inputs.add({...t,ioType:jc.AudioInput})}registerMidiOutput(t){return this.outputs.add({...t,ioType:jc.MidiOutput})}registerAudioOutput(t){return this.outputs.add({...t,ioType:jc.AudioOutput})}registerBasicOutputs(){this.registerAudioOutput({name:"output",internalModule:this.internalModule})}registerBasicInputs(){this.registerAudioInput({name:"input",internalModule:this.internalModule}),this.registerDefaultMidiInput()}registerDefaultMidiInput(){this.registerMidiInput({name:"midi in",onMidiEvent:this.onMidiEvent})}};class au{static moduleName;id;child;_name;audioModules;inputs;outputs;_numberOfVoices;constructor(t){this.id=t.id||ta(),delete t.id,this.audioModules=[];const{child:e,props:s,...n}=t;this.child=e,Object.assign(this,n),this.numberOfVoices=t.numberOfVoices||1,this.inputs=new nu(this),this.outputs=new nu(this),Object.assign(this,{props:s})}get name(){return this._name}set name(t){this._name=t,this.audioModules.forEach((e=>e.name=t))}get props(){if(0===this.audioModules.length)throw Error("There isn't any initialized module");return this.audioModules[0].props}set props(t){Object.assign(this,t),this.audioModules.forEach((e=>e.props=t))}get numberOfVoices(){return this._numberOfVoices}set numberOfVoices(t){this._numberOfVoices=t,this.adjustNumberOfModules()}plug(t,e,s){const n=this.outputs.findByName(e);if(!n)throw Error(`Output ${e} not exist`);const i=t.inputs.findByName(s);if(!i)throw Error(`Input ${s} not exist`);$c(i,n)}unPlugAll(){this.outputs.unPlugAll()}dispose(){this.unPlugAll(),this.audioModules.forEach((t=>t.dispose()))}onMidiEvent=t=>{const e=t.voiceNo||0,s=this.findVoice(e);s?.onMidiEvent(t)};serialize(){if(0===this.audioModules.length)throw Error("There isn't any initialized module");const t=this.constructor;return{...this.audioModules[0].serialize(),id:this.id,type:t.moduleName,numberOfVoices:this.numberOfVoices,inputs:this.inputs.serialize(),outputs:this.outputs.serialize()}}find(t){const e=this.audioModules.find(t);if(!e)throw Error("Audio module not found");return e}findVoice(t){return this.audioModules.find((e=>e.voiceNo===t))}registerForwardAudioInput(t){return this.inputs.add({...t,ioType:jc.ForwardAudioInput})}registerForwardAudioOutput(t){return this.outputs.add({...t,ioType:jc.ForwardAudioOutput})}registerMidiInput(t){return this.inputs.add({...t,ioType:jc.MidiInput})}registerMidiOutput(t){return this.outputs.add({...t,ioType:jc.MidiOutput})}registerBasicOutputs(){this.registerForwardAudioOutput({name:"output"})}registerBasicInputs(){this.registerForwardAudioInput({name:"input"}),this.registerMidiIn()}registerMidiIn(){this.registerMidiInput({name:"midi in",onMidiEvent:this.onMidiEvent})}adjustNumberOfModules(){if(this.audioModules.length!==this.numberOfVoices){if(this.audioModules.length>this.numberOfVoices){const t=this.audioModules.pop();t?.dispose()}else{const t=this.audioModules.length,e=Wc(this.id,t.toString()),s=0===t?{}:this.props,n=new this.child({id:e,name:this.name,props:{...s,voiceNo:t}});if(n instanceof au)throw Error("Polymodule not supported");this.audioModules.push(n)}this.adjustNumberOfModules()}}}!function(t){t.Attack="attack",t.Decay="decay",t.Sustain="sustain",t.Release="release"}(ru||(ru={}));const cu=.01,uu={attack:cu,decay:cu,sustain:1,release:cu};class hu extends ou{activeNote;triggeredAt;constructor(t){const{id:e,name:s,props:n,internalModule:i}=t;super(i,{id:e,name:s,props:{...uu,...n}}),this.registerBasicInputs(),this.registerBasicOutputs()}get attack(){return this._props.attack}set attack(t){this.setStage(ru.Attack,t)}get decay(){return this._props.decay}set decay(t){this.setStage(ru.Decay,t)}get sustain(){return this._props.sustain}set sustain(t){this.setStage(ru.Sustain,t)}get release(){return this._props.release}set release(t){this.setStage(ru.Release,t)}setStage(t,e){const s=0===e?this.minTime(t):this.maxTime(t)*e;this._props={...this.props,[t]:e},this.internalModule[t]=s}triggerAttack=(t,e)=>{this.activeNote=t.fullName,this.triggeredAt=e,this.internalModule.triggerAttack(e,t.velocity)};triggerRelease=(t,e)=>{this.activeNote&&this.activeNote!==t.fullName||(this.internalModule.triggerRelease(e),this.activeNote=void 0)};maxTime(t){return t===ru.Sustain?1:2}minTime(t){return t===ru.Sustain?0:cu}}class lu extends au{constructor(t){const{id:e,name:s,child:n,props:i}=t;super({id:e,name:s,child:n,props:{...uu,...i}}),this.registerBasicInputs(),this.registerBasicOutputs()}}class pu extends hu{constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new so,props:n})}}class du extends lu{static moduleName="Envelope";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:pu,props:{...uu,...n}})}}class fu extends hu{constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new oo,props:n})}}class mu extends lu{static moduleName="AmpEnvelope";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:fu,props:n})}}const _u={amount:0};class gu extends hu{_frequency;_amount;filter;constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new ho,props:{..._u,...n}})}get frequency(){return this._frequency}set frequency(t){this._frequency=t,this.internalModule.baseFrequency=t}get amount(){return this._amount}set amount(t){this._amount=t,this.internalModule.octaves=t}}class vu extends lu{static moduleName="FreqEnvelope";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:gu,props:n})}}const yu={noteName:"C3",fine:0,coarse:0,wave:"sine",range:0,volume:0};class wu extends ou{_note;_fineSignal;constructor(t){const{id:e,name:s,props:n}=t;super(new Br,{id:e,name:s,props:{...yu,...n}}),this.registerInputs(),this.registerBasicOutputs(),this.start(Bo())}get note(){return this._note}setNoteAt(t,e){this._note=this.getNote(t),this.updateFrequency(e)}set note(t){this._note=this.getNote(t),this.updateFrequency()}get noteName(){return this._props.noteName}set noteName(t){this._props={...this.props,noteName:t},this.note=new Fo(this.noteName)}get fineSingal(){return this._fineSignal||(this._fineSignal=new Fr(100),this._fineSignal.connect(this.internalModule.detune)),this._fineSignal}get fine(){return this._props.fine}set fine(t){this._props={...this.props,fine:t},this.fineSingal.value=this.fine}get coarse(){return this._props.coarse}set coarse(t){this._props={...this.props,coarse:Math.floor(t)},this.updateFrequency()}get wave(){return this._props.wave}set wave(t){this._props={...this.props,wave:t},this.internalModule.type=this.wave}get volume(){return this._props.volume}set volume(t){this._props={...this.props,volume:t},this.internalModule.volume.value=this.volume}get range(){return this._props.range}set range(t){this._props={...this.props,range:t},this.updateFrequency()}start(t){if(!Qu.isStarted)return;"started"===this.internalModule.state?this.internalModule.restart(t):this.internalModule.start(t)}stop(t){this.internalModule.stop(t)}triggerAttack=(t,e)=>{this.setNoteAt(t,e),this.start(e)};triggerRelease=()=>{};updateFrequency(t){if(!this.note)return;const e=this.note.adjustFrequency(this.range,this.coarse);t?this.internalModule.frequency.linearRampToValueAtTime(e,t):this.internalModule.frequency.value=e}getNote(t){return t instanceof Fo?t:new Fo(t)}registerInputs(){this.registerAudioInput({name:"fine",internalModule:this.fineSingal})}}class xu extends au{static moduleName="Oscillator";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:wu,props:{...yu,...n}}),this.registerBasicOutputs(),this.registerMidiIn(),this.registerForwardAudioInput({name:"fine"})}start(t){this.audioModules.forEach((e=>e.start(t)))}stop(t){this.audioModules.forEach((e=>e.stop(t)))}}const bu={cutoff:2e4,resonance:0,envelopeAmount:0,slope:-24,filterType:"lowpass"};class Tu extends ou{_cutoff;_amount;constructor(t){const{id:e,name:s,props:n}=t;super(new uo({type:"lowpass"}),{id:e,name:s,props:{...bu,...n}}),this._cutoff=new $r,this._cutoff.connect(this.internalModule.frequency),this._amount=new Fr,this._amount.connect(this._cutoff),this.updateAmountFactor(),this.registerBasicInputs(),this.registerOutputs()}get cutoff(){return this._props.cutoff}set cutoff(t){this._cutoff&&(this._cutoff.addend.value=t),this._props={...this.props,cutoff:t},this.updateAmountFactor()}get filterType(){return this._props.filterType}set filterType(t){this._props={...this.props,filterType:t},this.internalModule.type=t}get slope(){return this._props.slope}set slope(t){this._props={...this.props,slope:t},this.internalModule.rolloff=t}get frequency(){return this.internalModule.frequency}get resonance(){return this._props.resonance}set resonance(t){this._props={...this.props,resonance:t},this.internalModule.Q.value=t}get envelopeAmount(){return this._props.envelopeAmount}set envelopeAmount(t){this._props={...this.props,envelopeAmount:t},this.updateAmountFactor()}registerOutputs(){this.registerBasicOutputs(),this.registerAudioInput({name:"cutoff",internalModule:this._amount})}updateAmountFactor(){if(!this._amount)return;const t=this.envelopeAmount>0?this.envelopeAmount*Math.abs(2e4-this.cutoff):this.envelopeAmount*Math.abs(1-this.cutoff);this._amount.factor.value=t}}class Au extends au{static moduleName="Filter";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:Tu,props:{...bu,...n}}),this.registerBasicInputs(),this.registerOutputs()}registerOutputs(){this.registerBasicOutputs(),this.registerForwardAudioInput({name:"cutoff"})}}class ku extends ou{static moduleName="Master";constructor({id:t}){super(zi().destination,{id:t,name:"Master"}),this.registerAudioInput({name:"input",internalModule:this.internalModule})}dispose(){this.inputs.unPlugAll(),this.outputs.unPlugAll()}}class Cu extends au{static moduleName="VoiceScheduler";midiOutput;constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:Su,props:n}),this.registerInputs(),this.registerOutputs(),this.polyNumber=this.numberOfVoices}set polyNumber(t){super.numberOfVoices=t}get polyNumber(){return this.numberOfVoices}onMidiEvent=t=>{let e;switch(t.type){case"noteOn":e=this.findFreeVoice();break;case"noteOff":e=this.audioModules.find((e=>e.activeNote===t.note.fullName));break;default:throw Error("This type is not a note")}e&&(e.midiTriggered(t),t.voiceNo=e.voiceNo,this.midiOutput.onMidiEvent(t))};serialize(){const t=super.serialize();return{...t,props:{...t.props,polyNumber:this.polyNumber}}}findFreeVoice(){let t=this.audioModules.find((t=>!t.activeNote));return t||(t=this.audioModules.sort(((t,e)=>t&&e?t.triggeredAt-e.triggeredAt:0))[0]),t}registerInputs(){this.registerMidiInput({name:"midi in",onMidiEvent:this.onMidiEvent})}registerOutputs(){this.midiOutput=this.registerMidiOutput({name:"midi out"})}}class Su extends ou{midiEvent;activeNote;triggeredAt;constructor(t){const{id:e,name:s,props:n}=t;super(new iu,{id:e,name:s,props:n})}midiTriggered=t=>{if(void 0===this.voiceNo)throw Error("Voice without voiceNo");const{triggeredAt:e,note:s,type:n}=t;if(!s)return;const i=s.fullName;switch(n){case"noteOn":this.activeNote=i,this.triggeredAt=e,this.midiEvent=t;break;case"noteOff":this.activeNote=null,this.midiEvent=null;break;default:throw Error("This type is not a note")}}}const Ou={selectedId:null};class Mu extends ou{static moduleName="MidiSelector";midiOutput;constructor(t){const{id:e,name:s,props:n}=t;super(new iu,{id:e,name:s,props:{...Ou,...n}}),this.registerOutputs(),this.addEventListener(this.selectedId)}get selectedId(){return this._props.selectedId}set selectedId(t){this.removeEventListener(),this._props={...this.props,selectedId:t},this.addEventListener(t)}dispose(){this.removeEventListener(),super.dispose()}registerOutputs(){this.midiOutput=this.registerMidiOutput({name:"midi out"})}addEventListener(t){if(!this.onMidiEvent||!t)return;const e=Qu.midiDeviceManager.find(t);e?.addEventListener(this.forwardMidiEvent)}forwardMidiEvent=t=>{this.midiOutput.onMidiEvent(t)};removeEventListener(){if(!this.selectedId)return;const t=Qu.midiDeviceManager.find(this.selectedId);t?.removeEventListener(this.forwardMidiEvent)}}const Eu={volume:-1/0};class Du extends ou{constructor(t){const{id:e,name:s,props:n}=t;super(new xr,{id:e,name:s,props:{...Eu,...n}}),this.registerBasicInputs(),this.registerBasicOutputs()}get volume(){return this._props.volume}set volume(t){this._props={...this.props,volume:t},this.internalModule.volume.value=this.volume}triggerAttack=(t,e)=>{const s=20*Math.log10(t.velocity);this.internalModule.volume.exponentialRampToValueAtTime(s,e)};triggerRelease=()=>{}}class Iu extends au{static moduleName="Volume";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:Du,props:{...Eu,...n}}),this.registerBasicInputs(),this.registerBasicOutputs()}}const Ru={activeNotes:[]};class Nu extends ou{static moduleName="VirtualMidi";midiOutput;constructor(t){const{id:e,name:s,props:n}=t;super(new iu,{id:e,name:s,props:{...Ru,...n}}),this.registerInputs(),this.registerOutputs()}get activeNotes(){return this._props.activeNotes}set activeNotes(t){this._props={...this.props,activeNotes:t}}sendMidi(t){this.midiOutput.onMidiEvent(t)}triggerAttack=(t,e)=>{this.activeNotes=[...this.activeNotes,t.fullName],Qu._triggerPropsUpdate(this.id,this.props),this.sendMidi(zo.fromNote(t,!0,e))};triggerRelease=(t,e)=>{this.activeNotes=this.activeNotes.filter((e=>e!==t.fullName)),Qu._triggerPropsUpdate(this.id,this.props),this.sendMidi(zo.fromNote(t,!1,e))};serialize(){return{...super.serialize(),activeNotes:this.activeNotes}}registerInputs(){this.registerMidiInput({name:"midi in",onMidiEvent:this.onMidiEvent})}registerOutputs(){this.midiOutput=this.registerMidiOutput({name:"midi out"})}}const Bu={wet:1};class Vu extends ou{constructor(t){const{id:e,name:s,internalModule:n,props:i}=t;super(n,{id:e,name:s,props:{...Bu,...i}}),this.registerBasicInputs(),this.registerBasicOutputs()}get wet(){return this._props.wet}set wet(t){this._props={...this.props,wet:t},this.internalModule.wet.value=this.wet}}const Pu={decay:1.5,preDelay:.025};class qu extends Vu{static moduleName="Reverb";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new Eo,props:{...Pu,...n}})}get decay(){return this._props.decay}set decay(t){this._props={...this.props,decay:t},this.internalModule.decay=this.decay}get preDelay(){return this._props.preDelay}set preDelay(t){this._props={...this.props,preDelay:t},this.internalModule.preDelay=this.preDelay}}const Fu={delayTime:1,feedback:.3};class ju extends Vu{static moduleName="Delay";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new Mo,props:{...Fu,...n}})}get delayTime(){return this._props.delayTime}set delayTime(t){this._props={...this.props,delayTime:t},this.internalModule.delayTime.value=this.delayTime}get feedback(){return this._props.feedback}set feedback(t){this._props={...this.props,feedback:t},this.internalModule.feedback.value=this.feedback}}const zu={drive:.3};class Wu extends Vu{static moduleName="Distortion";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new So,props:{...zu,...n}})}get drive(){return this._props.drive}set drive(t){this._props={...this.props,drive:t},this.internalModule.distortion=this.drive}}const Lu={bits:16};class Hu extends Vu{static moduleName="BitCrusher";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new Ao,props:{...Lu,...n}})}get bits(){return this._props.bits}set bits(t){this._props={...this.props,bits:t},this.internalModule.bits.value=this.bits}}class Uu extends ou{static moduleName="Sequencer";midiOutput;part;constructor(t){const{id:e,name:s,props:n}=t;super(new iu,{id:e,name:s,props:{sequences:[],steps:16,bars:1,...n}}),this.initializePart(),this.start(Bo()),this.registerOutputs()}get props(){return super.props}set props(t){this.sequences||(this._props.sequences=[]),super.props={...this.props,...t},this.adjust()}get steps(){return this._props.steps}set steps(t){this._props={...this.props,steps:t}}get bars(){return this.props.bars}set bars(t){this._props={...this.props,bars:t}}get sequences(){return this._props.sequences}set sequences(t){const e=t;this._props={...this.props,sequences:e}}start(t){Qu.isStarted&&this.part.start(t)}stop(){this.part.stop()}registerOutputs(){this.midiOutput=this.registerMidiOutput({name:"midi out"})}initializePart(){this.part=new yo(this.onPartEvent,[]),this.part.loop=!0,this.part.loopEnd=this.loopEnd}adjust(){this.part&&(this.adjustNumberOfBars(),this.adjustNumberOfSteps(),this.updateBarParts())}adjustNumberOfBars(){const t=this.sequences.length-this.bars,e=[...this.sequences];0!==t&&(t>0?e.pop():e.push([]),this.sequences=e,this.adjustNumberOfBars())}adjustNumberOfSteps(t=0){if(!this.bars)return;const e=[...this.sequences],s=[...e[t]],n=s.length-this.steps;if(0!==n){if(n>0)s.pop();else{const e=s.length;s.push({active:!1,time:`${t}:0:${e}`,notes:[]})}e[t]=s,this.sequences=e,this.adjustNumberOfSteps(t)}else{if(t===this.bars-1)return;this.adjustNumberOfSteps(t+1)}}updateBarParts(){this.part.clear(),this.sequences.forEach((t=>{t.forEach((t=>this.part.add(t.time,t)))})),this.part.loopEnd=this.loopEnd}get loopEnd(){return`${this.bars}:0:0`}onPartEvent=(t,e)=>{e.active&&zo.fromSequence(e,t).forEach((t=>{this.midiOutput.onMidiEvent(t)}))}}const Gu={wave:"sine",frequency:.1,min:0,max:1,amount:1};class $u extends ou{constructor(t){const{id:e,name:s,props:n}=t;super(new Yr,{id:e,name:s,props:{...Gu,...n}}),this.registerBasicOutputs(),this.registerInputs(),this.start(Bo())}get wave(){return this._props.wave}set wave(t){this._props={...this.props,wave:t},this.internalModule.type=this.wave}get min(){return this._props.min}set min(t){this._props={...this.props,min:t},this.internalModule.min=this.min}get max(){return this._props.max}set max(t){this._props={...this.props,max:t},this.internalModule.max=this.max}get frequency(){return this._props.frequency}set frequency(t){this._props={...this.props,frequency:t},this.internalModule.frequency.value=this.frequency}get amount(){return this._props.amount}set amount(t){this._props={...this.props,amount:t},this.internalModule.amplitude.value=this.amount}start(t){if(!Qu.isStarted)return;"started"===this.internalModule.state?(this.internalModule.stop(t-2),this.internalModule.start(t)):this.internalModule.start(t)}stop(t){this.internalModule.stop(t)}triggerAttack=(t,e)=>{this.start(e)};triggerRelease=()=>{};registerInputs(){this.registerAudioInput({name:"amount",internalModule:this.internalModule.amplitude})}}class Xu extends au{static moduleName="LFO";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:$u,props:{...Gu,...n}}),this.registerBasicOutputs(),this.registerMidiIn(),this.registerForwardAudioInput({name:"amount"})}start(t){this.audioModules.forEach((e=>e.start(t)))}stop(t){this.audioModules.forEach((e=>e.stop(t)))}}function Zu(t){const{id:e,type:s,name:n,props:i}=t,r=function(t){switch(t){case xu.moduleName:return xu;case du.moduleName:return du;case mu.moduleName:return mu;case vu.moduleName:return vu;case Au.moduleName:return Au;case Iu.moduleName:return Iu;case ku.moduleName:return ku;case Cu.moduleName:return Cu;case Mu.moduleName:return Mu;case Nu.moduleName:return Nu;case qu.moduleName:return qu;case ju.moduleName:return ju;case Wu.moduleName:return Wu;case Hu.moduleName:return Hu;case Uu.moduleName:return Uu;case Xu.moduleName:return Xu;default:throw Error(`Unknown module type ${t}`)}}(s);return new r({id:e,name:n,props:i})}class Yu{midiDeviceManager;static instance;context;propsUpdateCallbacks;_isStarted=!1;modules;routes;constructor(){this.modules={},this.routes={},this.propsUpdateCallbacks=[]}static getInstance(){return Yu.instance||(Yu.instance=new Yu),Yu.instance}initialize(t){return new Promise((e=>{if(this.context)return e({});this.context=new Ri(t.context),Wi(this.context),this.context.transport.start(),this.midiDeviceManager=new Go,setTimeout((()=>{e({})}),0)}))}addModule(t){const{id:e,name:s,numberOfVoices:n,type:i,props:r={}}=t,o=Zu({id:e,name:s,type:i,props:{}});return o instanceof au&&n&&(o.numberOfVoices=n),o.props=r,this.modules[o.id]=o,this.updateRoutes(),o.serialize()}removeModule(t){this.modules[t].dispose();const e=this.moduleRouteIds(t);return e.forEach((t=>delete this.routes[t])),this.updateRoutes(),delete this.modules[t],e}updateModule(t){const{id:e,changes:{name:s,numberOfVoices:n,props:i={}}}=t,r=this.findById(e);return r.props=i,s&&(r.name=s),r instanceof au&&n&&(r.numberOfVoices=n),n&&this.updateRoutes(),r.serialize()}onPropsUpdate(t){this.propsUpdateCallbacks.push(t)}_triggerPropsUpdate(t,e){this.propsUpdateCallbacks.forEach((s=>s(t,e)))}addRoute(t){if(!this.validRoute(t))throw Error("Invalid route, incompatible IOs");const e=function(t){const e=t.id||ta();return{...t,id:e}}(t),s={...this.routes,[e.id]:e};return this.routes=s,this.updateRoutes(),e}validRoute(t){const{sourceId:e,sourceIOId:s,destinationId:n,destinationIOId:i}=t,r=this.findById(e).outputs.find(s),o=this.findById(n).inputs.find(i);return!(!r?.isMidi||!o?.isMidi)||!(!r?.isAudio||!o?.isAudio)}removeRoute(t){delete this.routes[t],this.updateRoutes()}triggerVirtualMidi(t,e,s){this.findById(t).sendMidi(zo.fromNote(e,"noteOn"===s))}dispose(){Object.values(this.modules).forEach((t=>{t.dispose()})),this.modules={},this.routes={}}findById(t){const e=this.modules[t];if(!e)throw Error(`Audio module with id ${t} not exists`);return e}get isStarted(){return void 0!==this.context&&"started"===this.context.transport.state&&this._isStarted}start(){const t=Bo();this._isStarted=!0,this.updateRoutes(),Object.values(this.modules).forEach((e=>{const s=e;s.start&&s.start(t)}))}stop(){const t=Bo();Object.values(this.modules).forEach((e=>{const s=e;s.stop&&s.stop(t)})),this._isStarted=!1}get bpm(){return this.context.transport.bpm.value}set bpm(t){this.context.transport.bpm.value=t}updateRoutes(){var t;t=Object.values(this.routes),Object.values(Qu.modules).forEach((t=>{t.unPlugAll()})),t.map((t=>{const{sourceId:e,sourceIOId:s,destinationId:n,destinationIOId:i}=t,r=Qu.findById(e),o=Qu.findById(n),a=r.outputs.find(s),c=o.inputs.find(i);if(!c||!a)throw Error("IO not found");return $c(c,a),!0})).every((t=>t))?console.log("######## Routes succesfully applied"):console.log("######## Routes partialy applied")}moduleRouteIds(t){const e={...this.routes};return Object.keys(e).filter((s=>{const{sourceId:n,destinationId:i}=e[s];return n===t||i===t}))}}var Qu=Yu.getInstance();exports.MidiDevice=Wo,exports.MidiDeviceManager=Go,exports.Note=Fo,exports.default=Qu;
|
|
25
|
-
//# sourceMappingURL=main.cjs.js.map
|