@blibliki/engine 0.1.22 → 0.1.24
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/README.md +2 -2
- package/dist/build/Engine.d.ts +1 -1
- package/dist/build/modules/LFO.d.ts +44 -0
- package/dist/build/modules/Oscillator.d.ts +8 -4
- package/dist/build/routes.d.ts +1 -1
- package/dist/main.cjs.js +4 -12
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.esm.js +4 -12
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/core/IO/AudioNode.ts +5 -1
- package/src/modules/LFO.ts +150 -0
- package/src/modules/Oscillator.ts +28 -6
- package/src/modules/index.ts +3 -3
package/dist/main.esm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const t="14.7.77",e=(t,e,n)=>({endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}),n=(t,e,n)=>({endTime:e,insertTime:n,type:"linearRampToValue",value:t}),s=(t,e)=>({startTime:e,type:"setValue",value:t}),i=(t,e,n)=>({duration:n,startTime:e,type:"setValueCurve",values:t}),r=(t,e,{startTime:n,target:s,timeConstant:i})=>s+(e-s)*Math.exp((n-t)/i),o=t=>"exponentialRampToValue"===t.type,a=t=>"linearRampToValue"===t.type,u=t=>o(t)||a(t),c=t=>"setValue"===t.type,l=t=>"setValueCurve"===t.type,h=(t,e,n,s)=>{const i=t[e];return void 0===i?s:u(i)||c(i)?i.value:l(i)?i.values[i.values.length-1]:r(n,h(t,e-1,i.startTime,s),i)},p=(t,e,n,s,i)=>void 0===n?[s.insertTime,i]:u(n)?[n.endTime,n.value]:c(n)?[n.startTime,n.value]:l(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,h(t,e-1,n.startTime,i)],d=t=>"cancelAndHold"===t.type,f=t=>"cancelScheduledValues"===t.type,_=t=>d(t)||f(t)?t.cancelTime:o(t)||a(t)?t.endTime:t.startTime,m=(t,e,n,{endTime:s,value:i})=>n===i?i:0<n&&0<i||n<0&&i<0?n*(i/n)**((t-e)/(s-e)):0,g=(t,e,n,{endTime:s,value:i})=>n+(t-e)/(s-e)*(i-n),v=(t,{duration:e,startTime:n,values:s})=>((t,e)=>{const n=Math.floor(e),s=Math.ceil(e);return n===s?t[n]:(1-(e-n))*t[n]+(1-(s-e))*t[s]})(s,(t-n)/e*(s.length-1)),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=_(t);if(d(t)||f(t)){const a=this._automationEvents.findIndex((e=>f(t)&&l(e)?e.startTime+e.duration>=r:_(e)>=r)),c=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!==c&&u(c)){if(void 0!==t&&y(t))throw new Error("The internal list is malformed.");const s=void 0===t?c.insertTime:l(t)?t.startTime+t.duration:_(t),i=void 0===t?this._defaultValue:l(t)?t.values[t.values.length-1]:t.value,a=o(c)?m(r,s,i,c):g(r,s,i,c),u=o(c)?e(a,r,this._currenTime):n(a,r,this._currenTime);this._automationEvents.push(u)}if(void 0!==t&&y(t)&&this._automationEvents.push(s(this.getValue(r),r)),void 0!==t&&l(t)&&t.startTime+t.duration>r){const e=r-t.startTime,n=(t.values.length-1)/t.duration,s=Math.max(2,1+Math.ceil(e*n)),o=e/(s-1)*n,a=t.values.slice(0,s);if(o<1)for(let e=1;e<s;e+=1){const n=o*e%1;a[e]=t.values[e-1]*(1-n)+t.values[e]*n}this._automationEvents[this._automationEvents.length-1]=i(a,t.startTime,e)}}}else{const s=this._automationEvents.findIndex((t=>_(t)>r)),i=-1===s?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[s-1];if(void 0!==i&&l(i)&&_(i)+i.duration>r)return!1;const u=o(t)?e(t.value,t.endTime,this._currenTime):a(t)?n(t.value,r,this._currenTime):t;if(-1===s)this._automationEvents.push(u);else{if(l(t)&&r+t.duration>_(this._automationEvents[s]))return!1;this._automationEvents.splice(s,0,u)}}return!0}flush(t){const e=this._automationEvents.findIndex((e=>_(e)>t));if(e>1){const t=this._automationEvents.slice(e-1),n=t[0];y(n)&&t.unshift(s(h(this._automationEvents,e-2,n.startTime,this._defaultValue),n.startTime)),this._automationEvents=t}}getValue(t){if(0===this._automationEvents.length)return this._defaultValue;const e=this._automationEvents.findIndex((e=>_(e)>t)),n=this._automationEvents[e],s=(-1===e?this._automationEvents.length:e)-1,i=this._automationEvents[s];if(void 0!==i&&y(i)&&(void 0===n||!u(n)||n.insertTime>t))return r(t,h(this._automationEvents,s-1,i.startTime,this._defaultValue),i);if(void 0!==i&&c(i)&&(void 0===n||!u(n)))return i.value;if(void 0!==i&&l(i)&&(void 0===n||!u(n)||i.startTime+i.duration>t))return t<i.startTime+i.duration?v(t,i):i.values[i.values.length-1];if(void 0!==i&&u(i)&&(void 0===n||!u(n)))return i.value;if(void 0!==n&&o(n)){const[e,r]=p(this._automationEvents,s,i,n,this._defaultValue);return m(t,e,r,n)}if(void 0!==n&&a(n)){const[e,r]=p(this._automationEvents,s,i,n,this._defaultValue);return g(t,e,r,n)}return this._defaultValue}}const b=new WeakSet,x=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 n=[];let s=t.replace(/^[\s]+/,""),i=s.match(I);for(;null!==i;){const t=i[1].slice(1,-1),r=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(r),s=s.slice(i[0].length).replace(/^[\s]+/,""),i=s.match(I)}return[n.join(";"),s]},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.")},P=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},V=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[s]=n;return t.delete(s),s},F=(t,e,n,s)=>{const i=P(t,e),r=V(i,(t=>t[0]===n&&t[1]===s));return 0===i.size&&t.delete(e),r},q=t=>P(S,t),j=t=>{if(b.has(t))throw new Error("The AudioNode is already stored.");b.add(t),q(t).forEach((t=>t(!0)))},z=t=>"port"in t,W=t=>{if(!b.has(t))throw new Error("The AudioNode is not stored.");b.delete(t),q(t).forEach((t=>t(!1)))},L=(t,e)=>{!z(t)&&e.every((t=>0===t.size))&&W(t)},U={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},H=(t,e)=>t.context===e,$=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},G=()=>new DOMException("","IndexSizeError"),X=t=>{var e;t.getChannelData=(e=t.getChannelData,n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw G();throw t}})},Z={numberOfChannels:1},Y=-34028234663852886e22,Q=-Y,K=t=>b.has(t),J={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},tt=t=>P(x,t),et=t=>P(A,t),nt=(t,e)=>{const{activeInputs:n}=tt(t);n.forEach((n=>n.forEach((([n])=>{e.includes(t)||nt(n,[...e,t])}))));const s=(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 s){const n=et(t);void 0!==n&&n.activeInputs.forEach((([t])=>nt(t,e)))}K(t)&&W(t)},st=t=>{nt(t.destination,[])},it=t=>"context"in t,rt=t=>it(t[0]),ot=(t,e,n,s)=>{for(const e of t)if(n(e)){if(s)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},at=(t,e,[n,s],i)=>{ot(t,[e,n,s],(t=>t[0]===e&&t[1]===n),i)},ut=(t,[e,n,s],i)=>{const r=t.get(e);void 0===r?t.set(e,new Set([[n,s]])):ot(r,[n,s],(t=>t[0]===n),i)},ct=t=>"inputs"in t,lt=(t,e,n,s)=>{if(ct(e)){const i=e.inputs[s];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,s),[e,n,s]},ht=(t,e,n)=>{for(const s of t)if(s[0]===e&&s[1]===n)return t.delete(s),s;return null},pt=(t,e)=>{if(!q(t).delete(e))throw new Error("Missing the expected event listener.")},dt=(t,e,n)=>{const s=P(t,e),i=V(s,(t=>t[0]===n));return 0===s.size&&t.delete(e),i},ft=(t,e,n,s)=>{ct(e)?t.disconnect(e.inputs[s],n,0):t.disconnect(e,n,s)},_t=t=>P(T,t),mt=t=>P(k,t),gt=t=>O.has(t),vt=t=>!b.has(t),yt=(t,e)=>new Promise((n=>{if(null!==e)n(!0);else{const e=t.createScriptProcessor(256,1,1),s=t.createGain(),i=t.createBuffer(1,2,44100),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(s),o.disconnect(s),e.onaudioprocess=s=>{const i=s.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?n(!0):n(!1),o.stop(),e.onaudioprocess=null,o.disconnect(e),e.disconnect(t.destination)},o.start()}})),wt=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach(((t,n)=>e(n,t)))},bt=t=>"context"in t,xt=(t,e,n,s)=>{const{activeInputs:i,passiveInputs:r}=et(e),{outputs:o}=tt(t),a=q(t),u=o=>{const a=_t(t),u=mt(e);if(o){const e=dt(r,t,n);at(i,t,e,!1),s||gt(t)||a.connect(u,n)}else{const e=((t,e,n)=>V(t,(t=>t[0]===e&&t[1]===n)))(i,t,n);ut(r,e,!1),s||gt(t)||a.disconnect(u,n)}};return!!ot(o,[e,n],(t=>t[0]===e&&t[1]===n),!0)&&(a.add(u),K(t)?at(i,t,[n,u],!0):ut(r,[t,n,u],!0),!0)},Tt=(t,e,n,s,i)=>{const[r,o]=((t,e,n,s)=>{const{activeInputs:i,passiveInputs:r}=tt(e),o=ht(i[s],t,n);if(null===o)return[F(r,t,n,s)[2],!1];return[o[2],!0]})(t,n,s,i);if(null!==r&&(pt(t,r),!o||e||gt(t)||ft(_t(t),_t(n),s,i)),K(n)){const{activeInputs:t}=tt(n);L(n,t)}},At=(t,e,n,s)=>{const[i,r]=((t,e,n)=>{const{activeInputs:s,passiveInputs:i}=et(e),r=ht(s,t,n);if(null===r)return[dt(i,t,n)[1],!1];return[r[2],!0]})(t,n,s);null!==i&&(pt(t,i),!r||e||gt(t)||_t(t).disconnect(mt(n),s))};class kt{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach(((n,s)=>t.call(e,n,s,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const Ct={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function St(t,e,n,s,i){if("function"==typeof t.copyFromChannel)0===e[n].byteLength&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],s,i);else{const r=t.getChannelData(s);if(0===e[n].byteLength)e[n]=r.slice(i,i+128);else{const t=new Float32Array(r.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(t)}}}const Ot=(t,e,n,s,i)=>{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],s,i):0!==e[n].byteLength&&t.getChannelData(s).set(e[n],i)},Mt=(t,e)=>{const n=[];for(let s=0;s<t;s+=1){const t=[],i="number"==typeof e?e:e[s];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));n.push(t)}return n},Et=async(t,e,n,s,i,r,o)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,u=s.channelCount*s.numberOfInputs,c=i.reduce(((t,e)=>t+e),0),l=0===c?null:n.createBuffer(c,a,n.sampleRate);if(void 0===r)throw new Error("Missing the processor constructor.");const h=tt(t),p=await((t,e)=>{const n=P(E,t),s=_t(e);return P(n,s)})(n,t),d=Mt(s.numberOfInputs,s.channelCount),f=Mt(s.numberOfOutputs,i),_=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let c=0;c<a;c+=128){if(s.numberOfInputs>0&&null!==e)for(let t=0;t<s.numberOfInputs;t+=1)for(let n=0;n<s.channelCount;n+=1)St(e,d[t],n,n,c);void 0!==r.parameterDescriptors&&null!==e&&r.parameterDescriptors.forEach((({name:t},n)=>{St(e,_,t,u+n,c)}));for(let t=0;t<s.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===f[t][e].byteLength&&(f[t][e]=new Float32Array(128));try{const t=d.map(((t,e)=>0===h.activeInputs[e].size?[]:t)),e=o(c/n.sampleRate,n.sampleRate,(()=>p.process(t,f,_)));if(null!==l)for(let t=0,e=0;t<s.numberOfOutputs;t+=1){for(let n=0;n<i[t];n+=1)Ot(l,f[t],n,e+n,c);e+=i[t]}if(!e)break}catch(e){t.dispatchEvent(new ErrorEvent("processorerror",{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}));break}}return l},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},Pt=t=>{const{port1:e,port2:n}=new MessageChannel;return new Promise((s=>{const i=()=>{n.onmessage=null,e.close(),n.close(),s()};n.onmessage=()=>i();try{e.postMessage(t,[t])}catch{}finally{i()}}))},Vt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},Ft=(t,e,n)=>{const s=e[n];if(void 0===s)throw t();return s},qt={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"},Ut=(t,e,n,s,i,r,o,a,u,c,l)=>{const h=c.length;let p=a;for(let a=0;a<h;a+=1){let h=n[0]*c[a];for(let e=1;e<i;e+=1){const s=p-e&u-1;h+=n[e]*r[s],h-=t[e]*o[s]}for(let t=i;t<s;t+=1)h+=n[t]*r[p-t&u-1];for(let n=i;n<e;n+=1)h-=t[n]*o[p-n&u-1];r[p]=c[a],o[p]=h,p=p+1&u-1,l[a]=h}return p},Ht={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},$t=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==n&&(n.catch((()=>{})),!0)}catch{}return!1},Gt=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n]&&(t[n]=s)},Xt=(t,e)=>{Gt(t,e,"channelCount"),Gt(t,e,"channelCountMode"),Gt(t,e,"channelInterpretation")},Zt=t=>"function"==typeof t.getFloatTimeDomainData,Yt=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n].value&&(t[n].value=s)},Qt=t=>{var e;t.start=(e=t.start,(n=0,s=0,i)=>{if("number"==typeof i&&i<0||s<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,s,i)})},Kt=t=>{var e;t.stop=(e=t.stop,(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})},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 n=await(t=>new Promise(((e,n)=>{const{port1:s,port2:i}=new MessageChannel;s.onmessage=({data:t})=>{s.close(),i.close(),e(t)},s.onmessageerror=({data:t})=>{s.close(),i.close(),n(t)},i.postMessage(t)})))(e);return new t(n)},ee=(t,e)=>{const n=t.createBiquadFilter();return Xt(n,e),Yt(n,e,"Q"),Yt(n,e,"detune"),Yt(n,e,"frequency"),Yt(n,e,"gain"),Gt(n,e,"type"),n},ne=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return Xt(n,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()}})})(n),n},se=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),ie=(t,e)=>{const n=t.createDelay(e.maxDelayTime);return Xt(n,e),Yt(n,e,"delayTime"),n},re=(t,e)=>{const n=t.createGain();return Xt(n,e),Yt(n,e,"gain"),n};function oe(t,e){const n=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/n,(t[1]*e[0]-t[0]*e[1])/n]}function ae(t,e){let n=[0,0];for(let r=t.length-1;r>=0;r-=1)i=e,n=[(s=n)[0]*i[0]-s[1]*i[1],s[0]*i[1]+s[1]*i[0]],n[0]+=t[r];var s,i;return n}const ue=(t,e,n,s)=>t.createScriptProcessor(e,n,s),ce=()=>new DOMException("","NotSupportedError"),le={numberOfChannels:1},he={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},_e={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},me=(t,e,n)=>void 0===t.copyFromChannel?t.getChannelData(n)[0]:(t.copyFromChannel(e,n),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,n,s)=>{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:n(r),set:s(o)})},ye=(t,e,n)=>{try{t.setValueAtTime(e,n)}catch(s){if(9!==s.code)throw s;ye(t,e,n+1e-7)}},we=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},be=t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},xe=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},Te=(t,e)=>{const n=e.createGain();t.connect(n);const s=(e=>()=>{e.call(t,n),t.removeEventListener("ended",s)})(t.disconnect);t.addEventListener("ended",s),se(t,n),t.stop=(e=>{let s=!1;return(i=0)=>{if(s)try{e.call(t,i)}catch{n.gain.setValueAtTime(0,i)}else e.call(t,i),s=!0}})(t.stop)},Ae=(t,e)=>n=>{const s={value:t};return Object.defineProperties(n,{currentTarget:s,target:s}),"function"==typeof e?e.call(t,n):e.handleEvent.call(t,n)},ke=(t=>(e,n,[s,i,r],o)=>{t(e[i],[n,s,r],(t=>t[0]===n&&t[1]===s),o)})(ot),Ce=(t=>(e,n,[s,i,r],o)=>{const a=e.get(s);void 0===a?e.set(s,new Set([[i,n,r]])):t(a,[i,n,r],(t=>t[0]===i&&t[1]===n),o)})(ot),Se=(t=>(e,n,s,i)=>t(e[i],(t=>t[0]===n&&t[1]===s)))(V),Oe=new WeakMap,Me=(t=>e=>{var n;return null!==(n=t.get(e))&&void 0!==n?n:0})(Oe),Ee=(De=new Map,Ie=new WeakMap,(t,e)=>{const n=Ie.get(t);if(void 0!==n)return n;const s=De.get(t);if(void 0!==s)return s;try{const n=e();return n instanceof Promise?(De.set(t,n),n.catch((()=>!1)).then((e=>(De.delete(t),Ie.set(t,e),e)))):(Ie.set(t,n),n)}catch{return Ie.set(t,!1),!1}});var De,Ie;const Re="undefined"==typeof window?null:window,Ne=((t,e)=>(n,s)=>{const i=n.createAnalyser();if(Xt(i,s),!(s.maxDecibels>s.minDecibels))throw e();return Gt(i,s,"fftSize"),Gt(i,s,"maxDecibels"),Gt(i,s,"minDecibels"),Gt(i,s,"smoothingTimeConstant"),t(Zt,(()=>Zt(i)))||(t=>{t.getFloatTimeDomainData=e=>{const n=new Uint8Array(e.length);t.getByteTimeDomainData(n);const s=Math.max(n.length,t.fftSize);for(let t=0;t<s;t+=1)e[t]=.0078125*(n[t]-128);return e}})(i),i})(Ee,G),Be=(t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer})(tt),Pe=((t,e,n)=>async(s,i,r)=>{const o=t(s);await Promise.all(o.activeInputs.map(((t,o)=>Array.from(t).map((async([t,a])=>{const u=e(t),c=await u.render(t,i),l=s.context.destination;n(t)||s===l&&n(s)||c.connect(r,a,o)})))).reduce(((t,e)=>[...t,...e]),[]))})(tt,Be,gt),Ve=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,r){const o=s.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!H(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 s.set(r,o),await n(i,r,o),o})(i,r)}}})(Ne,_t,Pe),Fe=(qe=C,t=>{const e=qe.get(t);if(void 0===e)throw zt();return e});var qe;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,n,s){if(null!==n){let i=this._listeners.get(n);void 0===i&&(i=t(this,n),"function"==typeof n&&this._listeners.set(n,i)),this._nativeEventTarget.addEventListener(e,i,s)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const s=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===s?null:s,n)}})(Ae),Ue=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(Re),He=(t=>e=>null!==t&&e instanceof t)(Ue),$e=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(Re),Ge=(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,n,s,i,r,o,a,u,c,l,h,p,d,f,_)=>class extends c{constructor(e,s,i,r){super(i),this._context=e,this._nativeAudioNode=i;const o=l(e);h(o)&&!0!==n(yt,(()=>yt(o,_)))&&(t=>{const e=new Map;t.connect=(t=>(n,s=0,i=0)=>{const r=bt(n)?t(n,s,i):t(n,s),o=e.get(n);return void 0===o?e.set(n,[{input:i,output:s}]):o.every((t=>t.input!==i||t.output!==s))&&o.push({input:i,output:s}),r})(t.connect.bind(t)),t.disconnect=(n=>(s,i,r)=>{if(n.apply(t),void 0===s)e.clear();else if("number"==typeof s)for(const[t,n]of e){const i=n.filter((t=>t.output!==s));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(s))if(void 0===i)e.delete(s);else{const t=e.get(s);if(void 0!==t){const n=t.filter((t=>t.output!==i&&(t.input!==r||void 0===r)));0===n.length?e.delete(s):e.set(s,n)}}for(const[n,s]of e)s.forEach((e=>{bt(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)}))})(t.disconnect)})(i),T.set(this,i),S.set(this,new Set),"closed"!==e.state&&s&&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,n=0,a=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();const c=l(this._context),h=f(c);if(p(t)||d(t))throw r();if(it(t)){const i=_t(t);try{const e=lt(this._nativeAudioNode,i,n,a),s=vt(this);(h||s)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!s&&vt(t)&&j(t)}catch(t){if(12===t.code)throw r();throw t}if(e(this,t,n,a,h)){const e=u([this],t);wt(e,s(h))}return t}const _=mt(t);if("playbackRate"===_.name&&1024===_.maxValue)throw o();try{this._nativeAudioNode.connect(_,n),(h||vt(this))&&this._nativeAudioNode.disconnect(_,n)}catch(t){if(12===t.code)throw r();throw t}if(xt(this,t,n,h)){const e=u([this],t);wt(e,s(h))}}disconnect(t,e,n){let s;const o=l(this._context),c=f(o);if(void 0===t)s=((t,e)=>{const n=tt(t),s=[];for(const i of n.outputs)rt(i)?Tt(t,e,...i):At(t,e,...i),s.push(i[0]);return n.outputs.clear(),s})(this,c);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();s=((t,e,n)=>{const s=tt(t),i=[];for(const r of s.outputs)r[1]===n&&(rt(r)?Tt(t,e,...r):At(t,e,...r),i.push(r[0]),s.outputs.delete(r));return i})(this,c,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(it(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(s=((t,e,n,s,i)=>{const r=tt(t);return Array.from(r.outputs).filter((t=>!(t[0]!==n||void 0!==s&&t[1]!==s||void 0!==i&&t[2]!==i))).map((n=>(rt(n)?Tt(t,e,...n):At(t,e,...n),r.outputs.delete(n),n[0])))})(this,c,t,e,n),0===s.length)throw r()}for(const t of s){const e=u([this],t);wt(e,a)}}})((Ye=x,(t,e,n)=>{const s=[];for(let t=0;t<n.numberOfInputs;t+=1)s.push(new Set);Ye.set(t,{activeInputs:s,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,n,s,i,r,o,a,u,c,l,h,p)=>{const d=new WeakMap;return(f,_,m,g,v)=>{const{activeInputs:y,passiveInputs:w}=r(_),{outputs:b}=r(f),x=a(f),T=r=>{const a=u(_),c=u(f);if(r){const e=F(w,f,m,g);t(y,f,e,!1),v||h(f)||n(c,a,m,g),p(_)&&j(_)}else{const t=s(y,f,m,g);e(w,g,t,!1),v||h(f)||i(c,a,m,g);const n=o(_);if(0===n)l(_)&&L(_,y);else{const t=d.get(_);void 0!==t&&clearTimeout(t),d.set(_,setTimeout((()=>{l(_)&&L(_,y)}),1e3*n))}}};return!!c(b,[_,m,g],(t=>t[0]===_&&t[1]===m&&t[2]===g),!0)&&(x.add(T),l(f)?t(y,f,[m,g,T],!0):e(w,g,[f,m,T],!0),!0)}})(ke,Ce,lt,Se,ft,tt,Me,q,_t,ot,K,gt,vt),Ee,((t,e,n,s,i,r)=>o=>(a,u)=>{const c=t.get(a);if(void 0===c){if(!o&&r(a)){const t=s(a),{outputs:r}=n(a);for(const n of r)if(rt(n)){const i=s(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(a,u)}else t.set(a,c+u)})(O,ft,tt,_t,mt,K),G,Wt,ce,((t,e,n,s,i,r,o,a)=>(u,c)=>{const l=e.get(u);if(void 0===l)throw new Error("Missing the expected cycle count.");const h=r(u.context),p=a(h);if(l===c){if(e.delete(u),!p&&o(u)){const e=s(u),{outputs:r}=n(u);for(const n of r)if(rt(n)){const i=s(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(u,l-c)})(lt,O,tt,_t,mt,Fe,K,ze),((t,e,n)=>function s(i,r){const o=it(r)?r:n(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=>s([...i,o],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(We,tt,P),Le,Fe,He,$e,Ge,ze,Xe);var Ye;const Qe=((t,e,n,s,i,r)=>class extends t{constructor(t,n){const o=i(t),a={...U,...n},u=s(o,a);super(t,!1,u,r(o)?e():null),this._nativeAnalyserNode=u}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,n()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,n()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(Ze,Ve,G,Ne,Fe,ze),Ke=new WeakSet,Je=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(Re),tn=(en=new Uint32Array(1),t=>(en[0]=t,en[0]));var en;const nn=((t,e)=>n=>{n.copyFromChannel=(s,i,r=0)=>{const o=t(r),a=t(i);if(a>=n.numberOfChannels)throw e();const u=n.length,c=n.getChannelData(a),l=s.length;for(let t=o<0?-o:0;t+o<u&&t<l;t+=1)s[t]=c[t+o]},n.copyToChannel=(s,i,r=0)=>{const o=t(r),a=t(i);if(a>=n.numberOfChannels)throw e();const u=n.length,c=n.getChannelData(a),l=s.length;for(let t=o<0?-o:0;t+o<u&&t<l;t+=1)c[t+o]=s[t]}})(tn,G),sn=(t=>e=>{e.copyFromChannel=(n=>(s,i,r=0)=>{const o=t(r),a=t(i);if(o<e.length)return n.call(e,s,a,o)})(e.copyFromChannel),e.copyToChannel=(n=>(s,i,r=0)=>{const o=t(r),a=t(i);if(o<e.length)return n.call(e,s,a,o)})(e.copyToChannel)})(tn),rn=((t,e,n,s,i,r,o,a)=>{let u=null;return class c{constructor(c){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:h,sampleRate:p}={...Z,...c};null===u&&(u=new i(1,1,44100));const d=null!==s&&e(r,r)?new s({length:l,numberOfChannels:h,sampleRate:p}):u.createBuffer(h,l,p);if(0===d.numberOfChannels)throw n();return"function"!=typeof d.copyFromChannel?(o(d),X(d)):e($,(()=>$(d)))||a(d),t.add(d),d}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===c.prototype||t.has(e)}}})(Ke,Ee,ce,Je,je,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(Je),nn,sn),on=(t=>(e,n)=>{const s=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.connect(s).connect(e.destination);const i=()=>{n.removeEventListener("ended",i),n.disconnect(s),s.disconnect()};n.addEventListener("ended",i)})(re),an=((t,e,n)=>async(s,i,r)=>{const o=e(s);await Promise.all(Array.from(o.activeInputs).map((async([e,s])=>{const o=t(e),a=await o.render(e,i);n(e)||a.connect(r,s)})))})(Be,et,gt),un=(t=>(e,n,s)=>t(n,e,s))(an),cn=((t,e,n,s,i,r,o,a,u,c,l)=>(h,p)=>{const d=h.createBufferSource();return Xt(d,p),Yt(d,p,"playbackRate"),Gt(d,p,"buffer"),Gt(d,p,"loop"),Gt(d,p,"loopEnd"),Gt(d,p,"loopStart"),e(n,(()=>n(h)))||(t=>{t.start=(e=>{let n=!1;return(s=0,i=0,r)=>{if(n)throw zt();e.call(t,s,i,r),n=!0}})(t.start)})(d),e(s,(()=>s(h)))||u(d),e(i,(()=>i(h)))||c(d,h),e(r,(()=>r(h)))||Qt(d),e(o,(()=>o(h)))||l(d,h),e(a,(()=>a(h)))||Kt(d),t(h,d),d})(on,Ee,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;try{e.start(0,1)}catch{return!1}return!0}),(t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0}),we,be,xe,(t=>{var e;t.start=(e=t.start,(n=0,s=0,i)=>{const r=t.buffer,o=null===r?s:Math.min(r.duration,s);null!==r&&o>r.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,o,i)})}),(t=>(e,n)=>{const s=n.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=s),t(e,"buffer",(t=>()=>{const n=t.call(e);return n===s?null:n}),(t=>n=>t.call(e,null===n?s:n)))})(ve),Te),ln=((t,e)=>(n,s,i)=>(t(s).replay(i),e(s,n,i)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(et),an),hn=((t,e,n,s,i)=>()=>{const r=new WeakMap;let o=null,a=null;return{set start(t){o=t},set stop(t){a=t},render(u,c){const l=r.get(c);return void 0!==l?Promise.resolve(l):(async(u,c)=>{let l=n(u);const h=H(l,c);if(!h){const t={buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value};l=e(c,t),null!==o&&l.start(...o),null!==a&&l.stop(a)}return r.set(c,l),h?await t(c,u.playbackRate,l.playbackRate):await s(c,u.playbackRate,l.playbackRate),await i(u,c,l),l})(u,c)}}})(un,cn,_t,ln,Pe),pn=((t,e,n,s,i,r,o,a,u,c,l,h,p)=>(d,f,_,m=null,g=null)=>{const v=_.value,y=new w(v),b=f?s(y):null,x={get defaultValue(){return v},get maxValue(){return null===m?_.maxValue:m},get minValue(){return null===g?_.minValue:g},get value(){return _.value},set value(t){_.value=t,x.setValueAtTime(t,d.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof _.cancelAndHoldAtTime)null===b&&y.flush(d.context.currentTime),y.add(i(t)),_.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===b&&y.flush(d.context.currentTime),y.add(i(t));const n=Array.from(y).pop();_.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?_.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?_.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?_.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&_.setValueCurveAtTime(n.values,n.startTime,n.duration))}return x},cancelScheduledValues:t=>(null===b&&y.flush(d.context.currentTime),y.add(r(t)),_.cancelScheduledValues(t),x),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const n=d.context.currentTime;return null===b&&y.flush(n),0===Array.from(y).length&&(y.add(c(v,n)),_.setValueAtTime(v,n)),y.add(o(t,e)),_.exponentialRampToValueAtTime(t,e),x},linearRampToValueAtTime(t,e){const n=d.context.currentTime;return null===b&&y.flush(n),0===Array.from(y).length&&(y.add(c(v,n)),_.setValueAtTime(v,n)),y.add(a(t,e)),_.linearRampToValueAtTime(t,e),x},setTargetAtTime:(t,e,n)=>(null===b&&y.flush(d.context.currentTime),y.add(u(t,e,n)),_.setTargetAtTime(t,e,n),x),setValueAtTime:(t,e)=>(null===b&&y.flush(d.context.currentTime),y.add(c(t,e)),_.setValueAtTime(t,e),x),setValueCurveAtTime(t,e,n){const s=t instanceof Float32Array?t:new Float32Array(t);if(null!==h&&"webkitAudioContext"===h.name){const t=e+n,i=d.context.sampleRate,r=Math.ceil(e*i),o=Math.floor(t*i),a=o-r,u=new Float32Array(a);for(let t=0;t<a;t+=1){const o=(s.length-1)/n*((r+t)/i-e),a=Math.floor(o),c=Math.ceil(o);u[t]=a===c?s[a]:(1-(o-a))*s[a]+(1-(c-o))*s[c]}null===b&&y.flush(d.context.currentTime),y.add(l(u,e,n)),_.setValueCurveAtTime(u,e,n);const c=o/i;c<t&&p(x,u[u.length-1],c),p(x,s[s.length-1],t)}else null===b&&y.flush(d.context.currentTime),y.add(l(s,e,n)),_.setValueCurveAtTime(s,e,n);return x}};return n.set(x,_),e.set(x,d),t(x,b),x})((dn=A,(t,e)=>{dn.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),We,k,(t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:s}=n;e.exponentialRampToValueAtTime(s,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:s}=n;e.linearRampToValueAtTime(s,t)}else if("setTarget"===n.type){const{startTime:t,target:s,timeConstant:i}=n;e.setTargetAtTime(s,t,i)}else if("setValue"===n.type){const{startTime:t,value:s}=n;e.setValueAtTime(s,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:s,values:i}=n;e.setValueCurveAtTime(i,s,t)}}}})),(t=>({cancelTime:t,type:"cancelAndHold"})),(t=>({cancelTime:t,type:"cancelScheduledValues"})),((t,e)=>({endTime:e,type:"exponentialRampToValue",value:t})),((t,e)=>({endTime:e,type:"linearRampToValue",value:t})),((t,e,n)=>({startTime:e,target:t,timeConstant:n,type:"setTarget"})),s,i,Ue,ye);var dn;const fn=((t,e,n,s,i,r,o,a)=>class extends t{constructor(t,s){const a=r(t),u={...J,...s},c=i(a,u),l=o(a),h=l?e():null;super(t,!1,c,h),this._audioBufferSourceNodeRenderer=h,this._isBufferNullified=!1,this._isBufferSet=null!==u.buffer,this._nativeAudioBufferSourceNode=c,this._onended=null,this._playbackRate=n(this,l,c.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 s();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const n=this._nativeAudioBufferSourceNode.onended;this._onended=null!==n&&n===e?t:n}get playbackRate(){return this._playbackRate}start(t=0,e=0,n){if(this._nativeAudioBufferSourceNode.start(t,e,n),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===n?[t,e]:[t,e,n]),"closed"!==this.context.state){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,hn,pn,zt,cn,Fe,ze,Ae),_n=((t,e,n,s,i,r,o,a)=>class extends t{constructor(t,n){const s=r(t),u=o(s),c=i(s,n,u);super(t,!1,c,u?e(a):null),this._isNodeOfNativeOfflineAudioContext=u,this._nativeAudioDestinationNode=c}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw s();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw s();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(Ze,(t=>{const e=new WeakMap;return{render(n,s){const i=e.get(s);return void 0!==i?Promise.resolve(i):(async(n,s)=>{const i=s.destination;return e.set(s,i),await t(n,s,i),i})(n,s)}}}),G,zt,((t,e)=>(n,s,i)=>{const r=n.destination;if(r.channelCount!==s)try{r.channelCount=s}catch{}i&&"explicit"!==r.channelCountMode&&(r.channelCountMode="explicit"),0===r.maxChannelCount&&Object.defineProperty(r,"maxChannelCount",{value:s});const o=t(n,{channelCount:s,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),Fe,ze,Pe),mn=((t,e,n,s,i)=>()=>{const r=new WeakMap;return{render(o,a){const u=r.get(a);return void 0!==u?Promise.resolve(u):(async(o,a)=>{let u=n(o);const c=H(u,a);if(!c){const t={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=e(a,t)}return r.set(a,u),c?(await t(a,o.Q,u.Q),await t(a,o.detune,u.detune),await t(a,o.frequency,u.frequency),await t(a,o.gain,u.gain)):(await s(a,o.Q,u.Q),await s(a,o.detune,u.detune),await s(a,o.frequency,u.frequency),await s(a,o.gain,u.gain)),await i(o,a,u),u})(o,a)}}})(un,ee,_t,ln,Pe),gn=(t=>(e,n)=>t.set(e,n))(Oe),vn=((t,e,n,s,i,r,o,a)=>class extends t{constructor(t,s){const u=r(t),c={...Dt,...s},l=i(u,c),h=o(u);super(t,!1,l,h?n():null),this._Q=e(this,h,l.Q,Q,Y),this._detune=e(this,h,l.detune,1200*Math.log2(Q),-1200*Math.log2(Q)),this._frequency=e(this,h,l.frequency,t.sampleRate/2,0),this._gain=e(this,h,l.gain,40*Math.log10(Q),Y),this._nativeBiquadFilterNode=l,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,n){try{this._nativeBiquadFilterNode.getFrequencyResponse(t,e,n)}catch(t){if(11===t.code)throw s();throw t}if(t.length!==e.length||e.length!==n.length)throw s()}})(Ze,pn,mn,Wt,ee,Fe,ze,gn),yn=((t,e)=>(n,s,i)=>{const r=new Set;return n.connect=(i=>(o,a=0,u=0)=>{const c=0===r.size;if(e(o))return i.call(n,o,a,u),t(r,[o,a,u],(t=>t[0]===o&&t[1]===a&&t[2]===u),!0),c&&s(),o;i.call(n,o,a),t(r,[o,a],(t=>t[0]===o&&t[1]===a),!0),c&&s()})(n.connect),n.disconnect=(t=>(s,o,a)=>{const u=r.size>0;if(void 0===s)t.apply(n),r.clear();else if("number"==typeof s){t.call(n,s);for(const t of r)t[1]===s&&r.delete(t)}else{e(s)?t.call(n,s,o,a):t.call(n,s,o);for(const t of r)t[0]!==s||void 0!==o&&t[1]!==o||void 0!==a&&t[2]!==a||r.delete(t)}const c=0===r.size;u&&c&&i()})(n.disconnect),n})(ot,$e),wn=((t,e)=>(n,s)=>{s.channelCount=1,s.channelCountMode="explicit",Object.defineProperty(s,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(s,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=n.createBufferSource();e(s,(()=>{const t=s.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(s,0,e)}),(()=>i.disconnect(s)))})(zt,yn),bn=((t,e)=>(n,s)=>{const i=n.createChannelMerger(s.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(n,i),Xt(i,s),i})(Ue,wn),xn=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,r){const o=s.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!H(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfInputs:o.numberOfInputs};o=t(r,e)}return s.set(r,o),await n(i,r,o),o})(i,r)}}})(bn,_t,Pe),Tn=((t,e,n,s,i)=>class extends t{constructor(t,r){const o=s(t),a={...It,...r};super(t,!1,n(o,a),i(o)?e():null)}})(Ze,xn,bn,Fe,ze),An=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,r){const o=s.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!H(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfOutputs:o.numberOfOutputs};o=t(r,e)}return s.set(r,o),await n(i,r,o),o})(i,r)}}})(ne,_t,Pe),kn=((t,e,n,s,i,r)=>class extends t{constructor(t,o){const a=s(t),u=r({...Rt,...o});super(t,!1,n(a,u),i(a)?e():null)}})(Ze,An,ne,Fe,ze,(t=>({...t,channelCount:t.numberOfOutputs}))),Cn=((t,e,n,s)=>(i,{offset:r,...o})=>{const a=i.createBuffer(1,2,44100),u=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),c=n(i,{...o,gain:r}),l=a.getChannelData(0);l[0]=1,l[1]=1,u.buffer=a,u.loop=!0;const h={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(t){c.channelCount=t},get channelCountMode(){return c.channelCountMode},set channelCountMode(t){c.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){c.channelInterpretation=t},get context(){return c.context},get inputs(){return[]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get offset(){return c.gain},get onended(){return u.onended},set onended(t){u.onended=t},addEventListener:(...t)=>u.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>u.dispatchEvent(t[0]),removeEventListener:(...t)=>u.removeEventListener(t[0],t[1],t[2]),start(t=0){u.start.call(u,t)},stop(t=0){u.stop.call(u,t)}};return t(i,u),s(se(h,c),(()=>u.connect(c)),(()=>u.disconnect(c)))})(on,cn,re,yn),Sn=((t,e,n,s,i)=>(r,o)=>{if(void 0===r.createConstantSource)return n(r,o);const a=r.createConstantSource();return Xt(a,o),Yt(a,o,"offset"),e(s,(()=>s(r)))||Qt(a),e(i,(()=>i(r)))||Kt(a),t(r,a),a})(on,Ee,Cn,we,xe),On=((t,e,n,s,i)=>()=>{const r=new WeakMap;let o=null,a=null;return{set start(t){o=t},set stop(t){a=t},render(u,c){const l=r.get(c);return void 0!==l?Promise.resolve(l):(async(u,c)=>{let l=n(u);const h=H(l,c);if(!h){const t={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,offset:l.offset.value};l=e(c,t),null!==o&&l.start(o),null!==a&&l.stop(a)}return r.set(c,l),h?await t(c,u.offset,l.offset):await s(c,u.offset,l.offset),await i(u,c,l),l})(u,c)}}})(un,Sn,_t,ln,Pe),Mn=((t,e,n,s,i,r,o)=>class extends t{constructor(t,o){const a=i(t),u={...Nt,...o},c=s(a,u),l=r(a),h=l?n():null;super(t,!1,c,h),this._constantSourceNodeRenderer=h,this._nativeConstantSourceNode=c,this._offset=e(this,l,c.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 n=this._nativeConstantSourceNode.onended;this._onended=null!==n&&n===e?t:n}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){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,pn,On,Sn,Fe,ze,Ae),En=((t,e)=>(n,s)=>{const i=n.createConvolver();if(Xt(i,s),s.disableNormalization===i.normalize&&(i.normalize=!s.disableNormalization),Gt(i,s,"buffer"),s.channelCount>2)throw t();if(e(i,"channelCount",(t=>()=>t.call(i)),(e=>n=>{if(n>2)throw t();return e.call(i,n)})),"max"===s.channelCountMode)throw t();return e(i,"channelCountMode",(t=>()=>t.call(i)),(e=>n=>{if("max"===n)throw t();return e.call(i,n)})),i})(ce,ve),Dn=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,r){const o=s.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!H(o,r)){const e={buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize};o=t(r,e)}return s.set(r,o),ct(o)?await n(i,r,o.inputs[0]):await n(i,r,o),o})(i,r)}}})(En,_t,Pe),In=((t,e,n,s,i,r)=>class extends t{constructor(t,o){const a=s(t),u={...Bt,...o},c=n(a,u);super(t,!1,c,i(a)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=c,null!==u.buffer&&r(this,u.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,Dn,En,Fe,ze,gn),Rn=((t,e,n,s,i)=>r=>{const o=new WeakMap;return{render(a,u){const c=o.get(u);return void 0!==c?Promise.resolve(c):(async(a,u)=>{let c=n(a);const l=H(c,u);if(!l){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,delayTime:c.delayTime.value,maxDelayTime:r};c=e(u,t)}return o.set(u,c),l?await t(u,a.delayTime,c.delayTime):await s(u,a.delayTime,c.delayTime),await i(a,u,c),c})(a,u)}}})(un,ie,_t,ln,Pe),Nn=((t,e,n,s,i,r,o)=>class extends t{constructor(t,a){const u=i(t),c={...Vt,...a},l=s(u,c),h=r(u);super(t,!1,l,h?n(c.maxDelayTime):null),this._delayTime=e(this,h,l.delayTime),o(this,c.maxDelayTime)}get delayTime(){return this._delayTime}})(Ze,pn,Rn,ie,Fe,ze,gn),Bn=(t=>(e,n)=>{const s=e.createDynamicsCompressor();if(Xt(s,n),n.channelCount>2)throw t();if("max"===n.channelCountMode)throw t();return Yt(s,n,"attack"),Yt(s,n,"knee"),Yt(s,n,"ratio"),Yt(s,n,"release"),Yt(s,n,"threshold"),s})(ce),Pn=((t,e,n,s,i)=>()=>{const r=new WeakMap;return{render(o,a){const u=r.get(a);return void 0!==u?Promise.resolve(u):(async(o,a)=>{let u=n(o);const c=H(u,a);if(!c){const t={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=e(a,t)}return r.set(a,u),c?(await t(a,o.attack,u.attack),await t(a,o.knee,u.knee),await t(a,o.ratio,u.ratio),await t(a,o.release,u.release),await t(a,o.threshold,u.threshold)):(await s(a,o.attack,u.attack),await s(a,o.knee,u.knee),await s(a,o.ratio,u.ratio),await s(a,o.release,u.release),await s(a,o.threshold,u.threshold)),await i(o,a,u),u})(o,a)}}})(un,Bn,_t,ln,Pe),Vn=((t,e,n,s,i,r,o,a)=>class extends t{constructor(t,i){const u=r(t),c={...qt,...i},l=s(u,c),h=o(u);super(t,!1,l,h?n():null),this._attack=e(this,h,l.attack),this._knee=e(this,h,l.knee),this._nativeDynamicsCompressorNode=l,this._ratio=e(this,h,l.ratio),this._release=e(this,h,l.release),this._threshold=e(this,h,l.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(t){const e=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=t,t>2)throw this._nativeDynamicsCompressorNode.channelCount=e,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(t){const e=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=t,"max"===t)throw this._nativeDynamicsCompressorNode.channelCountMode=e,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return"number"==typeof this._nativeDynamicsCompressorNode.reduction.value?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}})(Ze,pn,Pn,Bn,ce,Fe,ze,gn),Fn=((t,e,n,s,i)=>()=>{const r=new WeakMap;return{render(o,a){const u=r.get(a);return void 0!==u?Promise.resolve(u):(async(o,a)=>{let u=n(o);const c=H(u,a);if(!c){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=e(a,t)}return r.set(a,u),c?await t(a,o.gain,u.gain):await s(a,o.gain,u.gain),await i(o,a,u),u})(o,a)}}})(un,re,_t,ln,Pe),qn=((t,e,n,s,i,r)=>class extends t{constructor(t,o){const a=i(t),u={...jt,...o},c=s(a,u),l=r(a);super(t,!1,c,l?n():null),this._gain=e(this,l,c.gain,Q,Y)}get gain(){return this._gain}})(Ze,pn,Fn,re,Fe,ze),jn=((t,e,n,s)=>(i,r,{channelCount:o,channelCountMode:a,channelInterpretation:u,feedback:c,feedforward:l})=>{const h=Jt(r,i.sampleRate),p=c instanceof Float64Array?c:new Float64Array(c),d=l instanceof Float64Array?l:new Float64Array(l),f=p.length,_=d.length,m=Math.min(f,_);if(0===f||f>20)throw s();if(0===p[0])throw e();if(0===_||_>20)throw s();if(0===d[0])throw e();if(1!==p[0]){for(let t=0;t<_;t+=1)d[t]/=p[0];for(let t=1;t<f;t+=1)p[t]/=p[0]}const g=n(i,h,o,o);g.channelCount=o,g.channelCountMode=a,g.channelInterpretation=u;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,n=t.outputBuffer,s=e.numberOfChannels;for(let t=0;t<s;t+=1){const s=e.getChannelData(t),i=n.getChannelData(t);v[t]=Ut(p,f,d,_,m,y[t],w[t],v[t],32,s,i)}};const b=i.sampleRate/2,x={get bufferSize(){return h},get channelCount(){return g.channelCount},set channelCount(t){g.channelCount=t},get channelCountMode(){return g.channelCountMode},set channelCountMode(t){g.channelCountMode=t},get channelInterpretation(){return g.channelInterpretation},set channelInterpretation(t){g.channelInterpretation=t},get context(){return g.context},get inputs(){return[g]},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},addEventListener:(...t)=>g.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>g.dispatchEvent(t[0]),getFrequencyResponse(e,n,s){if(e.length!==n.length||n.length!==s.length)throw t();const i=e.length;for(let t=0;t<i;t+=1){const i=-Math.PI*(e[t]/b),r=[Math.cos(i),Math.sin(i)],o=oe(ae(d,r),ae(p,r));n[t]=Math.sqrt(o[0]*o[0]+o[1]*o[1]),s[t]=Math.atan2(o[1],o[0])}},removeEventListener:(...t)=>g.removeEventListener(t[0],t[1],t[2])};return se(x,g)})(Wt,zt,ue,ce),zn=((t,e,n,s)=>i=>t($t,(()=>$t(i)))?Promise.resolve(t(s,s)).then((t=>{if(!t){const t=n(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()})))(Ee,re,ue,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),s=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{n.oncomplete=()=>{s.disconnect(),t(0!==n.currentTime)},n.startRendering()}))})(re,je)),Wn=((t,e,n,s,i)=>(r,o)=>{const a=new WeakMap;let u=null;const c=async(c,l)=>{let h=null,p=e(c);const d=H(p,l);if(void 0===l.createIIRFilter?h=t(l,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):d||(p=l.createIIRFilter(o,r)),a.set(l,null===h?p:h),null!==h){if(null===u){if(null===n)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new n(c.context.destination.channelCount,c.context.length,l.sampleRate);u=(async()=>{await s(c,t,t.destination);return((t,e,n,s)=>{const i=n instanceof Float64Array?n:new Float64Array(n),r=s instanceof Float64Array?s:new Float64Array(s),o=i.length,a=r.length,u=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 c=new Float32Array(32),l=new Float32Array(32),h=e.createBuffer(t.numberOfChannels,t.length,t.sampleRate),p=t.numberOfChannels;for(let e=0;e<p;e+=1){const n=t.getChannelData(e),s=h.getChannelData(e);c.fill(0),l.fill(0),Ut(i,o,r,a,u,c,l,0,32,n,s)}return h})(await i(t),l,r,o)})()}const t=await u;return h.buffer=t,h.start(0),h}return await s(c,l,p),p};return{render(t,e){const n=a.get(e);return void 0!==n?Promise.resolve(n):c(t,e)}}})(cn,_t,je,Pe,zn),Ln=(t=>(e,n,s)=>{if(void 0===e.createIIRFilter)return t(e,n,s);const i=e.createIIRFilter(s.feedforward,s.feedback);return Xt(i,s),i})(jn),Un=((t,e,n,s,i,r)=>class extends t{constructor(t,o){const a=s(t),u=i(a),c={...Lt,...o},l=e(a,u?null:t.baseLatency,c);super(t,!1,l,u?n(c.feedback,c.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(n,s,i)=>{if(n.length!==s.length||s.length!==i.length)throw Wt();return e.call(t,n,s,i)})})(l),this._nativeIIRFilterNode=l,r(this,1)}getFrequencyResponse(t,e,n){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,n)}})(Ze,Ln,Wn,Fe,ze,gn),Hn=((t,e,n,s,i,r,o,a)=>(u,c)=>{const l=c.listener,{forwardX:h,forwardY:p,forwardZ:d,positionX:f,positionY:_,positionZ:m,upX:g,upY:v,upZ:y}=void 0===l.forwardX?(()=>{const h=new Float32Array(1),p=e(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),d=o(c);let f=!1,_=[0,0,-1,0,1,0],m=[0,0,0];const g=()=>{if(f)return;f=!0;const t=s(c,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[r(t,h,0),r(t,h,1),r(t,h,2),r(t,h,3),r(t,h,4),r(t,h,5)];e.some(((t,e)=>t!==_[e]))&&(l.setOrientation(...e),_=e);const n=[r(t,h,6),r(t,h,7),r(t,h,8)];n.some(((t,e)=>t!==m[e]))&&(l.setPosition(...n),m=n)},p.connect(t)},v=t=>e=>{e!==_[t]&&(_[t]=e,l.setOrientation(..._))},y=t=>e=>{e!==m[t]&&(m[t]=e,l.setPosition(...m))},w=(e,s,r)=>{const o=n(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:s});o.connect(p,0,e),o.start(),Object.defineProperty(o.offset,"defaultValue",{get:()=>s});const l=t({context:u},d,o.offset,Q,Y);var h,f,_,m,v,y,w;return a(l,"value",(t=>()=>t.call(l)),(t=>e=>{try{t.call(l,e)}catch(t){if(9!==t.code)throw t}g(),d&&r(e)})),l.cancelAndHoldAtTime=(h=l.cancelAndHoldAtTime,d?()=>{throw i()}:(...t)=>{const e=h.apply(l,t);return g(),e}),l.cancelScheduledValues=(f=l.cancelScheduledValues,d?()=>{throw i()}:(...t)=>{const e=f.apply(l,t);return g(),e}),l.exponentialRampToValueAtTime=(_=l.exponentialRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=_.apply(l,t);return g(),e}),l.linearRampToValueAtTime=(m=l.linearRampToValueAtTime,d?()=>{throw i()}:(...t)=>{const e=m.apply(l,t);return g(),e}),l.setTargetAtTime=(v=l.setTargetAtTime,d?()=>{throw i()}:(...t)=>{const e=v.apply(l,t);return g(),e}),l.setValueAtTime=(y=l.setValueAtTime,d?()=>{throw i()}:(...t)=>{const e=y.apply(l,t);return g(),e}),l.setValueCurveAtTime=(w=l.setValueCurveAtTime,d?()=>{throw i()}:(...t)=>{const e=w.apply(l,t);return g(),e}),l};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))}})():l;return{get forwardX(){return h},get forwardY(){return p},get forwardZ(){return d},get positionX(){return f},get positionY(){return _},get positionZ(){return m},get upX(){return g},get upY(){return v},get upZ(){return y}}})(pn,bn,Sn,ue,ce,me,ze,ve),$n=new WeakMap,Gn=((t,e,n,s,i,r)=>class extends n{constructor(n,r){super(n),this._nativeContext=n,C.set(this,n),s(n)&&i.set(n,new Set),this._destination=new t(this,r),this._listener=e(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e="function"==typeof t?r(this,t):null;this._nativeContext.onstatechange=e;const n=this._nativeContext.onstatechange;this._onstatechange=null!==n&&n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(_n,Hn,Le,ze,$n,Ae),Xn=((t,e,n,s,i,r)=>(o,a)=>{const u=o.createOscillator();return Xt(u,a),Yt(u,a,"detune"),Yt(u,a,"frequency"),void 0!==a.periodicWave?u.setPeriodicWave(a.periodicWave):Gt(u,a,"type"),e(n,(()=>n(o)))||Qt(u),e(s,(()=>s(o)))||r(u,o),e(i,(()=>i(o)))||Kt(u),t(o,u),u})(on,Ee,we,be,xe,Te),Zn=((t,e,n,s,i)=>()=>{const r=new WeakMap;let o=null,a=null,u=null;return{set periodicWave(t){o=t},set start(t){a=t},set stop(t){u=t},render(c,l){const h=r.get(l);return void 0!==h?Promise.resolve(h):(async(c,l)=>{let h=n(c);const p=H(h,l);if(!p){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,detune:h.detune.value,frequency:h.frequency.value,periodicWave:null===o?void 0:o,type:h.type};h=e(l,t),null!==a&&h.start(a),null!==u&&h.stop(u)}return r.set(l,h),p?(await t(l,c.detune,h.detune),await t(l,c.frequency,h.frequency)):(await s(l,c.detune,h.detune),await s(l,c.frequency,h.frequency)),await i(c,l,h),h})(c,l)}}})(un,Xn,_t,ln,Pe),Yn=((t,e,n,s,i,r,o)=>class extends t{constructor(t,o){const a=i(t),u={...he,...o},c=n(a,u),l=r(a),h=l?s():null,p=t.sampleRate/2;super(t,!1,c,h),this._detune=e(this,l,c.detune,153600,-153600),this._frequency=e(this,l,c.frequency,p,-p),this._nativeOscillatorNode=c,this._onended=null,this._oscillatorNodeRenderer=h,null!==this._oscillatorNodeRenderer&&void 0!==u.periodicWave&&(this._oscillatorNodeRenderer.periodicWave=u.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 n=this._nativeOscillatorNode.onended;this._onended=null!==n&&n===e?t:n}get type(){return this._nativeOscillatorNode.type}set type(t){this._nativeOscillatorNode.type=t,null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.start=t),"closed"!==this.context.state){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,pn,Xn,Zn,Fe,ze,Ae),Qn=(t=>(e,n)=>{const s=t(e,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=e.createBuffer(1,2,44100);return s.buffer=i,s.loop=!0,s.connect(n),s.start(),()=>{s.stop(),s.disconnect(n)}})(cn),Kn=((t,e,n,s,i)=>(r,{curve:o,oversample:a,...u})=>{const c=r.createWaveShaper(),l=r.createWaveShaper();Xt(c,u),Xt(l,u);const h=n(r,{...u,gain:1}),p=n(r,{...u,gain:-1}),d=n(r,{...u,gain:1}),f=n(r,{...u,gain:-1});let _=null,m=!1,g=null;const v={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(t){h.channelCount=t,p.channelCount=t,c.channelCount=t,d.channelCount=t,l.channelCount=t,f.channelCount=t},get channelCountMode(){return c.channelCountMode},set channelCountMode(t){h.channelCountMode=t,p.channelCountMode=t,c.channelCountMode=t,d.channelCountMode=t,l.channelCountMode=t,f.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t,p.channelInterpretation=t,c.channelInterpretation=t,d.channelInterpretation=t,l.channelInterpretation=t,f.channelInterpretation=t},get context(){return c.context},get curve(){return g},set curve(n){if(null!==n&&n.length<2)throw e();if(null===n)c.curve=n,l.curve=n;else{const t=n.length,e=new Float32Array(t+2-t%2),s=new Float32Array(t+2-t%2);e[0]=n[0],s[0]=-n[t-1];const i=Math.ceil((t+1)/2),r=(t+1)/2-1;for(let o=1;o<i;o+=1){const a=o/i*r,u=Math.floor(a),c=Math.ceil(a);e[o]=u===c?n[u]:(1-(a-u))*n[u]+(1-(c-a))*n[c],s[o]=u===c?-n[t-1-u]:-(1-(a-u))*n[t-1-u]-(1-(c-a))*n[t-1-c]}e[i]=t%2==1?n[i-1]:(n[i-2]+n[i-1])/2,c.curve=e,l.curve=s}g=n,m&&(s(g)&&null===_?_=t(r,h):null!==_&&(_(),_=null))},get inputs(){return[h]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get oversample(){return c.oversample},set oversample(t){c.oversample=t,l.oversample=t},addEventListener:(...t)=>h.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>h.dispatchEvent(t[0]),removeEventListener:(...t)=>h.removeEventListener(t[0],t[1],t[2])};null!==o&&(v.curve=o instanceof Float32Array?o:new Float32Array(o)),a!==v.oversample&&(v.oversample=a);return i(se(v,d),(()=>{h.connect(c).connect(d),h.connect(p).connect(l).connect(f).connect(d),m=!0,s(g)&&(_=t(r,h))}),(()=>{h.disconnect(c),c.disconnect(d),h.disconnect(p),p.disconnect(l),l.disconnect(f),f.disconnect(d),m=!1,null!==_&&(_(),_=null)}))})(Qn,zt,re,ge,yn),Jn=((t,e,n,s,i,r,o)=>(a,u)=>{const c=a.createWaveShaper();if(null!==r&&"webkitAudioContext"===r.name&&void 0===a.createGain().gain.automationRate)return n(a,u);Xt(c,u);const l=null===u.curve||u.curve instanceof Float32Array?u.curve:new Float32Array(u.curve);if(null!==l&&l.length<2)throw e();Gt(c,{curve:l},"curve"),Gt(c,u,"oversample");let h=null,p=!1;o(c,"curve",(t=>()=>t.call(c)),(e=>n=>(e.call(c,n),p&&(s(n)&&null===h?h=t(a,c):s(n)||null===h||(h(),h=null)),n)));return i(c,(()=>{p=!0,s(c.curve)&&(h=t(a,c))}),(()=>{p=!1,null!==h&&(h(),h=null)}))})(Qn,zt,Kn,ge,yn,Ue,ve),ts=((t,e,n,s,i,r,o,a,u,c)=>(l,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:_,orientationX:m,orientationY:g,orientationZ:v,panningModel:y,positionX:w,positionY:b,positionZ:x,refDistance:T,rolloffFactor:A,...k})=>{const C=l.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=n(l,{...S,channelInterpretation:"speakers",numberOfInputs:6}),M=s(l,{...k,gain:1}),E=s(l,{...S,gain:1}),D=s(l,{...S,gain:0}),I=s(l,{...S,gain:0}),R=s(l,{...S,gain:0}),N=s(l,{...S,gain:0}),B=s(l,{...S,gain:0}),P=i(l,256,6,1),V=r(l,{...S,curve:new Float32Array([1,1]),oversample:"none"});let F=[m,g,v],q=[w,b,x];const j=new Float32Array(1);P.onaudioprocess=({inputBuffer:t})=>{const e=[u(t,j,0),u(t,j,1),u(t,j,2)];e.some(((t,e)=>t!==F[e]))&&(C.setOrientation(...e),F=e);const n=[u(t,j,3),u(t,j,4),u(t,j,5)];n.some(((t,e)=>t!==q[e]))&&(C.setPosition(...n),q=n)},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])};h!==z.coneInnerAngle&&(z.coneInnerAngle=h),p!==z.coneOuterAngle&&(z.coneOuterAngle=p),d!==z.coneOuterGain&&(z.coneOuterGain=d),f!==z.distanceModel&&(z.distanceModel=f),_!==z.maxDistance&&(z.maxDistance=_),m!==z.orientationX.value&&(z.orientationX.value=m),g!==z.orientationY.value&&(z.orientationY.value=g),v!==z.orientationZ.value&&(z.orientationZ.value=v),y!==z.panningModel&&(z.panningModel=y),w!==z.positionX.value&&(z.positionX.value=w),b!==z.positionY.value&&(z.positionY.value=b),x!==z.positionZ.value&&(z.positionZ.value=x),T!==z.refDistance&&(z.refDistance=T),A!==z.rolloffFactor&&(z.rolloffFactor=A),1===F[0]&&0===F[1]&&0===F[2]||C.setOrientation(...F),0===q[0]&&0===q[1]&&0===q[2]||C.setPosition(...q);return c(se(z,C),(()=>{M.connect(C),t(M,V,0,0),V.connect(E).connect(O,0,0),V.connect(D).connect(O,0,1),V.connect(I).connect(O,0,2),V.connect(R).connect(O,0,3),V.connect(N).connect(O,0,4),V.connect(B).connect(O,0,5),O.connect(P).connect(l.destination)}),(()=>{M.disconnect(C),a(M,V,0,0),V.disconnect(E),E.disconnect(O),V.disconnect(D),D.disconnect(O),V.disconnect(I),I.disconnect(O),V.disconnect(R),R.disconnect(O),V.disconnect(N),N.disconnect(O),V.disconnect(B),B.disconnect(O),O.disconnect(P),P.disconnect(l.destination)}))})(lt,zt,bn,re,ue,Jn,ce,ft,me,yn),es=(t=>(e,n)=>{const s=e.createPanner();return void 0===s.orientationX?t(e,n):(Xt(s,n),Yt(s,n,"orientationX"),Yt(s,n,"orientationY"),Yt(s,n,"orientationZ"),Yt(s,n,"positionX"),Yt(s,n,"positionY"),Yt(s,n,"positionZ"),Gt(s,n,"coneInnerAngle"),Gt(s,n,"coneOuterAngle"),Gt(s,n,"coneOuterGain"),Gt(s,n,"distanceModel"),Gt(s,n,"maxDistance"),Gt(s,n,"panningModel"),Gt(s,n,"refDistance"),Gt(s,n,"rolloffFactor"),s)})(ts),ns=((t,e,n,s,i,r,o,a,u,c)=>()=>{const l=new WeakMap;let h=null;return{render(p,d){const f=l.get(d);return void 0!==f?Promise.resolve(f):(async(p,d)=>{let f=null,_=r(p);const m={channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation},g={...m,coneInnerAngle:_.coneInnerAngle,coneOuterAngle:_.coneOuterAngle,coneOuterGain:_.coneOuterGain,distanceModel:_.distanceModel,maxDistance:_.maxDistance,panningModel:_.panningModel,refDistance:_.refDistance,rolloffFactor:_.rolloffFactor},v=H(_,d);if("bufferSize"in _)f=s(d,{...m,gain:1});else if(!v){const t={...g,orientationX:_.orientationX.value,orientationY:_.orientationY.value,orientationZ:_.orientationZ.value,positionX:_.positionX.value,positionY:_.positionY.value,positionZ:_.positionZ.value};_=i(d,t)}if(l.set(d,null===f?_:f),null!==f){if(null===h){if(null===o)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new o(6,p.context.length,d.sampleRate),s=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});s.connect(t.destination),h=(async()=>{const e=await Promise.all([p.orientationX,p.orientationY,p.orientationZ,p.positionX,p.positionY,p.positionZ].map((async(e,s)=>{const i=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===s?1:0});return await a(t,e,i.offset),i})));for(let t=0;t<6;t+=1)e[t].connect(s,0,t),e[t].start(0);return c(t)})()}const t=await h,r=s(d,{...m,gain:1});await u(p,d,r);const l=[];for(let e=0;e<t.numberOfChannels;e+=1)l.push(t.getChannelData(e));let _=[l[0][0],l[1][0],l[2][0]],v=[l[3][0],l[4][0],l[5][0]],y=s(d,{...m,gain:1}),w=i(d,{...g,orientationX:_[0],orientationY:_[1],orientationZ:_[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=[l[0][e],l[1][e],l[2][e]],n=[l[3][e],l[4][e],l[5][e]];if(t.some(((t,e)=>t!==_[e]))||n.some(((t,e)=>t!==v[e]))){_=t,v=n;const o=e/d.sampleRate;y.gain.setValueAtTime(0,o),y=s(d,{...m,gain:0}),w=i(d,{...g,orientationX:_[0],orientationY:_[1],orientationZ:_[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,_.orientationX),await t(d,p.orientationY,_.orientationY),await t(d,p.orientationZ,_.orientationZ),await t(d,p.positionX,_.positionX),await t(d,p.positionY,_.positionY),await t(d,p.positionZ,_.positionZ)):(await a(d,p.orientationX,_.orientationX),await a(d,p.orientationY,_.orientationY),await a(d,p.orientationZ,_.orientationZ),await a(d,p.positionX,_.positionX),await a(d,p.positionY,_.positionY),await a(d,p.positionZ,_.positionZ)),ct(_)?await u(p,d,_.inputs[0]):await u(p,d,_),_})(p,d)}}})(un,bn,Sn,re,es,_t,je,ln,Pe,zn),ss=((t,e,n,s,i,r,o)=>class extends t{constructor(t,a){const u=i(t),c={...pe,...a},l=n(u,c),h=r(u);super(t,!1,l,h?s():null),this._nativePannerNode=l,this._orientationX=e(this,h,l.orientationX,Q,Y),this._orientationY=e(this,h,l.orientationY,Q,Y),this._orientationZ=e(this,h,l.orientationZ,Q,Y),this._positionX=e(this,h,l.positionX,Q,Y),this._positionY=e(this,h,l.positionY,Q,Y),this._positionZ=e(this,h,l.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,pn,es,ns,Fe,ze,gn),is=(t=>(e,{disableNormalization:n,imag:s,real:i})=>{const r=s instanceof Float32Array?s:new Float32Array(s),o=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(o,r,{disableNormalization:n});if(Array.from(s).length<2)throw t();return a})(G),rs=((t,e,n,s)=>class i{constructor(i,r){const o=e(i),a=s({...de,...r}),u=t(o,a);return n.add(u),u}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===i.prototype||n.has(t)}})(is,Fe,new WeakSet,(t=>{const{imag:e,real:n}=t;return void 0===e?void 0===n?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(n,(()=>0)),real:n}:void 0===n?{...t,imag:e,real:Array.from(e,(()=>0))}:{...t,imag:e,real:n}})),os=((t,e,n,s,i,r)=>{const o=16385,a=new Float32Array([1,1]),u=Math.PI/2,c={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l={...c,oversample:"none"},h=(t,r,h,p,d)=>{if(1===r)return((t,e,i,r)=>{const h=new Float32Array(o),p=new Float32Array(o);for(let t=0;t<o;t+=1){const e=t/16384*u;h[t]=Math.cos(e),p[t]=Math.sin(e)}const d=n(t,{...c,gain:0}),f=s(t,{...l,curve:h}),_=s(t,{...l,curve:a}),m=n(t,{...c,gain:0}),g=s(t,{...l,curve:p});return{connectGraph(){e.connect(d),e.connect(void 0===_.inputs?_:_.inputs[0]),e.connect(m),_.connect(i),i.connect(void 0===f.inputs?f:f.inputs[0]),i.connect(void 0===g.inputs?g:g.inputs[0]),f.connect(d.gain),g.connect(m.gain),d.connect(r,0,0),m.connect(r,0,1)},disconnectGraph(){e.disconnect(d),e.disconnect(void 0===_.inputs?_:_.inputs[0]),e.disconnect(m),_.disconnect(i),i.disconnect(void 0===f.inputs?f:f.inputs[0]),i.disconnect(void 0===g.inputs?g:g.inputs[0]),f.disconnect(d.gain),g.disconnect(m.gain),d.disconnect(r,0,0),m.disconnect(r,0,1)}}})(t,h,p,d);if(2===r)return((t,i,r,h)=>{const p=new Float32Array(o),d=new Float32Array(o),f=new Float32Array(o),_=new Float32Array(o),m=Math.floor(8192.5);for(let t=0;t<o;t+=1)if(t>m){const e=(t-m)/(16384-m)*u;p[t]=Math.cos(e),d[t]=Math.sin(e),f[t]=0,_[t]=1}else{const e=t/(16384-m)*u;p[t]=1,d[t]=0,f[t]=Math.cos(e),_[t]=Math.sin(e)}const g=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),v=n(t,{...c,gain:0}),y=s(t,{...l,curve:p}),w=n(t,{...c,gain:0}),b=s(t,{...l,curve:d}),x=s(t,{...l,curve:a}),T=n(t,{...c,gain:0}),A=s(t,{...l,curve:f}),k=n(t,{...c,gain:0}),C=s(t,{...l,curve:_});return{connectGraph(){i.connect(g),i.connect(void 0===x.inputs?x:x.inputs[0]),g.connect(v,0),g.connect(w,0),g.connect(T,1),g.connect(k,1),x.connect(r),r.connect(void 0===y.inputs?y:y.inputs[0]),r.connect(void 0===b.inputs?b:b.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),b.connect(w.gain),A.connect(T.gain),C.connect(k.gain),v.connect(h,0,0),T.connect(h,0,0),w.connect(h,0,1),k.connect(h,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(void 0===x.inputs?x:x.inputs[0]),g.disconnect(v,0),g.disconnect(w,0),g.disconnect(T,1),g.disconnect(k,1),x.disconnect(r),r.disconnect(void 0===y.inputs?y:y.inputs[0]),r.disconnect(void 0===b.inputs?b:b.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),b.disconnect(w.gain),A.disconnect(T.gain),C.disconnect(k.gain),v.disconnect(h,0,0),T.disconnect(h,0,0),w.disconnect(h,0,1),k.disconnect(h,0,1)}}})(t,h,p,d);throw i()};return(e,{channelCount:s,channelCountMode:o,pan:a,...u})=>{if("max"===o)throw i();const c=t(e,{...u,channelCount:1,channelCountMode:o,numberOfInputs:2}),l=n(e,{...u,channelCount:s,channelCountMode:o,gain:1}),p=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:d,disconnectGraph:f}=h(e,s,l,p,c);Object.defineProperty(p.gain,"defaultValue",{get:()=>0}),Object.defineProperty(p.gain,"maxValue",{get:()=>1}),Object.defineProperty(p.gain,"minValue",{get:()=>-1});const _={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(t){l.channelCount!==t&&(m&&f(),({connectGraph:d,disconnectGraph:f}=h(e,t,l,p,c)),m&&d()),l.channelCount=t},get channelCountMode(){return l.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();l.channelCountMode=t},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(t){l.channelInterpretation=t},get context(){return l.context},get inputs(){return[l]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get pan(){return p.gain},addEventListener:(...t)=>l.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>l.dispatchEvent(t[0]),removeEventListener:(...t)=>l.removeEventListener(t[0],t[1],t[2])};let m=!1;return r(se(_,c),(()=>{d(),m=!0}),(()=>{f(),m=!1}))}})(bn,ne,re,Jn,ce,yn),as=((t,e)=>(n,s)=>{const i=s.channelCountMode;if("clamped-max"===i)throw e();if(void 0===n.createStereoPanner)return t(n,s);const r=n.createStereoPanner();return Xt(r,s),Yt(r,s,"pan"),Object.defineProperty(r,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),r})(os,ce),us=((t,e,n,s,i)=>()=>{const r=new WeakMap;return{render(o,a){const u=r.get(a);return void 0!==u?Promise.resolve(u):(async(o,a)=>{let u=n(o);const c=H(u,a);if(!c){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=e(a,t)}return r.set(a,u),c?await t(a,o.pan,u.pan):await s(a,o.pan,u.pan),ct(u)?await i(o,a,u.inputs[0]):await i(o,a,u),u})(o,a)}}})(un,as,_t,ln,Pe),cs=((t,e,n,s,i,r)=>class extends t{constructor(t,o){const a=i(t),u={...fe,...o},c=n(a,u),l=r(a);super(t,!1,c,l?s():null),this._pan=e(this,l,c.pan)}get pan(){return this._pan}})(Ze,pn,as,us,Fe,ze),ls=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,r){const o=s.get(r);return void 0!==o?Promise.resolve(o):(async(i,r)=>{let o=e(i);if(!H(o,r)){const e={channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample};o=t(r,e)}return s.set(r,o),ct(o)?await n(i,r,o.inputs[0]):await n(i,r,o),o})(i,r)}}})(Jn,_t,Pe),hs=((t,e,n,s,i,r,o)=>class extends t{constructor(t,e){const a=i(t),u={..._e,...e},c=n(a,u);super(t,!0,c,r(a)?s():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=c,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,Jn,ls,Fe,ze,gn),ps=(t=>null!==t&&t.isSecureContext)(Re),ds=(t=>(e,n,s)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return s()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(Re),fs=new WeakMap,_s=((t,e)=>n=>{let s=t.get(n);if(void 0!==s)return s;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return s=new e(1,1,44100),t.set(n,s),s})(fs,je),ms=ps?((t,e,n,s,i,r,o,a,u,c,l,h,p)=>{let d=0;return(f,_,m={credentials:"omit"})=>{const g=l.get(f);if(void 0!==g&&g.has(_))return Promise.resolve();const v=c.get(f);if(void 0!==v){const t=v.get(_);if(void 0!==t)return t}const y=r(f),w=void 0===y.audioWorklet?i(_).then((([t,e])=>{const[s,i]=R(t,e);return n(`${s};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}\n})})(window,'_AWGS')`)})).then((()=>{const t=p._AWGS.pop();if(void 0===t)throw new SyntaxError;s(y.currentTime,y.sampleRate,(()=>t(class{},void 0,((t,n)=>{if(""===t.trim())throw e();const s=M.get(y);if(void 0!==s){if(s.has(t))throw e();B(n),N(n.parameterDescriptors),s.set(t,n)}else B(n),N(n.parameterDescriptors),M.set(y,new Map([[t,n]]))}),y.sampleRate,void 0,void 0)))})):Promise.all([i(_),Promise.resolve(t(h,h))]).then((([[t,e],n])=>{const s=d+1;d=s;const[i,r]=R(t,e),c=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${r}\n})(${n?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${n?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${n?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${s}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),l=URL.createObjectURL(c);return y.audioWorklet.addModule(l,m).then((()=>{if(a(y))return y;const t=o(y);return t.audioWorklet.addModule(l,m).then((()=>t))})).then((t=>{if(null===u)throw new SyntaxError;try{new u(t,`__sac${s}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(l)))}));return void 0===v?c.set(f,new Map([[_,w]])):v.set(_,w),w.then((()=>{const t=l.get(f);void 0===t?l.set(f,new Set([_])):t.add(_)})).finally((()=>{const t=c.get(f);void 0!==t&&t.delete(_)})),w}})(Ee,ce,(t=>e=>new Promise(((n,s)=>{if(null===t)return void s(new SyntaxError);const i=t.document.head;if(null===i)s(new SyntaxError);else{const r=t.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),u=t.onerror,c=()=>{t.onerror=u,URL.revokeObjectURL(a)};t.onerror=(e,n,i,r,o)=>n===a||n===t.location.href&&1===i&&1===r?(c(),s(o),!1):null!==u?u(e,n,i,r,o):void 0,r.onerror=()=>{c(),s(new SyntaxError)},r.onload=()=>{c(),n()},r.src=a,r.type="module",i.appendChild(r)}})))(Re),ds,(t=>async e=>{try{const t=await fetch(e);if(t.ok)return[await t.text(),t.url]}catch{}throw t()})((()=>new DOMException("","AbortError"))),Fe,_s,ze,Xe,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),s=new e(1,128,44100),i=URL.createObjectURL(n);let r=!1,o=!1;try{await s.audioWorklet.addModule(i);const e=new t(s,"a",{numberOfOutputs:0}),n=s.createOscillator();e.port.onmessage=()=>r=!0,e.onprocessorerror=()=>o=!0,n.connect(e),n.start(0),await s.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return r&&!o})(Xe,je),Re):void 0,gs=((t,e)=>n=>t(n)||e(n))(He,ze),vs=((t,e,n,s,i,r,o,a,u,c,l)=>(h,p)=>{const d=o(h)?h:r(h);if(i.has(p)){const t=n();return Promise.reject(t)}try{i.add(p)}catch{}return e(u,(()=>u(d)))?d.decodeAudioData(p).then((n=>(Pt(p).catch((()=>{})),e(a,(()=>a(n)))||l(n),t.add(n),n))):new Promise(((e,n)=>{const i=async()=>{try{await Pt(p)}catch{}},r=t=>{n(t),i()};try{d.decodeAudioData(p,(n=>{"function"!=typeof n.copyFromChannel&&(c(n),X(n)),t.add(n),i().then((()=>e(n)))}),(t=>{r(null===t?s():t)}))}catch(t){r(t)}}))})(Ke,Ee,(()=>new DOMException("","DataCloneError")),(()=>new DOMException("","EncodingError")),new WeakSet,Fe,gs,$,$t,nn,sn),ys=((t,e,n,s,i,r,o,a,u,c,l,h,p,d,f,_,m,g,v,y)=>class extends f{constructor(e,n){super(e,n),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,n)=>t(this,e,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,s){return new n({length:e,numberOfChannels:t,sampleRate:s})}createBufferSource(){return new s(this)}createChannelMerger(t=6){return new r(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new o(this,{numberOfOutputs:t})}createConstantSource(){return new a(this)}createConvolver(){return new u(this)}createDelay(t=1){return new l(this,{maxDelayTime:t})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(t,e){return new d(this,{feedback:e,feedforward:t})}createOscillator(){return new _(this)}createPanner(){return new m(this)}createPeriodicWave(t,e,n={disableNormalization:!1}){return new g(this,{...n,imag:e,real:t})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(t,e,n){return c(this._nativeContext,t).then((t=>("function"==typeof e&&e(t),t)),(t=>{throw"function"==typeof n&&n(t),t}))}})(ms,Qe,rn,fn,vn,Tn,kn,Mn,In,vs,Nn,Vn,qn,Un,Gn,Yn,ss,rs,cs,hs),ws=((t,e,n,s)=>class extends t{constructor(t,i){const r=n(t),o=e(r,i);if(s(r))throw TypeError();super(t,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})(Ze,((t,e)=>t.createMediaElementSource(e.mediaElement)),Fe,ze),bs=((t,e,n,s)=>class extends t{constructor(t,i){const r=n(t);if(s(r))throw new TypeError;const o={...Ht,...i},a=e(r,o);super(t,!1,a,null),this._nativeMediaStreamAudioDestinationNode=a}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})(Ze,((t,e)=>{const n=t.createMediaStreamDestination();return Xt(n,e),1===n.numberOfOutputs&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n}),Fe,ze),xs=((t,e,n,s)=>class extends t{constructor(t,i){const r=n(t),o=e(r,i);if(s(r))throw new TypeError;super(t,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(Ze,((t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const s=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(s));return Object.defineProperty(i,"mediaStream",{value:e}),i}),Fe,ze),Ts=((t,e)=>(n,{mediaStreamTrack:s})=>{if("function"==typeof n.createMediaStreamTrackSource)return n.createMediaStreamTrackSource(s);const i=new MediaStream([s]),r=n.createMediaStreamSource(i);if("audio"!==s.kind)throw t();if(e(n))throw new TypeError;return r})(zt,ze),As=((t,e,n)=>class extends t{constructor(t,s){const i=n(t);super(t,!0,e(i,s),null)}})(Ze,Ts,Fe),ks=((t,e,n,s,i,r,o,a,u)=>class extends t{constructor(t={}){if(null===u)throw new Error("Missing the native AudioContext constructor.");let e;try{e=new u(t)}catch(t){if(12===t.code&&"sampleRate is not in range"===t.message)throw n();throw t}if(null===e)throw s();if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw n();super(e,2);const{latencyHint:i}=t,{sampleRate: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"===u.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()),st(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 n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)})):this._nativeAudioContext.resume().catch((t=>{if(void 0===t||15===t.code)throw e();throw t}))}suspend(){return this._nativeAudioContext.suspend().catch((t=>{if(void 0===t)throw e();throw t}))}})(ys,zt,ce,(()=>new DOMException("","UnknownError")),ws,bs,xs,As,Ue),Cs=(t=>e=>{const n=t.get(e);if(void 0===n)throw new Error("The context has no set of AudioWorkletNodes.");return n})($n),Ss=(t=>(e,n)=>{t(e).add(n)})(Cs),Os=(t=>(e,n,s=0,i=0)=>{const r=e[s];if(void 0===r)throw t();return bt(n)?r.connect(n,0,i):r.connect(n,0)})(G),Ms=(t=>(e,n)=>{t(e).delete(n)})(Cs),Es=(t=>(e,n=void 0,s=void 0,i=0)=>void 0===n?e.forEach((t=>t.disconnect())):"number"==typeof n?Ft(t,e,n).disconnect():bt(n)?void 0===s?e.forEach((t=>t.disconnect(n))):void 0===i?Ft(t,e,s).disconnect(n,0):Ft(t,e,s).disconnect(n,0,i):void 0===s?e.forEach((t=>t.disconnect(n))):Ft(t,e,s).disconnect(n,0))(G),Ds=new WeakMap,Is=((t,e)=>n=>e(t,n))(Ds,P),Rs=((t,e,n,s,i,r,o,a,u,c,l,h,p)=>(d,f,_,m)=>{if(0===m.numberOfInputs&&0===m.numberOfOutputs)throw u();const g=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(g.some((t=>t<1)))throw u();if(g.length!==m.numberOfOutputs)throw e();if("explicit"!==m.channelCountMode)throw u();const v=m.channelCount*m.numberOfInputs,y=g.reduce(((t,e)=>t+e),0),w=void 0===_.parameterDescriptors?0:_.parameterDescriptors.length;if(v+w>6||y>6)throw u();const b=new MessageChannel,x=[],T=[];for(let t=0;t<m.numberOfInputs;t+=1)x.push(o(d,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),T.push(i(d,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const A=[];if(void 0!==_.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:s}of _.parameterDescriptors){const i=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==m.parameterData[s]?m.parameterData[s]: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===n?Y:n}}),A.push(i)}const k=s(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<m.numberOfOutputs;t+=1)M.push(s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:g[t]}));for(let t=0;t<m.numberOfInputs;t+=1){x[t].connect(T[t]);for(let e=0;e<m.channelCount;e+=1)T[t].connect(k,e,t*m.channelCount+e)}const D=new kt(void 0===_.parameterDescriptors?[]:_.parameterDescriptors.map((({name:t},e)=>{const n=A[e];return n.connect(k,0,v+e),n.start(0),[t,n.offset]})));k.connect(S);let I=m.channelInterpretation,R=null;const N=0===m.numberOfOutputs?[S]:M,B={get bufferSize(){return C},get channelCount(){return m.channelCount},set channelCount(t){throw n()},get channelCountMode(){return m.channelCountMode},set channelCountMode(t){throw n()},get channelInterpretation(){return I},set channelInterpretation(t){for(const e of x)e.channelInterpretation=t;I=t},get context(){return S.context},get inputs(){return x},get numberOfInputs(){return m.numberOfInputs},get numberOfOutputs(){return m.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 b.port2},addEventListener:(...t)=>S.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,N),disconnect:c.bind(null,N),dispatchEvent:(...t)=>S.dispatchEvent(t[0]),removeEventListener:(...t)=>S.removeEventListener(t[0],t[1],t[2])},P=new Map;var V,F;b.port1.addEventListener=(V=b.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=P.get(t[1]);void 0!==n?t[1]=n:(t[1]=t=>{l(d.currentTime,d.sampleRate,(()=>e(t)))},P.set(e,t[1]))}}return V.call(b.port1,t[0],t[1],t[2])}),b.port1.removeEventListener=(F=b.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=P.get(t[1]);void 0!==e&&(P.delete(t[1]),t[1]=e)}return F.call(b.port1,t[0],t[1],t[2])});let q=null;Object.defineProperty(b.port1,"onmessage",{get:()=>q,set:t=>{"function"==typeof q&&b.port1.removeEventListener("message",q),q="function"==typeof t?t:null,"function"==typeof q&&(b.port1.addEventListener("message",q),b.port1.start())}}),_.prototype.port=b.port1;let j=null;const z=((t,e,n,s)=>{let i=E.get(t);void 0===i&&(i=new WeakMap,E.set(t,i));const r=te(n,s);return i.set(e,r),r})(d,B,_,m);z.then((t=>j=t));const W=Mt(m.numberOfInputs,m.channelCount),L=Mt(m.numberOfOutputs,g),U=void 0===_.parameterDescriptors?[]:_.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let H=!0;const $=()=>{m.numberOfOutputs>0&&S.disconnect(O);for(let t=0,e=0;t<m.numberOfOutputs;t+=1){const n=M[t];for(let s=0;s<g[t];s+=1)O.disconnect(n,e+s,s);e+=g[t]}},G=new Map;S.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==j){const n=h(B);for(let s=0;s<C;s+=128){for(let e=0;e<m.numberOfInputs;e+=1)for(let n=0;n<m.channelCount;n+=1)St(t,W[e],n,n,s);void 0!==_.parameterDescriptors&&_.parameterDescriptors.forEach((({name:e},n)=>{St(t,U,e,v+n,s)}));for(let t=0;t<m.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(n[e].size>0)return G.set(e,C/128),t;const s=G.get(e);return void 0===s?[]:(t.every((t=>t.every((t=>0===t))))&&(1===s?G.delete(e):G.set(e,s-1)),t)})),i=l(d.currentTime+s/d.sampleRate,d.sampleRate,(()=>j.process(t,L,U)));H=i;for(let t=0,n=0;t<m.numberOfOutputs;t+=1){for(let i=0;i<g[t];i+=1)Ot(e,L[t],i,n+i,s);n+=g[t]}}catch(t){H=!1,B.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!H){for(let t=0;t<m.numberOfInputs;t+=1){x[t].disconnect(T[t]);for(let e=0;e<m.channelCount;e+=1)T[s].disconnect(k,e,t*m.channelCount+e)}if(void 0!==_.parameterDescriptors){const t=_.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?$():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(H){J(),m.numberOfOutputs>0&&S.connect(O);for(let t=0,e=0;t<m.numberOfOutputs;t+=1){const n=M[t];for(let s=0;s<g[t];s+=1)O.connect(n,e+s,s);e+=g[t]}}X=!0}),(()=>{H&&(K(),$()),X=!1}))})(Os,G,zt,bn,ne,Sn,re,ue,ce,Es,ds,Is,yn),Ns=((t,e,n,s,i)=>(r,o,a,u,c,l)=>{if(null!==a)try{const e=new a(r,u,l),s=new Map;let o=null;if(Object.defineProperties(e,{channelCount:{get:()=>l.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 n=s.get(t[1]);void 0!==n?t[1]=n:(t[1]=n=>{"error"===n.type?(Object.defineProperties(n,{type:{value:"processorerror"}}),e(n)):e(new ErrorEvent(t[0],{...n}))},s.set(e,t[1]))}}return p.call(e,"error",t[1],t[2]),p.call(e,...t)}),e.removeEventListener=(h=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=s.get(t[1]);void 0!==e&&(s.delete(t[1]),t[1]=e)}return h.call(e,"error",t[1],t[2]),h.call(e,t[0],t[1],t[2])}),0!==l.numberOfOutputs){const t=n(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 s();throw t}var h,p;if(void 0===c)throw s();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),e(r,o,c,l)})(zt,Rs,re,ce,yn),Bs=((t,e,n,s,i,r,o,a,u,c,l,h,p,d,f,_)=>(m,g,v)=>{const y=new WeakMap;let w=null;return{render(b,x){a(x,b);const T=y.get(x);return void 0!==T?Promise.resolve(T):(async(a,b)=>{let x=l(a),T=null;const A=H(x,b),k=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(null===h){const t=k.reduce(((t,e)=>t+e),0),n=i(b,{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(s(b,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:k[t]}));const c=o(b,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1});c.connect=e.bind(null,r),c.disconnect=u.bind(null,r),T=[n,r,c]}else A||(x=new h(b,m));if(y.set(b,null===T?x: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,n=t+e,u=async()=>{const u=new p(n,128*Math.ceil(a.context.length/128),b.sampleRate),c=[],l=[];for(let t=0;t<g.numberOfInputs;t+=1)c.push(o(u,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),l.push(i(u,{channelCount:g.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:g.channelCount}));const h=await Promise.all(Array.from(a.parameters.values()).map((async t=>{const e=r(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await d(u,t,e.offset),e}))),m=s(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<g.numberOfInputs;t+=1){c[t].connect(l[t]);for(let e=0;e<g.channelCount;e+=1)l[t].connect(m,e,t*g.channelCount+e)}for(const[e,n]of h.entries())n.connect(m,0,t+e),n.start(0);return m.connect(u.destination),await Promise.all(c.map((t=>f(a,u,t)))),_(u)};w=Et(a,0===n?null:await u(),b,g,k,v,c)}const t=await w,e=n(b,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[u,l,h]=T;null!==t&&(e.buffer=t,e.start(0)),e.connect(u);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const n=l[t];for(let s=0;s<k[t];s+=1)u.connect(n,e+s,s);e+=k[t]}return h}if(A)for(const[e,n]of a.parameters.entries())await t(b,n,x.parameters.get(e));else for(const[t,e]of a.parameters.entries())await d(b,e,x.parameters.get(t));return await f(a,b,x),x})(b,x)}}})(un,Os,cn,bn,ne,Sn,re,Ms,Es,ds,_t,Xe,je,ln,Pe,zn),Ps=(t=>e=>t.get(e))(fs),Vs=(t=>(e,n)=>{t.set(e,n)})(Ds),Fs=ps?((t,e,n,s,i,r,o,a,u,c,l,h,p,d)=>class extends e{constructor(e,d,f){var _;const m=a(e),g=u(m),v=l({...Ct,...f});p(v);const y=M.get(m),w=null==y?void 0:y.get(d),b=g||"closed"!==m.state?m:null!==(_=o(m))&&void 0!==_?_:m,x=i(b,g?null:e.baseLatency,c,d,w,v);super(e,!0,x,g?s(d,v,w):null);const T=[];x.parameters.forEach(((t,e)=>{const s=n(this,g,t);T.push([e,s])})),this._nativeAudioWorkletNode=x,this._onprocessorerror=null,this._parameters=new kt(T),g&&t(m,this);const{activeInputs:A}=r(this);h(x,A)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?d(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==n&&n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(Ss,Ze,pn,Bs,Ns,tt,Ps,Fe,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))})),Vs,(t=>{const{port1:e,port2:n}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),n.close()}}),Ae):void 0,qs=((t,e)=>(n,s,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(n,s,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(ce,je),js=((t,e,n,s,i,r,o,a)=>(u,c)=>n(u).render(u,c).then((()=>Promise.all(Array.from(s(c)).map((t=>n(t).render(t,c)))))).then((()=>i(c))).then((n=>("function"!=typeof n.copyFromChannel?(o(n),X(n)):e(r,(()=>r(n)))||a(n),t.add(n),n))))(Ke,Ee,Be,Cs,zn,$,nn,sn),zs=((t,e,n,s,i)=>class extends t{constructor(t,n,i){let r;if("number"==typeof t&&void 0!==n&&void 0!==i)r={length:n,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:u}={...le,...r},c=s(a,o,u);e($t,(()=>$t(c)))||c.addEventListener("statechange",(()=>{let t=0;const e=n=>{"running"===this._state&&(t>0?(c.removeEventListener("statechange",e),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):t+=1)};return e})()),super(c,a),this._length=o,this._nativeOfflineAudioContext=c,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(n()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally((()=>{this._state=null,st(this)})))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout((()=>this._waitForThePromiseToSettle(t)))}})(ys,Ee,zt,qs,js),Ws=((t,e)=>n=>{const s=t.get(n);return e(s)||e(n)})(C,He),Ls=((t,e)=>n=>t.has(n)||e(n))(T,$e),Us=((t,e)=>n=>t.has(n)||e(n))(k,Ge),Hs=((t,e)=>n=>{const s=t.get(n);return e(s)||e(n)})(C,ze);function $s(t,e){if(!t)throw new Error(e)}function Gs(t,e,n=1/0){if(!(e<=t&&t<=n))throw new RangeError(`Value must be within [${e}, ${n}], got: ${t}`)}function Xs(t){t.isOffline||"running"===t.state||Ys('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Zs=console;function Ys(...t){Zs.warn(...t)}function Qs(t){return void 0===t}function Ks(t){return!Qs(t)}function Js(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 ni(t){return Array.isArray(t)}function si(t){return"string"==typeof t}function ii(t){return si(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,n,s){var i,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,s);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r<3?i(o):r>3?i(e,n,o):i(e,n))||o);return r>3&&o&&Object.defineProperty(e,n,o),o}function ui(t,e,n,s){return new(n||(n=Promise))((function(i,r){function o(t){try{u(s.next(t))}catch(t){r(t)}}function a(t){try{u(s.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class ci{constructor(t,e,n){this._callback=t,this._type=e,this._updateInterval=n,this._createClock()}_createWorker(){const t=new Blob([`\n\t\t\t// the initial timeout time\n\t\t\tlet timeoutTime = ${(1e3*this._updateInterval).toFixed(1)};\n\t\t\t// onmessage callback\n\t\t\tself.onmessage = function(msg){\n\t\t\t\ttimeoutTime = parseInt(msg.data);\n\t\t\t};\n\t\t\t// the tick function which posts a message\n\t\t\t// and schedules a new tick\n\t\t\tfunction tick(){\n\t\t\t\tsetTimeout(tick, timeoutTime);\n\t\t\t\tself.postMessage('tick');\n\t\t\t}\n\t\t\t// call tick initially\n\t\t\ttick();\n\t\t\t`],{type:"text/javascript"}),e=URL.createObjectURL(t),n=new Worker(e);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout((()=>{this._createTimeout(),this._callback()}),1e3*this._updateInterval)}_createClock(){if("worker"===this._type)try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else"timeout"===this._type&&this._createTimeout()}_disposeClock(){this._timeout&&(clearTimeout(this._timeout),this._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 li(t){return Us(t)}function hi(t){return Ls(t)}function pi(t){return Hs(t)}function di(t){return Ws(t)}function fi(t){return t instanceof AudioBuffer}function _i(t,e){return"value"===t||li(e)||hi(e)||fi(e)}function mi(t,...e){if(!e.length)return t;const n=e.shift();if(ti(t)&&ti(n))for(const e in n)_i(e,n[e])?t[e]=n[e]:ti(n[e])?(t[e]||Object.assign(t,{[e]:{}}),mi(t[e],n[e])):Object.assign(t,{[e]:n[e]});return mi(t,...e)}function gi(t,e,n=[],s){const i={},r=Array.from(e);if(ti(r[0])&&s&&!Reflect.has(r[0],s)){Object.keys(r[0]).some((e=>Reflect.has(t,e)))||(mi(i,{[s]:r[0]}),n.splice(n.indexOf(s),1),r.shift())}if(1===r.length&&ti(r[0]))mi(i,r[0]);else for(let t=0;t<n.length;t++)Ks(r[t])&&(i[n[t]]=r[t]);return mi(t,i)}function vi(t,e){return Qs(t)?e:t}function yi(t,e){return e.forEach((e=>{Reflect.has(t,e)&&delete t[e]})),t}
|
|
1
|
+
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,C=new WeakMap,k=new WeakMap,A=new WeakMap,S=new WeakMap,M=new WeakMap,O=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]*);?/,N=(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]},R=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.")},P=(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},V=(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=P(t,e),r=V(i,(t=>t[0]===s&&t[1]===n));return 0===i.size&&t.delete(e),r},F=t=>P(S,t),z=t=>{if(x.has(t))throw new Error("The AudioNode is already stored.");x.add(t),F(t).forEach((t=>t(!0)))},j=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)=>{!j(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=>P(b,t),et=t=>P(C,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]:j(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=P(t,e),i=V(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=>P(T,t),_t=t=>P(k,t),gt=t=>M.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)=>V(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)}},Ct=(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 At={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 Mt=(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)},Ot=(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=P(E,t),n=mt(e);return P(s,n)})(s,t),d=Ot(n.numberOfInputs,n.channelCount),f=Ot(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)Mt(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},Nt={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Rt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},Bt={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Pt=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()}}))},Vt={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},zt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},jt=()=>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 jt()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw jt()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw jt()}})})(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)},Ce=(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),Ae=(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)))(V),Me=new WeakMap,Oe=(t=>e=>{var s;return null!==(s=t.get(e))&&void 0!==s?s:0})(Me),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 Ne="undefined"==typeof window?null:window,Re=((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),Pe=((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),Ve=((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)}}})(Re,mt,Pe),qe=(Fe=A,t=>{const e=Fe.get(t);if(void 0===e)throw jt();return e});var Fe;const ze=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(Ne),je=(t=>e=>null!==t&&e instanceof t)(ze),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)}})(Ce),He=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(Ne),Ue=(t=>e=>null!==t&&e instanceof t)(He),Ge=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(Ne),$e=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(Ne),Xe=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(Ne),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&&z(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)&&z(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):Ct(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):Ct(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):Ct(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)&&z(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,Ae,ht,Se,ft,tt,Oe,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)})(M,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,M,tt,mt,_t,qe,K,je),((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,P),Le,qe,Ue,Ge,$e,je,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,Ve,$,Re,qe,je),Ke=new WeakSet,Je=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(Ne),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,ze,(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 jt();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,Pe),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=C,(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){z(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,jt,cs,qe,je,Ce),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)}}}),$,jt,((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,je,Pe),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,Pe),_s=(t=>(e,s)=>t.set(e,s))(Me),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,je,_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)))})(jt,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,Pe),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,je),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,Pe),Cs=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=n(t),c=r({...Nt,...o});super(t,!1,s(a,c),i(a)?e():null)}})(Ze,Ts,se,qe,je,(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),As=((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,As,mt,us,Pe),Ms=((t,e,s,n,i,r,o)=>class extends t{constructor(t,o){const a=i(t),c={...Rt,...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){z(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,As,qe,je,Ce),Os=((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)}}})(Os,mt,Pe),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,Os,qe,je,_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,Pe),Ns=((t,e,s,n,i,r,o)=>class extends t{constructor(t,a){const c=i(t),u={...Vt,...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,je,_s),Rs=(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,Rs,mt,us,Pe),Ps=((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,Rs,ue,qe,je,_s),Vs=((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,Pe),qs=((t,e,s,n,i,r)=>class extends t{constructor(t,o){const a=i(t),c={...zt,...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,Vs,re,qe,je),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,jt,ce,ue),zs=((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,ze)),js=((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,ze,Pe,zs),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,js,qe,je,_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,As,ce,ue,_e,je,ve),Us=new WeakMap,Gs=((t,e,s,n,i,r)=>class extends s{constructor(s,r){super(s),this._nativeContext=s,A.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,je,Us,Ce),$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,Pe),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){z(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,je,Ce),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,jt,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,jt,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:C,...k})=>{const A=h.createPanner();if(k.channelCount>2)throw o();if("max"===k.channelCountMode)throw o();Xt(A,k);const S={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},M=s(h,{...S,channelInterpretation:"speakers",numberOfInputs:6}),O=n(h,{...k,gain:1}),E=n(h,{...S,gain:1}),D=n(h,{...S,gain:0}),I=n(h,{...S,gain:0}),N=n(h,{...S,gain:0}),R=n(h,{...S,gain:0}),B=n(h,{...S,gain:0}),P=i(h,256,6,1),V=r(h,{...S,curve:new Float32Array([1,1]),oversample:"none"});let q=[_,g,v],F=[w,x,b];const z=new Float32Array(1);P.onaudioprocess=({inputBuffer:t})=>{const e=[c(t,z,0),c(t,z,1),c(t,z,2)];e.some(((t,e)=>t!==q[e]))&&(A.setOrientation(...e),q=e);const s=[c(t,z,3),c(t,z,4),c(t,z,5)];s.some(((t,e)=>t!==F[e]))&&(A.setPosition(...s),F=s)},Object.defineProperty(D.gain,"defaultValue",{get:()=>0}),Object.defineProperty(I.gain,"defaultValue",{get:()=>0}),Object.defineProperty(N.gain,"defaultValue",{get:()=>0}),Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(B.gain,"defaultValue",{get:()=>0});const j={get bufferSize(){},get channelCount(){return A.channelCount},set channelCount(t){if(t>2)throw o();O.channelCount=t,A.channelCount=t},get channelCountMode(){return A.channelCountMode},set channelCountMode(t){if("max"===t)throw o();O.channelCountMode=t,A.channelCountMode=t},get channelInterpretation(){return A.channelInterpretation},set channelInterpretation(t){O.channelInterpretation=t,A.channelInterpretation=t},get coneInnerAngle(){return A.coneInnerAngle},set coneInnerAngle(t){A.coneInnerAngle=t},get coneOuterAngle(){return A.coneOuterAngle},set coneOuterAngle(t){A.coneOuterAngle=t},get coneOuterGain(){return A.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();A.coneOuterGain=t},get context(){return A.context},get distanceModel(){return A.distanceModel},set distanceModel(t){A.distanceModel=t},get inputs(){return[O]},get maxDistance(){return A.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;A.maxDistance=t},get numberOfInputs(){return A.numberOfInputs},get numberOfOutputs(){return A.numberOfOutputs},get orientationX(){return E.gain},get orientationY(){return D.gain},get orientationZ(){return I.gain},get panningModel(){return A.panningModel},set panningModel(t){A.panningModel=t},get positionX(){return N.gain},get positionY(){return R.gain},get positionZ(){return B.gain},get refDistance(){return A.refDistance},set refDistance(t){if(t<0)throw new RangeError;A.refDistance=t},get rolloffFactor(){return A.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;A.rolloffFactor=t},addEventListener:(...t)=>O.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>O.dispatchEvent(t[0]),removeEventListener:(...t)=>O.removeEventListener(t[0],t[1],t[2])};l!==j.coneInnerAngle&&(j.coneInnerAngle=l),p!==j.coneOuterAngle&&(j.coneOuterAngle=p),d!==j.coneOuterGain&&(j.coneOuterGain=d),f!==j.distanceModel&&(j.distanceModel=f),m!==j.maxDistance&&(j.maxDistance=m),_!==j.orientationX.value&&(j.orientationX.value=_),g!==j.orientationY.value&&(j.orientationY.value=g),v!==j.orientationZ.value&&(j.orientationZ.value=v),y!==j.panningModel&&(j.panningModel=y),w!==j.positionX.value&&(j.positionX.value=w),x!==j.positionY.value&&(j.positionY.value=x),b!==j.positionZ.value&&(j.positionZ.value=b),T!==j.refDistance&&(j.refDistance=T),C!==j.rolloffFactor&&(j.rolloffFactor=C),1===q[0]&&0===q[1]&&0===q[2]||A.setOrientation(...q),0===F[0]&&0===F[1]&&0===F[2]||A.setPosition(...F);return u(ne(j,A),(()=>{O.connect(A),t(O,V,0,0),V.connect(E).connect(M,0,0),V.connect(D).connect(M,0,1),V.connect(I).connect(M,0,2),V.connect(N).connect(M,0,3),V.connect(R).connect(M,0,4),V.connect(B).connect(M,0,5),M.connect(P).connect(h.destination)}),(()=>{O.disconnect(A),a(O,V,0,0),V.disconnect(E),E.disconnect(M),V.disconnect(D),D.disconnect(M),V.disconnect(I),I.disconnect(M),V.disconnect(N),N.disconnect(M),V.disconnect(R),R.disconnect(M),V.disconnect(B),B.disconnect(M),M.disconnect(P),P.disconnect(h.destination)}))})(ht,jt,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,As,re,tn,mt,ze,us,Pe,zs),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,je,_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}),C=n(t,{...h,curve:f}),k=s(t,{...u,gain:0}),A=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===C.inputs?C:C.inputs[0]),r.connect(void 0===A.inputs?A:A.inputs[0]),y.connect(v.gain),x.connect(w.gain),C.connect(T.gain),A.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===C.inputs?C:C.inputs[0]),r.disconnect(void 0===A.inputs?A:A.inputs[0]),y.disconnect(v.gain),x.disconnect(w.gain),C.disconnect(T.gain),A.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,Pe),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,je),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,Pe),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,jt,Ks,hn,qe,je,_s),pn=(t=>null!==t&&t.isSecureContext)(Ne),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)}})(Ne),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,ze),_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]=N(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=O.get(y);if(void 0!==n){if(n.has(t))throw e();B(s),R(s.parameterDescriptors),n.set(t,s)}else B(s),R(s.parameterDescriptors),O.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]=N(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)}})))(Ne),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,je,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,ze),Ne):void 0,gn=((t,e)=>s=>t(s)||e(s))(Ue,je),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=>(Pt(p).catch((()=>{})),e(a,(()=>a(s)))||h(s),t.add(s),s))):new Promise(((e,s)=>{const i=async()=>{try{await Pt(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,Cs,Ms,Ds,vn,Ns,Ps,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,je),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,je),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,je),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})(jt,je),Cn=((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,jt,ue,(()=>new DOMException("","UnknownError")),wn,xn,bn,Cn,He),An=(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)})(An),Mn=(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)})($),On=(t=>(e,s)=>{t(e).delete(s)})(An),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,P),Nn=((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 C=[];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}}),C.push(i)}const k=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,v+w)}),A=Jt(f,d.sampleRate),S=a(d,A,v+w,Math.max(1,y)),M=i(d,{channelCount:Math.max(1,y),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,y)}),O=[];for(let t=0;t<_.numberOfOutputs;t+=1)O.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=C[e];return s.connect(k,0,v+e),s.start(0),[t,s.offset]})));k.connect(S);let I=_.channelInterpretation,N=null;const R=0===_.numberOfOutputs?[S]:O,B={get bufferSize(){return A},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 N},set onprocessorerror(t){"function"==typeof N&&B.removeEventListener("processorerror",N),N="function"==typeof t?t:null,"function"==typeof N&&B.addEventListener("processorerror",N)},get parameters(){return D},get port(){return x.port2},addEventListener:(...t)=>S.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,R),disconnect:u.bind(null,R),dispatchEvent:(...t)=>S.dispatchEvent(t[0]),removeEventListener:(...t)=>S.removeEventListener(t[0],t[1],t[2])},P=new Map;var V,q;x.port1.addEventListener=(V=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=P.get(t[1]);void 0!==s?t[1]=s:(t[1]=t=>{h(d.currentTime,d.sampleRate,(()=>e(t)))},P.set(e,t[1]))}}return V.call(x.port1,t[0],t[1],t[2])}),x.port1.removeEventListener=(q=x.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=P.get(t[1]);void 0!==e&&(P.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 z=null;const j=((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,_);j.then((t=>z=t));const W=Ot(_.numberOfInputs,_.channelCount),L=Ot(_.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(M);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const s=O[t];for(let n=0;n<g[t];n+=1)M.disconnect(s,e+n,n);e+=g[t]}},$=new Map;S.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==z){const s=l(B);for(let n=0;n<A;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,A/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,(()=>z.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)Mt(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=C[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(M);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const s=O[t];for(let n=0;n<g[t];n+=1)M.connect(s,e+n,n);e+=g[t]}}X=!0}),(()=>{U&&(K(),G()),X=!1}))})(Mn,$,jt,ws,se,As,re,ce,ue,En,dn,In,vs),Rn=((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)})(jt,Nn,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 C=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 C||(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(C)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,Mn,cs,ws,se,As,re,On,En,dn,mt,Xe,ze,us,Pe,zs),Pn=(t=>e=>t.get(e))(fn),Vn=(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({...At,...f});p(v);const y=O.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:C}=r(this);l(b,C)}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,Rn,tt,Pn,qe,je,Xe,(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))})),Vn,(t=>{const{port1:e,port2:s}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),s.close()}}),Ce):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,ze),zn=((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,An,zs,G,ss,ns),jn=((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,jt,Fn,zn),Wn=((t,e)=>s=>{const n=t.get(s);return e(n)||e(s)})(A,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)})(A,je);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
2
|
/**
|
|
3
3
|
* Tone.js
|
|
4
4
|
* @author Yotam Mann
|
|
5
5
|
* @license http://opensource.org/licenses/MIT MIT License
|
|
6
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){Zs.log(...t)}(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}wi.version=t;const bi=1e-6;function xi(t,e){return t>e+bi}function Ti(t,e){return xi(t,e)||ki(t,e)}function Ai(t,e){return t+bi<e}function ki(t,e){return Math.abs(t-e)<bi}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($s(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];$s(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 n=this._search(t,e);return-1!==n?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const n=this._search(t,e);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(t){const e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];const n=this._search(t);return n-1>=0?this._timeline[n-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(ki(this._timeline[e].time,t)){for(let n=e;n>=0&&ki(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&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 n=0;const s=this._timeline.length;let i=s;if(s>0&&this._timeline[s-1][e]<=t)return s-1;for(;n<i;){let s=Math.floor(n+(i-n)/2);const r=this._timeline[s],o=this._timeline[s+1];if(ki(r[e],t)){for(let n=s;n<this._timeline.length;n++){if(!ki(this._timeline[n][e],t))break;s=n}return s}if(Ai(r[e],t)&&xi(o[e],t))return s;xi(r[e],t)?i=s:n=s+1}return-1}_iterate(t,e=0,n=this._timeline.length-1){this._timeline.slice(e,n+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){const n=this._search(t);return-1!==n&&this._iterate(e,0,n),this}forEachAfter(t,e){const n=this._search(t);return this._iterate(e,n+1),this}forEachBetween(t,e,n){let s=this._search(t),i=this._search(e);return-1!==s&&-1!==i?(this._timeline[s].time!==t&&(s+=1),this._timeline[i].time===e&&(i-=1),this._iterate(n,s,i)):-1===s&&this._iterate(n,0,i),this}forEachFrom(t,e){let n=this._search(t);for(;n>=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this}forEachAtTime(t,e){const n=this._search(t);if(-1!==n&&ki(this._timeline[n].time,t)){let s=n;for(let e=n;e>=0&&ki(this._timeline[e].time,t);e--)s=e;this._iterate((t=>{e(t)}),s,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const 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=>{Qs(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)})),this}once(t,e){const n=(...s)=>{e(...s),this.off(t,n)};return this.on(t,n),this}off(t,e){return t.split(/\W+/).forEach((n=>{if(Qs(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(Qs(e))this._events[t]=[];else{const n=this._events[t];for(let t=n.length-1;t>=0;t--)n[t]===e&&n.splice(t,1)}})),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const n=this._events[t].slice(0);for(let t=0,s=n.length;t<s;t++)n[t].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach((e=>{const n=Object.getOwnPropertyDescriptor(Di.prototype,e);Object.defineProperty(t.prototype,e,n)}))}dispose(){return super.dispose(),this._events=void 0,this}}class 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 ks(t)}({latencyHint:t.latencyHint}),this._ticker=new ci(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,n){return this._context.createBuffer(t,e,n)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,n){return this._context.createPeriodicWave(t,e,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){$s(di(this._context),"Not available if OfflineAudioContext");return this._context.createMediaStreamSource(t)}createMediaElementSource(t){$s(di(this._context),"Not available if OfflineAudioContext");return this._context.createMediaElementSource(t)}createMediaStreamDestination(){$s(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){$s(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){$s(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){$s(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){$s(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,n){return $s(Ks(Fs),"This node only works in a secure context (https or localhost)"),new Fs(t,e,n)}(this.rawContext,t,e)}addAudioWorkletModule(t,e){return ui(this,void 0,void 0,(function*(){$s(Ks(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 ui(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,si(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 ui(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),n=e.getChannelData(0);for(let e=0;e<n.length;e++)n[e]=t;const s=this._context.createBufferSource();return s.channelCount=1,s.channelCountMode="explicit",s.buffer=e,s.loop=!0,s.start(0),this._constants.set(t,s),s}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map((t=>this._constants[t].disconnect())),this}_timeoutLoop(){const t=this.now();let e=this._timeouts.peek();for(;this._timeouts.length&&e&&e.time<=t;)e.callback(),this._timeouts.shift(),e=this._timeouts.peek()}setTimeout(t,e){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:n+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach((e=>{e.id===t&&this._timeouts.remove(e)})),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const n=++this._timeoutIds,s=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),s()},id:n,time:i+e})};return s(),n}}function Ni(t,e){ni(e)?e.forEach((e=>Ni(t,e))):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function Bi(t,e){ni(e)?e.forEach((e=>Bi(t,e))):Object.defineProperty(t,e,{writable:!0})}const Pi=()=>{};class Vi extends wi{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Pi;const t=gi(Vi.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,t.url&&fi(t.url)||t.url instanceof Vi?this.set(t.url):si(t.url)&&this.load(t.url).catch(t.onerror)}static getDefaults(){return{onerror:Pi,onload:Pi,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:zi().sampleRate}set(t){return t instanceof Vi?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 ui(this,void 0,void 0,(function*(){const e=Vi.load(t).then((t=>{this.set(t),this.onload(this)}));Vi.downloads.push(e);try{yield e}finally{const t=Vi.downloads.indexOf(e);Vi.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=ni(t)&&t[0].length>0,n=e?t.length:1,s=e?t[0].length:t.length,i=zi(),r=i.createBuffer(n,s,i.sampleRate),o=e||1!==n?t:[t];for(let t=0;t<n;t++)r.copyToChannel(o[t],t);return this._buffer=r,this}toMono(t){if(Js(t))this.fromArray(this.toArray(t));else{let t=new Float32Array(this.length);const e=this.numberOfChannels;for(let n=0;n<e;n++){const e=this.toArray(n);for(let n=0;n<e.length;n++)t[n]+=e[n]}t=t.map((t=>t/e)),this.fromArray(t)}return this}toArray(t){if(Js(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 n=Math.floor(t*this.sampleRate),s=Math.floor(e*this.sampleRate);$s(n<s,"The start time must be less than the end time");const i=s-n,r=zi().createBuffer(this.numberOfChannels,i,this.sampleRate);for(let t=0;t<this.numberOfChannels;t++)r.copyToChannel(this.getChannelData(t).subarray(n,s),t);return new Vi(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 Vi).fromArray(t)}static fromUrl(t){return ui(this,void 0,void 0,(function*(){const e=new Vi;return yield e.load(t)}))}static load(t){return ui(this,void 0,void 0,(function*(){const e=t.match(/\[([^\]\[]+\|.+)\]$/);if(e){const n=e[1].split("|");let s=n[0];for(const t of n)if(Vi.supportsType(t)){s=t;break}t=t.replace(e[0],s)}const n=""===Vi.baseUrl||Vi.baseUrl.endsWith("/")?Vi.baseUrl:Vi.baseUrl+"/",s=yield fetch(n+t);if(!s.ok)throw new Error(`could not load url: ${t}`);const i=yield s.arrayBuffer();return yield zi().decodeAudioData(i)}))}static supportsType(t){const e=t.split("."),n=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+n)}static loaded(){return ui(this,void 0,void 0,(function*(){for(yield Promise.resolve();Vi.downloads.length;)yield Vi.downloads[0]}))}}Vi.baseUrl="",Vi.downloads=[];class Fi extends Ri{constructor(){var t,e,n;super({clockSource:"offline",context:pi(arguments[0])?arguments[0]:(t=arguments[0],e=arguments[1]*arguments[2],n=arguments[2],new zs(t,e,n)),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 ui(this,void 0,void 0,(function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const n=Math.floor(this.sampleRate/128);t&&e%n==0&&(yield new Promise((t=>setTimeout(t,1))))}}))}render(t=!0){return ui(this,void 0,void 0,(function*(){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new Vi(e)}))}close(){return Promise.resolve()}}const qi=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,n){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t,e){return ui(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=qi;function zi(){return ji===qi&&oi&&Wi(new Ri),ji}function Wi(t){ji=di(t)?new Ri(t):pi(t)?new Fi(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 Ui=440;function Hi(t){return Math.round($i(t))}function $i(t){return 69+12*Math.log2(t/Ui)}class Gi extends wi{constructor(t,e,n){super(),this.defaultUnits="s",this._val=e,this._units=n,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const n=parseInt(t,10),s="."===e?1.5:1;return 1===n?this._beatsToUnits(this._getTimeSignature())*s:this._beatsToUnits(4/n)*s},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(3*Math.floor(e)))},regexp:/^(\d+)t$/i},tr:{method:(t,e,n)=>{let s=0;return t&&"0"!==t&&(s+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(s+=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(s+=this._beatsToUnits(parseFloat(n)/4)),s},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof Gi&&this.fromType(this._val),Qs(this._val))return this._noArg();if(si(this._val)&&Qs(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(Ks(this._val[e])){const n=this._val[e];t+=new this.constructor(this.context,e).valueOf()*n}return t}if(Ks(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 si(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 Gi{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 n=new this.constructor(this.context,t).valueOf(),s=this.valueOf();return s+(Math.round(s/n)*n-s)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const n=Math.pow(2,t);e.push(n+"n."),e.push(n+"n"),e.push(n+"t")}e.push("0");let n=e[0],s=new Xi(this.context,e[0]).toSeconds();return e.forEach((e=>{const i=new Xi(this.context,e).toSeconds();Math.abs(i-t)<Math.abs(s-t)&&(n=e,s=i)})),n}toBarsBeatsSixteenths(){const t=this._beatsToUnits(1);let e=this.valueOf()/t;e=parseFloat(e.toFixed(4));const n=Math.floor(e/this._getTimeSignature());let s=e%1*4;e=Math.floor(e)%this._getTimeSignature();const i=s.toString();i.length>3&&(s=parseFloat(parseFloat(i).toFixed(3)));return[n,e,s].join(":")}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.round(e*this._getPPQ())}toSeconds(){return this.valueOf()}toMidi(){return Hi(this.toFrequency())}_now(){return this.context.now()}}class Zi extends Xi{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return Ui}static set A4(t){!function(t){Ui=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 n=Yi[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?n:Zi.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,n){let s=1;return t&&"0"!==t&&(s*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(s*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(s*=this._beatsToUnits(parseFloat(n)/4)),s}}})}transpose(t){return new Zi(this.context,this.valueOf()*Li(t))}harmonize(t){return t.map((t=>this.transpose(t)))}toMidi(){return Hi(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/Zi.A4);let n=Math.round(12*e)+57;const s=Math.floor(n/12);s<0&&(n+=-12*s);return Qi[n%12]+s.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return function(t){return Ui*Math.pow(2,(t-69)/12)}(t)}static ftom(t){return Hi(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((n=>{Qs(t[n])&&delete e[n]})),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach((e=>{if(Reflect.has(this,e)){const n=this[e];Ks(n)&&Ks(n.value)&&Ks(n.setValueAtTime)?t[e]=n.value:n instanceof Ji?t[e]=n._getPartialProperties(t[e]):ni(n)||Js(n)||si(n)||ei(n)?t[e]=n:delete t[e]}})),t}set(t){return Object.keys(t).forEach((e=>{Reflect.has(this,e)&&Ks(this[e])&&(this[e]&&Ks(this[e].value)&&Ks(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,n){return Gs(e,0),this.add(Object.assign({},n,{state:t,time:e})),this}getLastState(t,e){for(let n=this._search(e);n>=0;n--){const e=this._timeline[n];if(e.state===t)return e}}getNextState(t,e){const n=this._search(e);if(-1!==n)for(let e=n;e<this._timeline.length;e++){const n=this._timeline[e];if(n.state===t)return n}}}class 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($s(Ks(t.param)&&(li(t.param)||t.param instanceof er),"param must be an AudioParam");!li(t.param);)t.param=t.param._param;this._swappable=!!Ks(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,Ks(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 Ks(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 Ks(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return Ks(this.maxValue)&&Ks(this.minValue)&&Gs(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?(e=t,Math.pow(10,e/20)):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t;var e}_toType(t){return this.convert&&"decibels"===this.units?(e=t,Math.log(e)/Math.LN10*20):t;var e}setValueAtTime(t,e){const n=this.toSeconds(e),s=this._fromType(t);return $s(isFinite(s)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(s),this.log(this.units,"setValueAtTime",t,n),this._events.add({time:n,type:"setValueAtTime",value:s}),this._param.setValueAtTime(s,n),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),n=this._events.getAfter(e),s=this._events.get(e);let i=this._initialValue;if(null===s)i=this._initialValue;else if("setTargetAtTime"!==s.type||null!==n&&"setValueAtTime"!==n.type)if(null===n)i=s.value;else if("linearRampToValueAtTime"===n.type||"exponentialRampToValueAtTime"===n.type){let t=s.value;if("setTargetAtTime"===s.type){const e=this._events.getBefore(s.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===n.type?this._linearInterpolate(s.time,t,n.time,n.value,e):this._exponentialInterpolate(s.time,t,n.time,n.value,e)}else i=s.value;else{const t=this._events.getBefore(s.time);let n;n=null===t?this._initialValue:t.value,"setTargetAtTime"===s.type&&(i=this._exponentialApproach(s.time,n,s.value,s.constant,e))}return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===this._fromType(e)&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const n=this._fromType(t),s=this.toSeconds(e);return $s(isFinite(n)&&isFinite(s),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this._events.add({time:s,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",t,s),this._param.linearRampToValueAtTime(n,s),this}exponentialRampToValueAtTime(t,e){let n=this._fromType(t);n=ki(n,0)?this._minOutput:n,this._assertRange(n);const s=this.toSeconds(e);return $s(isFinite(n)&&isFinite(s),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:s,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",t,s),this._param.exponentialRampToValueAtTime(n,s),this}exponentialRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(t,n+this.toSeconds(e)),this}linearRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(t,n+this.toSeconds(e)),this}targetRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(t,n,e),this}exponentialApproachValueAtTime(t,e,n){e=this.toSeconds(e),n=this.toSeconds(n);const s=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(t,e,s),this.cancelAndHoldAtTime(e+.9*n),this.linearRampToValueAtTime(t,e+n),this}setTargetAtTime(t,e,n){const s=this._fromType(t);$s(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(s),$s(isFinite(s)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:n,time:i,type:"setTargetAtTime",value:s}),this.log(this.units,"setTargetAtTime",t,i,n),this._param.setTargetAtTime(s,i,n),this}setValueCurveAtTime(t,e,n,s=1){n=this.toSeconds(n),e=this.toSeconds(e);const i=this._fromType(t[0])*s;this.setValueAtTime(this._toType(i),e);const r=n/(t.length-1);for(let n=1;n<t.length;n++){const i=this._fromType(t[n])*s;this.linearRampToValueAtTime(this._toType(i),e+n*r)}return this}cancelScheduledValues(t){const e=this.toSeconds(t);return $s(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){const e=this.toSeconds(t),n=this._fromType(this.getValueAtTime(e));$s(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+n);const s=this._events.get(e),i=this._events.getAfter(e);return s&&ki(s.time,e)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),"linearRampToValueAtTime"===i.type?this.linearRampToValueAtTime(this._toType(n),e):"exponentialRampToValueAtTime"===i.type&&this.exponentialRampToValueAtTime(this._toType(n),e)),this._events.add({time:e,type:"setValueAtTime",value:n}),this._param.setValueAtTime(n,e),this}rampTo(t,e=.1,n){return"frequency"===this.units||"bpm"===this.units||"decibels"===this.units?this.exponentialRampTo(t,e,n):this.linearRampTo(t,e,n),this}apply(t){const e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);const n=this._events.get(e);if(n&&"setTargetAtTime"===n.type){const s=this._events.getAfter(n.time),i=s?s.time:e+2,r=(i-e)/10;for(let n=e;n<i;n+=r)t.linearRampToValueAtTime(this.getValueAtTime(n),n)}return this._events.forEachAfter(this.context.currentTime,(e=>{"cancelScheduledValues"===e.type?t.cancelScheduledValues(e.time):"setTargetAtTime"===e.type?t.setTargetAtTime(e.value,e.time,e.constant):t[e.type](e.value,e.time)})),this}setParam(t){$s(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,n,s,i){return n+(e-n)*Math.exp(-(i-t)/s)}_linearInterpolate(t,e,n,s,i){return e+(i-t)/(n-t)*(s-e)}_exponentialInterpolate(t,e,n,s,i){return e*Math.pow(s/e,(i-t)/(n-t))}}class nr extends Ji{constructor(){super(...arguments),this.name="ToneAudioNode",this._internalChannels=[]}get numberOfInputs(){return Ks(this.input)?li(this.input)||this.input instanceof er?1:this.input.numberOfInputs:0}get numberOfOutputs(){return Ks(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return Ks(t)&&(t instanceof nr||hi(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();$s(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,n=0){return ir(this,t,e,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return Ys("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,n=0){return function(t,e,n=0,s=0){if(Ks(e))for(;e instanceof nr;)e=e.input;for(;!hi(t);)Ks(t.output)&&(t=t.output);li(e)?t.disconnect(e,n):hi(e)?t.disconnect(e,n,s):t.disconnect()}(this,t,e,n),this}chain(...t){return sr(this,...t),this}fan(...t){return t.forEach((t=>this.connect(t))),this}dispose(){return super.dispose(),Ks(this.input)&&(this.input instanceof nr?this.input.dispose():hi(this.input)&&this.input.disconnect()),Ks(this.output)&&(this.output instanceof nr?this.output.dispose():hi(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function sr(...t){const e=t.shift();t.reduce(((t,e)=>(t instanceof nr?t.connect(e):hi(t)&&ir(t,e),e)),e)}function ir(t,e,n=0,s=0){for($s(Ks(t),"Cannot connect from undefined node"),$s(Ks(e),"Cannot connect to undefined node"),(e instanceof nr||hi(e))&&$s(e.numberOfInputs>0,"Cannot connect to node with no inputs"),$s(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof nr||e instanceof er;)Ks(e.input)&&(e=e.input);for(;t instanceof nr;)Ks(t.output)&&(t=t.output);li(e)?t.connect(e,n):t.connect(e,n,s)}class rr extends nr{constructor(){super(gi(rr.getDefaults(),arguments,["gain","units"])),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode;const t=gi(rr.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(nr.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class or extends nr{constructor(t){super(t),this.onended=Pi,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new rr({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(nr.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Pi})}_startGain(t,e=1){$s(-1===this._startTime,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=t+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+n):this._gainNode.gain.exponentialApproachValueAtTime(e,t,n)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){$s(-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!==Pi&&(this.onended(this),this.onended=Pi,!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"),$s(-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 ar extends or{constructor(){super(gi(ar.getDefaults(),arguments,["offset"])),this.name="ToneConstantSource",this._source=this.context.createConstantSource();const t=gi(ar.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(or.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 nr{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 ar({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(nr.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,n=0){return cr(this,t,e,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,n){return this._param.exponentialRampTo(t,e,n),this}linearRampTo(t,e,n){return this._param.linearRampTo(t,e,n),this}targetRampTo(t,e,n){return this._param.targetRampTo(t,e,n),this}exponentialApproachValueAtTime(t,e,n){return this._param.exponentialApproachValueAtTime(t,e,n),this}setTargetAtTime(t,e,n){return this._param.setTargetAtTime(t,e,n),this}setValueCurveAtTime(t,e,n,s){return this._param.setValueCurveAtTime(t,e,n,s),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,n){return this._param.rampTo(t,e,n),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}function cr(t,e,n,s){(e instanceof er||li(e)||e instanceof ur&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof ur&&(e.overridden=!0)),ir(t,e,n,s)}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,n){e=this.toSeconds(e),this.setRampPoint(e);const s=this._fromType(t),i=this._events.get(e),r=Math.round(Math.max(1/n,1));for(let t=0;t<=r;t++){const r=n*t+e,o=this._exponentialApproach(i.time,i.value,s,n,r);this.linearRampToValueAtTime(this._toType(o),r)}return this}setValueAtTime(t,e){const n=this.toSeconds(e);super.setValueAtTime(t,e);const s=this._events.get(n),i=this._events.previousEvent(s),r=this._getTicksUntilEvent(i,n);return s.ticks=Math.max(r,0),this}linearRampToValueAtTime(t,e){const n=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const s=this._events.get(n),i=this._events.previousEvent(s),r=this._getTicksUntilEvent(i,n);return s.ticks=Math.max(r,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const n=this._fromType(t),s=this._events.get(e),i=Math.round(Math.max(10*(e-s.time),1)),r=(e-s.time)/i;for(let t=0;t<=i;t++){const i=r*t+s.time,o=this._exponentialInterpolate(s.time,s.value,e,n,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(Qs(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const n=this._fromType(this.getValueAtTime(t.time));let s=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(s=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(n+s)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),n=this._events.get(e);return Math.max(this._getTicksUntilEvent(n,e),0)}getDurationOfTicks(t,e){const n=this.toSeconds(e),s=this.getTicksAtTime(e);return this.getTimeOfTick(s+t)-n}getTimeOfTick(t){const e=this._events.get(t,"ticks"),n=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&n&&"linearRampToValueAtTime"===n.type&&e.value!==n.value){const s=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(n.time))-s)/(n.time-e.time),r=Math.sqrt(Math.pow(s,2)-2*i*(e.ticks-t)),o=(-s+r)/i;return(o>0?o:(-s-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 n=this.toSeconds(e),s=this.toSeconds(t),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+s)-i}_fromType(t){return"bpm"===this.units&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return"bpm"===this.units&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class hr extends ur{constructor(){super(gi(hr.getDefaults(),arguments,["value"])),this.name="TickSignal";const t=gi(hr.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 pr extends Ji{constructor(){super(gi(pr.getDefaults(),arguments,["frequency"])),this.name="TickSource",this._state=new tr,this._tickOffset=new Ci;const t=gi(pr.getDefaults(),arguments,["frequency"]);this.frequency=new hr({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 n=this.toSeconds(t);return"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),Ks(e)&&this.setTicksAtTime(e,n)),this}stop(t){const e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){const t=this._state.get(e);t&&t.time>0&&(this._tickOffset.cancel(t.time),this._state.cancel(t.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this}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),n=this._state.getLastState("stopped",e),s={state:"paused",time:e};this._state.add(s);let i=n,r=0;return this._state.forEachBetween(n.time,e+this.sampleTime,(t=>{let e=i.time;const n=this._tickOffset.get(t.time);n&&n.time>=i.time&&(r=n.ticks,e=n.time),"started"===i.state&&"started"!==t.state&&(r+=this.frequency.getTicksAtTime(t.time)-this.frequency.getTicksAtTime(e)),i=t})),this._state.remove(s),r}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),n=this.frequency.timeToTicks(t,e);this.setTicksAtTime(n,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),n={state:"paused",time:t};this._state.add(n);let s=e,i=0;return this._state.forEachBetween(e.time,t+this.sampleTime,(t=>{let e=s.time;const n=this._tickOffset.get(t.time);n&&n.time>=s.time&&(i=n.seconds,e=n.time),"started"===s.state&&"started"!==t.state&&(i+=t.time-e),s=t})),this._state.remove(n),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 n=this._tickOffset.get(e),s=this._state.get(e),i=Math.max(n.time,s.time),r=this.frequency.getTicksAtTime(i)+t-n.ticks;return this.frequency.getTimeOfTick(r)}forEachTickBetween(t,e,n){let s=this._state.get(t);this._state.forEachBetween(t,e,(e=>{s&&"started"===s.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(s.time,t),e.time-this.sampleTime,n),s=e}));let i=null;if(s&&"started"===s.state){const r=Math.max(s.time,t),o=this.frequency.getTicksAtTime(r),a=o-this.frequency.getTicksAtTime(s.time);let u=Math.ceil(a)-a;u=ki(u,1)?0:u;let c=this.frequency.getTimeOfTick(o+u);for(;c<e;){try{n(c,Math.round(this.getTicksAtTime(c)))}catch(t){i=t;break}c+=this.frequency.getDurationOfTicks(1,c)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this.frequency.dispose(),this}}class dr extends Ji{constructor(){super(gi(dr.getDefaults(),arguments,["callback","frequency"])),this.name="Clock",this.callback=Pi,this._lastUpdate=0,this._state=new tr("stopped"),this._boundLoop=this._loop.bind(this);const t=gi(dr.getDefaults(),arguments,["callback","frequency"]);this.callback=t.callback,this._tickSource=new pr({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:Pi,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){Xs(this.context);const n=this.toSeconds(t);return this.log("start",n),"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),this._tickSource.start(n,e),n<this._lastUpdate&&this.emit("start",n,e)),this}stop(t){const e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){const n=this.toSeconds(e),s=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(s+t,n)}_loop(){const t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,(t=>{switch(t.state){case"started":const e=this._tickSource.getTicksAtTime(t.time);this.emit("start",t.time,e);break;case"stopped":0!==t.time&&this.emit("stop",t.time);break;case"paused":this.emit("pause",t.time)}})),this._tickSource.forEachTickBetween(t,e,((t,e)=>{this.callback(t,e)})))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Di.mixin(dr);let fr=class t extends nr{constructor(){super(gi(t.getDefaults(),arguments,["delayTime","maxDelay"])),this.name="Delay";const e=gi(t.getDefaults(),arguments,["delayTime","maxDelay"]),n=this.toSeconds(e.maxDelay);this._maxDelay=Math.max(n,this.toSeconds(e.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(n),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(nr.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 n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)}))}static getDefaults(){return{baseUrl:"",onerror:Pi,onload:Pi,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return $s(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,0===this._loadingCount&&t&&t()}get loaded(){return Array.from(this._buffers).every((([t,e])=>e.loaded))}add(t,e,n=Pi,s=Pi){return si(e)?this._buffers.set(t.toString(),new Vi(this.baseUrl+e,n,s)):this._buffers.set(t.toString(),new Vi(e,n,s)),this}dispose(){return super.dispose(),this._buffers.forEach((t=>t.dispose())),this._buffers.clear(),this}}class mr extends Ki{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}class gr 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 gr({context:t})})),Ei((t=>{t.draw.dispose()}));class vr extends wi{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){$s(Ks(t.time),"Events must have a time property"),$s(Ks(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new yr(t.time,t.time+t.duration,t);for(null===this._root?this._root=e:this._root.insert(e),this._length++;null!==e;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(null!==this._root){const e=[];this._root.search(t.time,e);for(const n of e)if(n.event===t){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,(t=>this.remove(t))),this}_setRoot(t){this._root=t,null!==this._root&&(this._root.parent=null)}_replaceNodeInParent(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{let e,n=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,n=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,n=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,n=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,n=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){const e=t.parent,n=t.isLeftChild(),s=t.right;s&&(t.right=s.left,s.left=t),null!==e?n?e.left=s:e.right=s:this._setRoot(s)}_rotateRight(t){const e=t.parent,n=t.isLeftChild(),s=t.left;s&&(t.left=s.right,s.right=t),null!==e?n?e.left=s:e.right=s:this._setRoot(s)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(null!==this._root){const e=[];if(this._root.search(t,e),e.length>0){let t=e[0];for(let n=1;n<e.length;n++)e[n].low>t.low&&(t=e[n]);return t.event}}return null}forEach(t){if(null!==this._root){const e=[];this._root.traverse((t=>e.push(t))),e.forEach((e=>{e.event&&t(e.event)}))}return this}forEachAtTime(t,e){if(null!==this._root){const n=[];this._root.search(t,n),n.forEach((t=>{t.event&&e(t.event)}))}return this}forEachFrom(t,e){if(null!==this._root){const n=[];this._root.searchAfter(t,n),n.forEach((t=>{t.event&&e(t.event)}))}return this}dispose(){return super.dispose(),null!==this._root&&this._root.traverse((t=>t.dispose())),this._root=null,this}}class yr{constructor(t,e,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)}traverse(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)}updateHeight(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t}isLeftChild(){return null!==this.parent&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}let wr=class t extends nr{constructor(){super(gi(t.getDefaults(),arguments,["volume"])),this.name="Volume";const e=gi(t.getDefaults(),arguments,["volume"]);this.input=this.output=new rr({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(nr.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 nr{constructor(){super(gi(br.getDefaults(),arguments)),this.name="Destination",this.input=new wr({context:this.context}),this.output=new rr({context:this.context}),this.volume=this.input.volume;const t=gi(br.getDefaults(),arguments);sr(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(nr.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),sr(...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 xr 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 Tr{constructor(t,e){this.id=Tr._eventId++;const n=Object.assign(Tr.getDefaults(),e);this.transport=t,this.callback=n.callback,this._once=n.once,this.time=n.time}static getDefaults(){return{callback:Pi,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}}Tr._eventId=0;class Ar extends Tr{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(Ar.getDefaults(),e);this.duration=new mr(t.context,n.duration).valueOf(),this._interval=new mr(t.context,n.interval).valueOf(),this._nextTick=n.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({},Tr.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 mr(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 mr(this.context,this._nextTick).toSeconds()),this._nextTick+=this._interval,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new mr(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 kr extends Ji{constructor(){super(gi(kr.getDefaults(),arguments)),this.name="Transport",this._loop=new xr(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Ci,this._repeatedEvents=new vr,this._syncedSignals=[],this._swingAmount=0;const t=gi(kr.getDefaults(),arguments);this._ppq=t.ppq,this._clock=new dr({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 n=e%(2*this._swingTicks)/(2*this._swingTicks),s=Math.sin(n*Math.PI)*this._swingAmount;t+=new mr(this.context,2*this._swingTicks/3).toSeconds()*s}this._timeline.forEachAtTime(e,(e=>e.invoke(t)))}schedule(t,e){const n=new Tr(this,{callback:t,time:new Ki(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(t,e,n,s=1/0){const i=new Ar(this,{callback:t,duration:new Xi(this.context,s).toTicks(),interval:new Xi(this.context,e).toTicks(),time:new Ki(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const n=new Tr(this,{callback:t,once:!0,time:new Ki(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,(t=>this.clear(t.id))),this._repeatedEvents.forEachFrom(e,(t=>this.clear(t.id))),this}_bindClockEvents(){this._clock.on("start",((t,e)=>{e=new mr(this.context,e).toSeconds(),this.emit("start",t,e)})),this._clock.on("stop",(t=>{this.emit("stop",t)})),this._clock.on("pause",(t=>{this.emit("pause",t)}))}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){let n;return Ks(e)&&(n=this.toTicks(e)),this._clock.start(t,n),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){ni(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 mr(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){const t=this.now(),e=this._clock.getTicksAtTime(t);return new mr(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),n=this._clock.frequency.timeToTicks(t,e);this.ticks=n}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){const e=this.now();if("started"===this.state){const n=this._clock.getTicksAtTime(e),s=e+this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,e);this.emit("stop",s),this._clock.setTicksAtTime(t,s),this.emit("start",s,this._clock.getSecondsAtTime(s))}else this._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(),n=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){if(!e){const n=this.now();if(0!==t.getValueAtTime(n)){const s=1/(60/this.bpm.getValueAtTime(n)/this.PPQ);e=t.getValueAtTime(n)/s}else e=0}const n=new rr(e);return this.bpm.connect(n),n.connect(t._param),this._syncedSignals.push({initial:t.value,ratio:n,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const n=this._syncedSignals[e];n.signal===t&&(n.ratio.dispose(),n.signal.value=n.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(kr),Oi((t=>{t.transport=new kr({context:t})})),Ei((t=>{t.transport.dispose()}));class Cr extends nr{constructor(t){super(t),this.input=void 0,this._state=new tr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Pi,this._syncedStop=Pi,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new wr({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(nr.getDefaults(),{mute:!1,onstop:Pi,volume:0})}get state(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,n){let s=Qs(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(s=this._clampToCurrentTime(s),this._synced||"started"!==this._state.getValueAtTime(s))if(this.log("start",s),this._state.setStateAtTime("started",s),this._synced){const t=this._state.get(s);t&&(t.offset=this.toSeconds(vi(e,0)),t.duration=n?this.toSeconds(n):void 0);const i=this.context.transport.schedule((t=>{this._start(t,e,n)}),s);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>s&&this._syncedStart(this.now(),this.context.transport.seconds)}else Xs(this.context),this._start(s,e,n);else $s(xi(s,this._state.get(s).time),"Start time must be strictly greater than previous start time"),this._state.cancel(s),this._state.setStateAtTime("started",s),this.log("restart",s),this.restart(s,e,n);return this}stop(t){let e=Qs(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||Ks(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){const t=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(t)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,n){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(e>0){const n=this._state.get(e);if(n&&"started"===n.state&&n.time!==e){const s=e-this.toSeconds(n.time);let i;n.duration&&(i=this.toSeconds(n.duration)-s),this._start(t,this.toSeconds(n.offset)+s,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));"started"===this._state.getValueAtTime(e)&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach((t=>this.context.transport.clear(t))),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=Pi,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Sr extends or{constructor(){super(gi(Sr.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(Sr.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 Vi(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(or.getDefaults(),{url:new Vi,loop:!1,loopEnd:0,loopStart:0,onload:Pi,onerror:Pi,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,n,s=1){$s(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,s),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),n=t-e;Ti(r,t)&&(r=(r-e)%n+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)),Ks(n)){let t=this.toSeconds(n);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class Or extends Cr{constructor(){super(gi(Or.getDefaults(),arguments,["type"])),this.name="Noise",this._source=null;const t=gi(Or.getDefaults(),arguments,["type"]);this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Cr.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if($s(t in Dr,"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=Dr[this._type];this._source=new Sr({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 Mr=220500,Er={brown:null,pink:null,white:null},Dr={get brown(){if(!Er.brown){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(Mr);t[e]=n;let s=0;for(let t=0;t<Mr;t++){const e=2*Math.random()-1;n[t]=(s+.02*e)/1.02,s=n[t],n[t]*=3.5}}Er.brown=(new Vi).fromArray(t)}return Er.brown},get pink(){if(!Er.pink){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(Mr);let s,i,r,o,a,u,c;t[e]=n,s=i=r=o=a=u=c=0;for(let t=0;t<Mr;t++){const e=2*Math.random()-1;s=.99886*s+.0555179*e,i=.99332*i+.0750759*e,r=.969*r+.153852*e,o=.8665*o+.3104856*e,a=.55*a+.5329522*e,u=-.7616*u-.016898*e,n[t]=s+i+r+o+a+u+c+.5362*e,n[t]*=.11,c=.115926*e}}Er.pink=(new Vi).fromArray(t)}return Er.pink},get white(){if(!Er.white){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(Mr);t[e]=n;for(let t=0;t<Mr;t++)n[t]=2*Math.random()-1}Er.white=(new Vi).fromArray(t)}return Er.white}};function Ir(t,e){return ui(this,void 0,void 0,(function*(){const n=e/t.context.sampleRate,s=new Fi(1,n,t.context.sampleRate);new t.constructor(Object.assign(t.get(),{frequency:2/n,detune:0,context:s})).toDestination().start(0);return(yield s.render()).getChannelData(0)}))}class Rr extends or{constructor(){super(gi(Rr.getDefaults(),arguments,["frequency","type"])),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator];const t=gi(Rr.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(or.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 Nr=class t extends Cr{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(Cr.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),n=new Rr({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){const e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){const e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if("custom"===this._type){return t._periodicWaveCache.find((t=>{return t.phase===this._phase&&(e=t.partials,n=this._partials,e.length===n.length&&e.every(((t,e)=>n[e]===t)));var e,n}))}{const 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 n=-1!==["sine","square","sawtooth","triangle"].indexOf(e);if(0===this._phase&&n)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=e);else{const n=this._getCachedPeriodicWave();if(Ks(n)){const{partials:t,wave:e}=n;this._wave=e,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[n,s]=this._getRealImaginary(e,this._phase),i=this.context.createPeriodicWave(n,s);this._wave=i,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),t._periodicWaveCache.push({imag:s,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:n,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){Gs(t,0);let e=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(e=n[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach(((t,n)=>e[n]=t)),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let n=2048;const s=new Float32Array(n),i=new Float32Array(n);let r=1;if("custom"===t){if(r=this._partials.length+1,this._partialCount=this._partials.length,n=r,0===this._partials.length)return[s,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),n=r):this._partialCount=0,this._partials=[]}for(let o=1;o<n;++o){const n=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*n:0,this._partials[o-1]=a;break;case"sawtooth":a=n*(1&o?1:-1),this._partials[o-1]=a;break;case"triangle":a=1&o?n*n*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?(s[o]=-a*Math.sin(e*o),i[o]=a*Math.cos(e*o)):(s[o]=0,i[o]=0)}return[s,i]}_inverseFFT(t,e,n){let s=0;const i=t.length;for(let r=0;r<i;r++)s+=t[r]*Math.cos(r*n)+e[r]*Math.sin(r*n);return s}getInitialValue(){const[t,e]=this._getRealImaginary(this._type,0);let n=0;const s=2*Math.PI;for(let i=0;i<32;i++)n=Math.max(this._inverseFFT(t,e,i/32*s),n);return i=-this._inverseFFT(t,e,this._phase)/n,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 ui(this,void 0,void 0,(function*(){return Ir(this,t)}))}dispose(){return super.dispose(),null!==this._oscillator&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Nr._periodicWaveCache=[];class Br extends nr{constructor(){super(Object.assign(gi(Br.getDefaults(),arguments,["context"])))}connect(t,e=0,n=0){return cr(this,t,e,n),this}}class Pr extends Br{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"]);ni(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 n=new Float32Array(e);for(let s=0,i=e;s<i;s++){const e=s/(i-1)*2-1;n[s]=t(e,s)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){$s(["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 Vr extends Br{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 rr({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 qr extends Cr{constructor(){super(gi(qr.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="AMOscillator",this._modulationScale=new Vr({context:this.context}),this._modulationNode=new rr({context:this.context});const t=gi(qr.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new Nr({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 Nr({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(Nr.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 ui(this,void 0,void 0,(function*(){return Ir(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 jr extends Cr{constructor(){super(gi(jr.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="FMOscillator",this._modulationNode=new rr({context:this.context,gain:0});const t=gi(jr.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new Nr({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 Nr({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(Nr.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 ui(this,void 0,void 0,(function*(){return Ir(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 zr extends Cr{constructor(){super(gi(zr.getDefaults(),arguments,["frequency","width"])),this.name="PulseOscillator",this._widthGate=new rr({context:this.context,gain:0}),this._thresh=new Pr({context:this.context,mapping:t=>t<=0?-1:1});const t=gi(zr.getDefaults(),arguments,["frequency","width"]);this.width=new ur({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Nr({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(Cr.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 ui(this,void 0,void 0,(function*(){return Ir(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class Wr extends Cr{constructor(){super(gi(Wr.getDefaults(),arguments,["frequency","type","spread"])),this.name="FatOscillator",this._oscillators=[];const t=gi(Wr.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(Nr.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach((e=>e.start(t)))}_stop(t){t=this.toSeconds(t),this._forEach((e=>e.stop(t)))}_restart(t){this._forEach((e=>e.restart(t)))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach((e=>e.type=t))}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,n=t/(this._oscillators.length-1);this._forEach(((t,s)=>t.detune.value=e+n*s))}}get count(){return this._oscillators.length}set count(t){if(Gs(t,1),this._oscillators.length!==t){this._forEach((t=>t.dispose())),this._oscillators=[];for(let e=0;e<t;e++){const n=new Nr({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):Pi});"custom"===this.type&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[e]=n}this.spread=this._spread,"started"===this.state&&this._forEach((t=>t.start()))}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach(((t,e)=>t.phase=this._phase+e/this.count*360))}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach((e=>e.baseType=t)),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach((e=>e.partials=t)))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach((e=>e.partialCount=t)),this._type=this._oscillators[0].type}asArray(t=1024){return ui(this,void 0,void 0,(function*(){return Ir(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach((t=>t.dispose())),this}}class Lr extends Cr{constructor(){super(gi(Lr.getDefaults(),arguments,["frequency","modulationFrequency"])),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Fr({context:this.context,value:2});const t=gi(Lr.getDefaults(),arguments,["frequency","modulationFrequency"]);this._pulse=new zr({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Nr({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(Cr.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 ui(this,void 0,void 0,(function*(){return Ir(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Ur={am:qr,fat:Wr,fm:jr,oscillator:Nr,pulse:zr,pwm:Lr};class Hr extends Cr{constructor(){super(gi(Hr.getDefaults(),arguments,["frequency","type"])),this.name="OmniOscillator";const t=gi(Hr.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(Nr.getDefaults(),jr.getDefaults(),qr.getDefaults(),Wr.getDefaults(),zr.getDefaults(),Lr.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],n=this.now();if(this._oscillator){const t=this._oscillator;t.stop(n),this.context.setTimeout((()=>t.dispose()),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),"started"===this.state&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";"pwm"!==this._oscillator.type&&"pulse"!==this._oscillator.type&&(e=this._oscillator.type),"fm"===t?this.type="fm"+e:"am"===t?this.type="am"+e:"fat"===t?this.type="fat"+e:"oscillator"===t?this.type=e:"pulse"===t?this.type="pulse":"pwm"===t&&(this.type="pwm")}_getOscType(t,e){return t instanceof 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")&&Js(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")&&Js(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"))&&si(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 ui(this,void 0,void 0,(function*(){return Ir(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 rr({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,sr(this._constantSource,this._sum)}static getDefaults(){return Object.assign(ur.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class Gr extends Br{constructor(){super(Object.assign(gi(Gr.getDefaults(),arguments,["min","max"]))),this.name="Scale";const t=gi(Gr.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(Br.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}}function Xr(t,e=1/0){const n=new WeakMap;return function(s,i){Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(s){Gs(s,t,e),n.set(this,s)}})}}function Zr(t,e=1/0){const n=new WeakMap;return function(s,i){Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(s){Gs(this.toSeconds(s),t,e),n.set(this,s)}})}}class Yr extends Cr{constructor(){super(gi(Yr.getDefaults(),arguments,["url","onload"])),this.name="Player",this._activeSources=new Set;const t=gi(Yr.getDefaults(),arguments,["url","onload"]);this._buffer=new Vi({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(Cr.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Pi,onerror:Pi,playbackRate:1,reverse:!1})}load(t){return ui(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_onload(t=Pi){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),0!==this._activeSources.size||this._synced||"started"!==this._state.getValueAtTime(this.now())||(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,n){return super.start(t,e,n),this}_start(t,e,n){e=this._loop?vi(e,this._loopStart):vi(e,0);const s=this.toSeconds(e),i=n;n=vi(n,Math.max(this._buffer.duration-s,0));let r=this.toSeconds(n);r/=this._playbackRate,t=this.toSeconds(t);const o=new Sr({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&&Qs(i)?o.start(t,s):o.start(t,s,r-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach((t=>t.stop(e)))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){this._stop(t),this._start(t,e,n)}seek(t,e){const n=this.toSeconds(e);if("started"===this._state.getValueAtTime(n)){const e=this.toSeconds(t);this._stop(n),this._start(n,e)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Gs(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&&Gs(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach((e=>{e.loopEnd=t}))}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach((e=>{e.loop=t})),t)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;const e=this.now(),n=this._state.getNextState("stopped",e);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach((t=>t.cancelStop()))),this._activeSources.forEach((n=>{n.playbackRate.setValueAtTime(t,e)}))}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach((t=>t.dispose())),this._activeSources.clear(),this._buffer.dispose(),this}}ai([Zr(0)],Yr.prototype,"fadeIn",void 0),ai([Zr(0)],Yr.prototype,"fadeOut",void 0);class Qr extends Br{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 Kr extends Br{constructor(){super(Object.assign(gi(Kr.getDefaults(),arguments,["value"]))),this.name="Pow";const t=gi(Kr.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(Br.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 Jr=class t extends nr{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(nr.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(si(t))return t;{let n;for(n in to)if(to[n][e]===t)return n;return t}}_setCurve(t,e,n){if(si(n)&&Reflect.has(to,n)){const s=to[n];ti(s)?"_decayCurve"!==t&&(this[t]=s[e]):this[t]=s}else{if(!ni(n)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+n);this[t]=n}}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._decayCurve}set decayCurve(t){$s(["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 n=this.toSeconds(this.attack);const s=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0){n=(1-i)/(1/n)}if(n<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if("linear"===this._attackCurve)this._sig.linearRampTo(e,n,t);else if("exponential"===this._attackCurve)this._sig.targetRampTo(e,n,t);else{this._sig.cancelAndHoldAtTime(t);let s=this._attackCurve;for(let t=1;t<s.length;t++)if(s[t-1]<=i&&i<=s[t]){s=this._attackCurve.slice(t),s[0]=i;break}this._sig.setValueCurveAtTime(s,t,n,e)}if(s&&this.sustain<1){const i=e*this.sustain,r=t+n;this.log("decay",r),"linear"===this._decayCurve?this._sig.linearRampToValueAtTime(i,s+r):this._sig.exponentialApproachValueAtTime(i,r,s)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);const e=this.getValueAtTime(t);if(e>0){const n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,t):"linear"===this._releaseCurve?this._sig.linearRampTo(0,n,t):"exponential"===this._releaseCurve?this._sig.targetRampTo(0,n,t):($s(ni(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,n,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,n=1){return e=this.toSeconds(e),this.triggerAttack(e,n),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,n=0){return cr(this,t,e,n),this}asArray(t=1024){return ui(this,void 0,void 0,(function*(){const e=t/this.context.sampleRate,n=new Fi(1,e,this.context.sampleRate),s=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=s+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:n}));a._sig.toDestination(),a.triggerAttackRelease(e*(s+r)/o,0);return(yield n.render()).getChannelData(0)}))}dispose(){return super.dispose(),this._sig.dispose(),this}};ai([Zr(0)],Jr.prototype,"attack",void 0),ai([Zr(0)],Jr.prototype,"decay",void 0),ai([Xr(0,1)],Jr.prototype,"sustain",void 0),ai([Zr(0)],Jr.prototype,"release",void 0);const to=(()=>{const t=128;let e,n;const s=[];for(e=0;e<t;e++)s[e]=Math.sin(e/127*(Math.PI/2));const i=[];for(e=0;e<127;e++){n=e/127;const t=Math.sin(n*(2*Math.PI)*6.4-Math.PI/2)+1;i[e]=t/10+.83*n}i[127]=1;const r=[];for(e=0;e<t;e++)r[e]=Math.ceil(e/127*5)/5;const o=[];for(e=0;e<t;e++)n=e/127,o[e]=.5*(1-Math.cos(Math.PI*n));const a=[];for(e=0;e<t;e++){n=e/127;const t=4*Math.pow(n,3)+.2,s=Math.cos(t*Math.PI*2*n);a[e]=Math.abs(s*(1-n))}function u(t){const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=1-t[n];return e}return{bounce:{In:u(a),Out:a},cosine:{In:s,Out:(c=s,c.slice(0).reverse())},exponential:"exponential",linear:"linear",ripple:{In:i,Out:u(i)},sine:{In:o,Out:u(o)},step:{In:r,Out:u(r)}};var c})();class eo extends nr{constructor(){super(gi(eo.getDefaults(),arguments)),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease;const t=gi(eo.getDefaults(),arguments);this._volume=this.output=new wr({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Ni(this,"volume")}static getDefaults(){return Object.assign(nr.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 n=this["_original_"+t]=this[t];this[t]=(...t)=>{const s=t[e],i=this.context.transport.schedule((s=>{t[e]=s,n.apply(this,t)}),s);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach((t=>this.context.transport.clear(t))),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease),this}triggerAttackRelease(t,e,n,s){const i=this.toSeconds(n),r=this.toSeconds(e);return this.triggerAttack(t,i,s),this.triggerRelease(i+r),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class no extends eo{constructor(){super(gi(no.getDefaults(),arguments));const t=gi(no.getDefaults(),arguments);this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(eo.getDefaults(),{detune:0,onsilence:Pi,portamento:0})}triggerAttack(t,e,n=1){this.log("triggerAttack",t,e,n);const s=this.toSeconds(e);return this._triggerEnvelopeAttack(s,n),this.setNote(t,s),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const n=this.toSeconds(e),s=t instanceof Zi?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(s,t,n)}else this.frequency.setValueAtTime(s,n);return this}}ai([Zr(0)],no.prototype,"portamento",void 0);class so extends Jr{constructor(){super(gi(so.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new rr({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 io extends no{constructor(){super(gi(io.getDefaults(),arguments)),this.name="Synth";const t=gi(io.getDefaults(),arguments);this.oscillator=new Hr(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 so(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(no.getDefaults(),{envelope:Object.assign(yi(Jr.getDefaults(),Object.keys(nr.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(yi(Hr.getDefaults(),[...Object.keys(Cr.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class ro extends nr{constructor(){super(gi(ro.getDefaults(),arguments,["frequency","type"])),this.name="BiquadFilter";const t=gi(ro.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(nr.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){$s(-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 n=0;n<t;n++){const s=19980*Math.pow(n/t,2)+20;e[n]=s}const n=new Float32Array(t),s=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,n,s),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}}let oo=class t extends nr{constructor(){super(gi(t.getDefaults(),arguments,["frequency","type","rolloff"])),this.name="Filter",this.input=new rr({context:this.context}),this.output=new rr({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(nr.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){$s(-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=Js(t)?t:parseInt(t,10),n=[-12,-24,-48,-96];let s=n.indexOf(e);$s(-1!==s,`rolloff can only be ${n.join(", ")}`),s+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach((t=>t.disconnect())),this._filters=new Array(s);for(let t=0;t<s;t++){const e=new ro({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,sr(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){const e=new ro({frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(t).map((()=>1));return this._filters.forEach((()=>{e.getFrequencyResponse(t).forEach(((t,e)=>n[e]*=t))})),e.dispose(),n}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 ao extends Jr{constructor(){super(gi(ao.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="FrequencyEnvelope";const t=gi(ao.getDefaults(),arguments,["attack","decay","sustain","release"]);this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new Kr({context:this.context,value:t.exponent}),this._scale=this.output=new Gr({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(Jr.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){const e=this.toFrequency(t);Gs(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 uo extends io{constructor(){super(gi(uo.getDefaults(),arguments)),this.name="MembraneSynth",this.portamento=0;const t=gi(uo.getDefaults(),arguments);this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Ni(this,["oscillator","envelope"])}static getDefaults(){return mi(no.getDefaults(),io.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const n=this.toSeconds(e),s=this.toFrequency(t instanceof Zi?t.toFrequency():t),i=s*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(s,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}ai([Xr(0)],uo.prototype,"octaves",void 0),ai([Zr(0)],uo.prototype,"pitchDecay",void 0);const co=new Set;function lo(t){co.add(t)}function ho(t,e){const n=`registerProcessor("${t}", ${e})`;co.add(n)}class po extends nr{constructor(t){super(t),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=Pi;const e=URL.createObjectURL(new Blob([Array.from(co).join("\n")],{type:"text/javascript"})),n=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(e,n).then((()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(n,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))}))}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage("dispose"),this._worklet.disconnect()),this}}lo('\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');lo("\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");lo("\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");ho("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 fo extends eo{constructor(){super(gi(fo.getDefaults(),arguments,["urls","onload","baseUrl"],"urls")),this.name="Sampler",this._activeSources=new Map;const t=gi(fo.getDefaults(),arguments,["urls","onload","baseUrl"],"urls"),e={};Object.keys(t.urls).forEach((n=>{const s=parseInt(n,10);if($s(ii(n)||Js(s)&&isFinite(s),`url key is neither a note or midi pitch: ${n}`),ii(n)){const s=new Zi(this.context,n).toMidi();e[s]=t.urls[n]}else Js(s)&&isFinite(s)&&(e[s]=t.urls[s])})),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(eo.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Pi,onerror:Pi,release:.1,urls:{}})}_findClosest(t){let e=0;for(;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,n=1){return this.log("triggerAttack",t,e,n),Array.isArray(t)||(t=[t]),t.forEach((t=>{const s=$i(new Zi(this.context,t).toFrequency()),i=Math.round(s),r=s-i,o=this._findClosest(i),a=i-o,u=this._buffers.get(a),c=Li(o+r),l=new Sr({url:u,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:c}).connect(this.output);l.start(e,0,u.duration/c,n),ni(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(l),l.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){const t=this._activeSources.get(i),e=t.indexOf(l);-1!==e&&t.splice(e,1)}}})),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach((t=>{const n=new Zi(this.context,t).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){const t=this._activeSources.get(n);e=this.toSeconds(e),t.forEach((t=>{t.stop(e)})),this._activeSources.set(n,[])}})),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach((t=>{for(;t.length;){t.shift().stop(e)}})),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,n,s=1){const i=this.toSeconds(n);return this.triggerAttack(t,i,s),ni(e)?($s(ni(t),"notes must be an array when duration is array"),t.forEach(((t,n)=>{const s=e[Math.min(n,e.length-1)];this.triggerRelease(t,i+this.toSeconds(s))}))):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,n){if($s(ii(t)||isFinite(t),`note must be a pitch or midi: ${t}`),ii(t)){const s=new Zi(this.context,t).toMidi();this._buffers.add(s,e,n)}else this._buffers.add(t,e,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach((t=>{t.forEach((t=>t.dispose()))})),this._activeSources.clear(),this}}ai([Zr(0)],fo.prototype,"attack",void 0),ai([Zr(0)],fo.prototype,"release",void 0);class _o extends Ji{constructor(){super(gi(_o.getDefaults(),arguments,["callback","value"])),this.name="ToneEvent",this._state=new tr("stopped"),this._startOffset=0;const t=gi(_o.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:Pi,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 n=t.time+Math.round(this.startOffset/this._playbackRate);if(!0===this._loop||Js(this._loop)&&this._loop>1){e=1/0,Js(this._loop)&&(e=this._loop*this._getLoopDuration());const s=this._state.getAfter(n);null!==s&&(e=Math.min(e,s.time-n)),e!==1/0&&(this._state.setStateAtTime("stopped",n+e+1,{id:-1}),e=new mr(this.context,e));const i=new mr(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new mr(this.context,n),e)}else t.id=this.context.transport.schedule(this._tick.bind(this),new mr(this.context,n))}}))}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 n=e;null!==t&&(n=t.time),this._rescheduleEvents(n)}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 mr(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}get loopStart(){return new mr(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){const n=this._getLoopDuration();return(t-e.time)%n/n}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class mo extends _o{constructor(){super(gi(mo.getDefaults(),arguments,["callback","events"])),this.name="Part",this._state=new tr("stopped"),this._events=new Set;const t=gi(mo.getDefaults(),arguments,["callback","events"]);this._state.increasing=!0,t.events.forEach((t=>{ni(t)?this.add(t[0],t[1]):this.add(t)}))}static getDefaults(){return Object.assign(_o.getDefaults(),{events:[]})}start(t,e){const n=this.toTicks(t);if("started"!==this._state.getValueAtTime(n)){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:n}),this._forEach((e=>{this._startNote(e,n,t)}))}return this}_startNote(t,e,n){e-=n,this._loop?t.startOffset>=this._loopStart&&t.startOffset<this._loopEnd?(t.startOffset<n&&(e+=this._getLoopDuration()),t.start(new mr(this.context,e))):t.startOffset<this._loopStart&&t.startOffset>=n&&(t.loop=!1,t.start(new mr(this.context,e))):t.startOffset>=n&&t.start(new mr(this.context,e))}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t,this._forEach((t=>{t.startOffset+=this._startOffset}))}stop(t){const e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach((e=>{e.stop(t)})),this}at(t,e){const n=new Ki(this.context,t).toTicks(),s=new mr(this.context,1).toSeconds(),i=this._events.values();let r=i.next();for(;!r.done;){const t=r.value;if(Math.abs(n-t.startOffset)<s)return Ks(e)&&(t.value=e),t;r=i.next()}return Ks(e)?(this.add(t,e),this.at(t)):null}add(t,e){t instanceof Object&&Reflect.has(t,"time")&&(t=(e=t).time);const n=this.toTicks(t);let s;return e instanceof _o?(s=e,s.callback=this._tick.bind(this)):s=new _o({callback:this._tick.bind(this),context:this.context,value:e}),s.startOffset=n,s.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(s),this._restartEvent(s),this}_restartEvent(t){this._state.forEach((e=>{"started"===e.state?this._startNote(t,e.time,e.offset):t.stop(new mr(this.context,e.time))}))}remove(t,e){return ti(t)&&t.hasOwnProperty("time")&&(t=(e=t).time),t=this.toTicks(t),this._events.forEach((n=>{n.startOffset===t&&(Qs(e)||Ks(e)&&n.value===e)&&(this._events.delete(n),n.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 mo?e._forEach(t):t(e)})),this}_setAll(t,e){this._forEach((n=>{n[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 mr(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 mr(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 go extends nr{constructor(){super(Object.assign(gi(go.getDefaults(),arguments,["fade"]))),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Qr({context:this.context}),this.a=new rr({context:this.context,gain:0}),this.b=new rr({context:this.context,gain:0}),this.output=new rr({context:this.context}),this._internalChannels=[this.a,this.b];const t=gi(go.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(nr.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 vo=class extends nr{constructor(t){super(t),this.name="Effect",this._dryWet=new go({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new rr({context:this.context}),this.effectReturn=new rr({context:this.context}),this.input=new rr({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(nr.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 yo extends nr{constructor(){super(Object.assign(gi(yo.getDefaults(),arguments,["pan"]))),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner;const t=gi(yo.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(nr.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}const wo="bit-crusher";ho(wo,"\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 bo=class t extends vo{constructor(){super(gi(t.getDefaults(),arguments,["bits"])),this.name="BitCrusher";const e=gi(t.getDefaults(),arguments,["bits"]);this._bitCrusherWorklet=new xo({context:this.context,bits:e.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(vo.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}};class xo extends po{constructor(){super(gi(xo.getDefaults(),arguments)),this.name="BitCrusherWorklet";const t=gi(xo.getDefaults(),arguments);this.input=new rr({context:this.context}),this.output=new rr({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(po.getDefaults(),{bits:12})}_audioWorkletName(){return wo}onReady(t){sr(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 To extends nr{constructor(){super(gi(To.getDefaults(),arguments,["channels"])),this.name="Merge";const t=gi(To.getDefaults(),arguments,["channels"]);this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(nr.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}let Ao=class t extends vo{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(vo.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(t){this._distortion=t;const e=100*t,n=Math.PI/180;this._shaper.setMap((t=>Math.abs(t)<.001?0:(3+e)*t*20*n/(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 ko extends vo{constructor(t){super(t),this.name="FeedbackEffect",this._feedbackGain=new rr({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(vo.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class Co extends ko{constructor(){super(gi(Co.getDefaults(),arguments,["delayTime","feedback"])),this.name="FeedbackDelay";const t=gi(Co.getDefaults(),arguments,["delayTime","feedback"]);this._delayNode=new fr({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(ko.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}let So=class t extends vo{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(vo.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){Gs(t=this.toSeconds(t),.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){Gs(t=this.toSeconds(t),0),this._preDelay=t,this.generate()}generate(){return ui(this,void 0,void 0,(function*(){const t=this.ready,e=new Fi(2,this._decay+this._preDelay,this.context.sampleRate),n=new Or({context:e}),s=new Or({context:e}),i=new To({context:e});n.connect(i,0,0),s.connect(i,0,1);const r=new rr({context:e}).toDestination();i.connect(r),n.start(0),s.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(Pi),yield t,this._convolver.buffer=(yield o).get(),this}))}dispose(){return super.dispose(),this._convolver.disconnect(),this}};class Oo extends nr{constructor(){super(gi(Oo.getDefaults(),arguments,["solo"])),this.name="Solo";const t=gi(Oo.getDefaults(),arguments,["solo"]);this.input=this.output=new rr({context:this.context}),Oo._allSolos.has(this.context)||Oo._allSolos.set(this.context,new Set),Oo._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(nr.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),Oo._allSolos.get(this.context).forEach((t=>t._updateSolo()))}get muted(){return 0===this.input.gain.value}_addSolo(){Oo._soloed.has(this.context)||Oo._soloed.set(this.context,new Set),Oo._soloed.get(this.context).add(this)}_removeSolo(){Oo._soloed.has(this.context)&&Oo._soloed.get(this.context).delete(this)}_isSoloed(){return Oo._soloed.has(this.context)&&Oo._soloed.get(this.context).has(this)}_noSolos(){return!Oo._soloed.has(this.context)||Oo._soloed.has(this.context)&&0===Oo._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),Oo._allSolos.get(this.context).delete(this),this._removeSolo(),this}}Oo._allSolos=new Map,Oo._soloed=new Map;class Mo extends nr{constructor(){super(gi(Mo.getDefaults(),arguments,["pan","volume"])),this.name="PanVol";const t=gi(Mo.getDefaults(),arguments,["pan","volume"]);this._panner=this.input=new yo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new wr({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(nr.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class Eo extends nr{constructor(){super(gi(Eo.getDefaults(),arguments,["volume","pan"])),this.name="Channel";const t=gi(Eo.getDefaults(),arguments,["volume","pan"]);this._solo=this.input=new Oo({solo:t.solo,context:this.context}),this._panVol=this.output=new Mo({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),Ni(this,["pan","volume"])}static getDefaults(){return Object.assign(nr.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 Eo.buses.has(t)||Eo.buses.set(t,new rr({context:this.context})),Eo.buses.get(t)}send(t,e=0){const n=this._getBus(t),s=new rr({context:this.context,units:"decibels",gain:e});return this.connect(s),s.connect(n),s}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}Eo.buses=new Map;class Do extends nr{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(nr.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 Io(){return zi().now()}Oi((t=>{t.listener=new Do({context:t})})),Ei((t=>{t.listener.dispose()})),zi().transport,zi().destination,zi().destination,zi().listener,zi().draw,zi();const Ro={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},No=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Bo=No.length;class Po{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 No.map((e=>new Po(`${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 No.indexOf(this.name)}adjustFrequency(t=0,e=0){if(this.frequency)return this.frequency;let n=this.octave+t;const s=No.indexOf(this.name)+e;let i=s;s>=Bo?(n++,i=s%Bo):s<0&&(n--,i=Bo+i);const r=No[i];return Ro[`${r}${n}`]}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=No[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 Vo={128:"noteOff",144:"noteOn",176:"cc"};class Fo{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,n){const s=t instanceof Po?t:new Po(t),i=new Fo(new MIDIMessageEvent("",{data:s.midiData(e)}),n);return i.note=s,i}static fromCC(t,e,n){return new Fo(new MIDIMessageEvent("",{data:new Uint8Array([176,t,e])}),n)}constructor(t,e){this.event=t,this.triggeredAt=e||Io(),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=Vo[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 Po(this.event)))}}class qo{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 Fo)&&this.processEvent(t)}}disconnect(){this._midi.onmidimessage=null}serialize(){const{id:t,name:e,state:n}=this;return{id:t,name:e,state:n}}addEventListener(t){this.eventListerCallbacks.push(t)}removeEventListener(t){this.eventListerCallbacks=this.eventListerCallbacks.filter((e=>e!==t))}processEvent(t){const e=t instanceof Fo?t:new Fo(t);switch(e.type){case"noteOn":case"noteOff":this.eventListerCallbacks.forEach((t=>t(e)))}}}const jo={a:new Po("C3"),s:new Po("D3"),d:new Po("E3"),f:new Po("F3"),g:new Po("G3"),h:new Po("A3"),j:new Po("B3"),k:new Po("C4"),l:new Po("D4"),w:new Po("C#3"),e:new Po("D#3"),t:new Po("F#3"),y:new Po("G#3"),u:new Po("A#3"),o:new Po("C#4"),p:new Po("D#4")},zo={id:"computer_keyboard",name:"Computer Keyboard",state:"connected"};class Wo{id;name;state;onmidimessage;constructor(){Object.assign(this,zo),document.addEventListener("keydown",this.onKeyTrigger(!0)),document.addEventListener("keyup",this.onKeyTrigger(!1))}onKeyTrigger=t=>e=>{if(!this.onmidimessage)return;const n=this.extractNote(e);if(!n)return;const s=Fo.fromNote(n,t);this.onmidimessage(s)};extractNote(t){if(!t.repeat)return jo[t.key]}}class Lo{devices={};initialized=!1;computerKeyboardInput;constructor(){this.computerKeyboardInput=new Wo,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 n=e.port,s=new qo(n);t(s)}})).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 qo(t))})),Object.values(this.devices)}async inputs(){const t=[this.computerKeyboardInput];return(await navigator.requestMIDIAccess()).inputs.forEach((e=>t.push(e))),t}}var Uo,Ho=new Uint8Array(16);function $o(){if(!Uo&&!(Uo="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 Uo(Ho)}var Go=/^(?:[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 Xo=[],Zo=0;Zo<256;++Zo)Xo.push((Zo+256).toString(16).substr(1));function Yo(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Xo[t[e+0]]+Xo[t[e+1]]+Xo[t[e+2]]+Xo[t[e+3]]+"-"+Xo[t[e+4]]+Xo[t[e+5]]+"-"+Xo[t[e+6]]+Xo[t[e+7]]+"-"+Xo[t[e+8]]+Xo[t[e+9]]+"-"+Xo[t[e+10]]+Xo[t[e+11]]+Xo[t[e+12]]+Xo[t[e+13]]+Xo[t[e+14]]+Xo[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Go.test(t)}(n))throw TypeError("Stringified UUID is invalid");return n}function Qo(t,e,n){var s=(t=t||{}).random||(t.rng||$o)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=s[i];return e}return Yo(s)}var Ko="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Jo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ta={exports:{}};var ea,na={exports:{}};function sa(){return ea||(ea=1,na.exports=function(){var t=t||function(t,e){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==Ko&&Ko.crypto&&(n=Ko.crypto),!n)try{n=require("crypto")}catch(t){}var s=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof n.randomBytes)try{return n.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 n;return t.prototype=e,n=new t,t.prototype=null,n}}(),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)}},u=o.WordArray=a.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,n=t.words,s=this.sigBytes,i=t.sigBytes;if(this.clamp(),s%4)for(var r=0;r<i;r++){var o=n[r>>>2]>>>24-r%4*8&255;e[s+r>>>2]|=o<<24-(s+r)%4*8}else for(var a=0;a<i;a+=4)e[s+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=a.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(s());return new u.init(e,t)}}),c=r.enc={},l=c.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,s=[],i=0;i<n;i++){var r=e[i>>>2]>>>24-i%4*8&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(t){for(var e=t.length,n=[],s=0;s<e;s+=2)n[s>>>3]|=parseInt(t.substr(s,2),16)<<24-s%8*4;return new u.init(n,e/2)}},h=c.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,s=[],i=0;i<n;i++){var r=e[i>>>2]>>>24-i%4*8&255;s.push(String.fromCharCode(r))}return s.join("")},parse:function(t){for(var e=t.length,n=[],s=0;s<e;s++)n[s>>>2]|=(255&t.charCodeAt(s))<<24-s%4*8;return new u.init(n,e)}},p=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(h.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return h.parse(unescape(encodeURIComponent(t)))}},d=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new u.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 n,s=this._data,i=s.words,r=s.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,l=t.min(4*c,r);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(i,h);n=i.splice(0,c),s.sigBytes-=l}return new u.init(n,l)},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,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new f.HMAC.init(t,n).finalize(e)}}});var f=r.algo={};return r}(Math);return t}()),na.exports}var ia,ra={exports:{}};function oa(){return ia||(ia=1,ra.exports=function(t){return s=(n=t).lib,i=s.Base,r=s.WordArray,(o=n.x64={}).Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),o.WordArray=i.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],s=0;s<e;s++){var i=t[s];n.push(i.high),n.push(i.low)}return r.create(n,this.sigBytes)},clone:function(){for(var t=i.clone.call(this),e=t.words=this.words.slice(0),n=e.length,s=0;s<n;s++)e[s]=e[s].clone();return t}}),t;var e,n,s,i,r,o}(sa())),ra.exports}var aa,ua={exports:{}};function ca(){return aa||(aa=1,ua.exports=function(t){return function(){if("function"==typeof ArrayBuffer){var e=t.lib.WordArray,n=e.init,s=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,s=[],i=0;i<e;i++)s[i>>>2]|=t[i]<<24-i%4*8;n.call(this,s,e)}else n.apply(this,arguments)};s.prototype=e}}(),t.lib.WordArray}(sa())),ua.exports}var la,ha={exports:{}};function pa(){return la||(la=1,ha.exports=function(t){return function(){var e=t,n=e.lib.WordArray,s=e.enc;function i(t){return t<<8&4278255360|t>>>8&16711935}s.Utf16=s.Utf16BE={stringify:function(t){for(var e=t.words,n=t.sigBytes,s=[],i=0;i<n;i+=2){var r=e[i>>>2]>>>16-i%4*8&65535;s.push(String.fromCharCode(r))}return s.join("")},parse:function(t){for(var e=t.length,s=[],i=0;i<e;i++)s[i>>>1]|=t.charCodeAt(i)<<16-i%2*16;return n.create(s,2*e)}},s.Utf16LE={stringify:function(t){for(var e=t.words,n=t.sigBytes,s=[],r=0;r<n;r+=2){var o=i(e[r>>>2]>>>16-r%4*8&65535);s.push(String.fromCharCode(o))}return s.join("")},parse:function(t){for(var e=t.length,s=[],r=0;r<e;r++)s[r>>>1]|=i(t.charCodeAt(r)<<16-r%2*16);return n.create(s,2*e)}}}(),t.enc.Utf16}(sa())),ha.exports}var da,fa={exports:{}};function _a(){return da||(da=1,fa.exports=function(t){return function(){var e=t,n=e.lib.WordArray;function s(t,e,s){for(var i=[],r=0,o=0;o<e;o++)if(o%4){var a=s[t.charCodeAt(o-1)]<<o%4*2|s[t.charCodeAt(o)]>>>6-o%4*2;i[r>>>2]|=a<<24-r%4*8,r++}return n.create(i,r)}e.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,s=this._map;t.clamp();for(var i=[],r=0;r<n;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<n;a++)i.push(s.charAt(o>>>6*(3-a)&63));var u=s.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var r=0;r<n.length;r++)i[n.charCodeAt(r)]=r}var o=n.charAt(64);if(o){var a=t.indexOf(o);-1!==a&&(e=a)}return s(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64}(sa())),fa.exports}var ma,ga={exports:{}};function va(){return ma||(ma=1,ga.exports=function(t){return function(){var e=t,n=e.lib.WordArray;function s(t,e,s){for(var i=[],r=0,o=0;o<e;o++)if(o%4){var a=s[t.charCodeAt(o-1)]<<o%4*2|s[t.charCodeAt(o)]>>>6-o%4*2;i[r>>>2]|=a<<24-r%4*8,r++}return n.create(i,r)}e.enc.Base64url={stringify:function(t,e){void 0===e&&(e=!0);var n=t.words,s=t.sigBytes,i=e?this._safe_map:this._map;t.clamp();for(var r=[],o=0;o<s;o+=3)for(var a=(n[o>>>2]>>>24-o%4*8&255)<<16|(n[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|n[o+2>>>2]>>>24-(o+2)%4*8&255,u=0;u<4&&o+.75*u<s;u++)r.push(i.charAt(a>>>6*(3-u)&63));var c=i.charAt(64);if(c)for(;r.length%4;)r.push(c);return r.join("")},parse:function(t,e){void 0===e&&(e=!0);var n=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 u=t.indexOf(a);-1!==u&&(n=u)}return s(t,n,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),t.enc.Base64url}(sa())),ga.exports}var ya,wa={exports:{}};function ba(){return ya||(ya=1,wa.exports=function(t){return function(e){var n=t,s=n.lib,i=s.WordArray,r=s.Hasher,o=n.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=o.MD5=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var n=0;n<16;n++){var s=e+n,i=t[s];t[s]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var r=this._hash.words,o=t[e+0],u=t[e+1],d=t[e+2],f=t[e+3],_=t[e+4],m=t[e+5],g=t[e+6],v=t[e+7],y=t[e+8],w=t[e+9],b=t[e+10],x=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=c(S,O,M,E,o,7,a[0]),E=c(E,S,O,M,u,12,a[1]),M=c(M,E,S,O,d,17,a[2]),O=c(O,M,E,S,f,22,a[3]),S=c(S,O,M,E,_,7,a[4]),E=c(E,S,O,M,m,12,a[5]),M=c(M,E,S,O,g,17,a[6]),O=c(O,M,E,S,v,22,a[7]),S=c(S,O,M,E,y,7,a[8]),E=c(E,S,O,M,w,12,a[9]),M=c(M,E,S,O,b,17,a[10]),O=c(O,M,E,S,x,22,a[11]),S=c(S,O,M,E,T,7,a[12]),E=c(E,S,O,M,A,12,a[13]),M=c(M,E,S,O,k,17,a[14]),S=l(S,O=c(O,M,E,S,C,22,a[15]),M,E,u,5,a[16]),E=l(E,S,O,M,g,9,a[17]),M=l(M,E,S,O,x,14,a[18]),O=l(O,M,E,S,o,20,a[19]),S=l(S,O,M,E,m,5,a[20]),E=l(E,S,O,M,b,9,a[21]),M=l(M,E,S,O,C,14,a[22]),O=l(O,M,E,S,_,20,a[23]),S=l(S,O,M,E,w,5,a[24]),E=l(E,S,O,M,k,9,a[25]),M=l(M,E,S,O,f,14,a[26]),O=l(O,M,E,S,y,20,a[27]),S=l(S,O,M,E,A,5,a[28]),E=l(E,S,O,M,d,9,a[29]),M=l(M,E,S,O,v,14,a[30]),S=h(S,O=l(O,M,E,S,T,20,a[31]),M,E,m,4,a[32]),E=h(E,S,O,M,y,11,a[33]),M=h(M,E,S,O,x,16,a[34]),O=h(O,M,E,S,k,23,a[35]),S=h(S,O,M,E,u,4,a[36]),E=h(E,S,O,M,_,11,a[37]),M=h(M,E,S,O,v,16,a[38]),O=h(O,M,E,S,b,23,a[39]),S=h(S,O,M,E,A,4,a[40]),E=h(E,S,O,M,o,11,a[41]),M=h(M,E,S,O,f,16,a[42]),O=h(O,M,E,S,g,23,a[43]),S=h(S,O,M,E,w,4,a[44]),E=h(E,S,O,M,T,11,a[45]),M=h(M,E,S,O,C,16,a[46]),S=p(S,O=h(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,m,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,b,15,a[54]),O=p(O,M,E,S,u,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,_,6,a[60]),E=p(E,S,O,M,x,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,n=t.words,s=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var r=e.floor(s/4294967296),o=s;n[15+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var l=u[c];u[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,n,s,i,r,o){var a=t+(e&n|~e&s)+i+o;return(a<<r|a>>>32-r)+e}function l(t,e,n,s,i,r,o){var a=t+(e&s|n&~s)+i+o;return(a<<r|a>>>32-r)+e}function h(t,e,n,s,i,r,o){var a=t+(e^n^s)+i+o;return(a<<r|a>>>32-r)+e}function p(t,e,n,s,i,r,o){var a=t+(n^(e|~s))+i+o;return(a<<r|a>>>32-r)+e}n.MD5=r._createHelper(u),n.HmacMD5=r._createHmacHelper(u)}(Math),t.MD5}(sa())),wa.exports}var xa,Ta={exports:{}};function Aa(){return xa||(xa=1,Ta.exports=function(t){return n=(e=t).lib,s=n.WordArray,i=n.Hasher,r=e.algo,o=[],a=r.SHA1=i.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,s=n[0],i=n[1],r=n[2],a=n[3],u=n[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var l=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=l<<1|l>>>31}var h=(s<<5|s>>>27)+u+o[c];h+=c<20?1518500249+(i&r|~i&a):c<40?1859775393+(i^r^a):c<60?(i&r|i&a|r&a)-1894007588:(i^r^a)-899497514,u=a,a=r,r=i<<30|i>>>2,i=s,s=h}n[0]=n[0]+s|0,n[1]=n[1]+i|0,n[2]=n[2]+r|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,s=8*t.sigBytes;return e[s>>>5]|=128<<24-s%32,e[14+(s+64>>>9<<4)]=Math.floor(n/4294967296),e[15+(s+64>>>9<<4)]=n,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,n,s,i,r,o,a}(sa())),Ta.exports}var ka,Ca={exports:{}};function Sa(){return ka||(ka=1,Ca.exports=function(t){return function(e){var n=t,s=n.lib,i=s.WordArray,r=s.Hasher,o=n.algo,a=[],u=[];!function(){function t(t){for(var n=e.sqrt(t),s=2;s<=n;s++)if(!(t%s))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var s=2,i=0;i<64;)t(s)&&(i<8&&(a[i]=n(e.pow(s,.5))),u[i]=n(e.pow(s,1/3)),i++),s++}();var c=[],l=o.SHA256=r.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,s=n[0],i=n[1],r=n[2],o=n[3],a=n[4],l=n[5],h=n[6],p=n[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var f=c[d-15],_=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,m=c[d-2],g=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;c[d]=_+c[d-7]+g+c[d-16]}var v=s&i^s&r^i&r,y=(s<<30|s>>>2)^(s<<19|s>>>13)^(s<<10|s>>>22),w=p+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+u[d]+c[d];p=h,h=l,l=a,a=o+w|0,o=r,r=i,i=s,s=w+(y+v)|0}n[0]=n[0]+s|0,n[1]=n[1]+i|0,n[2]=n[2]+r|0,n[3]=n[3]+o|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+h|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(s/4294967296),n[15+(i+64>>>9<<4)]=s,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=r._createHelper(l),n.HmacSHA256=r._createHmacHelper(l)}(Math),t.SHA256}(sa())),Ca.exports}var Oa,Ma={exports:{}};var Ea,Da={exports:{}};function Ia(){return Ea||(Ea=1,Da.exports=function(t){return function(){var e=t,n=e.lib.Hasher,s=e.x64,i=s.Word,r=s.WordArray,o=e.algo;function a(){return i.create.apply(i,arguments)}var u=[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)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var l=o.SHA512=n.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 n=this._hash.words,s=n[0],i=n[1],r=n[2],o=n[3],a=n[4],l=n[5],h=n[6],p=n[7],d=s.high,f=s.low,_=i.high,m=i.low,g=r.high,v=r.low,y=o.high,w=o.low,b=a.high,x=a.low,T=l.high,A=l.low,k=h.high,C=h.low,S=p.high,O=p.low,M=d,E=f,D=_,I=m,R=g,N=v,B=y,P=w,V=b,F=x,q=T,j=A,z=k,W=C,L=S,U=O,H=0;H<80;H++){var $,G,X=c[H];if(H<16)G=X.high=0|t[e+2*H],$=X.low=0|t[e+2*H+1];else{var Z=c[H-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=c[H-2],et=tt.high,nt=tt.low,st=(et>>>19|nt<<13)^(et<<3|nt>>>29)^et>>>6,it=(nt>>>19|et<<13)^(nt<<3|et>>>29)^(nt>>>6|et<<26),rt=c[H-7],ot=rt.high,at=rt.low,ut=c[H-16],ct=ut.high,lt=ut.low;G=(G=(G=K+ot+(($=J+at)>>>0<J>>>0?1:0))+st+(($+=it)>>>0<it>>>0?1:0))+ct+(($+=lt)>>>0<lt>>>0?1:0),X.high=G,X.low=$}var ht,pt=V&q^~V&z,dt=F&j^~F&W,ft=M&D^M&R^D&R,_t=E&I^E&N^I&N,mt=(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=(V>>>14|F<<18)^(V>>>18|F<<14)^(V<<23|F>>>9),yt=(F>>>14|V<<18)^(F>>>18|V<<14)^(F<<23|V>>>9),wt=u[H],bt=wt.high,xt=wt.low,Tt=L+vt+((ht=U+yt)>>>0<U>>>0?1:0),At=gt+_t;L=z,U=W,z=q,W=j,q=V,j=F,V=B+(Tt=(Tt=(Tt=Tt+pt+((ht+=dt)>>>0<dt>>>0?1:0))+bt+((ht+=xt)>>>0<xt>>>0?1:0))+G+((ht+=$)>>>0<$>>>0?1:0))+((F=P+ht|0)>>>0<P>>>0?1:0)|0,B=R,P=N,R=D,N=I,D=M,I=E,M=Tt+(mt+ft+(At>>>0<gt>>>0?1:0))+((E=ht+At|0)>>>0<ht>>>0?1:0)|0}f=s.low=f+E,s.high=d+M+(f>>>0<E>>>0?1:0),m=i.low=m+I,i.high=_+D+(m>>>0<I>>>0?1:0),v=r.low=v+N,r.high=g+R+(v>>>0<N>>>0?1:0),w=o.low=w+P,o.high=y+B+(w>>>0<P>>>0?1:0),x=a.low=x+F,a.high=b+V+(x>>>0<F>>>0?1:0),A=l.low=A+j,l.high=T+q+(A>>>0<j>>>0?1:0),C=h.low=C+W,h.high=k+z+(C>>>0<W>>>0?1:0),O=p.low=O+U,p.high=S+L+(O>>>0<U>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,s=8*t.sigBytes;return e[s>>>5]|=128<<24-s%32,e[30+(s+128>>>10<<5)]=Math.floor(n/4294967296),e[31+(s+128>>>10<<5)]=n,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=n._createHelper(l),e.HmacSHA512=n._createHmacHelper(l)}(),t.SHA512}(sa(),oa())),Da.exports}var Ra,Na={exports:{}};var Ba,Pa={exports:{}};function Va(){return Ba||(Ba=1,Pa.exports=function(t){return function(e){var n=t,s=n.lib,i=s.WordArray,r=s.Hasher,o=n.x64.Word,a=n.algo,u=[],c=[],l=[];!function(){for(var t=1,e=0,n=0;n<24;n++){u[t+5*e]=(n+1)*(n+2)/2%64;var s=(2*t+3*e)%5;t=e%5,e=s}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,r=0;r<24;r++){for(var a=0,h=0,p=0;p<7;p++){if(1&i){var d=(1<<p)-1;d<32?h^=1<<d:a^=1<<d-32}128&i?i=i<<1^113:i<<=1}l[r]=o.create(a,h)}}();var h=[];!function(){for(var t=0;t<25;t++)h[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 n=this._state,s=this.blockSize/2,i=0;i<s;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=n[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,_=0;_<5;_++)d^=(O=n[p+5*_]).high,f^=O.low;var m=h[p];m.high=d,m.low=f}for(p=0;p<5;p++){var g=h[(p+4)%5],v=h[(p+1)%5],y=v.high,w=v.low;for(d=g.high^(y<<1|w>>>31),f=g.low^(w<<1|y>>>31),_=0;_<5;_++)(O=n[p+5*_]).high^=d,O.low^=f}for(var b=1;b<25;b++){var x=(O=n[b]).high,T=O.low,A=u[b];A<32?(d=x<<A|T>>>32-A,f=T<<A|x>>>32-A):(d=T<<A-32|x>>>64-A,f=x<<A-32|T>>>64-A);var k=h[c[b]];k.high=d,k.low=f}var C=h[0],S=n[0];for(C.high=S.high,C.low=S.low,p=0;p<5;p++)for(_=0;_<5;_++){var O=n[b=p+5*_],M=h[b],E=h[(p+1)%5+5*_],D=h[(p+2)%5+5*_];O.high=M.high^~E.high&D.high,O.low=M.low^~E.low&D.low}O=n[0];var I=l[a];O.high^=I.high,O.low^=I.low}},_doFinalize:function(){var t=this._data,n=t.words;this._nDataBytes;var s=8*t.sigBytes,r=32*this.blockSize;n[s>>>5]|=1<<24-s%32,n[(e.ceil((s+1)/r)*r>>>5)-1]|=128,t.sigBytes=4*n.length,this._process();for(var o=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],l=0;l<u;l++){var h=o[l],p=h.high,d=h.low;p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(p)}return new i.init(c,a)},clone:function(){for(var t=r.clone.call(this),e=t._state=this._state.slice(0),n=0;n<25;n++)e[n]=e[n].clone();return t}});n.SHA3=r._createHelper(p),n.HmacSHA3=r._createHmacHelper(p)}(Math),t.SHA3}(sa(),oa())),Pa.exports}var Fa,qa={exports:{}};var ja,za={exports:{}};function Wa(){return ja||(ja=1,za.exports=function(t){var e,n,s;n=(e=t).lib.Base,s=e.enc.Utf8,e.algo.HMAC=n.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=s.parse(e));var n=t.blockSize,i=4*n;e.sigBytes>i&&(e=t.finalize(e)),e.clamp();for(var r=this._oKey=e.clone(),o=this._iKey=e.clone(),a=r.words,u=o.words,c=0;c<n;c++)a[c]^=1549556828,u[c]^=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,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})}(sa())),za.exports}var La,Ua={exports:{}};var Ha,$a={exports:{}};function Ga(){return Ha||(Ha=1,$a.exports=function(t){return n=(e=t).lib,s=n.Base,i=n.WordArray,r=e.algo,o=r.MD5,a=r.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n,s=this.cfg,r=s.hasher.create(),o=i.create(),a=o.words,u=s.keySize,c=s.iterations;a.length<u;){n&&r.update(n),n=r.update(t).finalize(e),r.reset();for(var l=1;l<c;l++)n=r.finalize(n),r.reset();o.concat(n)}return o.sigBytes=4*u,o}}),e.EvpKDF=function(t,e,n){return a.create(n).compute(t,e)},t.EvpKDF;var e,n,s,i,r,o,a}(sa(),Aa(),Wa())),$a.exports}var Xa,Za={exports:{}};function Ya(){return Xa||(Xa=1,Za.exports=function(t){t.lib.Cipher||function(e){var n=t,s=n.lib,i=s.Base,r=s.WordArray,o=s.BufferedBlockAlgorithm,a=n.enc;a.Utf8;var u=a.Base64,c=n.algo.EvpKDF,l=s.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,n){this.cfg=this.cfg.extend(n),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(n,s,i){return t(s).encrypt(e,n,s,i)},decrypt:function(n,s,i){return t(s).decrypt(e,n,s,i)}}}}()});s.StreamCipher=l.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=n.mode={},p=s.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=h.CBC=function(){var t=p.extend();function n(t,n,s){var i,r=this._iv;r?(i=r,this._iv=e):i=this._prevBlock;for(var o=0;o<s;o++)t[n+o]^=i[o]}return t.Encryptor=t.extend({processBlock:function(t,e){var s=this._cipher,i=s.blockSize;n.call(this,t,e,i),s.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),t.Decryptor=t.extend({processBlock:function(t,e){var s=this._cipher,i=s.blockSize,r=t.slice(e,e+i);s.decryptBlock(t,e),n.call(this,t,e,i),this._prevBlock=r}}),t}(),f=(n.pad={}).Pkcs7={pad:function(t,e){for(var n=4*e,s=n-t.sigBytes%n,i=s<<24|s<<16|s<<8|s,o=[],a=0;a<s;a+=4)o.push(i);var u=r.create(o,s);t.concat(u)},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}};s.BlockCipher=l.extend({cfg:l.cfg.extend({mode:d,padding:f}),reset:function(){var t;l.reset.call(this);var e=this.cfg,n=e.iv,s=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=s.createEncryptor:(t=s.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,n&&n.words):(this._mode=t.call(s,this,n&&n.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 _=s.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),m=(n.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,n=t.salt;return(n?r.create([1398893684,1701076831]).concat(n).concat(e):e).toString(u)},parse:function(t){var e,n=u.parse(t),s=n.words;return 1398893684==s[0]&&1701076831==s[1]&&(e=r.create(s.slice(2,4)),s.splice(0,4),n.sigBytes-=16),_.create({ciphertext:n,salt:e})}},g=s.SerializableCipher=i.extend({cfg:i.extend({format:m}),encrypt:function(t,e,n,s){s=this.cfg.extend(s);var i=t.createEncryptor(n,s),r=i.finalize(e),o=i.cfg;return _.create({ciphertext:r,key:n,iv:o.iv,algorithm:t,mode:o.mode,padding:o.padding,blockSize:t.blockSize,formatter:s.format})},decrypt:function(t,e,n,s){return s=this.cfg.extend(s),e=this._parse(e,s.format),t.createDecryptor(n,s).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(n.kdf={}).OpenSSL={execute:function(t,e,n,s,i){if(s||(s=r.random(8)),i)o=c.create({keySize:e+n,hasher:i}).compute(t,s);else var o=c.create({keySize:e+n}).compute(t,s);var a=r.create(o.words.slice(e),4*n);return o.sigBytes=4*e,_.create({key:o,iv:a,salt:s})}},y=s.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(t,e,n,s){var i=(s=this.cfg.extend(s)).kdf.execute(n,t.keySize,t.ivSize,s.salt,s.hasher);s.iv=i.iv;var r=g.encrypt.call(this,t,e,i.key,s);return r.mixIn(i),r},decrypt:function(t,e,n,s){s=this.cfg.extend(s),e=this._parse(e,s.format);var i=s.kdf.execute(n,t.keySize,t.ivSize,e.salt,s.hasher);return s.iv=i.iv,g.decrypt.call(this,t,e,i.key,s)}})}()}(sa(),Ga())),Za.exports}var Qa,Ka={exports:{}};function Ja(){return Qa||(Qa=1,Ka.exports=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function n(t,e,n,s){var i,r=this._iv;r?(i=r.slice(0),this._iv=void 0):i=this._prevBlock,s.encryptBlock(i,0);for(var o=0;o<n;o++)t[e+o]^=i[o]}return e.Encryptor=e.extend({processBlock:function(t,e){var s=this._cipher,i=s.blockSize;n.call(this,t,e,i,s),this._prevBlock=t.slice(e,e+i)}}),e.Decryptor=e.extend({processBlock:function(t,e){var s=this._cipher,i=s.blockSize,r=t.slice(e,e+i);n.call(this,t,e,i,s),this._prevBlock=r}}),e}(),t.mode.CFB}(sa(),Ya())),Ka.exports}var tu,eu={exports:{}};function nu(){return tu||(tu=1,eu.exports=function(t){return t.mode.CTR=(e=t.lib.BlockCipherMode.extend(),n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,s=n.blockSize,i=this._iv,r=this._counter;i&&(r=this._counter=i.slice(0),this._iv=void 0);var o=r.slice(0);n.encryptBlock(o,0),r[s-1]=r[s-1]+1|0;for(var a=0;a<s;a++)t[e+a]^=o[a]}}),e.Decryptor=n,e),t.mode.CTR;var e,n}(sa(),Ya())),eu.exports}var su,iu={exports:{}};function ru(){return su||(su=1,iu.exports=function(t){
|
|
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 Ci(t,e){return t+xi<e}function ki(t,e){return Math.abs(t-e)<xi}class Ai extends wi{constructor(){super(),this.name="Timeline",this._timeline=[];const t=gi(Ai.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(Ci(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 Mi(t){Si.push(t)}const Oi=[];function Ei(t){Oi.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 Ni extends Ii{constructor(){super(),this.name="Context",this._constants=new Map,this._timeouts=new Ai,this._timeoutIds=0,this._initialized=!1,this.isOffline=!1,this._workletModules=new Map;const t=gi(Ni.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,Oi.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 Ri(t,e){si(e)?e.forEach((e=>Ri(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 Pi=()=>{};class Vi extends wi{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Pi;const t=gi(Vi.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,t.url&&fi(t.url)||t.url instanceof Vi?this.set(t.url):ni(t.url)&&this.load(t.url).catch(t.onerror)}static getDefaults(){return{onerror:Pi,onload:Pi,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:ji().sampleRate}set(t){return t instanceof Vi?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=Vi.load(t).then((t=>{this.set(t),this.onload(this)}));Vi.downloads.push(e);try{yield e}finally{const t=Vi.downloads.indexOf(e);Vi.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=ji(),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=ji().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 Vi(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 Vi).fromArray(t)}static fromUrl(t){return ci(this,void 0,void 0,(function*(){const e=new Vi;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(Vi.supportsType(t)){n=t;break}t=t.replace(e[0],n)}const s=""===Vi.baseUrl||Vi.baseUrl.endsWith("/")?Vi.baseUrl:Vi.baseUrl+"/",n=yield fetch(s+t);if(!n.ok)throw new Error(`could not load url: ${t}`);const i=yield n.arrayBuffer();return yield ji().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();Vi.downloads.length;)yield Vi.downloads[0]}))}}Vi.baseUrl="",Vi.downloads=[];class qi extends Ni{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 jn(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 Vi(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 zi=Fi;function ji(){return zi===Fi&&oi&&Wi(new Ni),zi}function Wi(t){zi=di(t)?new Ni(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:ji()}}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 Ai{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 Ai(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}),Ri(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=Pi,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:Pi})}_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!==Pi&&(this.onended(this),this.onended=Pi,!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 Ai(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 Ai;const t=gi(dr.getDefaults(),arguments,["frequency"]);this.frequency=new pr({context:this.context,units:t.units,value:t.frequency}),Ri(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=Pi,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,Ri(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Ji.getDefaults(),{callback:Pi,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}),Ri(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:Pi,onload:Pi,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=Pi,n=Pi){return ni(e)?this._buffers.set(t.toString(),new Vi(this.baseUrl+e,s,n)):this._buffers.set(t.toString(),new Vi(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 Ai,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}}Mi((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,Ri(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}}Mi((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 Ai({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 Cr{constructor(t,e){this.id=Cr._eventId++;const s=Object.assign(Cr.getDefaults(),e);this.transport=t,this.callback=s.callback,this._once=s.once,this.time=s.time}static getDefaults(){return{callback:Pi,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}}Cr._eventId=0;class kr extends Cr{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({},Cr.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 Ar extends Ji{constructor(){super(gi(Ar.getDefaults(),arguments)),this.name="Transport",this._loop=new Tr(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Ai,this._repeatedEvents=new yr,this._syncedSignals=[],this._swingAmount=0;const t=gi(Ar.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),Ri(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 Cr(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 Cr(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(Ar),Mi((t=>{t.transport=new Ar({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=Pi,this._syncedStop=Pi,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,Ri(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(sr.getDefaults(),{mute:!1,onstop:Pi,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=Pi,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Mr extends ar{constructor(){super(gi(Mr.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(Mr.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 Vi(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(ar.getDefaults(),{url:new Vi,loop:!1,loopEnd:0,loopStart:0,onload:Pi,onerror:Pi,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,Ci(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 Or extends Sr{constructor(){super(gi(Or.getDefaults(),arguments,["type"])),this.name="Noise",this._source=null;const t=gi(Or.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 Mr({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 Vi).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 Vi).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 Vi).fromArray(t)}return Dr.white}};function Nr(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 Rr extends ar{constructor(){super(gi(Rr.getDefaults(),arguments,["frequency","type"])),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator];const t=gi(Rr.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}),Ri(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}),Ri(this,"frequency"),this.detune=new ur({context:this.context,units:"cents",value:e.detune}),Ri(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 Rr({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 Nr(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 Pr extends sr{constructor(){super(Object.assign(gi(Pr.getDefaults(),arguments,["context"])))}connect(t,e=0,s=0){return hr(this,t,e,s),this}}class Vr extends Pr{constructor(){super(Object.assign(gi(Vr.getDefaults(),arguments,["mapping","length"]))),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper;const t=gi(Vr.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 Pr{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new Vr({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 zr extends Sr{constructor(){super(gi(zr.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(zr.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),Ri(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 Nr(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 jr extends Sr{constructor(){super(gi(jr.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="FMOscillator",this._modulationNode=new or({context:this.context,gain:0});const t=gi(jr.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),Ri(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 Nr(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 Vr({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),Ri(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 Nr(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,Ri(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):Pi});"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 Nr(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),Ri(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 Nr(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const Ur={am:zr,fat:Lr,fm:jr,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}),Ri(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Br.getDefaults(),jr.getDefaults(),zr.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 Nr(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 Pr{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(Pr.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 Pr{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),Ri(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 Vi({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:Pi,onerror:Pi,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=Pi){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 Mr({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 Pr{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new Vr({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 Pr{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 Vr({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(Pr.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,Ri(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:Pi,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),Ri(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,Ri(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,Ri(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=Pi;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:Pi,onerror:Pi,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 Mr({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:Pi,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}),Ri(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],Ri(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",Ri(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 Co=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 Ao extends sr{constructor(){super(gi(Ao.getDefaults(),arguments,["channels"])),this.name="Merge";const t=gi(Ao.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 Vr({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 Mo 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,Ri(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 Oo extends Mo{constructor(){super(gi(Oo.getDefaults(),arguments,["delayTime","feedback"])),this.name="FeedbackDelay";const t=gi(Oo.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),Ri(this,"delayTime")}static getDefaults(){return Object.assign(Mo.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 Or({context:e}),n=new Or({context:e}),i=new Ao({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(Pi),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,Ri(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 No extends sr{constructor(){super(gi(No.getDefaults(),arguments,["volume","pan"])),this.name="Channel";const t=gi(No.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),Ri(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 No.buses.has(t)||No.buses.set(t,new or({context:this.context})),No.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}}No.buses=new Map;class Ro 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 ji().now()}Mi((t=>{t.listener=new Ro({context:t})})),Ei((t=>{t.listener.dispose()})),ji().transport,ji().destination,ji().destination,ji().listener,ji().draw,ji();const Po={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},Vo=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],qo=Vo.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 Vo.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 Vo.indexOf(this.name)}adjustFrequency(t=0,e=0){if(this.frequency)return this.frequency;let s=this.octave+t;const n=Vo.indexOf(this.name)+e;let i=n;n>=qo?(s++,i=n%qo):n<0&&(s--,i=qo+i);const r=Vo[i];return Po[`${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=Vo[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 zo={128:"noteOff",144:"noteOn",176:"cc"};class jo{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 jo(new MIDIMessageEvent("",{data:n.midiData(e)}),s);return i.note=n,i}static fromCC(t,e,s){return new jo(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=zo[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 jo)&&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 jo?t:new jo(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=jo.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 Ca(){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],C=t[e+13],k=t[e+14],A=t[e+15],S=r[0],M=r[1],O=r[2],E=r[3];S=u(S,M,O,E,o,7,a[0]),E=u(E,S,M,O,c,12,a[1]),O=u(O,E,S,M,d,17,a[2]),M=u(M,O,E,S,f,22,a[3]),S=u(S,M,O,E,m,7,a[4]),E=u(E,S,M,O,_,12,a[5]),O=u(O,E,S,M,g,17,a[6]),M=u(M,O,E,S,v,22,a[7]),S=u(S,M,O,E,y,7,a[8]),E=u(E,S,M,O,w,12,a[9]),O=u(O,E,S,M,x,17,a[10]),M=u(M,O,E,S,b,22,a[11]),S=u(S,M,O,E,T,7,a[12]),E=u(E,S,M,O,C,12,a[13]),O=u(O,E,S,M,k,17,a[14]),S=h(S,M=u(M,O,E,S,A,22,a[15]),O,E,c,5,a[16]),E=h(E,S,M,O,g,9,a[17]),O=h(O,E,S,M,b,14,a[18]),M=h(M,O,E,S,o,20,a[19]),S=h(S,M,O,E,_,5,a[20]),E=h(E,S,M,O,x,9,a[21]),O=h(O,E,S,M,A,14,a[22]),M=h(M,O,E,S,m,20,a[23]),S=h(S,M,O,E,w,5,a[24]),E=h(E,S,M,O,k,9,a[25]),O=h(O,E,S,M,f,14,a[26]),M=h(M,O,E,S,y,20,a[27]),S=h(S,M,O,E,C,5,a[28]),E=h(E,S,M,O,d,9,a[29]),O=h(O,E,S,M,v,14,a[30]),S=l(S,M=h(M,O,E,S,T,20,a[31]),O,E,_,4,a[32]),E=l(E,S,M,O,y,11,a[33]),O=l(O,E,S,M,b,16,a[34]),M=l(M,O,E,S,k,23,a[35]),S=l(S,M,O,E,c,4,a[36]),E=l(E,S,M,O,m,11,a[37]),O=l(O,E,S,M,v,16,a[38]),M=l(M,O,E,S,x,23,a[39]),S=l(S,M,O,E,C,4,a[40]),E=l(E,S,M,O,o,11,a[41]),O=l(O,E,S,M,f,16,a[42]),M=l(M,O,E,S,g,23,a[43]),S=l(S,M,O,E,w,4,a[44]),E=l(E,S,M,O,T,11,a[45]),O=l(O,E,S,M,A,16,a[46]),S=p(S,M=l(M,O,E,S,d,23,a[47]),O,E,o,6,a[48]),E=p(E,S,M,O,v,10,a[49]),O=p(O,E,S,M,k,15,a[50]),M=p(M,O,E,S,_,21,a[51]),S=p(S,M,O,E,T,6,a[52]),E=p(E,S,M,O,f,10,a[53]),O=p(O,E,S,M,x,15,a[54]),M=p(M,O,E,S,c,21,a[55]),S=p(S,M,O,E,y,6,a[56]),E=p(E,S,M,O,A,10,a[57]),O=p(O,E,S,M,g,15,a[58]),M=p(M,O,E,S,C,21,a[59]),S=p(S,M,O,E,m,6,a[60]),E=p(E,S,M,O,b,10,a[61]),O=p(O,E,S,M,d,15,a[62]),M=p(M,O,E,S,w,21,a[63]),r[0]=r[0]+S|0,r[1]=r[1]+M|0,r[2]=r[2]+O|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,Aa={exports:{}};function Sa(){return ka||(ka=1,Aa.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())),Aa.exports}var Ma,Oa={exports:{}};function Ea(){return Ma||(Ma=1,Oa.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())),Oa.exports}var Da,Ia={exports:{}};var Na,Ra={exports:{}};function Ba(){return Na||(Na=1,Ra.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,C=h.low,k=l.high,A=l.low,S=p.high,M=p.low,O=d,E=f,D=m,I=_,N=g,R=v,B=y,P=w,V=x,q=b,F=T,z=C,j=k,W=A,L=S,H=M,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=V&F^~V&j,dt=q&z^~q&W,ft=O&D^O&N^D&N,mt=E&I^E&R^I&R,_t=(O>>>28|E<<4)^(O<<30|E>>>2)^(O<<25|E>>>7),gt=(E>>>28|O<<4)^(E<<30|O>>>2)^(E<<25|O>>>7),vt=(V>>>14|q<<18)^(V>>>18|q<<14)^(V<<23|q>>>9),yt=(q>>>14|V<<18)^(q>>>18|V<<14)^(q<<23|V>>>9),wt=c[U],xt=wt.high,bt=wt.low,Tt=L+vt+((lt=H+yt)>>>0<H>>>0?1:0),Ct=gt+mt;L=j,H=W,j=F,W=z,F=V,z=q,V=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=P+lt|0)>>>0<P>>>0?1:0)|0,B=N,P=R,N=D,R=I,D=O,I=E,O=Tt+(_t+ft+(Ct>>>0<gt>>>0?1:0))+((E=lt+Ct|0)>>>0<lt>>>0?1:0)|0}f=n.low=f+E,n.high=d+O+(f>>>0<E>>>0?1:0),_=i.low=_+I,i.high=m+D+(_>>>0<I>>>0?1:0),v=r.low=v+R,r.high=g+N+(v>>>0<R>>>0?1:0),w=o.low=w+P,o.high=y+B+(w>>>0<P>>>0?1:0),b=a.low=b+q,a.high=x+V+(b>>>0<q>>>0?1:0),C=h.low=C+z,h.high=T+F+(C>>>0<z>>>0?1:0),A=l.low=A+W,l.high=k+j+(A>>>0<W>>>0?1:0),M=p.low=M+H,p.high=S+L+(M>>>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())),Ra.exports}var Pa,Va={exports:{}};var qa,Fa={exports:{}};function za(){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),(M=s[i]).high^=o,M.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^=(M=s[p+5*m]).high,f^=M.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++)(M=s[p+5*m]).high^=d,M.low^=f}for(var x=1;x<25;x++){var b=(M=s[x]).high,T=M.low,C=c[x];C<32?(d=b<<C|T>>>32-C,f=T<<C|b>>>32-C):(d=T<<C-32|b>>>64-C,f=b<<C-32|T>>>64-C);var k=l[u[x]];k.high=d,k.low=f}var A=l[0],S=s[0];for(A.high=S.high,A.low=S.low,p=0;p<5;p++)for(m=0;m<5;m++){var M=s[x=p+5*m],O=l[x],E=l[(p+1)%5+5*m],D=l[(p+2)%5+5*m];M.high=O.high^~E.high&D.high,M.low=O.low^~E.low&D.low}M=s[0];var I=h[a];M.high^=I.high,M.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 ja,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
8
|
/** @preserve
|
|
9
9
|
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
|
10
10
|
* derived from CryptoJS.mode.CTR
|
|
11
11
|
* Jan Hruby jhruby.web@gmail.com
|
|
12
12
|
*/
|
|
13
|
-
return t.mode.CTRGladman=function(){var e=t.lib.BlockCipherMode.extend();function n(t){if(255==(t>>24&255)){var e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}else t+=1<<24;return t}function s(t){return 0===(t[0]=n(t[0]))&&(t[1]=n(t[1])),t}var i=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,r=this._iv,o=this._counter;r&&(o=this._counter=r.slice(0),this._iv=void 0),s(o);var a=o.slice(0);n.encryptBlock(a,0);for(var u=0;u<i;u++)t[e+u]^=a[u]}});return e.Decryptor=i,e}(),t.mode.CTRGladman}(sa(),Ya())),iu.exports}var ou,au={exports:{}};function uu(){return ou||(ou=1,au.exports=function(t){return t.mode.OFB=(e=t.lib.BlockCipherMode.extend(),n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,s=n.blockSize,i=this._iv,r=this._keystream;i&&(r=this._keystream=i.slice(0),this._iv=void 0),n.encryptBlock(r,0);for(var o=0;o<s;o++)t[e+o]^=r[o]}}),e.Decryptor=n,e),t.mode.OFB;var e,n}(sa(),Ya())),au.exports}var cu,lu={exports:{}};var hu,pu={exports:{}};var du,fu={exports:{}};var _u,mu={exports:{}};var gu,vu={exports:{}};var yu,wu={exports:{}};var bu,xu={exports:{}};var Tu,Au={exports:{}};var ku,Cu={exports:{}};function Su(){return ku||(ku=1,Cu.exports=function(t){return function(){var e=t,n=e.lib,s=n.WordArray,i=n.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],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{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}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=r.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],n=0;n<56;n++){var s=o[n]-1;e[n]=t[s>>>5]>>>31-s%32&1}for(var i=this._subKeys=[],r=0;r<16;r++){var c=i[r]=[],l=u[r];for(n=0;n<24;n++)c[n/6|0]|=e[(a[n]-1+l)%28]<<31-n%6,c[4+(n/6|0)]|=e[28+(a[n+24]-1+l)%28]<<31-n%6;for(c[0]=c[0]<<1|c[0]>>>31,n=1;n<7;n++)c[n]=c[n]>>>4*(n-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(n=0;n<16;n++)h[n]=i[15-n]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,n){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 s=0;s<16;s++){for(var i=n[s],r=this._lBlock,o=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((o^i[u])&l[u])>>>0];this._lBlock=o,this._rBlock=r^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,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 n=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=n,this._lBlock^=n<<t}function d(t,e){var n=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=n,this._rBlock^=n<<t}e.DES=i._createHelper(h);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),n=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=h.createEncryptor(s.create(e)),this._des2=h.createEncryptor(s.create(n)),this._des3=h.createEncryptor(s.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}(sa(),_a(),ba(),Ga(),Ya())),Cu.exports}var Ou,Mu={exports:{}};var Eu,Du={exports:{}};var Iu,Ru={exports:{}};var Nu,Bu={exports:{}};function Pu(){return Nu||(Nu=1,Bu.exports=function(t){return function(){var e=t,n=e.lib.BlockCipher,s=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 u(t,e){let n=e>>24&255,s=e>>16&255,i=e>>8&255,r=255&e,o=t.sbox[0][n]+t.sbox[1][s];return o^=t.sbox[2][i],o+=t.sbox[3][r],o}function c(t,e,n){let s,r=e,o=n;for(let e=0;e<i;++e)r^=t.pbox[e],o=u(t,r)^o,s=r,r=o,o=s;return s=r,r=o,o=s,o^=t.pbox[i],r^=t.pbox[i+1],{left:r,right:o}}function l(t,e,n){let s,r=e,o=n;for(let e=i+1;e>1;--e)r^=t.pbox[e],o=u(t,r)^o,s=r,r=o,o=s;return s=r,r=o,o=s,o^=t.pbox[1],r^=t.pbox[0],{left:r,right:o}}function h(t,e,n){for(let e=0;e<4;e++){t.sbox[e]=[];for(let n=0;n<256;n++)t.sbox[e][n]=o[e][n]}let s=0;for(let o=0;o<i+2;o++)t.pbox[o]=r[o]^e[s],s++,s>=n&&(s=0);let a=0,u=0,l=0;for(let e=0;e<i+2;e+=2)l=c(t,a,u),a=l.left,u=l.right,t.pbox[e]=a,t.pbox[e+1]=u;for(let e=0;e<4;e++)for(let n=0;n<256;n+=2)l=c(t,a,u),a=l.left,u=l.right,t.sbox[e][n]=a,t.sbox[e][n+1]=u;return!0}var p=s.Blowfish=n.extend({_doReset:function(){if(this._keyPriorReset!==this._key){var t=this._keyPriorReset=this._key,e=t.words,n=t.sigBytes/4;h(a,e,n)}},encryptBlock:function(t,e){var n=c(a,t[e],t[e+1]);t[e]=n.left,t[e+1]=n.right},decryptBlock:function(t,e){var n=l(a,t[e],t[e+1]);t[e]=n.left,t[e+1]=n.right},blockSize:2,keySize:4,ivSize:2});e.Blowfish=n._createHelper(p)}(),t.Blowfish}(sa(),_a(),ba(),Ga(),Ya())),Bu.exports}ta.exports=function(t){return t}(sa(),oa(),ca(),pa(),_a(),va(),ba(),Aa(),Sa(),Oa||(Oa=1,Ma.exports=function(t){return n=(e=t).lib.WordArray,s=e.algo,i=s.SHA256,r=s.SHA224=i.extend({_doReset:function(){this._hash=new n.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,n,s,i,r}(sa(),Sa())),Ia(),Ra||(Ra=1,Na.exports=function(t){return n=(e=t).x64,s=n.Word,i=n.WordArray,r=e.algo,o=r.SHA512,a=r.SHA384=o.extend({_doReset:function(){this._hash=new i.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.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,n,s,i,r,o,a}(sa(),oa(),Ia())),Va(),Fa||(Fa=1,qa.exports=function(t){
|
|
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 Cc,kc={exports:{}};var Ac,Sc={exports:{}};var Mc,Oc={exports:{}};function Ec(){return Mc||(Mc=1,Oc.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(),Ca(),Ya(),Ja())),Oc.exports}var Dc,Ic={exports:{}};var Nc,Rc={exports:{}};var Bc,Pc={exports:{}};var Vc,qc={exports:{}};function Fc(){return Vc||(Vc=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(),Ca(),Ya(),Ja())),qc.exports}na.exports=function(t){return t}(oa(),ua(),pa(),ma(),va(),xa(),Ca(),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(),Pa||(Pa=1,Va.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())),za(),ja||(ja=1,Wa.exports=function(t){
|
|
14
14
|
/** @preserve
|
|
15
15
|
(c) 2012 by Cédric Mesnil. All rights reserved.
|
|
16
16
|
|
|
@@ -21,13 +21,5 @@ return t.mode.CTRGladman=function(){var e=t.lib.BlockCipherMode.extend();functio
|
|
|
21
21
|
|
|
22
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
23
|
*/
|
|
24
|
-
return function(e){var n=t,s=n.lib,i=s.WordArray,r=s.Hasher,o=n.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]),u=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]),c=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]),l=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]),h=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 n=0;n<16;n++){var s=e+n,i=t[s];t[s]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var r,o,d,w,b,x,T,A,k,C,S,O=this._hash.words,M=h.words,E=p.words,D=a.words,I=u.words,R=c.words,N=l.words;for(x=r=O[0],T=o=O[1],A=d=O[2],k=w=O[3],C=b=O[4],n=0;n<80;n+=1)S=r+t[e+D[n]]|0,S+=n<16?f(o,d,w)+M[0]:n<32?_(o,d,w)+M[1]:n<48?m(o,d,w)+M[2]:n<64?g(o,d,w)+M[3]:v(o,d,w)+M[4],S=(S=y(S|=0,R[n]))+b|0,r=b,b=w,w=y(d,10),d=o,o=S,S=x+t[e+I[n]]|0,S+=n<16?v(T,A,k)+E[0]:n<32?g(T,A,k)+E[1]:n<48?m(T,A,k)+E[2]:n<64?_(T,A,k)+E[3]:f(T,A,k)+E[4],S=(S=y(S|=0,N[n]))+C|0,x=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]+b+x|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,n=8*this._nDataBytes,s=8*t.sigBytes;e[s>>>5]|=128<<24-s%32,e[14+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>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,n){return t^e^n}function _(t,e,n){return t&e|~t&n}function m(t,e,n){return(t|~e)^n}function g(t,e,n){return t&n|e&~n}function v(t,e,n){return t^(e|~n)}function y(t,e){return t<<e|t>>>32-e}n.RIPEMD160=r._createHelper(d),n.HmacRIPEMD160=r._createHmacHelper(d)}(),t.RIPEMD160}(sa())),Wa(),La||(La=1,Ua.exports=function(t){return s=(n=(e=t).lib).Base,i=n.WordArray,o=(r=e.algo).SHA256,a=r.HMAC,u=r.PBKDF2=s.extend({cfg:s.extend({keySize:4,hasher:o,iterations:25e4}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var n=this.cfg,s=a.create(n.hasher,t),r=i.create(),o=i.create([1]),u=r.words,c=o.words,l=n.keySize,h=n.iterations;u.length<l;){var p=s.update(e).finalize(o);s.reset();for(var d=p.words,f=d.length,_=p,m=1;m<h;m++){_=s.finalize(_),s.reset();for(var g=_.words,v=0;v<f;v++)d[v]^=g[v]}r.concat(p),c[0]++}return r.sigBytes=4*l,r}}),e.PBKDF2=function(t,e,n){return u.create(n).compute(t,e)},t.PBKDF2;var e,n,s,i,r,o,a,u}(sa(),Sa(),Wa())),Ga(),Ya(),Ja(),nu(),ru(),uu(),cu||(cu=1,lu.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}(sa(),Ya())),hu||(hu=1,pu.exports=function(t){return t.pad.AnsiX923={pad:function(t,e){var n=t.sigBytes,s=4*e,i=s-n%s,r=n+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}(sa(),Ya())),du||(du=1,fu.exports=function(t){return t.pad.Iso10126={pad:function(e,n){var s=4*n,i=s-e.sigBytes%s;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}(sa(),Ya())),_u||(_u=1,mu.exports=function(t){return t.pad.Iso97971={pad:function(e,n){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,n)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971}(sa(),Ya())),gu||(gu=1,vu.exports=function(t){return t.pad.ZeroPadding={pad:function(t,e){var n=4*e;t.clamp(),t.sigBytes+=n-(t.sigBytes%n||n)},unpad:function(t){var e=t.words,n=t.sigBytes-1;for(n=t.sigBytes-1;n>=0;n--)if(e[n>>>2]>>>24-n%4*8&255){t.sigBytes=n+1;break}}},t.pad.ZeroPadding}(sa(),Ya())),yu||(yu=1,wu.exports=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding}(sa(),Ya())),bu||(bu=1,xu.exports=function(t){return n=(e=t).lib.CipherParams,s=e.enc.Hex,e.format.Hex={stringify:function(t){return t.ciphertext.toString(s)},parse:function(t){var e=s.parse(t);return n.create({ciphertext:e})}},t.format.Hex;var e,n,s}(sa(),Ya())),Tu||(Tu=1,Au.exports=function(t){return function(){var e=t,n=e.lib.BlockCipher,s=e.algo,i=[],r=[],o=[],a=[],u=[],c=[],l=[],h=[],p=[],d=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var n=0,s=0;for(e=0;e<256;e++){var f=s^s<<1^s<<2^s<<3^s<<4;f=f>>>8^255&f^99,i[n]=f,r[f]=n;var _=t[n],m=t[_],g=t[m],v=257*t[f]^16843008*f;o[n]=v<<24|v>>>8,a[n]=v<<16|v>>>16,u[n]=v<<8|v>>>24,c[n]=v,v=16843009*g^65537*m^257*_^16843008*n,l[f]=v<<24|v>>>8,h[f]=v<<16|v>>>16,p[f]=v<<8|v>>>24,d[f]=v,n?(n=_^t[t[t[g^_]]],s^=t[t[s]]):n=s=1}}();var f=[0,1,2,4,8,16,32,64,128,27,54],_=s.AES=n.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,n=t.sigBytes/4,s=4*((this._nRounds=n+6)+1),r=this._keySchedule=[],o=0;o<s;o++)o<n?r[o]=e[o]:(c=r[o-1],o%n?n>6&&o%n==4&&(c=i[c>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c]):(c=i[(c=c<<8|c>>>24)>>>24]<<24|i[c>>>16&255]<<16|i[c>>>8&255]<<8|i[255&c],c^=f[o/n|0]<<24),r[o]=r[o-n]^c);for(var a=this._invKeySchedule=[],u=0;u<s;u++){if(o=s-u,u%4)var c=r[o];else c=r[o-4];a[u]=u<4||o<=4?c:l[i[c>>>24]]^h[i[c>>>16&255]]^p[i[c>>>8&255]]^d[i[255&c]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,u,c,i)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,l,h,p,d,r),n=t[e+1],t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,s,i,r,o,a){for(var u=this._nRounds,c=t[e]^n[0],l=t[e+1]^n[1],h=t[e+2]^n[2],p=t[e+3]^n[3],d=4,f=1;f<u;f++){var _=s[c>>>24]^i[l>>>16&255]^r[h>>>8&255]^o[255&p]^n[d++],m=s[l>>>24]^i[h>>>16&255]^r[p>>>8&255]^o[255&c]^n[d++],g=s[h>>>24]^i[p>>>16&255]^r[c>>>8&255]^o[255&l]^n[d++],v=s[p>>>24]^i[c>>>16&255]^r[l>>>8&255]^o[255&h]^n[d++];c=_,l=m,h=g,p=v}_=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&p])^n[d++],m=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^n[d++],g=(a[h>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[d++],v=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^n[d++],t[e]=_,t[e+1]=m,t[e+2]=g,t[e+3]=v},keySize:8});e.AES=n._createHelper(_)}(),t.AES}(sa(),_a(),ba(),Ga(),Ya())),Su(),Ou||(Ou=1,Mu.exports=function(t){return function(){var e=t,n=e.lib.StreamCipher,s=e.algo,i=s.RC4=n.extend({_doReset:function(){for(var t=this._key,e=t.words,n=t.sigBytes,s=this._S=[],i=0;i<256;i++)s[i]=i;i=0;for(var r=0;i<256;i++){var o=i%n,a=e[o>>>2]>>>24-o%4*8&255;r=(r+s[i]+a)%256;var u=s[i];s[i]=s[r],s[r]=u}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,n=this._j,s=0,i=0;i<4;i++){n=(n+t[e=(e+1)%256])%256;var r=t[e];t[e]=t[n],t[n]=r,s|=t[(t[e]+t[n])%256]<<24-8*i}return this._i=e,this._j=n,s}e.RC4=n._createHelper(i);var o=s.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=n._createHelper(o)}(),t.RC4}(sa(),_a(),ba(),Ga(),Ya())),Eu||(Eu=1,Du.exports=function(t){return function(){var e=t,n=e.lib.StreamCipher,s=e.algo,i=[],r=[],o=[],a=s.Rabbit=n.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,n=0;n<4;n++)t[n]=16711935&(t[n]<<8|t[n]>>>24)|4278255360&(t[n]<<24|t[n]>>>8);var 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],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,n=0;n<4;n++)u.call(this);for(n=0;n<8;n++)i[n]^=s[n+4&7];if(e){var r=e.words,o=r[0],a=r[1],c=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),h=c>>>16|4294901760&l,p=l<<16|65535&c;for(i[0]^=c,i[1]^=h,i[2]^=l,i[3]^=p,i[4]^=c,i[5]^=h,i[6]^=l,i[7]^=p,n=0;n<4;n++)u.call(this)}},_doProcessBlock:function(t,e){var n=this._X;u.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var s=0;s<4;s++)i[s]=16711935&(i[s]<<8|i[s]>>>24)|4278255360&(i[s]<<24|i[s]>>>8),t[e+s]^=i[s]},blockSize:4,ivSize:2});function u(){for(var t=this._X,e=this._C,n=0;n<8;n++)r[n]=e[n];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,n=0;n<8;n++){var s=t[n]+e[n],i=65535&s,a=s>>>16,u=((i*i>>>17)+i*a>>>15)+a*a,c=((4294901760&s)*s|0)+((65535&s)*s|0);o[n]=u^c}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=n._createHelper(a)}(),t.Rabbit}(sa(),_a(),ba(),Ga(),Ya())),Iu||(Iu=1,Ru.exports=function(t){return function(){var e=t,n=e.lib.StreamCipher,s=e.algo,i=[],r=[],o=[],a=s.RabbitLegacy=n.extend({_doReset:function(){var t=this._key.words,e=this.cfg.iv,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],s=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++)u.call(this);for(i=0;i<8;i++)s[i]^=n[i+4&7];if(e){var r=e.words,o=r[0],a=r[1],c=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),h=c>>>16|4294901760&l,p=l<<16|65535&c;for(s[0]^=c,s[1]^=h,s[2]^=l,s[3]^=p,s[4]^=c,s[5]^=h,s[6]^=l,s[7]^=p,i=0;i<4;i++)u.call(this)}},_doProcessBlock:function(t,e){var n=this._X;u.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var s=0;s<4;s++)i[s]=16711935&(i[s]<<8|i[s]>>>24)|4278255360&(i[s]<<24|i[s]>>>8),t[e+s]^=i[s]},blockSize:4,ivSize:2});function u(){for(var t=this._X,e=this._C,n=0;n<8;n++)r[n]=e[n];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,n=0;n<8;n++){var s=t[n]+e[n],i=65535&s,a=s>>>16,u=((i*i>>>17)+i*a>>>15)+a*a,c=((4294901760&s)*s|0)+((65535&s)*s|0);o[n]=u^c}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=n._createHelper(a)}(),t.RabbitLegacy}(sa(),_a(),ba(),Ga(),Ya())),Pu());var Vu,Fu=Jo(ta.exports);function qu(t,e){const n=`${t}:${e}`,s=Fu.SHA256(n).toString(Fu.enc.Hex);return`${s.substring(0,8)}-${s.substring(8,12)}-4${s.substring(13,16)}-${"89AB"[parseInt(s.substring(17,18),16)%4]}${s.substring(18,21)}-${s.substring(21,33)}`}function ju(t,e){if(t instanceof Hu&&e instanceof $u)t.plug(e);else if(t instanceof Gu&&e instanceof Xu)t.plug(e);else if(t instanceof Lu&&e instanceof Uu)t.plug(e);else if(t instanceof Lu&&e instanceof Xu)t.plug(e);else if(t instanceof Lu&&e instanceof $u)t.plug(e);else if(t instanceof Hu&&e instanceof Uu)t.plug(e);else{if(!(t instanceof Gu&&e instanceof Uu))throw Error("Input and output type is not compatible");t.plug(e)}}function zu(t,e){if(t instanceof Hu&&e instanceof $u)t.unPlug(e);else if(t instanceof Gu&&e instanceof Xu)t.unPlug(e);else if(t instanceof Lu&&e instanceof Uu)t.unPlug(e);else if(t instanceof Lu&&e instanceof Xu)t.unPlug(e);else if(t instanceof Lu&&e instanceof $u)t.unPlug(e);else if(t instanceof Hu&&e instanceof Uu)t.unPlug(e);else{if(!(t instanceof Gu&&e instanceof Uu))throw Error("Input and output type is not compatible");t.unPlug(e)}}!function(t){t.AudioInput="audioInput",t.AudioOutput="audioOutput",t.MidiInput="midiInput",t.MidiOutput="midiOutput",t.ForwardInput="forwardInput",t.ForwardOutput="forwardOutput"}(Vu||(Vu={}));class Wu{id;ioType;name;plugableModule;connections=[];static unPlugAll(t){t.connections.forEach((e=>t.unPlug(e)))}constructor(t,e){this.plugableModule=t,this.id=qu(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)}serialize(){return{id:this.id,name:this.name,moduleId:this.plugableModule.id,moduleName:this.plugableModule.name,ioType:this.ioType}}}class Lu extends Wu{constructor(t,e){super(t,e),this.checkNameValidity()}get subInputs(){return this.plugableModule.audioModules.map((t=>{const e=t.inputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}))}get subModules(){return this.plugableModule.audioModules}subModule(t){const e=this.subModules.find((e=>e.voiceNo===t));if(!e)throw Error(`Submodule with voiceNo ${t} not found`);return e}subInput(t){const e=this.subModule(t).inputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}plug(t,e=!0){super.plug(t,e),!e&&t instanceof Uu||(t instanceof Uu?this.subModules.forEach((e=>{const n=e.inputs.findByName(this.name);if(!n)throw Error(`Could not forward input ${this.name}`);ju(n,t.subOutput(e.voiceNo))})):this.subInputs.forEach((e=>ju(e,t))))}unPlug(t,e=!0){super.unPlug(t,e),!e&&t instanceof Uu||(t instanceof Uu?this.subModules.forEach((e=>{const n=e.inputs.findByName(this.name);if(!n)throw Error(`Could not forward input ${this.name}`);zu(n,t.subOutput(e.voiceNo))})):this.subInputs.forEach((e=>zu(e,t))))}unPlugAll(){Wu.unPlugAll(this)}checkNameValidity(){if(!this.plugableModule.audioModules[0].inputs.findByName(this.name))throw Error("You should forward to existing input")}}class Uu extends Wu{constructor(t,e){super(t,e),this.checkNameValidity()}get subOutputs(){return this.subModules.map((t=>{const e=t.outputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}))}get subModules(){return this.plugableModule.audioModules}subModule(t){const e=this.subModules.find((e=>e.voiceNo===t));if(!e)throw Error(`Submodule with voiceNo ${t} not found`);return e}subOutput(t){const e=this.subModule(t).outputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}plug(t,e=!0){super.plug(t,e),!e&&t instanceof Lu||(t instanceof Lu?this.subModules.forEach((e=>{const n=e.outputs.findByName(this.name);if(!n)throw Error(`Could not forward output ${this.name}`);ju(t.subInput(e.voiceNo),n)})):this.subOutputs.forEach((e=>ju(t,e))))}unPlug(t,e=!0){super.unPlug(t,e),!e&&t instanceof Lu||(t instanceof Lu?this.subModules.forEach((e=>{const n=e.outputs.findByName(this.name);if(!n)throw Error(`Could not forward output ${this.name}`);zu(t.subInput(e.voiceNo),n)})):this.subOutputs.forEach((e=>zu(t,e))))}unPlugAll(){Wu.unPlugAll(this)}checkNameValidity(){if(!this.plugableModule.audioModules[0].outputs.findByName(this.name))throw Error("You should forward to existing output")}}class Hu extends Wu{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(){Wu.unPlugAll(this)}}class $u extends Wu{internalModule;constructor(t,e){super(t,e),this.internalModule=e.internalModule}plug(t,e=!0){super.plug(t,e),t instanceof Lu||this.internalModule.connect(t.internalModule)}unPlug(t,e=!0){super.unPlug(t,e),t instanceof Lu||this.internalModule.disconnect(t.internalModule)}unPlugAll(){Wu.unPlugAll(this)}}class Gu extends Wu{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(){Wu.unPlugAll(this)}}class Xu extends Wu{constructor(t,e){super(t,e)}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}unPlugAll(){Wu.unPlugAll(this)}onMidiEvent=t=>{this.midiConnections.forEach((e=>{e.onMidiEvent(t)}))};get midiConnections(){return this.connections.filter((t=>t instanceof Gu))}}class Zu{plugableModule;collection=[];constructor(t){this.plugableModule=t}add(t){let e;switch(t.ioType){case Vu.AudioInput:if(this.plugableModule instanceof Ku)throw Error("PolyModule is not supported");e=new Hu(this.plugableModule,t);break;case Vu.AudioOutput:if(this.plugableModule instanceof Ku)throw Error("PolyModule is not supported");e=new $u(this.plugableModule,t);break;case Vu.ForwardInput:if(this.plugableModule instanceof Qu)throw Error("MonoModule is not supported");e=new Lu(this.plugableModule,t);break;case Vu.ForwardOutput:if(this.plugableModule instanceof Qu)throw Error("MonoModule is not supported");e=new Uu(this.plugableModule,t);break;case Vu.MidiInput:e=new Gu(this.plugableModule,t);break;case Vu.MidiOutput:e=new Xu(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 Yu{connect(){throw Error("This module is not connectable")}disconnect(){throw Error("This module is not connectable")}dispose(){}}var Qu=class{static moduleName;id;name;internalModule;inputs;outputs;voiceNo;updatedAt;_props={};constructor(t,e){this.internalModule=t,this.id=e.id||Qo(),delete e.id,this.inputs=new Zu(this),this.outputs=new Zu(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,n){const s=this.outputs.findByName(e);if(!s)throw Error(`Output ${e} not exist`);const i=t.inputs.findByName(n);if(!i)throw Error(`Input ${n} not exist`);ju(i,s)}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:n}=t;switch(t.type){case"noteOn":{const{duration:t}=e;if(this.triggerer(this.triggerAttack,e,n),t){const r=n+(s=t,new Xi(zi(),s,i)).toSeconds();this.triggerer(this.triggerRelease,e,r)}break}case"noteOff":this.triggerer(this.triggerRelease,e,n);break;default:throw Error("This type is not a note")}var s,i};triggerer(t,e,n){t(e,n)}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:Vu.MidiInput})}registerAudioInput(t){return this.inputs.add({...t,ioType:Vu.AudioInput})}registerMidiOutput(t){return this.outputs.add({...t,ioType:Vu.MidiOutput})}registerAudioOutput(t){return this.outputs.add({...t,ioType:Vu.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 Ku{static moduleName;id;child;_name;audioModules;inputs;outputs;_numberOfVoices;constructor(t){this.id=t.id||Qo(),delete t.id,this.audioModules=[];const{child:e,props:n,...s}=t;this.child=e,Object.assign(this,s),this.numberOfVoices=t.numberOfVoices||1,this.inputs=new Zu(this),this.outputs=new Zu(this),Object.assign(this,{props:n})}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,n){const s=this.outputs.findByName(e);if(!s)throw Error(`Output ${e} not exist`);const i=t.inputs.findByName(n);if(!i)throw Error(`Input ${n} not exist`);ju(i,s)}unPlugAll(){this.outputs.unPlugAll()}dispose(){this.unPlugAll(),this.audioModules.forEach((t=>t.dispose()))}onMidiEvent=t=>{const e=t.voiceNo||0,n=this.findVoice(e);n?.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))}registerInput(t){return this.inputs.add({...t,ioType:Vu.ForwardInput})}registerOutput(t){return this.outputs.add({...t,ioType:Vu.ForwardOutput})}registerMidiInput(t){return this.inputs.add({...t,ioType:Vu.MidiInput})}registerMidiOutput(t){return this.outputs.add({...t,ioType:Vu.MidiOutput})}registerBasicOutputs(){this.registerOutput({name:"output"})}registerBasicInputs(){this.registerInput({name:"input"}),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=qu(this.id,t.toString()),n=0===t?{}:this.props,s=new this.child({id:e,name:this.name,props:{...n,voiceNo:t}});if(s instanceof Ku)throw Error("Polymodule not supported");this.audioModules.push(s)}this.adjustNumberOfModules()}}}var Ju,tc,ec={exports:{}};
|
|
25
|
-
/**
|
|
26
|
-
* @license
|
|
27
|
-
* Lodash <https://lodash.com/>
|
|
28
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
29
|
-
* Released under MIT license <https://lodash.com/license>
|
|
30
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
31
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
32
|
-
*/Ju=ec,tc=ec.exports,function(){var t,e="Expected a function",n="__lodash_hash_undefined__",s="__lodash_placeholder__",i=16,r=32,o=64,a=128,u=256,c=1/0,l=9007199254740991,h=NaN,p=4294967295,d=[["ary",a],["bind",1],["bindKey",2],["curry",8],["curryRight",i],["flip",512],["partial",r],["partialRight",o],["rearg",u]],f="[object Arguments]",_="[object Array]",m="[object Boolean]",g="[object Date]",v="[object Error]",y="[object Function]",w="[object GeneratorFunction]",b="[object Map]",x="[object Number]",T="[object Object]",A="[object Promise]",k="[object RegExp]",C="[object Set]",S="[object String]",O="[object Symbol]",M="[object WeakMap]",E="[object ArrayBuffer]",D="[object DataView]",I="[object Float32Array]",R="[object Float64Array]",N="[object Int8Array]",B="[object Int16Array]",P="[object Int32Array]",V="[object Uint8Array]",F="[object Uint8ClampedArray]",q="[object Uint16Array]",j="[object Uint32Array]",z=/\b__p \+= '';/g,W=/\b(__p \+=) '' \+/g,L=/(__e\(.*?\)|\b__t\)) \+\n'';/g,U=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,$=RegExp(U.source),G=RegExp(H.source),X=/<%-([\s\S]+?)%>/g,Z=/<%([\s\S]+?)%>/g,Y=/<%=([\s\S]+?)%>/g,Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K=/^\w*$/,J=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tt=/[\\^$.*+?()[\]{}|]/g,et=RegExp(tt.source),nt=/^\s+/,st=/\s/,it=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,rt=/\{\n\/\* \[wrapped with (.+)\] \*/,ot=/,? & /,at=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ut=/[()=,{}\[\]\/\s]/,ct=/\\(\\)?/g,lt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ht=/\w*$/,pt=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,ft=/^\[object .+?Constructor\]$/,_t=/^0o[0-7]+$/i,mt=/^(?:0|[1-9]\d*)$/,gt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vt=/($^)/,yt=/['\n\r\u2028\u2029\\]/g,wt="\\ud800-\\udfff",bt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xt="\\u2700-\\u27bf",Tt="a-z\\xdf-\\xf6\\xf8-\\xff",At="A-Z\\xc0-\\xd6\\xd8-\\xde",kt="\\ufe0e\\ufe0f",Ct="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",St="['’]",Ot="["+wt+"]",Mt="["+Ct+"]",Et="["+bt+"]",Dt="\\d+",It="["+xt+"]",Rt="["+Tt+"]",Nt="[^"+wt+Ct+Dt+xt+Tt+At+"]",Bt="\\ud83c[\\udffb-\\udfff]",Pt="[^"+wt+"]",Vt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ft="[\\ud800-\\udbff][\\udc00-\\udfff]",qt="["+At+"]",jt="\\u200d",zt="(?:"+Rt+"|"+Nt+")",Wt="(?:"+qt+"|"+Nt+")",Lt="(?:['’](?:d|ll|m|re|s|t|ve))?",Ut="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ht="(?:"+Et+"|"+Bt+")?",$t="["+kt+"]?",Gt=$t+Ht+"(?:"+jt+"(?:"+[Pt,Vt,Ft].join("|")+")"+$t+Ht+")*",Xt="(?:"+[It,Vt,Ft].join("|")+")"+Gt,Zt="(?:"+[Pt+Et+"?",Et,Vt,Ft,Ot].join("|")+")",Yt=RegExp(St,"g"),Qt=RegExp(Et,"g"),Kt=RegExp(Bt+"(?="+Bt+")|"+Zt+Gt,"g"),Jt=RegExp([qt+"?"+Rt+"+"+Lt+"(?="+[Mt,qt,"$"].join("|")+")",Wt+"+"+Ut+"(?="+[Mt,qt+zt,"$"].join("|")+")",qt+"?"+zt+"+"+Lt,qt+"+"+Ut,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Dt,Xt].join("|"),"g"),te=RegExp("["+jt+wt+bt+kt+"]"),ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ne=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],se=-1,ie={};ie[I]=ie[R]=ie[N]=ie[B]=ie[P]=ie[V]=ie[F]=ie[q]=ie[j]=!0,ie[f]=ie[_]=ie[E]=ie[m]=ie[D]=ie[g]=ie[v]=ie[y]=ie[b]=ie[x]=ie[T]=ie[k]=ie[C]=ie[S]=ie[M]=!1;var re={};re[f]=re[_]=re[E]=re[D]=re[m]=re[g]=re[I]=re[R]=re[N]=re[B]=re[P]=re[b]=re[x]=re[T]=re[k]=re[C]=re[S]=re[O]=re[V]=re[F]=re[q]=re[j]=!0,re[v]=re[y]=re[M]=!1;var oe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ae=parseFloat,ue=parseInt,ce="object"==typeof Ko&&Ko&&Ko.Object===Object&&Ko,le="object"==typeof self&&self&&self.Object===Object&&self,he=ce||le||Function("return this")(),pe=tc&&!tc.nodeType&&tc,de=pe&&Ju&&!Ju.nodeType&&Ju,fe=de&&de.exports===pe,_e=fe&&ce.process,me=function(){try{var t=de&&de.require&&de.require("util").types;return t||_e&&_e.binding&&_e.binding("util")}catch(t){}}(),ge=me&&me.isArrayBuffer,ve=me&&me.isDate,ye=me&&me.isMap,we=me&&me.isRegExp,be=me&&me.isSet,xe=me&&me.isTypedArray;function Te(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ae(t,e,n,s){for(var i=-1,r=null==t?0:t.length;++i<r;){var o=t[i];e(s,o,n(o),t)}return s}function ke(t,e){for(var n=-1,s=null==t?0:t.length;++n<s&&!1!==e(t[n],n,t););return t}function Ce(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Se(t,e){for(var n=-1,s=null==t?0:t.length;++n<s;)if(!e(t[n],n,t))return!1;return!0}function Oe(t,e){for(var n=-1,s=null==t?0:t.length,i=0,r=[];++n<s;){var o=t[n];e(o,n,t)&&(r[i++]=o)}return r}function Me(t,e){return!(null==t||!t.length)&&qe(t,e,0)>-1}function Ee(t,e,n){for(var s=-1,i=null==t?0:t.length;++s<i;)if(n(e,t[s]))return!0;return!1}function De(t,e){for(var n=-1,s=null==t?0:t.length,i=Array(s);++n<s;)i[n]=e(t[n],n,t);return i}function Ie(t,e){for(var n=-1,s=e.length,i=t.length;++n<s;)t[i+n]=e[n];return t}function Re(t,e,n,s){var i=-1,r=null==t?0:t.length;for(s&&r&&(n=t[++i]);++i<r;)n=e(n,t[i],i,t);return n}function Ne(t,e,n,s){var i=null==t?0:t.length;for(s&&i&&(n=t[--i]);i--;)n=e(n,t[i],i,t);return n}function Be(t,e){for(var n=-1,s=null==t?0:t.length;++n<s;)if(e(t[n],n,t))return!0;return!1}var Pe=Le("length");function Ve(t,e,n){var s;return n(t,(function(t,n,i){if(e(t,n,i))return s=n,!1})),s}function Fe(t,e,n,s){for(var i=t.length,r=n+(s?1:-1);s?r--:++r<i;)if(e(t[r],r,t))return r;return-1}function qe(t,e,n){return e==e?function(t,e,n){for(var s=n-1,i=t.length;++s<i;)if(t[s]===e)return s;return-1}(t,e,n):Fe(t,ze,n)}function je(t,e,n,s){for(var i=n-1,r=t.length;++i<r;)if(s(t[i],e))return i;return-1}function ze(t){return t!=t}function We(t,e){var n=null==t?0:t.length;return n?$e(t,e)/n:h}function Le(e){return function(n){return null==n?t:n[e]}}function Ue(e){return function(n){return null==e?t:e[n]}}function He(t,e,n,s,i){return i(t,(function(t,i,r){n=s?(s=!1,t):e(n,t,i,r)})),n}function $e(e,n){for(var s,i=-1,r=e.length;++i<r;){var o=n(e[i]);o!==t&&(s=s===t?o:s+o)}return s}function Ge(t,e){for(var n=-1,s=Array(t);++n<t;)s[n]=e(n);return s}function Xe(t){return t?t.slice(0,pn(t)+1).replace(nt,""):t}function Ze(t){return function(e){return t(e)}}function Ye(t,e){return De(e,(function(e){return t[e]}))}function Qe(t,e){return t.has(e)}function Ke(t,e){for(var n=-1,s=t.length;++n<s&&qe(e,t[n],0)>-1;);return n}function Je(t,e){for(var n=t.length;n--&&qe(e,t[n],0)>-1;);return n}var tn=Ue({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),en=Ue({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(t){return"\\"+oe[t]}function sn(t){return te.test(t)}function rn(t){var e=-1,n=Array(t.size);return t.forEach((function(t,s){n[++e]=[s,t]})),n}function on(t,e){return function(n){return t(e(n))}}function an(t,e){for(var n=-1,i=t.length,r=0,o=[];++n<i;){var a=t[n];a!==e&&a!==s||(t[n]=s,o[r++]=n)}return o}function un(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}function cn(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=[t,t]})),n}function ln(t){return sn(t)?function(t){for(var e=Kt.lastIndex=0;Kt.test(t);)++e;return e}(t):Pe(t)}function hn(t){return sn(t)?function(t){return t.match(Kt)||[]}(t):function(t){return t.split("")}(t)}function pn(t){for(var e=t.length;e--&&st.test(t.charAt(e)););return e}var dn=Ue({"&":"&","<":"<",">":">",""":'"',"'":"'"}),fn=function st(wt){var bt,xt=(wt=null==wt?he:fn.defaults(he.Object(),wt,fn.pick(he,ne))).Array,Tt=wt.Date,At=wt.Error,kt=wt.Function,Ct=wt.Math,St=wt.Object,Ot=wt.RegExp,Mt=wt.String,Et=wt.TypeError,Dt=xt.prototype,It=kt.prototype,Rt=St.prototype,Nt=wt["__core-js_shared__"],Bt=It.toString,Pt=Rt.hasOwnProperty,Vt=0,Ft=(bt=/[^.]+$/.exec(Nt&&Nt.keys&&Nt.keys.IE_PROTO||""))?"Symbol(src)_1."+bt:"",qt=Rt.toString,jt=Bt.call(St),zt=he._,Wt=Ot("^"+Bt.call(Pt).replace(tt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Lt=fe?wt.Buffer:t,Ut=wt.Symbol,Ht=wt.Uint8Array,$t=Lt?Lt.allocUnsafe:t,Gt=on(St.getPrototypeOf,St),Xt=St.create,Zt=Rt.propertyIsEnumerable,Kt=Dt.splice,te=Ut?Ut.isConcatSpreadable:t,oe=Ut?Ut.iterator:t,ce=Ut?Ut.toStringTag:t,le=function(){try{var t=pr(St,"defineProperty");return t({},"",{}),t}catch(t){}}(),pe=wt.clearTimeout!==he.clearTimeout&&wt.clearTimeout,de=Tt&&Tt.now!==he.Date.now&&Tt.now,_e=wt.setTimeout!==he.setTimeout&&wt.setTimeout,me=Ct.ceil,Pe=Ct.floor,Ue=St.getOwnPropertySymbols,_n=Lt?Lt.isBuffer:t,mn=wt.isFinite,gn=Dt.join,vn=on(St.keys,St),yn=Ct.max,wn=Ct.min,bn=Tt.now,xn=wt.parseInt,Tn=Ct.random,An=Dt.reverse,kn=pr(wt,"DataView"),Cn=pr(wt,"Map"),Sn=pr(wt,"Promise"),On=pr(wt,"Set"),Mn=pr(wt,"WeakMap"),En=pr(St,"create"),Dn=Mn&&new Mn,In={},Rn=Fr(kn),Nn=Fr(Cn),Bn=Fr(Sn),Pn=Fr(On),Vn=Fr(Mn),Fn=Ut?Ut.prototype:t,qn=Fn?Fn.valueOf:t,jn=Fn?Fn.toString:t;function zn(t){if(na(t)&&!Ho(t)&&!(t instanceof Hn)){if(t instanceof Un)return t;if(Pt.call(t,"__wrapped__"))return qr(t)}return new Un(t)}var Wn=function(){function e(){}return function(n){if(!ea(n))return{};if(Xt)return Xt(n);e.prototype=n;var s=new e;return e.prototype=t,s}}();function Ln(){}function Un(e,n){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=t}function Hn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=p,this.__views__=[]}function $n(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}function Gn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}function Xn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}function Zn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Xn;++e<n;)this.add(t[e])}function Yn(t){var e=this.__data__=new Gn(t);this.size=e.size}function Qn(t,e){var n=Ho(t),s=!n&&Uo(t),i=!n&&!s&&Zo(t),r=!n&&!s&&!i&&la(t),o=n||s||i||r,a=o?Ge(t.length,Mt):[],u=a.length;for(var c in t)!e&&!Pt.call(t,c)||o&&("length"==c||i&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||yr(c,u))||a.push(c);return a}function Kn(e){var n=e.length;return n?e[Zs(0,n-1)]:t}function Jn(t,e){return Br(Ei(t),us(e,0,t.length))}function ts(t){return Br(Ei(t))}function es(e,n,s){(s!==t&&!zo(e[n],s)||s===t&&!(n in e))&&os(e,n,s)}function ns(e,n,s){var i=e[n];Pt.call(e,n)&&zo(i,s)&&(s!==t||n in e)||os(e,n,s)}function ss(t,e){for(var n=t.length;n--;)if(zo(t[n][0],e))return n;return-1}function is(t,e,n,s){return ds(t,(function(t,i,r){e(s,t,n(t),r)})),s}function rs(t,e){return t&&Di(e,Ia(e),t)}function os(t,e,n){"__proto__"==e&&le?le(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function as(e,n){for(var s=-1,i=n.length,r=xt(i),o=null==e;++s<i;)r[s]=o?t:Sa(e,n[s]);return r}function us(e,n,s){return e==e&&(s!==t&&(e=e<=s?e:s),n!==t&&(e=e>=n?e:n)),e}function cs(e,n,s,i,r,o){var a,u=1&n,c=2&n,l=4&n;if(s&&(a=r?s(e,i,r,o):s(e)),a!==t)return a;if(!ea(e))return e;var h=Ho(e);if(h){if(a=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Pt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(e),!u)return Ei(e,a)}else{var p=_r(e),d=p==y||p==w;if(Zo(e))return Ai(e,u);if(p==T||p==f||d&&!r){if(a=c||d?{}:gr(e),!u)return c?function(t,e){return Di(t,fr(t),e)}(e,function(t,e){return t&&Di(e,Ra(e),t)}(a,e)):function(t,e){return Di(t,dr(t),e)}(e,rs(a,e))}else{if(!re[p])return r?e:{};a=function(t,e,n){var s,i=t.constructor;switch(e){case E:return ki(t);case m:case g:return new i(+t);case D:return function(t,e){var n=e?ki(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case I:case R:case N:case B:case P:case V:case F:case q:case j:return Ci(t,n);case b:return new i;case x:case S:return new i(t);case k:return function(t){var e=new t.constructor(t.source,ht.exec(t));return e.lastIndex=t.lastIndex,e}(t);case C:return new i;case O:return s=t,qn?St(qn.call(s)):{}}}(e,p,u)}}o||(o=new Yn);var _=o.get(e);if(_)return _;o.set(e,a),aa(e)?e.forEach((function(t){a.add(cs(t,n,s,t,e,o))})):sa(e)&&e.forEach((function(t,i){a.set(i,cs(t,n,s,i,e,o))}));var v=h?t:(l?c?rr:ir:c?Ra:Ia)(e);return ke(v||e,(function(t,i){v&&(t=e[i=t]),ns(a,i,cs(t,n,s,i,e,o))})),a}function ls(e,n,s){var i=s.length;if(null==e)return!i;for(e=St(e);i--;){var r=s[i],o=n[r],a=e[r];if(a===t&&!(r in e)||!o(a))return!1}return!0}function hs(n,s,i){if("function"!=typeof n)throw new Et(e);return Dr((function(){n.apply(t,i)}),s)}function ps(t,e,n,s){var i=-1,r=Me,o=!0,a=t.length,u=[],c=e.length;if(!a)return u;n&&(e=De(e,Ze(n))),s?(r=Ee,o=!1):e.length>=200&&(r=Qe,o=!1,e=new Zn(e));t:for(;++i<a;){var l=t[i],h=null==n?l:n(l);if(l=s||0!==l?l:0,o&&h==h){for(var p=c;p--;)if(e[p]===h)continue t;u.push(l)}else r(e,h,s)||u.push(l)}return u}zn.templateSettings={escape:X,evaluate:Z,interpolate:Y,variable:"",imports:{_:zn}},zn.prototype=Ln.prototype,zn.prototype.constructor=zn,Un.prototype=Wn(Ln.prototype),Un.prototype.constructor=Un,Hn.prototype=Wn(Ln.prototype),Hn.prototype.constructor=Hn,$n.prototype.clear=function(){this.__data__=En?En(null):{},this.size=0},$n.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},$n.prototype.get=function(e){var s=this.__data__;if(En){var i=s[e];return i===n?t:i}return Pt.call(s,e)?s[e]:t},$n.prototype.has=function(e){var n=this.__data__;return En?n[e]!==t:Pt.call(n,e)},$n.prototype.set=function(e,s){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=En&&s===t?n:s,this},Gn.prototype.clear=function(){this.__data__=[],this.size=0},Gn.prototype.delete=function(t){var e=this.__data__,n=ss(e,t);return!(n<0||(n==e.length-1?e.pop():Kt.call(e,n,1),--this.size,0))},Gn.prototype.get=function(e){var n=this.__data__,s=ss(n,e);return s<0?t:n[s][1]},Gn.prototype.has=function(t){return ss(this.__data__,t)>-1},Gn.prototype.set=function(t,e){var n=this.__data__,s=ss(n,t);return s<0?(++this.size,n.push([t,e])):n[s][1]=e,this},Xn.prototype.clear=function(){this.size=0,this.__data__={hash:new $n,map:new(Cn||Gn),string:new $n}},Xn.prototype.delete=function(t){var e=lr(this,t).delete(t);return this.size-=e?1:0,e},Xn.prototype.get=function(t){return lr(this,t).get(t)},Xn.prototype.has=function(t){return lr(this,t).has(t)},Xn.prototype.set=function(t,e){var n=lr(this,t),s=n.size;return n.set(t,e),this.size+=n.size==s?0:1,this},Zn.prototype.add=Zn.prototype.push=function(t){return this.__data__.set(t,n),this},Zn.prototype.has=function(t){return this.__data__.has(t)},Yn.prototype.clear=function(){this.__data__=new Gn,this.size=0},Yn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Yn.prototype.get=function(t){return this.__data__.get(t)},Yn.prototype.has=function(t){return this.__data__.has(t)},Yn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Gn){var s=n.__data__;if(!Cn||s.length<199)return s.push([t,e]),this.size=++n.size,this;n=this.__data__=new Xn(s)}return n.set(t,e),this.size=n.size,this};var ds=Ni(bs),fs=Ni(xs,!0);function _s(t,e){var n=!0;return ds(t,(function(t,s,i){return n=!!e(t,s,i)})),n}function ms(e,n,s){for(var i=-1,r=e.length;++i<r;){var o=e[i],a=n(o);if(null!=a&&(u===t?a==a&&!ca(a):s(a,u)))var u=a,c=o}return c}function gs(t,e){var n=[];return ds(t,(function(t,s,i){e(t,s,i)&&n.push(t)})),n}function vs(t,e,n,s,i){var r=-1,o=t.length;for(n||(n=vr),i||(i=[]);++r<o;){var a=t[r];e>0&&n(a)?e>1?vs(a,e-1,n,s,i):Ie(i,a):s||(i[i.length]=a)}return i}var ys=Bi(),ws=Bi(!0);function bs(t,e){return t&&ys(t,e,Ia)}function xs(t,e){return t&&ws(t,e,Ia)}function Ts(t,e){return Oe(e,(function(e){return Ko(t[e])}))}function As(e,n){for(var s=0,i=(n=wi(n,e)).length;null!=e&&s<i;)e=e[Vr(n[s++])];return s&&s==i?e:t}function ks(t,e,n){var s=e(t);return Ho(t)?s:Ie(s,n(t))}function Cs(e){return null==e?e===t?"[object Undefined]":"[object Null]":ce&&ce in St(e)?function(e){var n=Pt.call(e,ce),s=e[ce];try{e[ce]=t;var i=!0}catch(t){}var r=qt.call(e);return i&&(n?e[ce]=s:delete e[ce]),r}(e):function(t){return qt.call(t)}(e)}function Ss(t,e){return t>e}function Os(t,e){return null!=t&&Pt.call(t,e)}function Ms(t,e){return null!=t&&e in St(t)}function Es(e,n,s){for(var i=s?Ee:Me,r=e[0].length,o=e.length,a=o,u=xt(o),c=1/0,l=[];a--;){var h=e[a];a&&n&&(h=De(h,Ze(n))),c=wn(h.length,c),u[a]=!s&&(n||r>=120&&h.length>=120)?new Zn(a&&h):t}h=e[0];var p=-1,d=u[0];t:for(;++p<r&&l.length<c;){var f=h[p],_=n?n(f):f;if(f=s||0!==f?f:0,!(d?Qe(d,_):i(l,_,s))){for(a=o;--a;){var m=u[a];if(!(m?Qe(m,_):i(e[a],_,s)))continue t}d&&d.push(_),l.push(f)}}return l}function Ds(e,n,s){var i=null==(e=Or(e,n=wi(n,e)))?e:e[Vr(Yr(n))];return null==i?t:Te(i,e,s)}function Is(t){return na(t)&&Cs(t)==f}function Rs(e,n,s,i,r){return e===n||(null==e||null==n||!na(e)&&!na(n)?e!=e&&n!=n:function(e,n,s,i,r,o){var a=Ho(e),u=Ho(n),c=a?_:_r(e),l=u?_:_r(n),h=(c=c==f?T:c)==T,p=(l=l==f?T:l)==T,d=c==l;if(d&&Zo(e)){if(!Zo(n))return!1;a=!0,h=!1}if(d&&!h)return o||(o=new Yn),a||la(e)?nr(e,n,s,i,r,o):function(t,e,n,s,i,r,o){switch(n){case D:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case E:return!(t.byteLength!=e.byteLength||!r(new Ht(t),new Ht(e)));case m:case g:case x:return zo(+t,+e);case v:return t.name==e.name&&t.message==e.message;case k:case S:return t==e+"";case b:var a=rn;case C:var u=1&s;if(a||(a=un),t.size!=e.size&&!u)return!1;var c=o.get(t);if(c)return c==e;s|=2,o.set(t,e);var l=nr(a(t),a(e),s,i,r,o);return o.delete(t),l;case O:if(qn)return qn.call(t)==qn.call(e)}return!1}(e,n,c,s,i,r,o);if(!(1&s)){var y=h&&Pt.call(e,"__wrapped__"),w=p&&Pt.call(n,"__wrapped__");if(y||w){var A=y?e.value():e,M=w?n.value():n;return o||(o=new Yn),r(A,M,s,i,o)}}return!!d&&(o||(o=new Yn),function(e,n,s,i,r,o){var a=1&s,u=ir(e),c=u.length,l=ir(n),h=l.length;if(c!=h&&!a)return!1;for(var p=c;p--;){var d=u[p];if(!(a?d in n:Pt.call(n,d)))return!1}var f=o.get(e),_=o.get(n);if(f&&_)return f==n&&_==e;var m=!0;o.set(e,n),o.set(n,e);for(var g=a;++p<c;){var v=e[d=u[p]],y=n[d];if(i)var w=a?i(y,v,d,n,e,o):i(v,y,d,e,n,o);if(!(w===t?v===y||r(v,y,s,i,o):w)){m=!1;break}g||(g="constructor"==d)}if(m&&!g){var b=e.constructor,x=n.constructor;b==x||!("constructor"in e)||!("constructor"in n)||"function"==typeof b&&b instanceof b&&"function"==typeof x&&x instanceof x||(m=!1)}return o.delete(e),o.delete(n),m}(e,n,s,i,r,o))}(e,n,s,i,Rs,r))}function Ns(e,n,s,i){var r=s.length,o=r,a=!i;if(null==e)return!o;for(e=St(e);r--;){var u=s[r];if(a&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++r<o;){var c=(u=s[r])[0],l=e[c],h=u[1];if(a&&u[2]){if(l===t&&!(c in e))return!1}else{var p=new Yn;if(i)var d=i(l,h,c,e,n,p);if(!(d===t?Rs(h,l,3,i,p):d))return!1}}return!0}function Bs(t){return!(!ea(t)||(e=t,Ft&&Ft in e))&&(Ko(t)?Wt:ft).test(Fr(t));var e}function Ps(t){return"function"==typeof t?t:null==t?iu:"object"==typeof t?Ho(t)?Ws(t[0],t[1]):zs(t):du(t)}function Vs(t){if(!Ar(t))return vn(t);var e=[];for(var n in St(t))Pt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Fs(t){if(!ea(t))return function(t){var e=[];if(null!=t)for(var n in St(t))e.push(n);return e}(t);var e=Ar(t),n=[];for(var s in t)("constructor"!=s||!e&&Pt.call(t,s))&&n.push(s);return n}function qs(t,e){return t<e}function js(t,e){var n=-1,s=Go(t)?xt(t.length):[];return ds(t,(function(t,i,r){s[++n]=e(t,i,r)})),s}function zs(t){var e=hr(t);return 1==e.length&&e[0][2]?Cr(e[0][0],e[0][1]):function(n){return n===t||Ns(n,t,e)}}function Ws(e,n){return br(e)&&kr(n)?Cr(Vr(e),n):function(s){var i=Sa(s,e);return i===t&&i===n?Oa(s,e):Rs(n,i,3)}}function Ls(e,n,s,i,r){e!==n&&ys(n,(function(o,a){if(r||(r=new Yn),ea(o))!function(e,n,s,i,r,o,a){var u=Mr(e,s),c=Mr(n,s),l=a.get(c);if(l)es(e,s,l);else{var h=o?o(u,c,s+"",e,n,a):t,p=h===t;if(p){var d=Ho(c),f=!d&&Zo(c),_=!d&&!f&&la(c);h=c,d||f||_?Ho(u)?h=u:Xo(u)?h=Ei(u):f?(p=!1,h=Ai(c,!0)):_?(p=!1,h=Ci(c,!0)):h=[]:ra(c)||Uo(c)?(h=u,Uo(u)?h=va(u):ea(u)&&!Ko(u)||(h=gr(c))):p=!1}p&&(a.set(c,h),r(h,c,i,o,a),a.delete(c)),es(e,s,h)}}(e,n,a,s,Ls,i,r);else{var u=i?i(Mr(e,a),o,a+"",e,n,r):t;u===t&&(u=o),es(e,a,u)}}),Ra)}function Us(e,n){var s=e.length;if(s)return yr(n+=n<0?s:0,s)?e[n]:t}function Hs(t,e,n){e=e.length?De(e,(function(t){return Ho(t)?function(e){return As(e,1===t.length?t[0]:t)}:t})):[iu];var s=-1;e=De(e,Ze(cr()));var i=js(t,(function(t,n,i){var r=De(e,(function(e){return e(t)}));return{criteria:r,index:++s,value:t}}));return function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}(i,(function(t,e){return function(t,e,n){for(var s=-1,i=t.criteria,r=e.criteria,o=i.length,a=n.length;++s<o;){var u=Si(i[s],r[s]);if(u)return s>=a?u:u*("desc"==n[s]?-1:1)}return t.index-e.index}(t,e,n)}))}function $s(t,e,n){for(var s=-1,i=e.length,r={};++s<i;){var o=e[s],a=As(t,o);n(a,o)&&ti(r,wi(o,t),a)}return r}function Gs(t,e,n,s){var i=s?je:qe,r=-1,o=e.length,a=t;for(t===e&&(e=Ei(e)),n&&(a=De(t,Ze(n)));++r<o;)for(var u=0,c=e[r],l=n?n(c):c;(u=i(a,l,u,s))>-1;)a!==t&&Kt.call(a,u,1),Kt.call(t,u,1);return t}function Xs(t,e){for(var n=t?e.length:0,s=n-1;n--;){var i=e[n];if(n==s||i!==r){var r=i;yr(i)?Kt.call(t,i,1):pi(t,i)}}return t}function Zs(t,e){return t+Pe(Tn()*(e-t+1))}function Ys(t,e){var n="";if(!t||e<1||e>l)return n;do{e%2&&(n+=t),(e=Pe(e/2))&&(t+=t)}while(e);return n}function Qs(t,e){return Ir(Sr(t,e,iu),t+"")}function Ks(t){return Kn(za(t))}function Js(t,e){var n=za(t);return Br(n,us(e,0,n.length))}function ti(e,n,s,i){if(!ea(e))return e;for(var r=-1,o=(n=wi(n,e)).length,a=o-1,u=e;null!=u&&++r<o;){var c=Vr(n[r]),l=s;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(r!=a){var h=u[c];(l=i?i(h,c,u):t)===t&&(l=ea(h)?h:yr(n[r+1])?[]:{})}ns(u,c,l),u=u[c]}return e}var ei=Dn?function(t,e){return Dn.set(t,e),t}:iu,ni=le?function(t,e){return le(t,"toString",{configurable:!0,enumerable:!1,value:eu(e),writable:!0})}:iu;function si(t){return Br(za(t))}function ii(t,e,n){var s=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var r=xt(i);++s<i;)r[s]=t[s+e];return r}function ri(t,e){var n;return ds(t,(function(t,s,i){return!(n=e(t,s,i))})),!!n}function oi(t,e,n){var s=0,i=null==t?s:t.length;if("number"==typeof e&&e==e&&i<=2147483647){for(;s<i;){var r=s+i>>>1,o=t[r];null!==o&&!ca(o)&&(n?o<=e:o<e)?s=r+1:i=r}return i}return ai(t,e,iu,n)}function ai(e,n,s,i){var r=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(n=s(n))!=n,u=null===n,c=ca(n),l=n===t;r<o;){var h=Pe((r+o)/2),p=s(e[h]),d=p!==t,f=null===p,_=p==p,m=ca(p);if(a)var g=i||_;else g=l?_&&(i||d):u?_&&d&&(i||!f):c?_&&d&&!f&&(i||!m):!f&&!m&&(i?p<=n:p<n);g?r=h+1:o=h}return wn(o,4294967294)}function ui(t,e){for(var n=-1,s=t.length,i=0,r=[];++n<s;){var o=t[n],a=e?e(o):o;if(!n||!zo(a,u)){var u=a;r[i++]=0===o?0:o}}return r}function ci(t){return"number"==typeof t?t:ca(t)?h:+t}function li(t){if("string"==typeof t)return t;if(Ho(t))return De(t,li)+"";if(ca(t))return jn?jn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function hi(t,e,n){var s=-1,i=Me,r=t.length,o=!0,a=[],u=a;if(n)o=!1,i=Ee;else if(r>=200){var c=e?null:Yi(t);if(c)return un(c);o=!1,i=Qe,u=new Zn}else u=e?[]:a;t:for(;++s<r;){var l=t[s],h=e?e(l):l;if(l=n||0!==l?l:0,o&&h==h){for(var p=u.length;p--;)if(u[p]===h)continue t;e&&u.push(h),a.push(l)}else i(u,h,n)||(u!==a&&u.push(h),a.push(l))}return a}function pi(t,e){return null==(t=Or(t,e=wi(e,t)))||delete t[Vr(Yr(e))]}function di(t,e,n,s){return ti(t,e,n(As(t,e)),s)}function fi(t,e,n,s){for(var i=t.length,r=s?i:-1;(s?r--:++r<i)&&e(t[r],r,t););return n?ii(t,s?0:r,s?r+1:i):ii(t,s?r+1:0,s?i:r)}function _i(t,e){var n=t;return n instanceof Hn&&(n=n.value()),Re(e,(function(t,e){return e.func.apply(e.thisArg,Ie([t],e.args))}),n)}function mi(t,e,n){var s=t.length;if(s<2)return s?hi(t[0]):[];for(var i=-1,r=xt(s);++i<s;)for(var o=t[i],a=-1;++a<s;)a!=i&&(r[i]=ps(r[i]||o,t[a],e,n));return hi(vs(r,1),e,n)}function gi(e,n,s){for(var i=-1,r=e.length,o=n.length,a={};++i<r;){var u=i<o?n[i]:t;s(a,e[i],u)}return a}function vi(t){return Xo(t)?t:[]}function yi(t){return"function"==typeof t?t:iu}function wi(t,e){return Ho(t)?t:br(t,e)?[t]:Pr(ya(t))}var bi=Qs;function xi(e,n,s){var i=e.length;return s=s===t?i:s,!n&&s>=i?e:ii(e,n,s)}var Ti=pe||function(t){return he.clearTimeout(t)};function Ai(t,e){if(e)return t.slice();var n=t.length,s=$t?$t(n):new t.constructor(n);return t.copy(s),s}function ki(t){var e=new t.constructor(t.byteLength);return new Ht(e).set(new Ht(t)),e}function Ci(t,e){var n=e?ki(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Si(e,n){if(e!==n){var s=e!==t,i=null===e,r=e==e,o=ca(e),a=n!==t,u=null===n,c=n==n,l=ca(n);if(!u&&!l&&!o&&e>n||o&&a&&c&&!u&&!l||i&&a&&c||!s&&c||!r)return 1;if(!i&&!o&&!l&&e<n||l&&s&&r&&!i&&!o||u&&s&&r||!a&&r||!c)return-1}return 0}function Oi(t,e,n,s){for(var i=-1,r=t.length,o=n.length,a=-1,u=e.length,c=yn(r-o,0),l=xt(u+c),h=!s;++a<u;)l[a]=e[a];for(;++i<o;)(h||i<r)&&(l[n[i]]=t[i]);for(;c--;)l[a++]=t[i++];return l}function Mi(t,e,n,s){for(var i=-1,r=t.length,o=-1,a=n.length,u=-1,c=e.length,l=yn(r-a,0),h=xt(l+c),p=!s;++i<l;)h[i]=t[i];for(var d=i;++u<c;)h[d+u]=e[u];for(;++o<a;)(p||i<r)&&(h[d+n[o]]=t[i++]);return h}function Ei(t,e){var n=-1,s=t.length;for(e||(e=xt(s));++n<s;)e[n]=t[n];return e}function Di(e,n,s,i){var r=!s;s||(s={});for(var o=-1,a=n.length;++o<a;){var u=n[o],c=i?i(s[u],e[u],u,s,e):t;c===t&&(c=e[u]),r?os(s,u,c):ns(s,u,c)}return s}function Ii(t,e){return function(n,s){var i=Ho(n)?Ae:is,r=e?e():{};return i(n,t,cr(s,2),r)}}function Ri(e){return Qs((function(n,s){var i=-1,r=s.length,o=r>1?s[r-1]:t,a=r>2?s[2]:t;for(o=e.length>3&&"function"==typeof o?(r--,o):t,a&&wr(s[0],s[1],a)&&(o=r<3?t:o,r=1),n=St(n);++i<r;){var u=s[i];u&&e(n,u,i,o)}return n}))}function Ni(t,e){return function(n,s){if(null==n)return n;if(!Go(n))return t(n,s);for(var i=n.length,r=e?i:-1,o=St(n);(e?r--:++r<i)&&!1!==s(o[r],r,o););return n}}function Bi(t){return function(e,n,s){for(var i=-1,r=St(e),o=s(e),a=o.length;a--;){var u=o[t?a:++i];if(!1===n(r[u],u,r))break}return e}}function Pi(e){return function(n){var s=sn(n=ya(n))?hn(n):t,i=s?s[0]:n.charAt(0),r=s?xi(s,1).join(""):n.slice(1);return i[e]()+r}}function Vi(t){return function(e){return Re(Ka(Ua(e).replace(Yt,"")),t,"")}}function Fi(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=Wn(t.prototype),s=t.apply(n,e);return ea(s)?s:n}}function qi(e){return function(n,s,i){var r=St(n);if(!Go(n)){var o=cr(s,3);n=Ia(n),s=function(t){return o(r[t],t,r)}}var a=e(n,s,i);return a>-1?r[o?n[a]:a]:t}}function ji(n){return sr((function(s){var i=s.length,r=i,o=Un.prototype.thru;for(n&&s.reverse();r--;){var a=s[r];if("function"!=typeof a)throw new Et(e);if(o&&!u&&"wrapper"==ar(a))var u=new Un([],!0)}for(r=u?r:i;++r<i;){var c=ar(a=s[r]),l="wrapper"==c?or(a):t;u=l&&xr(l[0])&&424==l[1]&&!l[4].length&&1==l[9]?u[ar(l[0])].apply(u,l[3]):1==a.length&&xr(a)?u[c]():u.thru(a)}return function(){var t=arguments,e=t[0];if(u&&1==t.length&&Ho(e))return u.plant(e).value();for(var n=0,r=i?s[n].apply(this,t):e;++n<i;)r=s[n].call(this,r);return r}}))}function zi(e,n,s,i,r,o,u,c,l,h){var p=n&a,d=1&n,f=2&n,_=24&n,m=512&n,g=f?t:Fi(e);return function a(){for(var v=arguments.length,y=xt(v),w=v;w--;)y[w]=arguments[w];if(_)var b=ur(a),x=function(t,e){for(var n=t.length,s=0;n--;)t[n]===e&&++s;return s}(y,b);if(i&&(y=Oi(y,i,r,_)),o&&(y=Mi(y,o,u,_)),v-=x,_&&v<h){var T=an(y,b);return Xi(e,n,zi,a.placeholder,s,y,T,c,l,h-v)}var A=d?s:this,k=f?A[e]:e;return v=y.length,c?y=function(e,n){for(var s=e.length,i=wn(n.length,s),r=Ei(e);i--;){var o=n[i];e[i]=yr(o,s)?r[o]:t}return e}(y,c):m&&v>1&&y.reverse(),p&&l<v&&(y.length=l),this&&this!==he&&this instanceof a&&(k=g||Fi(k)),k.apply(A,y)}}function Wi(t,e){return function(n,s){return function(t,e,n,s){return bs(t,(function(t,i,r){e(s,n(t),i,r)})),s}(n,t,e(s),{})}}function Li(e,n){return function(s,i){var r;if(s===t&&i===t)return n;if(s!==t&&(r=s),i!==t){if(r===t)return i;"string"==typeof s||"string"==typeof i?(s=li(s),i=li(i)):(s=ci(s),i=ci(i)),r=e(s,i)}return r}}function Ui(t){return sr((function(e){return e=De(e,Ze(cr())),Qs((function(n){var s=this;return t(e,(function(t){return Te(t,s,n)}))}))}))}function Hi(e,n){var s=(n=n===t?" ":li(n)).length;if(s<2)return s?Ys(n,e):n;var i=Ys(n,me(e/ln(n)));return sn(n)?xi(hn(i),0,e).join(""):i.slice(0,e)}function $i(e){return function(n,s,i){return i&&"number"!=typeof i&&wr(n,s,i)&&(s=i=t),n=fa(n),s===t?(s=n,n=0):s=fa(s),function(t,e,n,s){for(var i=-1,r=yn(me((e-t)/(n||1)),0),o=xt(r);r--;)o[s?r:++i]=t,t+=n;return o}(n,s,i=i===t?n<s?1:-1:fa(i),e)}}function Gi(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=ga(e),n=ga(n)),t(e,n)}}function Xi(e,n,s,i,a,u,c,l,h,p){var d=8&n;n|=d?r:o,4&(n&=~(d?o:r))||(n&=-4);var f=[e,n,a,d?u:t,d?c:t,d?t:u,d?t:c,l,h,p],_=s.apply(t,f);return xr(e)&&Er(_,f),_.placeholder=i,Rr(_,e,n)}function Zi(t){var e=Ct[t];return function(t,n){if(t=ga(t),(n=null==n?0:wn(_a(n),292))&&mn(t)){var s=(ya(t)+"e").split("e");return+((s=(ya(e(s[0]+"e"+(+s[1]+n)))+"e").split("e"))[0]+"e"+(+s[1]-n))}return e(t)}}var Yi=On&&1/un(new On([,-0]))[1]==c?function(t){return new On(t)}:cu;function Qi(t){return function(e){var n=_r(e);return n==b?rn(e):n==C?cn(e):function(t,e){return De(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Ki(n,c,l,h,p,d,f,_){var m=2&c;if(!m&&"function"!=typeof n)throw new Et(e);var g=h?h.length:0;if(g||(c&=-97,h=p=t),f=f===t?f:yn(_a(f),0),_=_===t?_:_a(_),g-=p?p.length:0,c&o){var v=h,y=p;h=p=t}var w=m?t:or(n),b=[n,c,l,h,p,v,y,d,f,_];if(w&&function(t,e){var n=t[1],i=e[1],r=n|i,o=r<131,c=i==a&&8==n||i==a&&n==u&&t[7].length<=e[8]||384==i&&e[7].length<=e[8]&&8==n;if(!o&&!c)return t;1&i&&(t[2]=e[2],r|=1&n?0:4);var l=e[3];if(l){var h=t[3];t[3]=h?Oi(h,l,e[4]):l,t[4]=h?an(t[3],s):e[4]}(l=e[5])&&(h=t[5],t[5]=h?Mi(h,l,e[6]):l,t[6]=h?an(t[5],s):e[6]),(l=e[7])&&(t[7]=l),i&a&&(t[8]=null==t[8]?e[8]:wn(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=r}(b,w),n=b[0],c=b[1],l=b[2],h=b[3],p=b[4],!(_=b[9]=b[9]===t?m?0:n.length:yn(b[9]-g,0))&&24&c&&(c&=-25),c&&1!=c)x=8==c||c==i?function(e,n,s){var i=Fi(e);return function r(){for(var o=arguments.length,a=xt(o),u=o,c=ur(r);u--;)a[u]=arguments[u];var l=o<3&&a[0]!==c&&a[o-1]!==c?[]:an(a,c);return(o-=l.length)<s?Xi(e,n,zi,r.placeholder,t,a,l,t,t,s-o):Te(this&&this!==he&&this instanceof r?i:e,this,a)}}(n,c,_):c!=r&&33!=c||p.length?zi.apply(t,b):function(t,e,n,s){var i=1&e,r=Fi(t);return function e(){for(var o=-1,a=arguments.length,u=-1,c=s.length,l=xt(c+a),h=this&&this!==he&&this instanceof e?r:t;++u<c;)l[u]=s[u];for(;a--;)l[u++]=arguments[++o];return Te(h,i?n:this,l)}}(n,c,l,h);else var x=function(t,e,n){var s=1&e,i=Fi(t);return function e(){return(this&&this!==he&&this instanceof e?i:t).apply(s?n:this,arguments)}}(n,c,l);return Rr((w?ei:Er)(x,b),n,c)}function Ji(e,n,s,i){return e===t||zo(e,Rt[s])&&!Pt.call(i,s)?n:e}function tr(e,n,s,i,r,o){return ea(e)&&ea(n)&&(o.set(n,e),Ls(e,n,t,tr,o),o.delete(n)),e}function er(e){return ra(e)?t:e}function nr(e,n,s,i,r,o){var a=1&s,u=e.length,c=n.length;if(u!=c&&!(a&&c>u))return!1;var l=o.get(e),h=o.get(n);if(l&&h)return l==n&&h==e;var p=-1,d=!0,f=2&s?new Zn:t;for(o.set(e,n),o.set(n,e);++p<u;){var _=e[p],m=n[p];if(i)var g=a?i(m,_,p,n,e,o):i(_,m,p,e,n,o);if(g!==t){if(g)continue;d=!1;break}if(f){if(!Be(n,(function(t,e){if(!Qe(f,e)&&(_===t||r(_,t,s,i,o)))return f.push(e)}))){d=!1;break}}else if(_!==m&&!r(_,m,s,i,o)){d=!1;break}}return o.delete(e),o.delete(n),d}function sr(e){return Ir(Sr(e,t,Hr),e+"")}function ir(t){return ks(t,Ia,dr)}function rr(t){return ks(t,Ra,fr)}var or=Dn?function(t){return Dn.get(t)}:cu;function ar(t){for(var e=t.name+"",n=In[e],s=Pt.call(In,e)?n.length:0;s--;){var i=n[s],r=i.func;if(null==r||r==t)return i.name}return e}function ur(t){return(Pt.call(zn,"placeholder")?zn:t).placeholder}function cr(){var t=zn.iteratee||ru;return t=t===ru?Ps:t,arguments.length?t(arguments[0],arguments[1]):t}function lr(t,e){var n,s,i=t.__data__;return("string"==(s=typeof(n=e))||"number"==s||"symbol"==s||"boolean"==s?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function hr(t){for(var e=Ia(t),n=e.length;n--;){var s=e[n],i=t[s];e[n]=[s,i,kr(i)]}return e}function pr(e,n){var s=function(e,n){return null==e?t:e[n]}(e,n);return Bs(s)?s:t}var dr=Ue?function(t){return null==t?[]:(t=St(t),Oe(Ue(t),(function(e){return Zt.call(t,e)})))}:mu,fr=Ue?function(t){for(var e=[];t;)Ie(e,dr(t)),t=Gt(t);return e}:mu,_r=Cs;function mr(t,e,n){for(var s=-1,i=(e=wi(e,t)).length,r=!1;++s<i;){var o=Vr(e[s]);if(!(r=null!=t&&n(t,o)))break;t=t[o]}return r||++s!=i?r:!!(i=null==t?0:t.length)&&ta(i)&&yr(o,i)&&(Ho(t)||Uo(t))}function gr(t){return"function"!=typeof t.constructor||Ar(t)?{}:Wn(Gt(t))}function vr(t){return Ho(t)||Uo(t)||!!(te&&t&&t[te])}function yr(t,e){var n=typeof t;return!!(e=null==e?l:e)&&("number"==n||"symbol"!=n&&mt.test(t))&&t>-1&&t%1==0&&t<e}function wr(t,e,n){if(!ea(n))return!1;var s=typeof e;return!!("number"==s?Go(n)&&yr(e,n.length):"string"==s&&e in n)&&zo(n[e],t)}function br(t,e){if(Ho(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!ca(t))||K.test(t)||!Q.test(t)||null!=e&&t in St(e)}function xr(t){var e=ar(t),n=zn[e];if("function"!=typeof n||!(e in Hn.prototype))return!1;if(t===n)return!0;var s=or(n);return!!s&&t===s[0]}(kn&&_r(new kn(new ArrayBuffer(1)))!=D||Cn&&_r(new Cn)!=b||Sn&&_r(Sn.resolve())!=A||On&&_r(new On)!=C||Mn&&_r(new Mn)!=M)&&(_r=function(e){var n=Cs(e),s=n==T?e.constructor:t,i=s?Fr(s):"";if(i)switch(i){case Rn:return D;case Nn:return b;case Bn:return A;case Pn:return C;case Vn:return M}return n});var Tr=Nt?Ko:gu;function Ar(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Rt)}function kr(t){return t==t&&!ea(t)}function Cr(e,n){return function(s){return null!=s&&s[e]===n&&(n!==t||e in St(s))}}function Sr(e,n,s){return n=yn(n===t?e.length-1:n,0),function(){for(var t=arguments,i=-1,r=yn(t.length-n,0),o=xt(r);++i<r;)o[i]=t[n+i];i=-1;for(var a=xt(n+1);++i<n;)a[i]=t[i];return a[n]=s(o),Te(e,this,a)}}function Or(t,e){return e.length<2?t:As(t,ii(e,0,-1))}function Mr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Er=Nr(ei),Dr=_e||function(t,e){return he.setTimeout(t,e)},Ir=Nr(ni);function Rr(t,e,n){var s=e+"";return Ir(t,function(t,e){var n=e.length;if(!n)return t;var s=n-1;return e[s]=(n>1?"& ":"")+e[s],e=e.join(n>2?", ":" "),t.replace(it,"{\n/* [wrapped with "+e+"] */\n")}(s,function(t,e){return ke(d,(function(n){var s="_."+n[0];e&n[1]&&!Me(t,s)&&t.push(s)})),t.sort()}(function(t){var e=t.match(rt);return e?e[1].split(ot):[]}(s),n)))}function Nr(e){var n=0,s=0;return function(){var i=bn(),r=16-(i-s);if(s=i,r>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(t,arguments)}}function Br(e,n){var s=-1,i=e.length,r=i-1;for(n=n===t?i:n;++s<n;){var o=Zs(s,r),a=e[o];e[o]=e[s],e[s]=a}return e.length=n,e}var Pr=function(t){var e=Bo(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(J,(function(t,n,s,i){e.push(s?i.replace(ct,"$1"):n||t)})),e}));function Vr(t){if("string"==typeof t||ca(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fr(t){if(null!=t){try{return Bt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function qr(t){if(t instanceof Hn)return t.clone();var e=new Un(t.__wrapped__,t.__chain__);return e.__actions__=Ei(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var jr=Qs((function(t,e){return Xo(t)?ps(t,vs(e,1,Xo,!0)):[]})),zr=Qs((function(e,n){var s=Yr(n);return Xo(s)&&(s=t),Xo(e)?ps(e,vs(n,1,Xo,!0),cr(s,2)):[]})),Wr=Qs((function(e,n){var s=Yr(n);return Xo(s)&&(s=t),Xo(e)?ps(e,vs(n,1,Xo,!0),t,s):[]}));function Lr(t,e,n){var s=null==t?0:t.length;if(!s)return-1;var i=null==n?0:_a(n);return i<0&&(i=yn(s+i,0)),Fe(t,cr(e,3),i)}function Ur(e,n,s){var i=null==e?0:e.length;if(!i)return-1;var r=i-1;return s!==t&&(r=_a(s),r=s<0?yn(i+r,0):wn(r,i-1)),Fe(e,cr(n,3),r,!0)}function Hr(t){return null!=t&&t.length?vs(t,1):[]}function $r(e){return e&&e.length?e[0]:t}var Gr=Qs((function(t){var e=De(t,vi);return e.length&&e[0]===t[0]?Es(e):[]})),Xr=Qs((function(e){var n=Yr(e),s=De(e,vi);return n===Yr(s)?n=t:s.pop(),s.length&&s[0]===e[0]?Es(s,cr(n,2)):[]})),Zr=Qs((function(e){var n=Yr(e),s=De(e,vi);return(n="function"==typeof n?n:t)&&s.pop(),s.length&&s[0]===e[0]?Es(s,t,n):[]}));function Yr(e){var n=null==e?0:e.length;return n?e[n-1]:t}var Qr=Qs(Kr);function Kr(t,e){return t&&t.length&&e&&e.length?Gs(t,e):t}var Jr=sr((function(t,e){var n=null==t?0:t.length,s=as(t,e);return Xs(t,De(e,(function(t){return yr(t,n)?+t:t})).sort(Si)),s}));function to(t){return null==t?t:An.call(t)}var eo=Qs((function(t){return hi(vs(t,1,Xo,!0))})),no=Qs((function(e){var n=Yr(e);return Xo(n)&&(n=t),hi(vs(e,1,Xo,!0),cr(n,2))})),so=Qs((function(e){var n=Yr(e);return n="function"==typeof n?n:t,hi(vs(e,1,Xo,!0),t,n)}));function io(t){if(!t||!t.length)return[];var e=0;return t=Oe(t,(function(t){if(Xo(t))return e=yn(t.length,e),!0})),Ge(e,(function(e){return De(t,Le(e))}))}function ro(e,n){if(!e||!e.length)return[];var s=io(e);return null==n?s:De(s,(function(e){return Te(n,t,e)}))}var oo=Qs((function(t,e){return Xo(t)?ps(t,e):[]})),ao=Qs((function(t){return mi(Oe(t,Xo))})),uo=Qs((function(e){var n=Yr(e);return Xo(n)&&(n=t),mi(Oe(e,Xo),cr(n,2))})),co=Qs((function(e){var n=Yr(e);return n="function"==typeof n?n:t,mi(Oe(e,Xo),t,n)})),lo=Qs(io),ho=Qs((function(e){var n=e.length,s=n>1?e[n-1]:t;return s="function"==typeof s?(e.pop(),s):t,ro(e,s)}));function po(t){var e=zn(t);return e.__chain__=!0,e}function fo(t,e){return e(t)}var _o=sr((function(e){var n=e.length,s=n?e[0]:0,i=this.__wrapped__,r=function(t){return as(t,e)};return!(n>1||this.__actions__.length)&&i instanceof Hn&&yr(s)?((i=i.slice(s,+s+(n?1:0))).__actions__.push({func:fo,args:[r],thisArg:t}),new Un(i,this.__chain__).thru((function(e){return n&&!e.length&&e.push(t),e}))):this.thru(r)})),mo=Ii((function(t,e,n){Pt.call(t,n)?++t[n]:os(t,n,1)})),go=qi(Lr),vo=qi(Ur);function yo(t,e){return(Ho(t)?ke:ds)(t,cr(e,3))}function wo(t,e){return(Ho(t)?Ce:fs)(t,cr(e,3))}var bo=Ii((function(t,e,n){Pt.call(t,n)?t[n].push(e):os(t,n,[e])})),xo=Qs((function(t,e,n){var s=-1,i="function"==typeof e,r=Go(t)?xt(t.length):[];return ds(t,(function(t){r[++s]=i?Te(e,t,n):Ds(t,e,n)})),r})),To=Ii((function(t,e,n){os(t,n,e)}));function Ao(t,e){return(Ho(t)?De:js)(t,cr(e,3))}var ko=Ii((function(t,e,n){t[n?0:1].push(e)}),(function(){return[[],[]]})),Co=Qs((function(t,e){if(null==t)return[];var n=e.length;return n>1&&wr(t,e[0],e[1])?e=[]:n>2&&wr(e[0],e[1],e[2])&&(e=[e[0]]),Hs(t,vs(e,1),[])})),So=de||function(){return he.Date.now()};function Oo(e,n,s){return n=s?t:n,n=e&&null==n?e.length:n,Ki(e,a,t,t,t,t,n)}function Mo(n,s){var i;if("function"!=typeof s)throw new Et(e);return n=_a(n),function(){return--n>0&&(i=s.apply(this,arguments)),n<=1&&(s=t),i}}var Eo=Qs((function(t,e,n){var s=1;if(n.length){var i=an(n,ur(Eo));s|=r}return Ki(t,s,e,n,i)})),Do=Qs((function(t,e,n){var s=3;if(n.length){var i=an(n,ur(Do));s|=r}return Ki(e,s,t,n,i)}));function Io(n,s,i){var r,o,a,u,c,l,h=0,p=!1,d=!1,f=!0;if("function"!=typeof n)throw new Et(e);function _(e){var s=r,i=o;return r=o=t,h=e,u=n.apply(i,s)}function m(e){var n=e-l;return l===t||n>=s||n<0||d&&e-h>=a}function g(){var t=So();if(m(t))return v(t);c=Dr(g,function(t){var e=s-(t-l);return d?wn(e,a-(t-h)):e}(t))}function v(e){return c=t,f&&r?_(e):(r=o=t,u)}function y(){var e=So(),n=m(e);if(r=arguments,o=this,l=e,n){if(c===t)return function(t){return h=t,c=Dr(g,s),p?_(t):u}(l);if(d)return Ti(c),c=Dr(g,s),_(l)}return c===t&&(c=Dr(g,s)),u}return s=ga(s)||0,ea(i)&&(p=!!i.leading,a=(d="maxWait"in i)?yn(ga(i.maxWait)||0,s):a,f="trailing"in i?!!i.trailing:f),y.cancel=function(){c!==t&&Ti(c),h=0,r=l=o=c=t},y.flush=function(){return c===t?u:v(So())},y}var Ro=Qs((function(t,e){return hs(t,1,e)})),No=Qs((function(t,e,n){return hs(t,ga(e)||0,n)}));function Bo(t,n){if("function"!=typeof t||null!=n&&"function"!=typeof n)throw new Et(e);var s=function(){var e=arguments,i=n?n.apply(this,e):e[0],r=s.cache;if(r.has(i))return r.get(i);var o=t.apply(this,e);return s.cache=r.set(i,o)||r,o};return s.cache=new(Bo.Cache||Xn),s}function Po(t){if("function"!=typeof t)throw new Et(e);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Bo.Cache=Xn;var Vo=bi((function(t,e){var n=(e=1==e.length&&Ho(e[0])?De(e[0],Ze(cr())):De(vs(e,1),Ze(cr()))).length;return Qs((function(s){for(var i=-1,r=wn(s.length,n);++i<r;)s[i]=e[i].call(this,s[i]);return Te(t,this,s)}))})),Fo=Qs((function(e,n){var s=an(n,ur(Fo));return Ki(e,r,t,n,s)})),qo=Qs((function(e,n){var s=an(n,ur(qo));return Ki(e,o,t,n,s)})),jo=sr((function(e,n){return Ki(e,u,t,t,t,n)}));function zo(t,e){return t===e||t!=t&&e!=e}var Wo=Gi(Ss),Lo=Gi((function(t,e){return t>=e})),Uo=Is(function(){return arguments}())?Is:function(t){return na(t)&&Pt.call(t,"callee")&&!Zt.call(t,"callee")},Ho=xt.isArray,$o=ge?Ze(ge):function(t){return na(t)&&Cs(t)==E};function Go(t){return null!=t&&ta(t.length)&&!Ko(t)}function Xo(t){return na(t)&&Go(t)}var Zo=_n||gu,Yo=ve?Ze(ve):function(t){return na(t)&&Cs(t)==g};function Qo(t){if(!na(t))return!1;var e=Cs(t);return e==v||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ra(t)}function Ko(t){if(!ea(t))return!1;var e=Cs(t);return e==y||e==w||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Jo(t){return"number"==typeof t&&t==_a(t)}function ta(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=l}function ea(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function na(t){return null!=t&&"object"==typeof t}var sa=ye?Ze(ye):function(t){return na(t)&&_r(t)==b};function ia(t){return"number"==typeof t||na(t)&&Cs(t)==x}function ra(t){if(!na(t)||Cs(t)!=T)return!1;var e=Gt(t);if(null===e)return!0;var n=Pt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Bt.call(n)==jt}var oa=we?Ze(we):function(t){return na(t)&&Cs(t)==k},aa=be?Ze(be):function(t){return na(t)&&_r(t)==C};function ua(t){return"string"==typeof t||!Ho(t)&&na(t)&&Cs(t)==S}function ca(t){return"symbol"==typeof t||na(t)&&Cs(t)==O}var la=xe?Ze(xe):function(t){return na(t)&&ta(t.length)&&!!ie[Cs(t)]},ha=Gi(qs),pa=Gi((function(t,e){return t<=e}));function da(t){if(!t)return[];if(Go(t))return ua(t)?hn(t):Ei(t);if(oe&&t[oe])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[oe]());var e=_r(t);return(e==b?rn:e==C?un:za)(t)}function fa(t){return t?(t=ga(t))===c||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function _a(t){var e=fa(t),n=e%1;return e==e?n?e-n:e:0}function ma(t){return t?us(_a(t),0,p):0}function ga(t){if("number"==typeof t)return t;if(ca(t))return h;if(ea(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ea(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Xe(t);var n=dt.test(t);return n||_t.test(t)?ue(t.slice(2),n?2:8):pt.test(t)?h:+t}function va(t){return Di(t,Ra(t))}function ya(t){return null==t?"":li(t)}var wa=Ri((function(t,e){if(Ar(e)||Go(e))Di(e,Ia(e),t);else for(var n in e)Pt.call(e,n)&&ns(t,n,e[n])})),ba=Ri((function(t,e){Di(e,Ra(e),t)})),xa=Ri((function(t,e,n,s){Di(e,Ra(e),t,s)})),Ta=Ri((function(t,e,n,s){Di(e,Ia(e),t,s)})),Aa=sr(as),ka=Qs((function(e,n){e=St(e);var s=-1,i=n.length,r=i>2?n[2]:t;for(r&&wr(n[0],n[1],r)&&(i=1);++s<i;)for(var o=n[s],a=Ra(o),u=-1,c=a.length;++u<c;){var l=a[u],h=e[l];(h===t||zo(h,Rt[l])&&!Pt.call(e,l))&&(e[l]=o[l])}return e})),Ca=Qs((function(e){return e.push(t,tr),Te(Ba,t,e)}));function Sa(e,n,s){var i=null==e?t:As(e,n);return i===t?s:i}function Oa(t,e){return null!=t&&mr(t,e,Ms)}var Ma=Wi((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=qt.call(e)),t[e]=n}),eu(iu)),Ea=Wi((function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=qt.call(e)),Pt.call(t,e)?t[e].push(n):t[e]=[n]}),cr),Da=Qs(Ds);function Ia(t){return Go(t)?Qn(t):Vs(t)}function Ra(t){return Go(t)?Qn(t,!0):Fs(t)}var Na=Ri((function(t,e,n){Ls(t,e,n)})),Ba=Ri((function(t,e,n,s){Ls(t,e,n,s)})),Pa=sr((function(t,e){var n={};if(null==t)return n;var s=!1;e=De(e,(function(e){return e=wi(e,t),s||(s=e.length>1),e})),Di(t,rr(t),n),s&&(n=cs(n,7,er));for(var i=e.length;i--;)pi(n,e[i]);return n})),Va=sr((function(t,e){return null==t?{}:function(t,e){return $s(t,e,(function(e,n){return Oa(t,n)}))}(t,e)}));function Fa(t,e){if(null==t)return{};var n=De(rr(t),(function(t){return[t]}));return e=cr(e),$s(t,n,(function(t,n){return e(t,n[0])}))}var qa=Qi(Ia),ja=Qi(Ra);function za(t){return null==t?[]:Ye(t,Ia(t))}var Wa=Vi((function(t,e,n){return e=e.toLowerCase(),t+(n?La(e):e)}));function La(t){return Qa(ya(t).toLowerCase())}function Ua(t){return(t=ya(t))&&t.replace(gt,tn).replace(Qt,"")}var Ha=Vi((function(t,e,n){return t+(n?"-":"")+e.toLowerCase()})),$a=Vi((function(t,e,n){return t+(n?" ":"")+e.toLowerCase()})),Ga=Pi("toLowerCase"),Xa=Vi((function(t,e,n){return t+(n?"_":"")+e.toLowerCase()})),Za=Vi((function(t,e,n){return t+(n?" ":"")+Qa(e)})),Ya=Vi((function(t,e,n){return t+(n?" ":"")+e.toUpperCase()})),Qa=Pi("toUpperCase");function Ka(e,n,s){return e=ya(e),(n=s?t:n)===t?function(t){return ee.test(t)}(e)?function(t){return t.match(Jt)||[]}(e):function(t){return t.match(at)||[]}(e):e.match(n)||[]}var Ja=Qs((function(e,n){try{return Te(e,t,n)}catch(t){return Qo(t)?t:new At(t)}})),tu=sr((function(t,e){return ke(e,(function(e){e=Vr(e),os(t,e,Eo(t[e],t))})),t}));function eu(t){return function(){return t}}var nu=ji(),su=ji(!0);function iu(t){return t}function ru(t){return Ps("function"==typeof t?t:cs(t,1))}var ou=Qs((function(t,e){return function(n){return Ds(n,t,e)}})),au=Qs((function(t,e){return function(n){return Ds(t,n,e)}}));function uu(t,e,n){var s=Ia(e),i=Ts(e,s);null!=n||ea(e)&&(i.length||!s.length)||(n=e,e=t,t=this,i=Ts(e,Ia(e)));var r=!(ea(n)&&"chain"in n&&!n.chain),o=Ko(t);return ke(i,(function(n){var s=e[n];t[n]=s,o&&(t.prototype[n]=function(){var e=this.__chain__;if(r||e){var n=t(this.__wrapped__);return(n.__actions__=Ei(this.__actions__)).push({func:s,args:arguments,thisArg:t}),n.__chain__=e,n}return s.apply(t,Ie([this.value()],arguments))})})),t}function cu(){}var lu=Ui(De),hu=Ui(Se),pu=Ui(Be);function du(t){return br(t)?Le(Vr(t)):function(t){return function(e){return As(e,t)}}(t)}var fu=$i(),_u=$i(!0);function mu(){return[]}function gu(){return!1}var vu,yu=Li((function(t,e){return t+e}),0),wu=Zi("ceil"),bu=Li((function(t,e){return t/e}),1),xu=Zi("floor"),Tu=Li((function(t,e){return t*e}),1),Au=Zi("round"),ku=Li((function(t,e){return t-e}),0);return zn.after=function(t,n){if("function"!=typeof n)throw new Et(e);return t=_a(t),function(){if(--t<1)return n.apply(this,arguments)}},zn.ary=Oo,zn.assign=wa,zn.assignIn=ba,zn.assignInWith=xa,zn.assignWith=Ta,zn.at=Aa,zn.before=Mo,zn.bind=Eo,zn.bindAll=tu,zn.bindKey=Do,zn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Ho(t)?t:[t]},zn.chain=po,zn.chunk=function(e,n,s){n=(s?wr(e,n,s):n===t)?1:yn(_a(n),0);var i=null==e?0:e.length;if(!i||n<1)return[];for(var r=0,o=0,a=xt(me(i/n));r<i;)a[o++]=ii(e,r,r+=n);return a},zn.compact=function(t){for(var e=-1,n=null==t?0:t.length,s=0,i=[];++e<n;){var r=t[e];r&&(i[s++]=r)}return i},zn.concat=function(){var t=arguments.length;if(!t)return[];for(var e=xt(t-1),n=arguments[0],s=t;s--;)e[s-1]=arguments[s];return Ie(Ho(n)?Ei(n):[n],vs(e,1))},zn.cond=function(t){var n=null==t?0:t.length,s=cr();return t=n?De(t,(function(t){if("function"!=typeof t[1])throw new Et(e);return[s(t[0]),t[1]]})):[],Qs((function(e){for(var s=-1;++s<n;){var i=t[s];if(Te(i[0],this,e))return Te(i[1],this,e)}}))},zn.conforms=function(t){return function(t){var e=Ia(t);return function(n){return ls(n,t,e)}}(cs(t,1))},zn.constant=eu,zn.countBy=mo,zn.create=function(t,e){var n=Wn(t);return null==e?n:rs(n,e)},zn.curry=function e(n,s,i){var r=Ki(n,8,t,t,t,t,t,s=i?t:s);return r.placeholder=e.placeholder,r},zn.curryRight=function e(n,s,r){var o=Ki(n,i,t,t,t,t,t,s=r?t:s);return o.placeholder=e.placeholder,o},zn.debounce=Io,zn.defaults=ka,zn.defaultsDeep=Ca,zn.defer=Ro,zn.delay=No,zn.difference=jr,zn.differenceBy=zr,zn.differenceWith=Wr,zn.drop=function(e,n,s){var i=null==e?0:e.length;return i?ii(e,(n=s||n===t?1:_a(n))<0?0:n,i):[]},zn.dropRight=function(e,n,s){var i=null==e?0:e.length;return i?ii(e,0,(n=i-(n=s||n===t?1:_a(n)))<0?0:n):[]},zn.dropRightWhile=function(t,e){return t&&t.length?fi(t,cr(e,3),!0,!0):[]},zn.dropWhile=function(t,e){return t&&t.length?fi(t,cr(e,3),!0):[]},zn.fill=function(e,n,s,i){var r=null==e?0:e.length;return r?(s&&"number"!=typeof s&&wr(e,n,s)&&(s=0,i=r),function(e,n,s,i){var r=e.length;for((s=_a(s))<0&&(s=-s>r?0:r+s),(i=i===t||i>r?r:_a(i))<0&&(i+=r),i=s>i?0:ma(i);s<i;)e[s++]=n;return e}(e,n,s,i)):[]},zn.filter=function(t,e){return(Ho(t)?Oe:gs)(t,cr(e,3))},zn.flatMap=function(t,e){return vs(Ao(t,e),1)},zn.flatMapDeep=function(t,e){return vs(Ao(t,e),c)},zn.flatMapDepth=function(e,n,s){return s=s===t?1:_a(s),vs(Ao(e,n),s)},zn.flatten=Hr,zn.flattenDeep=function(t){return null!=t&&t.length?vs(t,c):[]},zn.flattenDepth=function(e,n){return null!=e&&e.length?vs(e,n=n===t?1:_a(n)):[]},zn.flip=function(t){return Ki(t,512)},zn.flow=nu,zn.flowRight=su,zn.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,s={};++e<n;){var i=t[e];s[i[0]]=i[1]}return s},zn.functions=function(t){return null==t?[]:Ts(t,Ia(t))},zn.functionsIn=function(t){return null==t?[]:Ts(t,Ra(t))},zn.groupBy=bo,zn.initial=function(t){return null!=t&&t.length?ii(t,0,-1):[]},zn.intersection=Gr,zn.intersectionBy=Xr,zn.intersectionWith=Zr,zn.invert=Ma,zn.invertBy=Ea,zn.invokeMap=xo,zn.iteratee=ru,zn.keyBy=To,zn.keys=Ia,zn.keysIn=Ra,zn.map=Ao,zn.mapKeys=function(t,e){var n={};return e=cr(e,3),bs(t,(function(t,s,i){os(n,e(t,s,i),t)})),n},zn.mapValues=function(t,e){var n={};return e=cr(e,3),bs(t,(function(t,s,i){os(n,s,e(t,s,i))})),n},zn.matches=function(t){return zs(cs(t,1))},zn.matchesProperty=function(t,e){return Ws(t,cs(e,1))},zn.memoize=Bo,zn.merge=Na,zn.mergeWith=Ba,zn.method=ou,zn.methodOf=au,zn.mixin=uu,zn.negate=Po,zn.nthArg=function(t){return t=_a(t),Qs((function(e){return Us(e,t)}))},zn.omit=Pa,zn.omitBy=function(t,e){return Fa(t,Po(cr(e)))},zn.once=function(t){return Mo(2,t)},zn.orderBy=function(e,n,s,i){return null==e?[]:(Ho(n)||(n=null==n?[]:[n]),Ho(s=i?t:s)||(s=null==s?[]:[s]),Hs(e,n,s))},zn.over=lu,zn.overArgs=Vo,zn.overEvery=hu,zn.overSome=pu,zn.partial=Fo,zn.partialRight=qo,zn.partition=ko,zn.pick=Va,zn.pickBy=Fa,zn.property=du,zn.propertyOf=function(e){return function(n){return null==e?t:As(e,n)}},zn.pull=Qr,zn.pullAll=Kr,zn.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?Gs(t,e,cr(n,2)):t},zn.pullAllWith=function(e,n,s){return e&&e.length&&n&&n.length?Gs(e,n,t,s):e},zn.pullAt=Jr,zn.range=fu,zn.rangeRight=_u,zn.rearg=jo,zn.reject=function(t,e){return(Ho(t)?Oe:gs)(t,Po(cr(e,3)))},zn.remove=function(t,e){var n=[];if(!t||!t.length)return n;var s=-1,i=[],r=t.length;for(e=cr(e,3);++s<r;){var o=t[s];e(o,s,t)&&(n.push(o),i.push(s))}return Xs(t,i),n},zn.rest=function(n,s){if("function"!=typeof n)throw new Et(e);return Qs(n,s=s===t?s:_a(s))},zn.reverse=to,zn.sampleSize=function(e,n,s){return n=(s?wr(e,n,s):n===t)?1:_a(n),(Ho(e)?Jn:Js)(e,n)},zn.set=function(t,e,n){return null==t?t:ti(t,e,n)},zn.setWith=function(e,n,s,i){return i="function"==typeof i?i:t,null==e?e:ti(e,n,s,i)},zn.shuffle=function(t){return(Ho(t)?ts:si)(t)},zn.slice=function(e,n,s){var i=null==e?0:e.length;return i?(s&&"number"!=typeof s&&wr(e,n,s)?(n=0,s=i):(n=null==n?0:_a(n),s=s===t?i:_a(s)),ii(e,n,s)):[]},zn.sortBy=Co,zn.sortedUniq=function(t){return t&&t.length?ui(t):[]},zn.sortedUniqBy=function(t,e){return t&&t.length?ui(t,cr(e,2)):[]},zn.split=function(e,n,s){return s&&"number"!=typeof s&&wr(e,n,s)&&(n=s=t),(s=s===t?p:s>>>0)?(e=ya(e))&&("string"==typeof n||null!=n&&!oa(n))&&!(n=li(n))&&sn(e)?xi(hn(e),0,s):e.split(n,s):[]},zn.spread=function(t,n){if("function"!=typeof t)throw new Et(e);return n=null==n?0:yn(_a(n),0),Qs((function(e){var s=e[n],i=xi(e,0,n);return s&&Ie(i,s),Te(t,this,i)}))},zn.tail=function(t){var e=null==t?0:t.length;return e?ii(t,1,e):[]},zn.take=function(e,n,s){return e&&e.length?ii(e,0,(n=s||n===t?1:_a(n))<0?0:n):[]},zn.takeRight=function(e,n,s){var i=null==e?0:e.length;return i?ii(e,(n=i-(n=s||n===t?1:_a(n)))<0?0:n,i):[]},zn.takeRightWhile=function(t,e){return t&&t.length?fi(t,cr(e,3),!1,!0):[]},zn.takeWhile=function(t,e){return t&&t.length?fi(t,cr(e,3)):[]},zn.tap=function(t,e){return e(t),t},zn.throttle=function(t,n,s){var i=!0,r=!0;if("function"!=typeof t)throw new Et(e);return ea(s)&&(i="leading"in s?!!s.leading:i,r="trailing"in s?!!s.trailing:r),Io(t,n,{leading:i,maxWait:n,trailing:r})},zn.thru=fo,zn.toArray=da,zn.toPairs=qa,zn.toPairsIn=ja,zn.toPath=function(t){return Ho(t)?De(t,Vr):ca(t)?[t]:Ei(Pr(ya(t)))},zn.toPlainObject=va,zn.transform=function(t,e,n){var s=Ho(t),i=s||Zo(t)||la(t);if(e=cr(e,4),null==n){var r=t&&t.constructor;n=i?s?new r:[]:ea(t)&&Ko(r)?Wn(Gt(t)):{}}return(i?ke:bs)(t,(function(t,s,i){return e(n,t,s,i)})),n},zn.unary=function(t){return Oo(t,1)},zn.union=eo,zn.unionBy=no,zn.unionWith=so,zn.uniq=function(t){return t&&t.length?hi(t):[]},zn.uniqBy=function(t,e){return t&&t.length?hi(t,cr(e,2)):[]},zn.uniqWith=function(e,n){return n="function"==typeof n?n:t,e&&e.length?hi(e,t,n):[]},zn.unset=function(t,e){return null==t||pi(t,e)},zn.unzip=io,zn.unzipWith=ro,zn.update=function(t,e,n){return null==t?t:di(t,e,yi(n))},zn.updateWith=function(e,n,s,i){return i="function"==typeof i?i:t,null==e?e:di(e,n,yi(s),i)},zn.values=za,zn.valuesIn=function(t){return null==t?[]:Ye(t,Ra(t))},zn.without=oo,zn.words=Ka,zn.wrap=function(t,e){return Fo(yi(e),t)},zn.xor=ao,zn.xorBy=uo,zn.xorWith=co,zn.zip=lo,zn.zipObject=function(t,e){return gi(t||[],e||[],ns)},zn.zipObjectDeep=function(t,e){return gi(t||[],e||[],ti)},zn.zipWith=ho,zn.entries=qa,zn.entriesIn=ja,zn.extend=ba,zn.extendWith=xa,uu(zn,zn),zn.add=yu,zn.attempt=Ja,zn.camelCase=Wa,zn.capitalize=La,zn.ceil=wu,zn.clamp=function(e,n,s){return s===t&&(s=n,n=t),s!==t&&(s=(s=ga(s))==s?s:0),n!==t&&(n=(n=ga(n))==n?n:0),us(ga(e),n,s)},zn.clone=function(t){return cs(t,4)},zn.cloneDeep=function(t){return cs(t,5)},zn.cloneDeepWith=function(e,n){return cs(e,5,n="function"==typeof n?n:t)},zn.cloneWith=function(e,n){return cs(e,4,n="function"==typeof n?n:t)},zn.conformsTo=function(t,e){return null==e||ls(t,e,Ia(e))},zn.deburr=Ua,zn.defaultTo=function(t,e){return null==t||t!=t?e:t},zn.divide=bu,zn.endsWith=function(e,n,s){e=ya(e),n=li(n);var i=e.length,r=s=s===t?i:us(_a(s),0,i);return(s-=n.length)>=0&&e.slice(s,r)==n},zn.eq=zo,zn.escape=function(t){return(t=ya(t))&&G.test(t)?t.replace(H,en):t},zn.escapeRegExp=function(t){return(t=ya(t))&&et.test(t)?t.replace(tt,"\\$&"):t},zn.every=function(e,n,s){var i=Ho(e)?Se:_s;return s&&wr(e,n,s)&&(n=t),i(e,cr(n,3))},zn.find=go,zn.findIndex=Lr,zn.findKey=function(t,e){return Ve(t,cr(e,3),bs)},zn.findLast=vo,zn.findLastIndex=Ur,zn.findLastKey=function(t,e){return Ve(t,cr(e,3),xs)},zn.floor=xu,zn.forEach=yo,zn.forEachRight=wo,zn.forIn=function(t,e){return null==t?t:ys(t,cr(e,3),Ra)},zn.forInRight=function(t,e){return null==t?t:ws(t,cr(e,3),Ra)},zn.forOwn=function(t,e){return t&&bs(t,cr(e,3))},zn.forOwnRight=function(t,e){return t&&xs(t,cr(e,3))},zn.get=Sa,zn.gt=Wo,zn.gte=Lo,zn.has=function(t,e){return null!=t&&mr(t,e,Os)},zn.hasIn=Oa,zn.head=$r,zn.identity=iu,zn.includes=function(t,e,n,s){t=Go(t)?t:za(t),n=n&&!s?_a(n):0;var i=t.length;return n<0&&(n=yn(i+n,0)),ua(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&qe(t,e,n)>-1},zn.indexOf=function(t,e,n){var s=null==t?0:t.length;if(!s)return-1;var i=null==n?0:_a(n);return i<0&&(i=yn(s+i,0)),qe(t,e,i)},zn.inRange=function(e,n,s){return n=fa(n),s===t?(s=n,n=0):s=fa(s),function(t,e,n){return t>=wn(e,n)&&t<yn(e,n)}(e=ga(e),n,s)},zn.invoke=Da,zn.isArguments=Uo,zn.isArray=Ho,zn.isArrayBuffer=$o,zn.isArrayLike=Go,zn.isArrayLikeObject=Xo,zn.isBoolean=function(t){return!0===t||!1===t||na(t)&&Cs(t)==m},zn.isBuffer=Zo,zn.isDate=Yo,zn.isElement=function(t){return na(t)&&1===t.nodeType&&!ra(t)},zn.isEmpty=function(t){if(null==t)return!0;if(Go(t)&&(Ho(t)||"string"==typeof t||"function"==typeof t.splice||Zo(t)||la(t)||Uo(t)))return!t.length;var e=_r(t);if(e==b||e==C)return!t.size;if(Ar(t))return!Vs(t).length;for(var n in t)if(Pt.call(t,n))return!1;return!0},zn.isEqual=function(t,e){return Rs(t,e)},zn.isEqualWith=function(e,n,s){var i=(s="function"==typeof s?s:t)?s(e,n):t;return i===t?Rs(e,n,t,s):!!i},zn.isError=Qo,zn.isFinite=function(t){return"number"==typeof t&&mn(t)},zn.isFunction=Ko,zn.isInteger=Jo,zn.isLength=ta,zn.isMap=sa,zn.isMatch=function(t,e){return t===e||Ns(t,e,hr(e))},zn.isMatchWith=function(e,n,s){return s="function"==typeof s?s:t,Ns(e,n,hr(n),s)},zn.isNaN=function(t){return ia(t)&&t!=+t},zn.isNative=function(t){if(Tr(t))throw new At("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Bs(t)},zn.isNil=function(t){return null==t},zn.isNull=function(t){return null===t},zn.isNumber=ia,zn.isObject=ea,zn.isObjectLike=na,zn.isPlainObject=ra,zn.isRegExp=oa,zn.isSafeInteger=function(t){return Jo(t)&&t>=-9007199254740991&&t<=l},zn.isSet=aa,zn.isString=ua,zn.isSymbol=ca,zn.isTypedArray=la,zn.isUndefined=function(e){return e===t},zn.isWeakMap=function(t){return na(t)&&_r(t)==M},zn.isWeakSet=function(t){return na(t)&&"[object WeakSet]"==Cs(t)},zn.join=function(t,e){return null==t?"":gn.call(t,e)},zn.kebabCase=Ha,zn.last=Yr,zn.lastIndexOf=function(e,n,s){var i=null==e?0:e.length;if(!i)return-1;var r=i;return s!==t&&(r=(r=_a(s))<0?yn(i+r,0):wn(r,i-1)),n==n?function(t,e,n){for(var s=n+1;s--;)if(t[s]===e)return s;return s}(e,n,r):Fe(e,ze,r,!0)},zn.lowerCase=$a,zn.lowerFirst=Ga,zn.lt=ha,zn.lte=pa,zn.max=function(e){return e&&e.length?ms(e,iu,Ss):t},zn.maxBy=function(e,n){return e&&e.length?ms(e,cr(n,2),Ss):t},zn.mean=function(t){return We(t,iu)},zn.meanBy=function(t,e){return We(t,cr(e,2))},zn.min=function(e){return e&&e.length?ms(e,iu,qs):t},zn.minBy=function(e,n){return e&&e.length?ms(e,cr(n,2),qs):t},zn.stubArray=mu,zn.stubFalse=gu,zn.stubObject=function(){return{}},zn.stubString=function(){return""},zn.stubTrue=function(){return!0},zn.multiply=Tu,zn.nth=function(e,n){return e&&e.length?Us(e,_a(n)):t},zn.noConflict=function(){return he._===this&&(he._=zt),this},zn.noop=cu,zn.now=So,zn.pad=function(t,e,n){t=ya(t);var s=(e=_a(e))?ln(t):0;if(!e||s>=e)return t;var i=(e-s)/2;return Hi(Pe(i),n)+t+Hi(me(i),n)},zn.padEnd=function(t,e,n){t=ya(t);var s=(e=_a(e))?ln(t):0;return e&&s<e?t+Hi(e-s,n):t},zn.padStart=function(t,e,n){t=ya(t);var s=(e=_a(e))?ln(t):0;return e&&s<e?Hi(e-s,n)+t:t},zn.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),xn(ya(t).replace(nt,""),e||0)},zn.random=function(e,n,s){if(s&&"boolean"!=typeof s&&wr(e,n,s)&&(n=s=t),s===t&&("boolean"==typeof n?(s=n,n=t):"boolean"==typeof e&&(s=e,e=t)),e===t&&n===t?(e=0,n=1):(e=fa(e),n===t?(n=e,e=0):n=fa(n)),e>n){var i=e;e=n,n=i}if(s||e%1||n%1){var r=Tn();return wn(e+r*(n-e+ae("1e-"+((r+"").length-1))),n)}return Zs(e,n)},zn.reduce=function(t,e,n){var s=Ho(t)?Re:He,i=arguments.length<3;return s(t,cr(e,4),n,i,ds)},zn.reduceRight=function(t,e,n){var s=Ho(t)?Ne:He,i=arguments.length<3;return s(t,cr(e,4),n,i,fs)},zn.repeat=function(e,n,s){return n=(s?wr(e,n,s):n===t)?1:_a(n),Ys(ya(e),n)},zn.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},zn.result=function(e,n,s){var i=-1,r=(n=wi(n,e)).length;for(r||(r=1,e=t);++i<r;){var o=null==e?t:e[Vr(n[i])];o===t&&(i=r,o=s),e=Ko(o)?o.call(e):o}return e},zn.round=Au,zn.runInContext=st,zn.sample=function(t){return(Ho(t)?Kn:Ks)(t)},zn.size=function(t){if(null==t)return 0;if(Go(t))return ua(t)?ln(t):t.length;var e=_r(t);return e==b||e==C?t.size:Vs(t).length},zn.snakeCase=Xa,zn.some=function(e,n,s){var i=Ho(e)?Be:ri;return s&&wr(e,n,s)&&(n=t),i(e,cr(n,3))},zn.sortedIndex=function(t,e){return oi(t,e)},zn.sortedIndexBy=function(t,e,n){return ai(t,e,cr(n,2))},zn.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var s=oi(t,e);if(s<n&&zo(t[s],e))return s}return-1},zn.sortedLastIndex=function(t,e){return oi(t,e,!0)},zn.sortedLastIndexBy=function(t,e,n){return ai(t,e,cr(n,2),!0)},zn.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var n=oi(t,e,!0)-1;if(zo(t[n],e))return n}return-1},zn.startCase=Za,zn.startsWith=function(t,e,n){return t=ya(t),n=null==n?0:us(_a(n),0,t.length),e=li(e),t.slice(n,n+e.length)==e},zn.subtract=ku,zn.sum=function(t){return t&&t.length?$e(t,iu):0},zn.sumBy=function(t,e){return t&&t.length?$e(t,cr(e,2)):0},zn.template=function(e,n,s){var i=zn.templateSettings;s&&wr(e,n,s)&&(n=t),e=ya(e),n=xa({},n,i,Ji);var r,o,a=xa({},n.imports,i.imports,Ji),u=Ia(a),c=Ye(a,u),l=0,h=n.interpolate||vt,p="__p += '",d=Ot((n.escape||vt).source+"|"+h.source+"|"+(h===Y?lt:vt).source+"|"+(n.evaluate||vt).source+"|$","g"),f="//# sourceURL="+(Pt.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++se+"]")+"\n";e.replace(d,(function(t,n,s,i,a,u){return s||(s=i),p+=e.slice(l,u).replace(yt,nn),n&&(r=!0,p+="' +\n__e("+n+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),s&&(p+="' +\n((__t = ("+s+")) == null ? '' : __t) +\n'"),l=u+t.length,t})),p+="';\n";var _=Pt.call(n,"variable")&&n.variable;if(_){if(ut.test(_))throw new At("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(z,""):p).replace(W,"$1").replace(L,"$1;"),p="function("+(_||"obj")+") {\n"+(_?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(r?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var m=Ja((function(){return kt(u,f+"return "+p).apply(t,c)}));if(m.source=p,Qo(m))throw m;return m},zn.times=function(t,e){if((t=_a(t))<1||t>l)return[];var n=p,s=wn(t,p);e=cr(e),t-=p;for(var i=Ge(s,e);++n<t;)e(n);return i},zn.toFinite=fa,zn.toInteger=_a,zn.toLength=ma,zn.toLower=function(t){return ya(t).toLowerCase()},zn.toNumber=ga,zn.toSafeInteger=function(t){return t?us(_a(t),-9007199254740991,l):0===t?t:0},zn.toString=ya,zn.toUpper=function(t){return ya(t).toUpperCase()},zn.trim=function(e,n,s){if((e=ya(e))&&(s||n===t))return Xe(e);if(!e||!(n=li(n)))return e;var i=hn(e),r=hn(n);return xi(i,Ke(i,r),Je(i,r)+1).join("")},zn.trimEnd=function(e,n,s){if((e=ya(e))&&(s||n===t))return e.slice(0,pn(e)+1);if(!e||!(n=li(n)))return e;var i=hn(e);return xi(i,0,Je(i,hn(n))+1).join("")},zn.trimStart=function(e,n,s){if((e=ya(e))&&(s||n===t))return e.replace(nt,"");if(!e||!(n=li(n)))return e;var i=hn(e);return xi(i,Ke(i,hn(n))).join("")},zn.truncate=function(e,n){var s=30,i="...";if(ea(n)){var r="separator"in n?n.separator:r;s="length"in n?_a(n.length):s,i="omission"in n?li(n.omission):i}var o=(e=ya(e)).length;if(sn(e)){var a=hn(e);o=a.length}if(s>=o)return e;var u=s-ln(i);if(u<1)return i;var c=a?xi(a,0,u).join(""):e.slice(0,u);if(r===t)return c+i;if(a&&(u+=c.length-u),oa(r)){if(e.slice(u).search(r)){var l,h=c;for(r.global||(r=Ot(r.source,ya(ht.exec(r))+"g")),r.lastIndex=0;l=r.exec(h);)var p=l.index;c=c.slice(0,p===t?u:p)}}else if(e.indexOf(li(r),u)!=u){var d=c.lastIndexOf(r);d>-1&&(c=c.slice(0,d))}return c+i},zn.unescape=function(t){return(t=ya(t))&&$.test(t)?t.replace(U,dn):t},zn.uniqueId=function(t){var e=++Vt;return ya(t)+e},zn.upperCase=Ya,zn.upperFirst=Qa,zn.each=yo,zn.eachRight=wo,zn.first=$r,uu(zn,(vu={},bs(zn,(function(t,e){Pt.call(zn.prototype,e)||(vu[e]=t)})),vu),{chain:!1}),zn.VERSION="4.17.21",ke(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){zn[t].placeholder=zn})),ke(["drop","take"],(function(e,n){Hn.prototype[e]=function(s){s=s===t?1:yn(_a(s),0);var i=this.__filtered__&&!n?new Hn(this):this.clone();return i.__filtered__?i.__takeCount__=wn(s,i.__takeCount__):i.__views__.push({size:wn(s,p),type:e+(i.__dir__<0?"Right":"")}),i},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),ke(["filter","map","takeWhile"],(function(t,e){var n=e+1,s=1==n||3==n;Hn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:cr(t,3),type:n}),e.__filtered__=e.__filtered__||s,e}})),ke(["head","last"],(function(t,e){var n="take"+(e?"Right":"");Hn.prototype[t]=function(){return this[n](1).value()[0]}})),ke(["initial","tail"],(function(t,e){var n="drop"+(e?"":"Right");Hn.prototype[t]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(iu)},Hn.prototype.find=function(t){return this.filter(t).head()},Hn.prototype.findLast=function(t){return this.reverse().find(t)},Hn.prototype.invokeMap=Qs((function(t,e){return"function"==typeof t?new Hn(this):this.map((function(n){return Ds(n,t,e)}))})),Hn.prototype.reject=function(t){return this.filter(Po(cr(t)))},Hn.prototype.slice=function(e,n){e=_a(e);var s=this;return s.__filtered__&&(e>0||n<0)?new Hn(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),n!==t&&(s=(n=_a(n))<0?s.dropRight(-n):s.take(n-e)),s)},Hn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Hn.prototype.toArray=function(){return this.take(p)},bs(Hn.prototype,(function(e,n){var s=/^(?:filter|find|map|reject)|While$/.test(n),i=/^(?:head|last)$/.test(n),r=zn[i?"take"+("last"==n?"Right":""):n],o=i||/^find/.test(n);r&&(zn.prototype[n]=function(){var n=this.__wrapped__,a=i?[1]:arguments,u=n instanceof Hn,c=a[0],l=u||Ho(n),h=function(t){var e=r.apply(zn,Ie([t],a));return i&&p?e[0]:e};l&&s&&"function"==typeof c&&1!=c.length&&(u=l=!1);var p=this.__chain__,d=!!this.__actions__.length,f=o&&!p,_=u&&!d;if(!o&&l){n=_?n:new Hn(this);var m=e.apply(n,a);return m.__actions__.push({func:fo,args:[h],thisArg:t}),new Un(m,p)}return f&&_?e.apply(this,a):(m=this.thru(h),f?i?m.value()[0]:m.value():m)})})),ke(["pop","push","shift","sort","splice","unshift"],(function(t){var e=Dt[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",s=/^(?:pop|shift)$/.test(t);zn.prototype[t]=function(){var t=arguments;if(s&&!this.__chain__){var i=this.value();return e.apply(Ho(i)?i:[],t)}return this[n]((function(n){return e.apply(Ho(n)?n:[],t)}))}})),bs(Hn.prototype,(function(t,e){var n=zn[e];if(n){var s=n.name+"";Pt.call(In,s)||(In[s]=[]),In[s].push({name:e,func:n})}})),In[zi(t,2).name]=[{name:"wrapper",func:t}],Hn.prototype.clone=function(){var t=new Hn(this.__wrapped__);return t.__actions__=Ei(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ei(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ei(this.__views__),t},Hn.prototype.reverse=function(){if(this.__filtered__){var t=new Hn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Hn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=Ho(t),s=e<0,i=n?t.length:0,r=function(t,e,n){for(var s=-1,i=n.length;++s<i;){var r=n[s],o=r.size;switch(r.type){case"drop":t+=o;break;case"dropRight":e-=o;break;case"take":e=wn(e,t+o);break;case"takeRight":t=yn(t,e-o)}}return{start:t,end:e}}(0,i,this.__views__),o=r.start,a=r.end,u=a-o,c=s?a:o-1,l=this.__iteratees__,h=l.length,p=0,d=wn(u,this.__takeCount__);if(!n||!s&&i==u&&d==u)return _i(t,this.__actions__);var f=[];t:for(;u--&&p<d;){for(var _=-1,m=t[c+=e];++_<h;){var g=l[_],v=g.iteratee,y=g.type,w=v(m);if(2==y)m=w;else if(!w){if(1==y)continue t;break t}}f[p++]=m}return f},zn.prototype.at=_o,zn.prototype.chain=function(){return po(this)},zn.prototype.commit=function(){return new Un(this.value(),this.__chain__)},zn.prototype.next=function(){this.__values__===t&&(this.__values__=da(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?t:this.__values__[this.__index__++]}},zn.prototype.plant=function(e){for(var n,s=this;s instanceof Ln;){var i=qr(s);i.__index__=0,i.__values__=t,n?r.__wrapped__=i:n=i;var r=i;s=s.__wrapped__}return r.__wrapped__=e,n},zn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var n=e;return this.__actions__.length&&(n=new Hn(this)),(n=n.reverse()).__actions__.push({func:fo,args:[to],thisArg:t}),new Un(n,this.__chain__)}return this.thru(to)},zn.prototype.toJSON=zn.prototype.valueOf=zn.prototype.value=function(){return _i(this.__wrapped__,this.__actions__)},zn.prototype.first=zn.prototype.head,oe&&(zn.prototype[oe]=function(){return this}),zn}();de?((de.exports=fn)._=fn,pe._=fn):he._=fn}.call(Ko);var nc,sc=ec.exports;!function(t){t.Attack="attack",t.Decay="decay",t.Sustain="sustain",t.Release="release"}(nc||(nc={}));const ic=.01,rc={attack:ic,decay:ic,sustain:1,release:ic};class oc extends Qu{activeNote;triggeredAt;constructor(t){const{id:e,name:n,props:s,internalModule:i}=t;super(i,{id:e,name:n,props:{...rc,...s}}),this.registerBasicInputs(),this.registerBasicOutputs()}get attack(){return this._props.attack}set attack(t){this.setStage(nc.Attack,t)}get decay(){return this._props.decay}set decay(t){this.setStage(nc.Decay,t)}get sustain(){return this._props.sustain}set sustain(t){this.setStage(nc.Sustain,t)}get release(){return this._props.release}set release(t){this.setStage(nc.Release,t)}setStage(t,e){const n=0===e?this.minTime(t):this.maxTime(t)*e;this._props={...this.props,[t]:e},this.internalModule[t]=n}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===nc.Sustain?1:2}minTime(t){return t===nc.Sustain?0:ic}}class ac extends Ku{constructor(t){const{id:e,name:n,child:s,props:i}=t;super({id:e,name:n,child:s,props:{...rc,...i}}),this.registerBasicInputs(),this.registerBasicOutputs()}}class uc extends oc{constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new Jr,props:s})}}class cc extends ac{static moduleName="Envelope";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:uc,props:{...rc,...s}})}}class lc extends oc{constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new so,props:s})}}class hc extends ac{static moduleName="AmpEnvelope";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:lc,props:s})}}const pc={amount:0};class dc extends oc{_frequency;_amount;filter;constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new ao,props:{...pc,...s}})}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 fc extends ac{static moduleName="FreqEnvelope";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:dc,props:s})}}const _c={noteName:"C3",fine:0,coarse:0,wave:"sine",range:0,volume:0};class mc extends Qu{_note;constructor(t){const{id:e,name:n,props:s}=t;super(new Nr,{id:e,name:n,props:{..._c,...s}}),this.registerBasicOutputs(),this.registerDefaultMidiInput(),this.start(Io())}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 Po(this.noteName)}get fine(){return this._props.fine}set fine(t){this._props={...this.props,fine:Math.floor(t)},this.internalModule.detune.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(!Uc.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 Po?t:new Po(t)}}class gc extends Ku{static moduleName="Oscillator";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:mc,props:{..._c,...s}}),this.registerBasicOutputs(),this.registerInput({name:"midi in"})}start(t){this.audioModules.forEach((e=>e.start(t)))}stop(t){this.audioModules.forEach((e=>e.stop(t)))}}const vc={cutoff:2e4,resonance:0,envelopeAmount:0,slope:-24,filterType:"lowpass"};class yc extends Qu{_cutoff;_amount;constructor(t){const{id:e,name:n,props:s}=t;super(new oo({type:"lowpass"}),{id:e,name:n,props:{...vc,...s}}),this._cutoff=new $r(this.cutoff),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 wc extends Ku{static moduleName="Filter";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:yc,props:{...vc,...s}}),this.registerBasicInputs(),this.registerOutputs()}registerOutputs(){this.registerBasicOutputs(),this.registerInput({name:"cutoff"})}}class bc extends Qu{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 xc extends Ku{static moduleName="VoiceScheduler";midiOutput;constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:Tc,props:s}),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 Tc extends Qu{midiEvent;activeNote;triggeredAt;constructor(t){const{id:e,name:n,props:s}=t;super(new Yu,{id:e,name:n,props:s})}midiTriggered=t=>{if(void 0===this.voiceNo)throw Error("Voice without voiceNo");const{triggeredAt:e,note:n,type:s}=t;if(!n)return;const i=n.fullName;switch(s){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 Ac={selectedId:null};class kc extends Qu{static moduleName="MidiSelector";midiOutput;constructor(t){const{id:e,name:n,props:s}=t;super(new Yu,{id:e,name:n,props:{...Ac,...s}}),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=Uc.midiDeviceManager.find(t);e?.addEventListener(this.forwardMidiEvent)}forwardMidiEvent=t=>{this.midiOutput.onMidiEvent(t)};removeEventListener(){if(!this.selectedId)return;const t=Uc.midiDeviceManager.find(this.selectedId);t?.removeEventListener(this.forwardMidiEvent)}}const Cc={volume:-1/0};class Sc extends Qu{constructor(t){const{id:e,name:n,props:s}=t;super(new wr,{id:e,name:n,props:{...Cc,...s}}),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 n=20*Math.log10(t.velocity);this.internalModule.volume.exponentialRampToValueAtTime(n,e)};triggerRelease=()=>{}}class Oc extends Ku{static moduleName="Volume";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,child:Sc,props:{...Cc,...s}}),this.registerBasicInputs(),this.registerBasicOutputs()}}const Mc={activeNotes:[]};class Ec extends Qu{static moduleName="VirtualMidi";midiOutput;constructor(t){const{id:e,name:n,props:s}=t;super(new Yu,{id:e,name:n,props:{...Mc,...s}}),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],Uc._triggerPropsUpdate(this.id,this.props),this.sendMidi(Fo.fromNote(t,!0,e))};triggerRelease=(t,e)=>{this.activeNotes=this.activeNotes.filter((e=>e!==t.fullName)),Uc._triggerPropsUpdate(this.id,this.props),this.sendMidi(Fo.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 Dc={wet:1};class Ic extends Qu{constructor(t){const{id:e,name:n,internalModule:s,props:i}=t;super(s,{id:e,name:n,props:{...Dc,...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 Rc={decay:1.5,preDelay:.025};class Nc extends Ic{static moduleName="Reverb";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new So,props:{...Rc,...s}})}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 Bc={delayTime:1,feedback:.3};class Pc extends Ic{static moduleName="Delay";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new Co,props:{...Bc,...s}})}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 Vc={drive:.3};class Fc extends Ic{static moduleName="Distortion";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new Ao,props:{...Vc,...s}})}get drive(){return this._props.drive}set drive(t){this._props={...this.props,drive:t},this.internalModule.distortion=this.drive}}const qc={bits:16};class jc extends Ic{static moduleName="BitCrusher";constructor(t){const{id:e,name:n,props:s}=t;super({id:e,name:n,internalModule:new bo,props:{...qc,...s}})}get bits(){return this._props.bits}set bits(t){this._props={...this.props,bits:t},this.internalModule.bits.value=this.bits}}class zc extends Qu{static moduleName="Sequencer";midiOutput;part;constructor(t){const{id:e,name:n,props:s}=t;super(new Yu,{id:e,name:n,props:{sequences:[],steps:16,bars:1,...s}}),this.initializePart(),this.start(Io()),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){Uc.isStarted&&this.part.start(t)}stop(){this.part.stop()}registerOutputs(){this.midiOutput=this.registerMidiOutput({name:"midi out"})}initializePart(){this.part=new mo(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],n=[...e[t]],s=n.length-this.steps;if(0!==s){if(s>0)n.pop();else{const e=n.length;n.push({active:!1,time:`${t}:0:${e}`,notes:[]})}e[t]=n,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&&Fo.fromSequence(e,t).forEach((t=>{this.midiOutput.onMidiEvent(t)}))}}function Wc(t){const{id:e,type:n,name:s,props:i}=t,r=function(t){switch(t=sc.upperFirst(sc.camelCase(t))){case gc.moduleName:return gc;case cc.moduleName:return cc;case hc.moduleName:return hc;case fc.moduleName:return fc;case wc.moduleName:return wc;case Oc.moduleName:return Oc;case bc.moduleName:return bc;case xc.moduleName:return xc;case kc.moduleName:return kc;case Ec.moduleName:return Ec;case Nc.moduleName:return Nc;case Pc.moduleName:return Pc;case Fc.moduleName:return Fc;case jc.moduleName:return jc;case zc.moduleName:return zc;default:throw Error(`Unknown module type ${t}`)}}(n);return new r({id:e,name:s,props:i})}class Lc{midiDeviceManager;static instance;context;propsUpdateCallbacks;_isStarted=!1;modules;routes;constructor(){this.modules={},this.routes={},this.propsUpdateCallbacks=[]}static getInstance(){return Lc.instance||(Lc.instance=new Lc),Lc.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 Lo,setTimeout((()=>{e({})}),0)}))}addModule(t){const{id:e,name:n,numberOfVoices:s,type:i,props:r={}}=t,o=Wc({id:e,name:n,type:i,props:{}});return o instanceof Ku&&s&&(o.numberOfVoices=s),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:n,numberOfVoices:s,props:i={}}}=t,r=this.findById(e);return r.props=i,n&&(r.name=n),r instanceof Ku&&s&&(r.numberOfVoices=s),r.serialize()}onPropsUpdate(t){this.propsUpdateCallbacks.push(t)}_triggerPropsUpdate(t,e){this.propsUpdateCallbacks.forEach((n=>n(t,e)))}addRoute(t){const e=function(t){const e=t.id||Qo();return{...t,id:e}}(t),n={...this.routes,[e.id]:e};return this.routes=n,this.updateRoutes(),e}removeRoute(t){delete this.routes[t],this.updateRoutes()}triggerVirtualMidi(t,e,n){this.findById(t).sendMidi(Fo.fromNote(e,"noteOn"===n))}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=Io();this._isStarted=!0,this.updateRoutes(),Object.values(this.modules).forEach((e=>{const n=e;n.start&&n.start(t)}))}stop(){const t=Io();Object.values(this.modules).forEach((e=>{const n=e;n.stop&&n.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(Uc.modules).forEach((t=>{t.unPlugAll()})),t.map((t=>{const{sourceId:e,sourceIOId:n,destinationId:s,destinationIOId:i}=t,r=Uc.findById(e),o=Uc.findById(s),a=r.outputs.find(n),u=o.inputs.find(i);if(!u||!a)throw Error("IO not found");return ju(u,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((n=>{const{sourceId:s,destinationId:i}=e[n];return s===t||i===t}))}}var Uc=Lc.getInstance();export{qo as MidiDevice,Lo as MidiDeviceManager,Po as Note,Uc as default};
|
|
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,C,k,A,S,M=this._hash.words,O=l.words,E=p.words,D=a.words,I=c.words,N=u.words,R=h.words;for(b=r=M[0],T=o=M[1],C=d=M[2],k=w=M[3],A=x=M[4],s=0;s<80;s+=1)S=r+t[e+D[s]]|0,S+=s<16?f(o,d,w)+O[0]:s<32?m(o,d,w)+O[1]:s<48?_(o,d,w)+O[2]:s<64?g(o,d,w)+O[3]:v(o,d,w)+O[4],S=(S=y(S|=0,N[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,C,k)+E[0]:s<32?g(T,C,k)+E[1]:s<48?_(T,C,k)+E[2]:s<64?m(T,C,k)+E[3]:f(T,C,k)+E[4],S=(S=y(S|=0,R[s]))+A|0,b=A,A=k,k=y(C,10),C=T,T=S;S=M[1]+d+k|0,M[1]=M[2]+w+A|0,M[2]=M[3]+x+b|0,M[3]=M[4]+r+T|0,M[4]=M[0]+o+C|0,M[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())),Cc||(Cc=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())),Ac||(Ac=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(),Ca(),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(),Ca(),Ya(),Ja())),Nc||(Nc=1,Rc.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(),Ca(),Ya(),Ja())),Bc||(Bc=1,Pc.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(),Ca(),Ya(),Ja())),Fc());var zc,jc=sa(na.exports);function Wc(t,e){const s=`${t}:${e}`,n=jc.SHA256(s).toString(jc.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 Lc(t,e){if(t instanceof Xc&&e instanceof Zc)t.plug(e);else if(t instanceof Yc&&e instanceof Qc)t.plug(e);else if(t instanceof Gc&&e instanceof $c)t.plug(e);else if(t instanceof Gc&&e instanceof Qc)t.plug(e);else if(t instanceof Gc&&e instanceof Zc)t.plug(e);else if(t instanceof Xc&&e instanceof $c)t.plug(e);else{if(!(t instanceof Yc&&e instanceof $c))throw Error("Input and output type is not compatible");t.plug(e)}}function Hc(t,e){if(t instanceof Xc&&e instanceof Zc)t.unPlug(e);else if(t instanceof Yc&&e instanceof Qc)t.unPlug(e);else if(t instanceof Gc&&e instanceof $c)t.unPlug(e);else if(t instanceof Gc&&e instanceof Qc)t.unPlug(e);else if(t instanceof Gc&&e instanceof Zc)t.unPlug(e);else if(t instanceof Xc&&e instanceof $c)t.unPlug(e);else{if(!(t instanceof Yc&&e instanceof $c))throw Error("Input and output type is not compatible");t.unPlug(e)}}!function(t){t.AudioInput="audioInput",t.AudioOutput="audioOutput",t.MidiInput="midiInput",t.MidiOutput="midiOutput",t.ForwardInput="forwardInput",t.ForwardOutput="forwardOutput"}(zc||(zc={}));class Uc{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)}serialize(){return{id:this.id,name:this.name,moduleId:this.plugableModule.id,moduleName:this.plugableModule.name,ioType:this.ioType}}}class Gc extends Uc{constructor(t,e){super(t,e),this.checkNameValidity()}get subInputs(){return this.plugableModule.audioModules.map((t=>{const e=t.inputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}))}get subModules(){return this.plugableModule.audioModules}subModule(t){const e=this.subModules.find((e=>e.voiceNo===t));if(!e)throw Error(`Submodule with voiceNo ${t} not found`);return e}subInput(t){const e=this.subModule(t).inputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}plug(t,e=!0){super.plug(t,e),!e&&t instanceof $c||(t instanceof $c?this.subModules.forEach((e=>{const s=e.inputs.findByName(this.name);if(!s)throw Error(`Could not forward input ${this.name}`);Lc(s,t.subOutput(e.voiceNo))})):this.subInputs.forEach((e=>Lc(e,t))))}unPlug(t,e=!0){super.unPlug(t,e),!e&&t instanceof $c||(t instanceof $c?this.subModules.forEach((e=>{const s=e.inputs.findByName(this.name);if(!s)throw Error(`Could not forward input ${this.name}`);Hc(s,t.subOutput(e.voiceNo))})):this.subInputs.forEach((e=>Hc(e,t))))}unPlugAll(){Uc.unPlugAll(this)}checkNameValidity(){if(!this.plugableModule.audioModules[0].inputs.findByName(this.name))throw Error("You should forward to existing input")}}class $c extends Uc{constructor(t,e){super(t,e),this.checkNameValidity()}get subOutputs(){return this.subModules.map((t=>{const e=t.outputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}))}get subModules(){return this.plugableModule.audioModules}subModule(t){const e=this.subModules.find((e=>e.voiceNo===t));if(!e)throw Error(`Submodule with voiceNo ${t} not found`);return e}subOutput(t){const e=this.subModule(t).outputs.findByName(this.name);if(!e)throw Error(`Could not forward input ${this.name}`);return e}plug(t,e=!0){super.plug(t,e),!e&&t instanceof Gc||(t instanceof Gc?this.subModules.forEach((e=>{const s=e.outputs.findByName(this.name);if(!s)throw Error(`Could not forward output ${this.name}`);Lc(t.subInput(e.voiceNo),s)})):this.subOutputs.forEach((e=>Lc(t,e))))}unPlug(t,e=!0){super.unPlug(t,e),!e&&t instanceof Gc||(t instanceof Gc?this.subModules.forEach((e=>{const s=e.outputs.findByName(this.name);if(!s)throw Error(`Could not forward output ${this.name}`);Hc(t.subInput(e.voiceNo),s)})):this.subOutputs.forEach((e=>Hc(t,e))))}unPlugAll(){Uc.unPlugAll(this)}checkNameValidity(){if(!this.plugableModule.audioModules[0].outputs.findByName(this.name))throw Error("You should forward to existing output")}}class Xc extends Uc{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(){Uc.unPlugAll(this)}}class Zc extends Uc{internalModule;constructor(t,e){super(t,e),this.internalModule=e.internalModule}plug(t,e=!0){super.plug(t,e),t instanceof Gc||this.internalModule.connect(t.internalModule)}unPlug(t,e=!0){if(super.unPlug(t,e),!(t instanceof Gc))try{this.internalModule.disconnect(t.internalModule)}catch(t){console.error(t)}}unPlugAll(){Uc.unPlugAll(this)}}class Yc extends Uc{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(){Uc.unPlugAll(this)}}class Qc extends Uc{constructor(t,e){super(t,e)}plug(t,e=!0){super.plug(t,e)}unPlug(t,e=!0){super.unPlug(t,e)}unPlugAll(){Uc.unPlugAll(this)}onMidiEvent=t=>{this.midiConnections.forEach((e=>{e.onMidiEvent(t)}))};get midiConnections(){return this.connections.filter((t=>t instanceof Yc))}}class Kc{plugableModule;collection=[];constructor(t){this.plugableModule=t}add(t){let e;switch(t.ioType){case zc.AudioInput:if(this.plugableModule instanceof su)throw Error("PolyModule is not supported");e=new Xc(this.plugableModule,t);break;case zc.AudioOutput:if(this.plugableModule instanceof su)throw Error("PolyModule is not supported");e=new Zc(this.plugableModule,t);break;case zc.ForwardInput:if(this.plugableModule instanceof eu)throw Error("MonoModule is not supported");e=new Gc(this.plugableModule,t);break;case zc.ForwardOutput:if(this.plugableModule instanceof eu)throw Error("MonoModule is not supported");e=new $c(this.plugableModule,t);break;case zc.MidiInput:e=new Yc(this.plugableModule,t);break;case zc.MidiOutput:e=new Qc(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 Jc{connect(){throw Error("This module is not connectable")}disconnect(){throw Error("This module is not connectable")}dispose(){}}var tu,eu=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 Kc(this),this.outputs=new Kc(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`);Lc(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(ji(),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:zc.MidiInput})}registerAudioInput(t){return this.inputs.add({...t,ioType:zc.AudioInput})}registerMidiOutput(t){return this.outputs.add({...t,ioType:zc.MidiOutput})}registerAudioOutput(t){return this.outputs.add({...t,ioType:zc.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 su{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 Kc(this),this.outputs=new Kc(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`);Lc(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))}registerInput(t){return this.inputs.add({...t,ioType:zc.ForwardInput})}registerOutput(t){return this.outputs.add({...t,ioType:zc.ForwardOutput})}registerMidiInput(t){return this.inputs.add({...t,ioType:zc.MidiInput})}registerMidiOutput(t){return this.outputs.add({...t,ioType:zc.MidiOutput})}registerBasicOutputs(){this.registerOutput({name:"output"})}registerBasicInputs(){this.registerInput({name:"input"}),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 su)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"}(tu||(tu={}));const nu=.01,iu={attack:nu,decay:nu,sustain:1,release:nu};class ru extends eu{activeNote;triggeredAt;constructor(t){const{id:e,name:s,props:n,internalModule:i}=t;super(i,{id:e,name:s,props:{...iu,...n}}),this.registerBasicInputs(),this.registerBasicOutputs()}get attack(){return this._props.attack}set attack(t){this.setStage(tu.Attack,t)}get decay(){return this._props.decay}set decay(t){this.setStage(tu.Decay,t)}get sustain(){return this._props.sustain}set sustain(t){this.setStage(tu.Sustain,t)}get release(){return this._props.release}set release(t){this.setStage(tu.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===tu.Sustain?1:2}minTime(t){return t===tu.Sustain?0:nu}}class ou extends su{constructor(t){const{id:e,name:s,child:n,props:i}=t;super({id:e,name:s,child:n,props:{...iu,...i}}),this.registerBasicInputs(),this.registerBasicOutputs()}}class au extends ru{constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new so,props:n})}}class cu extends ou{static moduleName="Envelope";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:au,props:{...iu,...n}})}}class uu extends ru{constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new oo,props:n})}}class hu extends ou{static moduleName="AmpEnvelope";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:uu,props:n})}}const lu={amount:0};class pu extends ru{_frequency;_amount;filter;constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new ho,props:{...lu,...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 du extends ou{static moduleName="FreqEnvelope";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:pu,props:n})}}const fu={noteName:"C3",fine:0,coarse:0,wave:"sine",range:0,volume:0};class mu extends eu{_note;_fineSignal;constructor(t){const{id:e,name:s,props:n}=t;super(new Br,{id:e,name:s,props:{...fu,...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(!Gu.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.registerDefaultMidiInput(),this.registerAudioInput({name:"fine",internalModule:this.fineSingal})}}class _u extends su{static moduleName="Oscillator";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:mu,props:{...fu,...n}}),this.registerBasicOutputs(),this.registerInput({name:"midi in"}),this.registerInput({name:"fine"})}start(t){this.audioModules.forEach((e=>e.start(t)))}stop(t){this.audioModules.forEach((e=>e.stop(t)))}}const gu={cutoff:2e4,resonance:0,envelopeAmount:0,slope:-24,filterType:"lowpass"};class vu extends eu{_cutoff;_amount;constructor(t){const{id:e,name:s,props:n}=t;super(new uo({type:"lowpass"}),{id:e,name:s,props:{...gu,...n}}),this._cutoff=new $r(this.cutoff),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 yu extends su{static moduleName="Filter";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:vu,props:{...gu,...n}}),this.registerBasicInputs(),this.registerOutputs()}registerOutputs(){this.registerBasicOutputs(),this.registerInput({name:"cutoff"})}}class wu extends eu{static moduleName="Master";constructor({id:t}){super(ji().destination,{id:t,name:"Master"}),this.registerAudioInput({name:"input",internalModule:this.internalModule})}dispose(){this.inputs.unPlugAll(),this.outputs.unPlugAll()}}class xu extends su{static moduleName="VoiceScheduler";midiOutput;constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:bu,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 bu extends eu{midiEvent;activeNote;triggeredAt;constructor(t){const{id:e,name:s,props:n}=t;super(new Jc,{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 Tu={selectedId:null};class Cu extends eu{static moduleName="MidiSelector";midiOutput;constructor(t){const{id:e,name:s,props:n}=t;super(new Jc,{id:e,name:s,props:{...Tu,...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=Gu.midiDeviceManager.find(t);e?.addEventListener(this.forwardMidiEvent)}forwardMidiEvent=t=>{this.midiOutput.onMidiEvent(t)};removeEventListener(){if(!this.selectedId)return;const t=Gu.midiDeviceManager.find(this.selectedId);t?.removeEventListener(this.forwardMidiEvent)}}const ku={volume:-1/0};class Au extends eu{constructor(t){const{id:e,name:s,props:n}=t;super(new xr,{id:e,name:s,props:{...ku,...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 Su extends su{static moduleName="Volume";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:Au,props:{...ku,...n}}),this.registerBasicInputs(),this.registerBasicOutputs()}}const Mu={activeNotes:[]};class Ou extends eu{static moduleName="VirtualMidi";midiOutput;constructor(t){const{id:e,name:s,props:n}=t;super(new Jc,{id:e,name:s,props:{...Mu,...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],Gu._triggerPropsUpdate(this.id,this.props),this.sendMidi(jo.fromNote(t,!0,e))};triggerRelease=(t,e)=>{this.activeNotes=this.activeNotes.filter((e=>e!==t.fullName)),Gu._triggerPropsUpdate(this.id,this.props),this.sendMidi(jo.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 Eu={wet:1};class Du extends eu{constructor(t){const{id:e,name:s,internalModule:n,props:i}=t;super(n,{id:e,name:s,props:{...Eu,...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 Iu={decay:1.5,preDelay:.025};class Nu extends Du{static moduleName="Reverb";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new Eo,props:{...Iu,...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 Ru={delayTime:1,feedback:.3};class Bu extends Du{static moduleName="Delay";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new Oo,props:{...Ru,...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 Pu={drive:.3};class Vu extends Du{static moduleName="Distortion";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new So,props:{...Pu,...n}})}get drive(){return this._props.drive}set drive(t){this._props={...this.props,drive:t},this.internalModule.distortion=this.drive}}const qu={bits:16};class Fu extends Du{static moduleName="BitCrusher";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,internalModule:new Co,props:{...qu,...n}})}get bits(){return this._props.bits}set bits(t){this._props={...this.props,bits:t},this.internalModule.bits.value=this.bits}}class zu extends eu{static moduleName="Sequencer";midiOutput;part;constructor(t){const{id:e,name:s,props:n}=t;super(new Jc,{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){Gu.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&&jo.fromSequence(e,t).forEach((t=>{this.midiOutput.onMidiEvent(t)}))}}const ju={wave:"sine",frequency:.1,min:0,max:1,amount:1};class Wu extends eu{constructor(t){const{id:e,name:s,props:n}=t;super(new Yr,{id:e,name:s,props:{...ju,...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(!Gu.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.registerDefaultMidiInput(),this.registerAudioInput({name:"amount",internalModule:this.internalModule.amplitude})}}class Lu extends su{static moduleName="LFO";constructor(t){const{id:e,name:s,props:n}=t;super({id:e,name:s,child:Wu,props:{...ju,...n}}),this.registerBasicOutputs(),this.registerInput({name:"midi in"}),this.registerInput({name:"amount"})}start(t){this.audioModules.forEach((e=>e.start(t)))}stop(t){this.audioModules.forEach((e=>e.stop(t)))}}function Hu(t){const{id:e,type:s,name:n,props:i}=t,r=function(t){switch(t){case _u.moduleName:return _u;case cu.moduleName:return cu;case hu.moduleName:return hu;case du.moduleName:return du;case yu.moduleName:return yu;case Su.moduleName:return Su;case wu.moduleName:return wu;case xu.moduleName:return xu;case Cu.moduleName:return Cu;case Ou.moduleName:return Ou;case Nu.moduleName:return Nu;case Bu.moduleName:return Bu;case Vu.moduleName:return Vu;case Fu.moduleName:return Fu;case zu.moduleName:return zu;case Lu.moduleName:return Lu;default:throw Error(`Unknown module type ${t}`)}}(s);return new r({id:e,name:n,props:i})}class Uu{midiDeviceManager;static instance;context;propsUpdateCallbacks;_isStarted=!1;modules;routes;constructor(){this.modules={},this.routes={},this.propsUpdateCallbacks=[]}static getInstance(){return Uu.instance||(Uu.instance=new Uu),Uu.instance}initialize(t){return new Promise((e=>{if(this.context)return e({});this.context=new Ni(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=Hu({id:e,name:s,type:i,props:{}});return o instanceof su&&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 su&&n&&(r.numberOfVoices=n),r.serialize()}onPropsUpdate(t){this.propsUpdateCallbacks.push(t)}_triggerPropsUpdate(t,e){this.propsUpdateCallbacks.forEach((s=>s(t,e)))}addRoute(t){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}removeRoute(t){delete this.routes[t],this.updateRoutes()}triggerVirtualMidi(t,e,s){this.findById(t).sendMidi(jo.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(Gu.modules).forEach((t=>{t.unPlugAll()})),t.map((t=>{const{sourceId:e,sourceIOId:s,destinationId:n,destinationIOId:i}=t,r=Gu.findById(e),o=Gu.findById(n),a=r.outputs.find(s),c=o.inputs.find(i);if(!c||!a)throw Error("IO not found");return Lc(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 Gu=Uu.getInstance();export{Wo as MidiDevice,Go as MidiDeviceManager,Fo as Note,Gu as default};
|
|
33
25
|
//# sourceMappingURL=main.esm.js.map
|