@pinkpixel/haku 0.1.0 → 1.0.0

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.
Files changed (121) hide show
  1. package/README.md +18 -11
  2. package/dist/cli.mjs +38 -4
  3. package/dist/{mcp-DDuNECfs.mjs → mcp-DsSn95Rn.mjs} +3 -2
  4. package/dist/samples/drums/cabasa_v0_r1.ogg +0 -0
  5. package/dist/samples/drums/cabasa_v0_r2.ogg +0 -0
  6. package/dist/samples/drums/cabasa_v1_r1.ogg +0 -0
  7. package/dist/samples/drums/cabasa_v1_r2.ogg +0 -0
  8. package/dist/samples/drums/shaker_v0_r1.ogg +0 -0
  9. package/dist/samples/drums/shaker_v0_r2.ogg +0 -0
  10. package/dist/samples/drums/shaker_v1_r1.ogg +0 -0
  11. package/dist/samples/drums/shaker_v1_r2.ogg +0 -0
  12. package/dist/samples/guitar/v0_31.ogg +0 -0
  13. package/dist/samples/guitar/v0_32.ogg +0 -0
  14. package/dist/samples/guitar/v0_33.ogg +0 -0
  15. package/dist/samples/guitar/v0_34.ogg +0 -0
  16. package/dist/samples/guitar/v0_35.ogg +0 -0
  17. package/dist/samples/guitar/v0_36.ogg +0 -0
  18. package/dist/samples/guitar/v0_37.ogg +0 -0
  19. package/dist/samples/guitar/v0_38.ogg +0 -0
  20. package/dist/samples/guitar/v0_39.ogg +0 -0
  21. package/dist/samples/guitar/v0_40.ogg +0 -0
  22. package/dist/samples/guitar/v0_41.ogg +0 -0
  23. package/dist/samples/guitar/v0_43.ogg +0 -0
  24. package/dist/samples/guitar/v0_45.ogg +0 -0
  25. package/dist/samples/guitar/v0_47.ogg +0 -0
  26. package/dist/samples/guitar/v0_48.ogg +0 -0
  27. package/dist/samples/guitar/v0_50.ogg +0 -0
  28. package/dist/samples/guitar/v0_52.ogg +0 -0
  29. package/dist/samples/guitar/v0_53.ogg +0 -0
  30. package/dist/samples/guitar/v0_54.ogg +0 -0
  31. package/dist/samples/guitar/v0_55.ogg +0 -0
  32. package/dist/samples/guitar/v0_56.ogg +0 -0
  33. package/dist/samples/guitar/v0_57.ogg +0 -0
  34. package/dist/samples/guitar/v0_58.ogg +0 -0
  35. package/dist/samples/guitar/v0_59.ogg +0 -0
  36. package/dist/samples/guitar/v0_60.ogg +0 -0
  37. package/dist/samples/guitar/v0_61.ogg +0 -0
  38. package/dist/samples/guitar/v0_62.ogg +0 -0
  39. package/dist/samples/guitar/v0_63.ogg +0 -0
  40. package/dist/samples/guitar/v0_64.ogg +0 -0
  41. package/dist/samples/guitar/v0_65.ogg +0 -0
  42. package/dist/samples/guitar/v0_66.ogg +0 -0
  43. package/dist/samples/guitar/v0_67.ogg +0 -0
  44. package/dist/samples/guitar/v0_69.ogg +0 -0
  45. package/dist/samples/guitar/v0_70.ogg +0 -0
  46. package/dist/samples/guitar/v0_71.ogg +0 -0
  47. package/dist/samples/guitar/v0_72.ogg +0 -0
  48. package/dist/samples/guitar/v0_73.ogg +0 -0
  49. package/dist/samples/guitar/v0_74.ogg +0 -0
  50. package/dist/samples/guitar/v0_75.ogg +0 -0
  51. package/dist/samples/guitar/v0_76.ogg +0 -0
  52. package/dist/samples/guitar/v0_77.ogg +0 -0
  53. package/dist/samples/guitar/v0_78.ogg +0 -0
  54. package/dist/samples/guitar/v0_79.ogg +0 -0
  55. package/dist/samples/guitar/v0_80.ogg +0 -0
  56. package/dist/samples/guitar/v0_81.ogg +0 -0
  57. package/dist/samples/guitar/v0_82.ogg +0 -0
  58. package/dist/samples/guitar/v0_83.ogg +0 -0
  59. package/dist/samples/guitar/v0_84.ogg +0 -0
  60. package/dist/samples/kalimba/v0_44.ogg +0 -0
  61. package/dist/samples/kalimba/v0_46.ogg +0 -0
  62. package/dist/samples/kalimba/v0_49.ogg +0 -0
  63. package/dist/samples/kalimba/v0_51.ogg +0 -0
  64. package/dist/samples/kalimba/v0_53.ogg +0 -0
  65. package/dist/samples/kalimba/v0_56.ogg +0 -0
  66. package/dist/samples/kalimba/v0_59.ogg +0 -0
  67. package/dist/samples/kalimba/v0_61.ogg +0 -0
  68. package/dist/samples/kalimba/v0_64.ogg +0 -0
  69. package/dist/samples/kalimba/v0_65.ogg +0 -0
  70. package/dist/samples/kalimba/v0_67.ogg +0 -0
  71. package/dist/samples/kalimba/v0_71.ogg +0 -0
  72. package/dist/samples/kalimba/v0_73.ogg +0 -0
  73. package/dist/samples/kalimba/v0_74.ogg +0 -0
  74. package/dist/samples/kalimba/v0_75.ogg +0 -0
  75. package/dist/samples/kalimba/v0_77.ogg +0 -0
  76. package/dist/samples/kalimba/v0_78.ogg +0 -0
  77. package/dist/samples/kalimba/v0_79.ogg +0 -0
  78. package/dist/samples/kalimba/v0_82.ogg +0 -0
  79. package/dist/samples/kalimba/v0_83.ogg +0 -0
  80. package/dist/samples/manifest.json +181 -0
  81. package/dist/samples/vibes/v0_53.ogg +0 -0
  82. package/dist/samples/vibes/v0_57.ogg +0 -0
  83. package/dist/samples/vibes/v0_60.ogg +0 -0
  84. package/dist/samples/vibes/v0_64.ogg +0 -0
  85. package/dist/samples/vibes/v0_67.ogg +0 -0
  86. package/dist/samples/vibes/v0_71.ogg +0 -0
  87. package/dist/samples/vibes/v0_74.ogg +0 -0
  88. package/dist/samples/vibes/v0_77.ogg +0 -0
  89. package/dist/samples/vibes/v0_81.ogg +0 -0
  90. package/dist/samples/vibes/v0_84.ogg +0 -0
  91. package/dist/samples/vibes/v0_88.ogg +0 -0
  92. package/dist/samples/vibes/v1_53.ogg +0 -0
  93. package/dist/samples/vibes/v1_57.ogg +0 -0
  94. package/dist/samples/vibes/v1_60.ogg +0 -0
  95. package/dist/samples/vibes/v1_64.ogg +0 -0
  96. package/dist/samples/vibes/v1_67.ogg +0 -0
  97. package/dist/samples/vibes/v1_71.ogg +0 -0
  98. package/dist/samples/vibes/v1_74.ogg +0 -0
  99. package/dist/samples/vibes/v1_77.ogg +0 -0
  100. package/dist/samples/vibes/v1_81.ogg +0 -0
  101. package/dist/samples/vibes/v1_84.ogg +0 -0
  102. package/dist/samples/vibes/v1_88.ogg +0 -0
  103. package/dist/{src-D5fW7AC1.mjs → src-Bz-0ulVm.mjs} +179 -23
  104. package/dist/{src-JrRbTOJC.mjs → src-DNP73wX3.mjs} +60 -3
  105. package/dist/{version-DoZ2etXG.mjs → tools-CO-tdB7d.mjs} +321 -82
  106. package/dist/web/assets/esm-J-U37_Wq.js +210 -0
  107. package/dist/web/assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2 +0 -0
  108. package/dist/web/assets/figtree-latin-wght-normal-D_ZTVpCC.woff2 +0 -0
  109. package/dist/web/assets/fraunces-latin-ext-wght-normal-Ca2vKHc0.woff2 +0 -0
  110. package/dist/web/assets/fraunces-latin-wght-normal-ukD16Tqj.woff2 +0 -0
  111. package/dist/web/assets/fraunces-vietnamese-wght-normal-CnvboYUG.woff2 +0 -0
  112. package/dist/web/assets/index-BkzOde44.js +65 -0
  113. package/dist/web/assets/index-D0m3L8JK.css +1 -0
  114. package/dist/web/assets/rolldown-runtime-BWaJ3C7D.js +1 -0
  115. package/dist/web/assets/src-m48ItyJA.js +1 -0
  116. package/dist/web/icon-192.png +0 -0
  117. package/dist/web/icon-512.png +0 -0
  118. package/dist/web/index.html +19 -0
  119. package/dist/web/manifest.webmanifest +24 -0
  120. package/dist/web/sw.js +37 -0
  121. package/package.json +2 -2
@@ -0,0 +1,210 @@
1
+ import{r as e,t}from"./rolldown-runtime-BWaJ3C7D.js";var n=`15.1.22`,r=t(((e,t)=>{function n(e){if(Array.isArray(e))return e}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),i=t(((e,t)=>{function n(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),a=t(((e,t)=>{function n(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),o=t(((e,t)=>{var n=a();function r(e,t){if(e){if(typeof e==`string`)return n(e,t);var r={}.toString.call(e).slice(8,-1);return r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`?Array.from(e):r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),s=t(((e,t)=>{function n(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),c=t(((e,t)=>{var n=r(),a=i(),c=o(),l=s();function u(e,t){return n(e)||a(e,t)||c(e,t)||l()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})),l=t(((e,t)=>{function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),u=t(((e,t)=>{function n(e){"@babel/helpers - typeof";return t.exports=n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,n(e)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),d=t(((e,t)=>{var n=u().default;function r(e,t){if(n(e)!=`object`||!e)return e;var r;if(typeof Symbol<`u`&&(r=e[Symbol.toPrimitive])!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})),f=t(((e,t)=>{var n=u().default,r=d();function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports})),p=t(((e,t)=>{var n=f();function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports})),m=t(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e,c(),l(),p()):typeof define==`function`&&define.amd?define([`exports`,`@babel/runtime/helpers/slicedToArray`,`@babel/runtime/helpers/classCallCheck`,`@babel/runtime/helpers/createClass`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n.automationEvents={},n._slicedToArray,n._classCallCheck,n._createClass))})(n,(function(e,t,n,r){var i=function(e,t,n){return{endTime:t,insertTime:n,type:`exponentialRampToValue`,value:e}},a=function(e,t,n){return{endTime:t,insertTime:n,type:`linearRampToValue`,value:e}},o=function(e,t){return{startTime:t,type:`setValue`,value:e}},s=function(e,t,n){return{duration:n,startTime:t,type:`setValueCurve`,values:e}},c=function(e,t,n){var r=n.startTime,i=n.target,a=n.timeConstant;return i+(t-i)*Math.exp((r-e)/a)},l=function(e){return e.type===`exponentialRampToValue`},u=function(e){return e.type===`linearRampToValue`},d=function(e){return l(e)||u(e)},f=function(e){return e.type===`setValue`},p=function(e){return e.type===`setValueCurve`},m=function(e,t,n,r){var i=e[t];return i===void 0?r:d(i)||f(i)?i.value:p(i)?i.values[i.values.length-1]:c(n,m(e,t-1,i.startTime,r),i)},h=function(e,t,n,r,i){return n===void 0?[r.insertTime,i]:d(n)?[n.endTime,n.value]:f(n)?[n.startTime,n.value]:p(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,m(e,t-1,n.startTime,i)]},g=function(e){return e.type===`cancelAndHold`},_=function(e){return e.type===`cancelScheduledValues`},v=function(e){return g(e)||_(e)?e.cancelTime:l(e)||u(e)?e.endTime:e.startTime},y=function(e,t,n,r){var i=r.endTime,a=r.value;return n===a?a:0<n&&0<a||n<0&&a<0?n*(a/n)**+((e-t)/(i-t)):e<i?n:a},b=function(e,t,n,r){var i=r.endTime,a=r.value;return n+(e-t)/(i-t)*(a-n)},x=function(e,t){var n=Math.floor(t);if(n===t)return e[n];var r=Math.ceil(t);return(1-(t-n))*e[n]+(1-(r-t))*e[r]},S=function(e,t){var n=t.duration,r=t.startTime,i=t.values;return x(i,(e-r)/n*(i.length-1))},C=function(e,t,n){for(var r=e.length,i=Math.max(1,Math.floor(n/t*r))+1,a=e instanceof Float32Array?new Float32Array(i):e.slice(0,i),o=0;o<i;o+=1){var s=o/(i-1)*n/t*(r-1);a[o]=x(e,s)}return a},w=function(e){return e.type===`setTarget`};e.AutomationEventList=function(){function e(t){n(this,e),this._automationEvents=[],this._currenTime=0,this._defaultValue=t}return r(e,[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:`add`,value:function(e){var t=v(e);if(g(e)||_(e)){var n=this._automationEvents.findIndex(function(n){return _(e)&&p(n)?n.startTime+n.duration>=t:v(n)>=t}),r=this._automationEvents[n];if(n!==-1&&(this._automationEvents=this._automationEvents.slice(0,n)),g(e)){var c=this._automationEvents[this._automationEvents.length-1];if(r!==void 0&&d(r)){if(c!==void 0&&w(c))throw Error(`The internal list is malformed.`);var f=c===void 0?r.insertTime:p(c)?c.startTime+c.duration:v(c),m=c===void 0?this._defaultValue:p(c)?c.values[c.values.length-1]:c.value,h=l(r)?y(t,f,m,r):b(t,f,m,r),x=l(r)?i(h,t,this._currenTime):a(h,t,this._currenTime);this._automationEvents.push(x)}if(c!==void 0&&w(c)&&this._automationEvents.push(o(this.getValue(t),t)),c!==void 0&&p(c)&&c.startTime+c.duration>t){var S=t-c.startTime;this._automationEvents[this._automationEvents.length-1]=s(C(c.values,c.duration,S),c.startTime,S)}}}else{var T=this._automationEvents.findIndex(function(e){return v(e)>t}),E=T===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[T-1];if(E!==void 0&&p(E)&&v(E)+E.duration>t)return!1;var D=l(e)?i(e.value,e.endTime,this._currenTime):u(e)?a(e.value,t,this._currenTime):e;if(T===-1)this._automationEvents.push(D);else{if(p(e)&&t+e.duration>v(this._automationEvents[T]))return!1;this._automationEvents.splice(T,0,D)}}return!0}},{key:`flush`,value:function(e){var t=this._automationEvents.findIndex(function(t){return v(t)>e});if(t>1){var n=this._automationEvents.slice(t-1),r=n[0];w(r)&&n.unshift(o(m(this._automationEvents,t-2,r.startTime,this._defaultValue),r.startTime)),this._automationEvents=n}}},{key:`getValue`,value:function(e){if(this._automationEvents.length===0)return this._defaultValue;var n=this._automationEvents.findIndex(function(t){return v(t)>e}),r=this._automationEvents[n],i=(n===-1?this._automationEvents.length:n)-1,a=this._automationEvents[i];if(a!==void 0&&w(a)&&(r===void 0||!d(r)||r.insertTime>e))return c(e,m(this._automationEvents,i-1,a.startTime,this._defaultValue),a);if(a!==void 0&&f(a)&&(r===void 0||!d(r)))return a.value;if(a!==void 0&&p(a)&&(r===void 0||!d(r)||a.startTime+a.duration>e))return e<a.startTime+a.duration?S(e,a):a.values[a.values.length-1];if(a!==void 0&&d(a)&&(r===void 0||!d(r)))return a.value;if(r!==void 0&&l(r)){var o=t(h(this._automationEvents,i,a,r,this._defaultValue),2),s=o[0],g=o[1];return y(e,s,g,r)}if(r!==void 0&&u(r)){var _=t(h(this._automationEvents,i,a,r,this._defaultValue),2),x=_[0],C=_[1];return b(e,x,C,r)}return this._defaultValue}}])}(),e.createCancelAndHoldAutomationEvent=function(e){return{cancelTime:e,type:`cancelAndHold`}},e.createCancelScheduledValuesAutomationEvent=function(e){return{cancelTime:e,type:`cancelScheduledValues`}},e.createExponentialRampToValueAutomationEvent=function(e,t){return{endTime:t,type:`exponentialRampToValue`,value:e}},e.createLinearRampToValueAutomationEvent=function(e,t){return{endTime:t,type:`linearRampToValue`,value:e}},e.createSetTargetAutomationEvent=function(e,t,n){return{startTime:t,target:e,timeConstant:n,type:`setTarget`}},e.createSetValueAutomationEvent=o,e.createSetValueCurveAutomationEvent=s}))}))(),h=()=>new DOMException(``,`AbortError`),g=e=>(t,n,[r,i,a],o)=>{e(t[i],[n,r,a],e=>e[0]===n&&e[1]===r,o)},_=e=>(t,n,r)=>{let i=[];for(let e=0;e<r.numberOfInputs;e+=1)i.push(new Set);e.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:n})},v=e=>(t,n)=>{e.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:n})},y=new WeakSet,b=new WeakMap,x=new WeakMap,S=new WeakMap,C=new WeakMap,w=new WeakMap,T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,ee={construct(){return ee}},te=e=>{try{new new Proxy(e,ee)}catch{return!1}return!0},ne=/^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]*);?/,re=(e,t)=>{let n=[],r=e.replace(/^[\s]+/,``),i=r.match(ne);for(;i!==null;){let e=i[1].slice(1,-1),a=i[0].replace(/([\s]+)?;?$/,``).replace(e,new URL(e,t).toString());n.push(a),r=r.slice(i[0].length).replace(/^[\s]+/,``),i=r.match(ne)}return[n.join(`;`),r]},ie=e=>{if(e!==void 0&&!Array.isArray(e))throw TypeError(`The parameterDescriptors property of given value for processorCtor is not an array.`)},ae=e=>{if(!te(e))throw TypeError(`The given value for processorCtor should be a constructor.`);if(e.prototype===null||typeof e.prototype!=`object`)throw TypeError(`The given value for processorCtor should have a prototype.`)},oe=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=0;return(m,h,g={credentials:`omit`})=>{let _=u.get(m);if(_!==void 0&&_.has(h))return Promise.resolve();let v=l.get(m);if(v!==void 0){let e=v.get(h);if(e!==void 0)return e}let y=a(m),b=y.audioWorklet===void 0?i(h).then(([e,t])=>{let[r,i]=re(e,t);return n(`${r};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}
3
+ })})(window,'_AWGS')`)}).then(()=>{let e=f._AWGS.pop();if(e===void 0)throw SyntaxError();r(y.currentTime,y.sampleRate,()=>e(class{},void 0,(e,n)=>{if(e.trim()===``)throw t();let r=D.get(y);if(r!==void 0){if(r.has(e))throw t();ae(n),ie(n.parameterDescriptors),r.set(e,n)}else ae(n),ie(n.parameterDescriptors),D.set(y,new Map([[e,n]]))},y.sampleRate,void 0,void 0))}):Promise.all([i(h),Promise.resolve(e(d,d))]).then(([[e,t],n])=>{let r=p+1;p=r;let[i,a]=re(e,t),l=`${i};((AudioWorkletProcessor,registerProcessor)=>{${a}
4
+ })(${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${r}',class extends AudioWorkletProcessor{process(){return !1}})`,u=new Blob([l],{type:`application/javascript; charset=utf-8`}),d=URL.createObjectURL(u);return y.audioWorklet.addModule(d,g).then(()=>{if(s(y))return y;let e=o(y);return e.audioWorklet.addModule(d,g).then(()=>e)}).then(e=>{if(c===null)throw SyntaxError();try{new c(e,`__sac${r}`)}catch{throw SyntaxError()}}).finally(()=>URL.revokeObjectURL(d))});return v===void 0?l.set(m,new Map([[h,b]])):v.set(h,b),b.then(()=>{let e=u.get(m);e===void 0?u.set(m,new Set([h])):e.add(h)}).finally(()=>{let e=l.get(m);e!==void 0&&e.delete(h)}),b}},k=(e,t)=>{let n=e.get(t);if(n===void 0)throw Error(`A value with the given key could not be found.`);return n},A=(e,t)=>{let n=Array.from(e).filter(t);if(n.length>1)throw Error(`More than one element was found.`);if(n.length===0)throw Error(`No element was found.`);let[r]=n;return e.delete(r),r},se=(e,t,n,r)=>{let i=k(e,t),a=A(i,e=>e[0]===n&&e[1]===r);return i.size===0&&e.delete(t),a},ce=e=>k(T,e),le=e=>{if(y.has(e))throw Error(`The AudioNode is already stored.`);y.add(e),ce(e).forEach(e=>e(!0))},j=e=>`port`in e,ue=e=>{if(!y.has(e))throw Error(`The AudioNode is not stored.`);y.delete(e),ce(e).forEach(e=>e(!1))},de=(e,t)=>{!j(e)&&t.every(e=>e.size===0)&&ue(e)},fe=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=new WeakMap;return(m,h,g,_,v)=>{let{activeInputs:y,passiveInputs:b}=a(h),{outputs:x}=a(m),S=s(m),C=a=>{let s=c(h),l=c(m);if(a){let t=se(b,m,g,_);e(y,m,t,!1),!v&&!d(m)&&n(l,s,g,_),f(h)&&le(h)}else{let e=r(y,m,g,_);t(b,_,e,!1),!v&&!d(m)&&i(l,s,g,_);let n=o(h);if(n===0)u(h)&&de(h,y);else{let e=p.get(h);e!==void 0&&clearTimeout(e),p.set(h,setTimeout(()=>{u(h)&&de(h,y)},n*1e3))}}};return l(x,[h,g,_],e=>e[0]===h&&e[1]===g&&e[2]===_,!0)?(S.add(C),u(m)?e(y,m,[g,_,C],!0):t(b,_,[m,g,C],!0),!0):!1}},pe=e=>(t,n,[r,i,a],o)=>{let s=t.get(r);s===void 0?t.set(r,new Set([[i,n,a]])):e(s,[i,n,a],e=>e[0]===i&&e[1]===n,o)},me=e=>(t,n)=>{let r=e(t,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});n.connect(r).connect(t.destination);let i=()=>{n.removeEventListener(`ended`,i),n.disconnect(r),r.disconnect()};n.addEventListener(`ended`,i)},he=e=>(t,n)=>{e(t).add(n)},ge={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},_e=(e,t,n,r,i,a)=>class extends e{constructor(e,n){let o=i(e),s=r(o,{...ge,...n}),c=a(o)?t():null;super(e,!1,s,c),this._nativeAnalyserNode=s}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(e){this._nativeAnalyserNode.fftSize=e}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(e){let t=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=e,!(e>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=t,n()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(e){let t=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=e,!(this._nativeAnalyserNode.maxDecibels>e))throw this._nativeAnalyserNode.minDecibels=t,n()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(e){this._nativeAnalyserNode.smoothingTimeConstant=e}getByteFrequencyData(e){this._nativeAnalyserNode.getByteFrequencyData(e)}getByteTimeDomainData(e){this._nativeAnalyserNode.getByteTimeDomainData(e)}getFloatFrequencyData(e){this._nativeAnalyserNode.getFloatFrequencyData(e)}getFloatTimeDomainData(e){this._nativeAnalyserNode.getFloatTimeDomainData(e)}},ve=(e,t)=>e.context===t,ye=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return ve(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,fftSize:o.fftSize,maxDecibels:o.maxDecibels,minDecibels:o.minDecibels,smoothingTimeConstant:o.smoothingTimeConstant})),r.set(a,o),await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},be=e=>{try{e.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},xe=()=>new DOMException(``,`IndexSizeError`),Se=e=>{e.getChannelData=(t=>n=>{try{return t.call(e,n)}catch(e){throw e.code===12?xe():e}})(e.getChannelData)},Ce={numberOfChannels:1},we=(e,t,n,r,i,a,o,s)=>{let c=null;return class l{constructor(l){if(i===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let{length:u,numberOfChannels:d,sampleRate:f}={...Ce,...l};c===null&&(c=new i(1,1,44100));let p=r!==null&&t(a,a)?new r({length:u,numberOfChannels:d,sampleRate:f}):c.createBuffer(d,u,f);if(p.numberOfChannels===0)throw n();return typeof p.copyFromChannel==`function`?t(be,()=>be(p))||s(p):(o(p),Se(p)),e.add(p),p}static[Symbol.hasInstance](t){return typeof t==`object`&&!!t&&Object.getPrototypeOf(t)===l.prototype||e.has(t)}}},Te=-34028234663852886e22,Ee=34028234663852886e22,De=e=>y.has(e),Oe={buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1},ke=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,r){let s=a(e),c={...Oe,...r},l=i(s,c),u=o(s),d=u?t():null;super(e,!1,l,d),this._audioBufferSourceNodeRenderer=d,this._isBufferNullified=!1,this._isBufferSet=c.buffer!==null,this._nativeAudioBufferSourceNode=l,this._onended=null,this._playbackRate=n(this,u,l.playbackRate,Ee,Te)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(e){if(this._nativeAudioBufferSourceNode.buffer=e,e!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(e){this._nativeAudioBufferSourceNode.loop=e}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(e){this._nativeAudioBufferSourceNode.loopEnd=e}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(e){this._nativeAudioBufferSourceNode.loopStart=e}get onended(){return this._onended}set onended(e){let t=typeof e==`function`?s(this,e):null;this._nativeAudioBufferSourceNode.onended=t;let n=this._nativeAudioBufferSourceNode.onended;this._onended=n!==null&&n===t?e:n}get playbackRate(){return this._playbackRate}start(e=0,t=0,n){if(this._nativeAudioBufferSourceNode.start(e,t,n),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=n===void 0?[e,t]:[e,t,n]),this.context.state!==`closed`){le(this);let e=()=>{this._nativeAudioBufferSourceNode.removeEventListener(`ended`,e),De(this)&&ue(this)};this._nativeAudioBufferSourceNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeAudioBufferSourceNode.stop(e),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=e)}},Ae=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=async(c,l)=>{let u=n(c),d=ve(u,l);return d||(u=t(l,{buffer:u.buffer,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,loop:u.loop,loopEnd:u.loopEnd,loopStart:u.loopStart,playbackRate:u.playbackRate.value}),o!==null&&u.start(...o),s!==null&&u.stop(s)),a.set(l,u),d?await e(l,c.playbackRate,u.playbackRate):await r(l,c.playbackRate,u.playbackRate),await i(c,l,u),u};return{set start(e){o=e},set stop(e){s=e},render(e,t){let n=a.get(t);return n===void 0?c(e,t):Promise.resolve(n)}}},je=e=>`playbackRate`in e,Me=e=>`frequency`in e&&`gain`in e,Ne=e=>`offset`in e,Pe=e=>!(`frequency`in e)&&`gain`in e,Fe=e=>`detune`in e&&`frequency`in e&&!(`gain`in e),Ie=e=>`pan`in e,Le=e=>k(b,e),Re=e=>k(S,e),ze=(e,t)=>{let{activeInputs:n}=Le(e);n.forEach(n=>n.forEach(([n])=>{t.includes(e)||ze(n,[...t,e])}));let r=je(e)?[e.playbackRate]:j(e)?Array.from(e.parameters.values()):Me(e)?[e.Q,e.detune,e.frequency,e.gain]:Ne(e)?[e.offset]:Pe(e)?[e.gain]:Fe(e)?[e.detune,e.frequency]:Ie(e)?[e.pan]:[];for(let e of r){let n=Re(e);n!==void 0&&n.activeInputs.forEach(([e])=>ze(e,t))}De(e)&&ue(e)},Be=e=>{ze(e.destination,[])},Ve=e=>e===void 0||typeof e==`number`||typeof e==`string`&&(e===`balanced`||e===`interactive`||e===`playback`),He=(e,t,n,r,i,a,o,s,c)=>class extends e{constructor(e={}){if(c===null)throw Error(`Missing the native AudioContext constructor.`);let t;try{t=new c(e)}catch(e){throw e.code===12&&e.message===`sampleRate is not in range`?n():e}if(t===null)throw r();if(!Ve(e.latencyHint))throw TypeError(`The provided value '${e.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(e.sampleRate!==void 0&&t.sampleRate!==e.sampleRate)throw n();super(t,2);let{latencyHint:i}=e,{sampleRate:a}=t;if(this._baseLatency=typeof t.baseLatency==`number`?t.baseLatency:i===`balanced`?512/a:i===`interactive`||i===void 0?256/a:i===`playback`?1024/a:Math.max(2,Math.min(128,Math.round(i*a/128)))*128/a,this._nativeAudioContext=t,c.name===`webkitAudioContext`?(this._nativeGainNode=t.createGain(),this._nativeOscillatorNode=t.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(t.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,t.state===`running`){this._state=`suspended`;let e=()=>{this._state===`suspended`&&(this._state=null),t.removeEventListener(`statechange`,e)};t.addEventListener(`statechange`,e)}}get baseLatency(){return this._baseLatency}get state(){return this._state===null?this._nativeAudioContext.state:this._state}close(){return this.state===`closed`?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state===`suspended`&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),Be(this)}))}createMediaElementSource(e){return new i(this,{mediaElement:e})}createMediaStreamDestination(){return new a(this)}createMediaStreamSource(e){return new o(this,{mediaStream:e})}createMediaStreamTrackSource(e){return new s(this,{mediaStreamTrack:e})}resume(){return this._state===`suspended`?new Promise((e,t)=>{let n=()=>{this._nativeAudioContext.removeEventListener(`statechange`,n),this._nativeAudioContext.state===`running`?e():this.resume().then(e,t)};this._nativeAudioContext.addEventListener(`statechange`,n)}):this._nativeAudioContext.resume().catch(e=>{throw e===void 0||e.code===15?t():e})}suspend(){return this._nativeAudioContext.suspend().catch(e=>{throw e===void 0?t():e})}},Ue=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,n){let r=a(e),c=o(r),l=i(r,n,c),u=c?t(s):null;super(e,!1,l,u),this._isNodeOfNativeOfflineAudioContext=c,this._nativeAudioDestinationNode=l}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(e){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(e>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=e}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(e){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=e}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},We=e=>{let t=new WeakMap,n=async(n,r)=>{let i=r.destination;return t.set(r,i),await e(n,r,i),i};return{render(e,r){let i=t.get(r);return i===void 0?n(e,r):Promise.resolve(i)}}},Ge=(e,t,n,r,i,a,o,s)=>(c,l)=>{let u=l.listener,{forwardX:d,forwardY:f,forwardZ:p,positionX:m,positionY:h,positionZ:g,upX:_,upY:v,upZ:y}=u.forwardX===void 0?(()=>{let d=new Float32Array(1),f=t(l,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:9}),p=o(l),m=!1,h=[0,0,-1,0,1,0],g=[0,0,0],_=()=>{if(m)return;m=!0;let e=r(l,256,9,0);e.onaudioprocess=({inputBuffer:e})=>{let t=[a(e,d,0),a(e,d,1),a(e,d,2),a(e,d,3),a(e,d,4),a(e,d,5)];t.some((e,t)=>e!==h[t])&&(u.setOrientation(...t),h=t);let n=[a(e,d,6),a(e,d,7),a(e,d,8)];n.some((e,t)=>e!==g[t])&&(u.setPosition(...n),g=n)},f.connect(e)},v=e=>t=>{t!==h[e]&&(h[e]=t,u.setOrientation(...h))},y=e=>t=>{t!==g[e]&&(g[e]=t,u.setPosition(...g))},b=(t,r,a)=>{let o=n(l,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:r});o.connect(f,0,t),o.start(),Object.defineProperty(o.offset,"defaultValue",{get(){return r}});let u=e({context:c},p,o.offset,Ee,Te);return s(u,`value`,e=>()=>e.call(u),e=>t=>{try{e.call(u,t)}catch(e){if(e.code!==9)throw e}_(),p&&a(t)}),u.cancelAndHoldAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.cancelAndHoldAtTime),u.cancelScheduledValues=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.cancelScheduledValues),u.exponentialRampToValueAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.exponentialRampToValueAtTime),u.linearRampToValueAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.linearRampToValueAtTime),u.setTargetAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.setTargetAtTime),u.setValueAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.setValueAtTime),u.setValueCurveAtTime=(e=>p?()=>{throw i()}:(...t)=>{let n=e.apply(u,t);return _(),n})(u.setValueCurveAtTime),u};return{forwardX:b(0,0,v(0)),forwardY:b(1,0,v(1)),forwardZ:b(2,-1,v(2)),positionX:b(6,0,y(0)),positionY:b(7,0,y(1)),positionZ:b(8,0,y(2)),upX:b(3,0,v(3)),upY:b(4,1,v(4)),upZ:b(5,0,v(5))}})():u;return{get forwardX(){return d},get forwardY(){return f},get forwardZ(){return p},get positionX(){return m},get positionY(){return h},get positionZ(){return g},get upX(){return _},get upY(){return v},get upZ(){return y}}},Ke=e=>`context`in e,qe=e=>Ke(e[0]),Je=(e,t,n,r)=>{for(let t of e)if(n(t)){if(r)return!1;throw Error(`The set contains at least one similar element.`)}return e.add(t),!0},Ye=(e,t,[n,r],i)=>{Je(e,[t,n,r],e=>e[0]===t&&e[1]===n,i)},Xe=(e,[t,n,r],i)=>{let a=e.get(t);a===void 0?e.set(t,new Set([[n,r]])):Je(a,[n,r],e=>e[0]===n,i)},Ze=e=>`inputs`in e,Qe=(e,t,n,r)=>{if(Ze(t)){let i=t.inputs[r];return e.connect(i,n,0),[i,n,0]}return e.connect(t,n,r),[t,n,r]},$e=(e,t,n)=>{for(let r of e)if(r[0]===t&&r[1]===n)return e.delete(r),r;return null},et=(e,t,n)=>A(e,e=>e[0]===t&&e[1]===n),tt=(e,t)=>{if(!ce(e).delete(t))throw Error(`Missing the expected event listener.`)},nt=(e,t,n)=>{let r=k(e,t),i=A(r,e=>e[0]===n);return r.size===0&&e.delete(t),i},rt=(e,t,n,r)=>{Ze(t)?e.disconnect(t.inputs[r],n,0):e.disconnect(t,n,r)},M=e=>k(x,e),it=e=>k(C,e),at=e=>E.has(e),ot=e=>!y.has(e),st=(e,t)=>new Promise(n=>{if(t!==null)n(!0);else{let t=e.createScriptProcessor(256,1,1),r=e.createGain(),i=e.createBuffer(1,2,44100),a=i.getChannelData(0);a[0]=1,a[1]=1;let o=e.createBufferSource();o.buffer=i,o.loop=!0,o.connect(t).connect(e.destination),o.connect(r),o.disconnect(r),t.onaudioprocess=r=>{let i=r.inputBuffer.getChannelData(0);Array.prototype.some.call(i,e=>e===1)?n(!0):n(!1),o.stop(),t.onaudioprocess=null,o.disconnect(t),t.disconnect(e.destination)},o.start()}}),ct=(e,t)=>{let n=new Map;for(let t of e)for(let e of t){let t=n.get(e);n.set(e,t===void 0?1:t+1)}n.forEach((e,n)=>t(n,e))},lt=e=>`context`in e,ut=e=>{let t=new Map;e.connect=(e=>(n,r=0,i=0)=>{let a=lt(n)?e(n,r,i):e(n,r),o=t.get(n);return o===void 0?t.set(n,[{input:i,output:r}]):o.every(e=>e.input!==i||e.output!==r)&&o.push({input:i,output:r}),a})(e.connect.bind(e)),e.disconnect=(n=>(r,i,a)=>{if(n.apply(e),r===void 0)t.clear();else if(typeof r==`number`)for(let[e,n]of t){let i=n.filter(e=>e.output!==r);i.length===0?t.delete(e):t.set(e,i)}else if(t.has(r)){if(i===void 0)t.delete(r);else{let e=t.get(r);if(e!==void 0){let n=e.filter(e=>e.output!==i&&(e.input!==a||a===void 0));n.length===0?t.delete(r):t.set(r,n)}}}for(let[n,r]of t)r.forEach(t=>{lt(n)?e.connect(n,t.output,t.input):e.connect(n,t.output)})})(e.disconnect)},dt=(e,t,n,r)=>{let{activeInputs:i,passiveInputs:a}=Re(t),{outputs:o}=Le(e),s=ce(e),c=o=>{let s=M(e),c=it(t);if(o){let t=nt(a,e,n);Ye(i,e,t,!1),!r&&!at(e)&&s.connect(c,n)}else{let t=et(i,e,n);Xe(a,t,!1),!r&&!at(e)&&s.disconnect(c,n)}};return Je(o,[t,n],e=>e[0]===t&&e[1]===n,!0)?(s.add(c),De(e)?Ye(i,e,[n,c],!0):Xe(a,[e,n,c],!0),!0):!1},ft=(e,t,n,r)=>{let{activeInputs:i,passiveInputs:a}=Le(t),o=$e(i[r],e,n);return o===null?[se(a,e,n,r)[2],!1]:[o[2],!0]},pt=(e,t,n)=>{let{activeInputs:r,passiveInputs:i}=Re(t),a=$e(r,e,n);return a===null?[nt(i,e,n)[1],!1]:[a[2],!0]},mt=(e,t,n,r,i)=>{let[a,o]=ft(e,n,r,i);if(a!==null&&(tt(e,a),o&&!t&&!at(e)&&rt(M(e),M(n),r,i)),De(n)){let{activeInputs:e}=Le(n);de(n,e)}},ht=(e,t,n,r)=>{let[i,a]=pt(e,n,r);i!==null&&(tt(e,i),a&&!t&&!at(e)&&M(e).disconnect(it(n),r))},gt=(e,t)=>{let n=Le(e),r=[];for(let i of n.outputs)qe(i)?mt(e,t,...i):ht(e,t,...i),r.push(i[0]);return n.outputs.clear(),r},_t=(e,t,n)=>{let r=Le(e),i=[];for(let a of r.outputs)a[1]===n&&(qe(a)?mt(e,t,...a):ht(e,t,...a),i.push(a[0]),r.outputs.delete(a));return i},vt=(e,t,n,r,i)=>{let a=Le(e);return Array.from(a.outputs).filter(e=>e[0]===n&&(r===void 0||e[1]===r)&&(i===void 0||e[2]===i)).map(n=>(qe(n)?mt(e,t,...n):ht(e,t,...n),a.outputs.delete(n),n[0]))},yt=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>class extends l{constructor(t,r,i,a){super(i),this._context=t,this._nativeAudioNode=i;let o=u(t);d(o)&&!0!==n(st,()=>st(o,h))&&ut(i),x.set(this,i),T.set(this,new Set),t.state!==`closed`&&r&&le(this),e(this,a,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(e){this._nativeAudioNode.channelCount=e}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(e){this._nativeAudioNode.channelCountMode=e}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(e){this._nativeAudioNode.channelInterpretation=e}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(e,n=0,s=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();let l=m(u(this._context));if(f(e)||p(e))throw a();if(Ke(e)){let i=M(e);try{let t=Qe(this._nativeAudioNode,i,n,s),r=ot(this);(l||r)&&this._nativeAudioNode.disconnect(...t),this.context.state!==`closed`&&!r&&ot(e)&&le(e)}catch(e){throw e.code===12?a():e}return t(this,e,n,s,l)&&ct(c([this],e),r(l)),e}let d=it(e);if(d.name===`playbackRate`&&d.maxValue===1024)throw o();try{this._nativeAudioNode.connect(d,n),(l||ot(this))&&this._nativeAudioNode.disconnect(d,n)}catch(e){throw e.code===12?a():e}dt(this,e,n,l)&&ct(c([this],e),r(l))}disconnect(e,t,n){let r,o=m(u(this._context));if(e===void 0)r=gt(this,o);else if(typeof e==`number`){if(e<0||e>=this.numberOfOutputs)throw i();r=_t(this,o,e)}else{if(t!==void 0&&(t<0||t>=this.numberOfOutputs)||Ke(e)&&n!==void 0&&(n<0||n>=e.numberOfInputs))throw i();if(r=vt(this,o,e,t,n),r.length===0)throw a()}for(let e of r)ct(c([this],e),s)}},bt=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>(p,h,g,_=null,v=null)=>{let y=g.value,b=new m.AutomationEventList(y),x=h?r(b):null,S={get defaultValue(){return y},get maxValue(){return _===null?g.maxValue:_},get minValue(){return v===null?g.minValue:v},get value(){return g.value},set value(e){g.value=e,S.setValueAtTime(e,p.context.currentTime)},cancelAndHoldAtTime(e){if(typeof g.cancelAndHoldAtTime==`function`)x===null&&b.flush(p.context.currentTime),b.add(i(e)),g.cancelAndHoldAtTime(e);else{let t=Array.from(b).pop();x===null&&b.flush(p.context.currentTime),b.add(i(e));let n=Array.from(b).pop();g.cancelScheduledValues(e),t!==n&&n!==void 0&&(n.type===`exponentialRampToValue`?g.exponentialRampToValueAtTime(n.value,n.endTime):n.type===`linearRampToValue`?g.linearRampToValueAtTime(n.value,n.endTime):n.type===`setValue`?g.setValueAtTime(n.value,n.startTime):n.type===`setValueCurve`&&g.setValueCurveAtTime(n.values,n.startTime,n.duration))}return S},cancelScheduledValues(e){return x===null&&b.flush(p.context.currentTime),b.add(a(e)),g.cancelScheduledValues(e),S},exponentialRampToValueAtTime(e,t){if(e===0||!Number.isFinite(t)||t<0)throw RangeError();let n=p.context.currentTime;return x===null&&b.flush(n),Array.from(b).length===0&&(b.add(l(y,n)),g.setValueAtTime(y,n)),b.add(o(e,t)),g.exponentialRampToValueAtTime(e,t),S},linearRampToValueAtTime(e,t){let n=p.context.currentTime;return x===null&&b.flush(n),Array.from(b).length===0&&(b.add(l(y,n)),g.setValueAtTime(y,n)),b.add(s(e,t)),g.linearRampToValueAtTime(e,t),S},setTargetAtTime(e,t,n){return x===null&&b.flush(p.context.currentTime),b.add(c(e,t,n)),g.setTargetAtTime(e,t,n),S},setValueAtTime(e,t){return x===null&&b.flush(p.context.currentTime),b.add(l(e,t)),g.setValueAtTime(e,t),S},setValueCurveAtTime(e,t,n){let r=e instanceof Float32Array?e:new Float32Array(e);if(d!==null&&d.name===`webkitAudioContext`){let e=t+n,i=p.context.sampleRate,a=Math.ceil(t*i),o=Math.floor(e*i),s=o-a,c=new Float32Array(s);for(let e=0;e<s;e+=1){let o=(r.length-1)/n*((a+e)/i-t),s=Math.floor(o),l=Math.ceil(o);c[e]=s===l?r[s]:(1-(o-s))*r[s]+(1-(l-o))*r[l]}x===null&&b.flush(p.context.currentTime),b.add(u(c,t,n)),g.setValueCurveAtTime(c,t,n);let l=o/i;l<e&&f(S,c[c.length-1],l),f(S,r[r.length-1],e)}else x===null&&b.flush(p.context.currentTime),b.add(u(r,t,n)),g.setValueCurveAtTime(r,t,n);return S}};return n.set(S,g),t.set(S,p),e(S,x),S},xt=e=>({replay(t){for(let n of e)if(n.type===`exponentialRampToValue`){let{endTime:e,value:r}=n;t.exponentialRampToValueAtTime(r,e)}else if(n.type===`linearRampToValue`){let{endTime:e,value:r}=n;t.linearRampToValueAtTime(r,e)}else if(n.type===`setTarget`){let{startTime:e,target:r,timeConstant:i}=n;t.setTargetAtTime(r,e,i)}else if(n.type===`setValue`){let{startTime:e,value:r}=n;t.setValueAtTime(r,e)}else if(n.type===`setValueCurve`){let{duration:e,startTime:r,values:i}=n;t.setValueCurveAtTime(i,r,e)}else throw Error(`Can't apply an unknown automation.`)}}),St=class{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,t=null){return this._map.forEach((n,r)=>e.call(t,n,r,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}},Ct={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},wt=(e,t,n,r,i,a,o,s,c,l,u,d,f,p)=>class extends t{constructor(t,p,m){let h=s(t),g=c(h),_=u({...Ct,...m});f(_);let v=D.get(h)?.get(p),y=i(g||h.state!==`closed`?h:o(h)??h,g?null:t.baseLatency,l,p,v,_),b=g?r(p,_,v):null;super(t,!0,y,b);let x=[];y.parameters.forEach((e,t)=>{let r=n(this,g,e);x.push([t,r])}),this._nativeAudioWorkletNode=y,this._onprocessorerror=null,this._parameters=new St(x),g&&e(h,this);let{activeInputs:S}=a(this);d(y,S)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(e){let t=typeof e==`function`?p(this,e):null;this._nativeAudioWorkletNode.onprocessorerror=t;let n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=n!==null&&n===t?e:n}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Tt(e,t,n,r,i){if(typeof e.copyFromChannel==`function`)t[n].byteLength===0&&(t[n]=new Float32Array(128)),e.copyFromChannel(t[n],r,i);else{let a=e.getChannelData(r);if(t[n].byteLength===0)t[n]=a.slice(i,i+128);else{let e=new Float32Array(a.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[n].set(e)}}}var Et=(e,t,n,r,i)=>{typeof e.copyToChannel==`function`?t[n].byteLength!==0&&e.copyToChannel(t[n],r,i):t[n].byteLength!==0&&e.getChannelData(r).set(t[n],i)},Dt=(e,t)=>{let n=[];for(let r=0;r<e;r+=1){let e=[],i=typeof t==`number`?t:t[r];for(let t=0;t<i;t+=1)e.push(new Float32Array(128));n.push(e)}return n},Ot=(e,t)=>k(k(O,e),M(t)),kt=async(e,t,n,r,i,a,o)=>{let s=t===null?Math.ceil(e.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,l=i.reduce((e,t)=>e+t,0),u=l===0?null:n.createBuffer(l,s,n.sampleRate);if(a===void 0)throw Error(`Missing the processor constructor.`);let d=Le(e),f=await Ot(n,e),p=Dt(r.numberOfInputs,r.channelCount),m=Dt(r.numberOfOutputs,i),h=Array.from(e.parameters.keys()).reduce((e,t)=>({...e,[t]:new Float32Array(128)}),{});for(let l=0;l<s;l+=128){if(r.numberOfInputs>0&&t!==null)for(let e=0;e<r.numberOfInputs;e+=1)for(let n=0;n<r.channelCount;n+=1)Tt(t,p[e],n,n,l);a.parameterDescriptors!==void 0&&t!==null&&a.parameterDescriptors.forEach(({name:e},n)=>{Tt(t,h,e,c+n,l)});for(let e=0;e<r.numberOfInputs;e+=1)for(let t=0;t<i[e];t+=1)m[e][t].byteLength===0&&(m[e][t]=new Float32Array(128));try{let e=p.map((e,t)=>d.activeInputs[t].size===0?[]:e),t=o(l/n.sampleRate,n.sampleRate,()=>f.process(e,m,h));if(u!==null)for(let e=0,t=0;e<r.numberOfOutputs;e+=1){for(let n=0;n<i[e];n+=1)Et(u,m[e],n,t+n,l);t+=i[e]}if(!t)break}catch(t){e.dispatchEvent(new ErrorEvent(`processorerror`,{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}));break}}return u},At=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>(g,_,v)=>{let y=new WeakMap,b=null,x=async(s,x)=>{let S=u(s),C=null,w=ve(S,x),T=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(d===null){let e=T.reduce((e,t)=>e+t,0),n=i(x,{channelCount:Math.max(1,e),channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:Math.max(1,e)}),a=[];for(let e=0;e<s.numberOfOutputs;e+=1)a.push(r(x,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:T[e]}));let l=o(x,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1});l.connect=t.bind(null,a),l.disconnect=c.bind(null,a),C=[n,a,l]}else w||(S=new d(x,g));if(y.set(x,C===null?S:C[2]),C!==null){if(b===null){if(v===void 0)throw Error(`Missing the processor constructor.`);if(f===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let e=s.channelCount*s.numberOfInputs,t=v.parameterDescriptors===void 0?0:v.parameterDescriptors.length,n=e+t;b=kt(s,n===0?null:await(async()=>{let c=new f(n,Math.ceil(s.context.length/128)*128,x.sampleRate),l=[],u=[];for(let e=0;e<_.numberOfInputs;e+=1)l.push(o(c,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),u.push(i(c,{channelCount:_.channelCount,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:_.channelCount}));let d=await Promise.all(Array.from(s.parameters.values()).map(async e=>{let t=a(c,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:e.value});return await p(c,e,t.offset),t})),g=r(c,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:Math.max(1,e+t)});for(let e=0;e<_.numberOfInputs;e+=1){l[e].connect(u[e]);for(let t=0;t<_.channelCount;t+=1)u[e].connect(g,t,e*_.channelCount+t)}for(let[t,n]of d.entries())n.connect(g,0,e+t),n.start(0);return g.connect(c.destination),await Promise.all(l.map(e=>m(s,c,e))),h(c)})(),x,_,T,v,l)}let e=await b,t=n(x,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,u,d]=C;e!==null&&(t.buffer=e,t.start(0)),t.connect(c);for(let e=0,t=0;e<s.numberOfOutputs;e+=1){let n=u[e];for(let r=0;r<T[e];r+=1)c.connect(n,t+r,r);t+=T[e]}return d}if(w)for(let[t,n]of s.parameters.entries())await e(x,n,S.parameters.get(t));else for(let[e,t]of s.parameters.entries())await p(x,t,S.parameters.get(e));return await m(s,x,S),S};return{render(e,t){s(t,e);let n=y.get(t);return n===void 0?x(e,t):Promise.resolve(n)}}},jt=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y)=>class extends m{constructor(t,n){super(t,n),this._nativeContext=t,this._audioWorklet=e===void 0?void 0:{addModule:(t,n)=>e(this,t,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(e,t,r){return new n({length:t,numberOfChannels:e,sampleRate:r})}createBufferSource(){return new r(this)}createChannelMerger(e=6){return new a(this,{numberOfInputs:e})}createChannelSplitter(e=6){return new o(this,{numberOfOutputs:e})}createConstantSource(){return new s(this)}createConvolver(){return new c(this)}createDelay(e=1){return new u(this,{maxDelayTime:e})}createDynamicsCompressor(){return new d(this)}createGain(){return new f(this)}createIIRFilter(e,t){return new p(this,{feedback:t,feedforward:e})}createOscillator(){return new h(this)}createPanner(){return new g(this)}createPeriodicWave(e,t,n={disableNormalization:!1}){return new _(this,{...n,imag:t,real:e})}createStereoPanner(){return new v(this)}createWaveShaper(){return new y(this)}decodeAudioData(e,t,n){return l(this._nativeContext,e).then(e=>(typeof t==`function`&&t(e),e),e=>{throw typeof n==`function`&&n(e),e})}},Mt={Q:1,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,detune:0,frequency:350,gain:0,type:`lowpass`},Nt=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,r){let c=a(e),l=i(c,{...Mt,...r}),u=o(c),d=u?n():null;super(e,!1,l,d),this._Q=t(this,u,l.Q,Ee,Te),this._detune=t(this,u,l.detune,1200*Math.log2(Ee),-1200*Math.log2(Ee)),this._frequency=t(this,u,l.frequency,e.sampleRate/2,0),this._gain=t(this,u,l.gain,40*Math.log10(Ee),Te),this._nativeBiquadFilterNode=l,s(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(e){this._nativeBiquadFilterNode.type=e}getFrequencyResponse(e,t,n){try{this._nativeBiquadFilterNode.getFrequencyResponse(e,t,n)}catch(e){throw e.code===11?r():e}if(e.length!==t.length||t.length!==n.length)throw r()}},Pt=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=ve(c,s);return l||(c=t(s,{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})),a.set(s,c),l?(await e(s,o.Q,c.Q),await e(s,o.detune,c.detune),await e(s,o.frequency,c.frequency),await e(s,o.gain,c.gain)):(await r(s,o.Q,c.Q),await r(s,o.detune,c.detune),await r(s,o.frequency,c.frequency),await r(s,o.gain,c.gain)),await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},Ft=(e,t)=>(n,r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e.get(n);if(a!==void 0)return a;try{let i=r();return i instanceof Promise?(e.set(n,i),i.catch(()=>!1).then(r=>(e.delete(n),t.set(n,r),r))):(t.set(n,i),i)}catch{return t.set(n,!1),!1}},It={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:6},Lt=(e,t,n,r,i)=>class extends e{constructor(e,a){let o=r(e),s=n(o,{...It,...a}),c=i(o)?t():null;super(e,!1,s,c)}},Rt=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return ve(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfInputs:o.numberOfInputs})),r.set(a,o),await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},zt={channelCount:6,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:6},Bt=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c=n(s,a({...zt,...o})),l=i(s)?t():null;super(e,!1,c,l)}},Vt=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return ve(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,numberOfOutputs:o.numberOfOutputs})),r.set(a,o),await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},Ht=e=>(t,n,r)=>e(n,t,r),Ut=e=>(t,n,r=0,i=0)=>{let a=t[r];if(a===void 0)throw e();return lt(n)?a.connect(n,0,i):a.connect(n,0)},Wt=e=>(t,n)=>{let r=e(t,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1});return r.buffer=t.createBuffer(1,2,44100),r.loop=!0,r.connect(n),r.start(),()=>{r.stop(),r.disconnect(n)}},Gt={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,offset:1},Kt=(e,t,n,r,i,a,o)=>class extends e{constructor(e,o){let s=i(e),c=r(s,{...Gt,...o}),l=a(s),u=l?n():null;super(e,!1,c,u),this._constantSourceNodeRenderer=u,this._nativeConstantSourceNode=c,this._offset=t(this,l,c.offset,Ee,Te),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(e){let t=typeof e==`function`?o(this,e):null;this._nativeConstantSourceNode.onended=t;let n=this._nativeConstantSourceNode.onended;this._onended=n!==null&&n===t?e:n}start(e=0){if(this._nativeConstantSourceNode.start(e),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=e),this.context.state!==`closed`){le(this);let e=()=>{this._nativeConstantSourceNode.removeEventListener(`ended`,e),De(this)&&ue(this)};this._nativeConstantSourceNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeConstantSourceNode.stop(e),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=e)}},qt=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=async(c,l)=>{let u=n(c),d=ve(u,l);return d||(u=t(l,{channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,offset:u.offset.value}),o!==null&&u.start(o),s!==null&&u.stop(s)),a.set(l,u),d?await e(l,c.offset,u.offset):await r(l,c.offset,u.offset),await i(c,l,u),u};return{set start(e){o=e},set stop(e){s=e},render(e,t){let n=a.get(t);return n===void 0?c(e,t):Promise.resolve(n)}}},Jt=e=>t=>(e[0]=t,e[0]),Yt={buffer:null,channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,disableNormalization:!1},Xt=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c={...Yt,...o},l=n(s,c),u=i(s)?t():null;super(e,!1,l,u),this._isBufferNullified=!1,this._nativeConvolverNode=l,c.buffer!==null&&a(this,c.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(e){if(this._nativeConvolverNode.buffer=e,e===null&&this._nativeConvolverNode.buffer!==null){let e=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=e.createBuffer(1,1,e.sampleRate),this._isBufferNullified=!0,a(this,0)}else this._isBufferNullified=!1,a(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(e){this._nativeConvolverNode.normalize=e}},Zt=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return ve(o,a)||(o=e(a,{buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize})),r.set(a,o),Ze(o)?await n(i,a,o.inputs[0]):await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},Qt=(e,t)=>(n,r,i)=>{if(t===null)throw Error(`Missing the native OfflineAudioContext constructor.`);try{return new t(n,r,i)}catch(t){throw t.name===`SyntaxError`?e():t}},$t=()=>new DOMException(``,`DataCloneError`),en=e=>{let{port1:t,port2:n}=new MessageChannel;return new Promise(r=>{let i=()=>{n.onmessage=null,t.close(),n.close(),r()};n.onmessage=()=>i();try{t.postMessage(e,[e])}catch{}finally{i()}})},tn=(e,t,n,r,i,a,o,s,c,l,u)=>(d,f)=>{let p=o(d)?d:a(d);if(i.has(f)){let e=n();return Promise.reject(e)}try{i.add(f)}catch{}return t(c,()=>c(p))?p.decodeAudioData(f).then(n=>(en(f).catch(()=>{}),t(s,()=>s(n))||u(n),e.add(n),n)):new Promise((t,n)=>{let i=async()=>{try{await en(f)}catch{}},a=e=>{n(e),i()};try{p.decodeAudioData(f,n=>{typeof n.copyFromChannel!=`function`&&(l(n),Se(n)),e.add(n),i().then(()=>t(n))},e=>{a(e===null?r():e)})}catch(e){a(e)}})},nn=(e,t,n,r,i,a,o,s)=>(c,l)=>{let u=t.get(c);if(u===void 0)throw Error(`Missing the expected cycle count.`);let d=s(a(c.context));if(u===l){if(t.delete(c),!d&&o(c)){let t=r(c),{outputs:a}=n(c);for(let n of a)if(qe(n))e(t,r(n[0]),n[1],n[2]);else{let e=i(n[0]);t.connect(e,n[1])}}}else t.set(c,u-l)},rn={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,delayTime:0,maxDelayTime:1},an=(e,t,n,r,i,a,o)=>class extends e{constructor(e,s){let c=i(e),l={...rn,...s},u=r(c,l),d=a(c),f=d?n(l.maxDelayTime):null;super(e,!1,u,f),this._delayTime=t(this,d,u.delayTime),o(this,l.maxDelayTime)}get delayTime(){return this._delayTime}},on=(e,t,n,r,i)=>a=>{let o=new WeakMap,s=async(s,c)=>{let l=n(s),u=ve(l,c);return u||(l=t(c,{channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:a})),o.set(c,l),u?await e(c,s.delayTime,l.delayTime):await r(c,s.delayTime,l.delayTime),await i(s,c,l),l};return{render(e,t){let n=o.get(t);return n===void 0?s(e,t):Promise.resolve(n)}}},sn=e=>(t,n,r,i)=>e(t[i],e=>e[0]===n&&e[1]===r),cn=e=>(t,n)=>{e(t).delete(n)},ln=e=>`delayTime`in e,un=(e,t,n)=>function r(i,a){let o=Ke(a)?a:n(e,a);if(ln(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];let{outputs:s}=t(o);return Array.from(s).map(e=>r([...i,o],e[0])).reduce((e,t)=>e.concat(t),[])},dn=(e,t,n)=>{let r=t[n];if(r===void 0)throw e();return r},fn=e=>(t,n=void 0,r=void 0,i=0)=>n===void 0?t.forEach(e=>e.disconnect()):typeof n==`number`?dn(e,t,n).disconnect():lt(n)?r===void 0?t.forEach(e=>e.disconnect(n)):i===void 0?dn(e,t,r).disconnect(n,0):dn(e,t,r).disconnect(n,0,i):r===void 0?t.forEach(e=>e.disconnect(n)):dn(e,t,r).disconnect(n,0),pn={attack:.003,channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,knee:30,ratio:12,release:.25,threshold:-24},mn=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,i){let c=a(e),l=r(c,{...pn,...i}),u=o(c),d=u?n():null;super(e,!1,l,d),this._attack=t(this,u,l.attack),this._knee=t(this,u,l.knee),this._nativeDynamicsCompressorNode=l,this._ratio=t(this,u,l.ratio),this._release=t(this,u,l.release),this._threshold=t(this,u,l.threshold),s(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(e){let t=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=e,e>2)throw this._nativeDynamicsCompressorNode.channelCount=t,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(e){let t=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=e,e===`max`)throw this._nativeDynamicsCompressorNode.channelCountMode=t,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return typeof this._nativeDynamicsCompressorNode.reduction.value==`number`?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}},hn=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=ve(c,s);return l||(c=t(s,{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})),a.set(s,c),l?(await e(s,o.attack,c.attack),await e(s,o.knee,c.knee),await e(s,o.ratio,c.ratio),await e(s,o.release,c.release),await e(s,o.threshold,c.threshold)):(await r(s,o.attack,c.attack),await r(s,o.knee,c.knee),await r(s,o.ratio,c.ratio),await r(s,o.release,c.release),await r(s,o.threshold,c.threshold)),await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},gn=()=>new DOMException(``,`EncodingError`),_n=e=>t=>new Promise((n,r)=>{if(e===null){r(SyntaxError());return}let i=e.document.head;if(i===null)r(SyntaxError());else{let a=e.document.createElement(`script`),o=new Blob([t],{type:`application/javascript`}),s=URL.createObjectURL(o),c=e.onerror,l=()=>{e.onerror=c,URL.revokeObjectURL(s)};e.onerror=(t,n,i,a,o)=>{if(n===s||n===e.location.href&&i===1&&a===1)return l(),r(o),!1;if(c!==null)return c(t,n,i,a,o)},a.onerror=()=>{l(),r(SyntaxError())},a.onload=()=>{l(),n()},a.src=s,a.type=`module`,i.appendChild(a)}}),vn=e=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(t,n,r){if(n!==null){let i=this._listeners.get(n);i===void 0&&(i=e(this,n),typeof n==`function`&&this._listeners.set(n,i)),this._nativeEventTarget.addEventListener(t,i,r)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,t,n){let r=t===null?void 0:this._listeners.get(t);this._nativeEventTarget.removeEventListener(e,r===void 0?null:r,n)}},yn=e=>(t,n,r)=>{Object.defineProperties(e,{currentFrame:{configurable:!0,get(){return Math.round(t*n)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{e!==null&&(delete e.currentFrame,delete e.currentTime)}},bn=e=>async t=>{try{let e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw e()},xn={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,gain:1},Sn=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=i(e),c=r(s,{...xn,...o}),l=a(s),u=l?n():null;super(e,!1,c,u),this._gain=t(this,l,c.gain,Ee,Te)}get gain(){return this._gain}},Cn=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=ve(c,s);return l||(c=t(s,{channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value})),a.set(s,c),l?await e(s,o.gain,c.gain):await r(s,o.gain,c.gain),await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},wn=(e,t)=>n=>t(e,n),Tn=e=>t=>{let n=e(t);if(n.renderer===null)throw Error(`Missing the renderer of the given AudioNode in the audio graph.`);return n.renderer},En=e=>t=>e.get(t)??0,Dn=e=>t=>{let n=e(t);if(n.renderer===null)throw Error(`Missing the renderer of the given AudioParam in the audio graph.`);return n.renderer},On=e=>t=>e.get(t),kn=()=>new DOMException(``,`InvalidStateError`),An=e=>t=>{let n=e.get(t);if(n===void 0)throw kn();return n},jn=(e,t)=>n=>{let r=e.get(n);if(r!==void 0)return r;if(t===null)throw Error(`Missing the native OfflineAudioContext constructor.`);return r=new t(1,1,44100),e.set(n,r),r},Mn=e=>t=>{let n=e.get(t);if(n===void 0)throw Error(`The context has no set of AudioWorkletNodes.`);return n},Nn=()=>new DOMException(``,`InvalidAccessError`),Pn=e=>{e.getFrequencyResponse=(t=>(n,r,i)=>{if(n.length!==r.length||r.length!==i.length)throw Nn();return t.call(e,n,r,i)})(e.getFrequencyResponse)},Fn={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`},In=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c=i(s),l={...Fn,...o},u=t(s,c?null:e.baseLatency,l),d=c?n(l.feedback,l.feedforward):null;super(e,!1,u,d),Pn(u),this._nativeIIRFilterNode=u,a(this,1)}getFrequencyResponse(e,t,n){return this._nativeIIRFilterNode.getFrequencyResponse(e,t,n)}},Ln=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=l.length,f=s;for(let s=0;s<d;s+=1){let d=n[0]*l[s];for(let t=1;t<i;t+=1){let r=f-t&c-1;d+=n[t]*a[r],d-=e[t]*o[r]}for(let e=i;e<r;e+=1)d+=n[e]*a[f-e&c-1];for(let n=i;n<t;n+=1)d-=e[n]*o[f-n&c-1];a[f]=l[s],o[f]=d,f=f+1&c-1,u[s]=d}return f},Rn=(e,t,n,r)=>{let i=n instanceof Float64Array?n:new Float64Array(n),a=r instanceof Float64Array?r:new Float64Array(r),o=i.length,s=a.length,c=Math.min(o,s);if(i[0]!==1){for(let e=0;e<o;e+=1)a[e]/=i[0];for(let e=1;e<s;e+=1)i[e]/=i[0]}let l=new Float32Array(32),u=new Float32Array(32),d=t.createBuffer(e.numberOfChannels,e.length,e.sampleRate),f=e.numberOfChannels;for(let t=0;t<f;t+=1){let n=e.getChannelData(t),r=d.getChannelData(t);l.fill(0),u.fill(0),Ln(i,o,a,s,c,l,u,0,32,n,r)}return d},zn=(e,t,n,r,i)=>(a,o)=>{let s=new WeakMap,c=null,l=async(l,u)=>{let d=null,f=t(l),p=ve(f,u);if(u.createIIRFilter===void 0?d=e(u,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):p||(f=u.createIIRFilter(o,a)),s.set(u,d===null?f:d),d!==null){if(c===null){if(n===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let e=new n(l.context.destination.channelCount,l.context.length,u.sampleRate);c=(async()=>(await r(l,e,e.destination),Rn(await i(e),u,a,o)))()}let e=await c;return d.buffer=e,d.start(0),d}return await r(l,u,f),f};return{render(e,t){let n=s.get(t);return n===void 0?l(e,t):Promise.resolve(n)}}},Bn=(e,t,n,r,i,a)=>o=>(s,c)=>{let l=e.get(s);if(l===void 0){if(!o&&a(s)){let e=r(s),{outputs:a}=n(s);for(let n of a)if(qe(n))t(e,r(n[0]),n[1],n[2]);else{let t=i(n[0]);e.disconnect(t,n[1])}}e.set(s,c)}else e.set(s,l+c)},Vn=(e,t)=>n=>t(e.get(n))||t(n),Hn=(e,t)=>n=>e.has(n)||t(n),Un=(e,t)=>n=>e.has(n)||t(n),Wn=(e,t)=>n=>t(e.get(n))||t(n),Gn=e=>t=>e!==null&&t instanceof e,Kn=e=>t=>e!==null&&typeof e.AudioNode==`function`&&t instanceof e.AudioNode,qn=e=>t=>e!==null&&typeof e.AudioParam==`function`&&t instanceof e.AudioParam,Jn=(e,t)=>n=>e(n)||t(n),Yn=e=>t=>e!==null&&t instanceof e,Xn=e=>e!==null&&e.isSecureContext,Zn=async(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>e(t,t)&&e(n,n)&&e(i,i)&&e(a,a)&&e(s,s)&&e(c,c)&&e(l,l)&&e(u,u)&&e(d,d)&&e(f,f)&&e(p,p)?(await Promise.all([e(r,r),e(o,o),e(m,m),e(h,h)])).every(e=>e):!1,Qn=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e),o=t(a,i);if(r(a))throw TypeError();super(e,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}},$n={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`},er=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e);if(r(a))throw TypeError();let o=t(a,{...$n,...i});super(e,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},tr=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e),o=t(a,i);if(r(a))throw TypeError();super(e,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},nr=(e,t,n)=>class extends e{constructor(e,r){let i=t(n(e),r);super(e,!0,i,null)}},rr=(e,t,n,r,i,a)=>class extends n{constructor(n,a){super(n),this._nativeContext=n,w.set(this,n),r(n)&&i.set(n,new Set),this._destination=new e(this,a),this._listener=t(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(e){let t=typeof e==`function`?a(this,e):null;this._nativeContext.onstatechange=t;let n=this._nativeContext.onstatechange;this._onstatechange=n!==null&&n===t?e:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},ir=e=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let n=e.decodeAudioData(t.buffer,()=>{});return n!==void 0&&(n.catch(()=>{}),!0)}catch{}return!1},ar=(e,t)=>(n,r,i)=>{let a=new Set;return n.connect=(i=>(o,s=0,c=0)=>{let l=a.size===0;if(t(o))return i.call(n,o,s,c),e(a,[o,s,c],e=>e[0]===o&&e[1]===s&&e[2]===c,!0),l&&r(),o;i.call(n,o,s),e(a,[o,s],e=>e[0]===o&&e[1]===s,!0),l&&r()})(n.connect),n.disconnect=(e=>(r,o,s)=>{let c=a.size>0;if(r===void 0)e.apply(n),a.clear();else if(typeof r==`number`){e.call(n,r);for(let e of a)e[1]===r&&a.delete(e)}else{t(r)?e.call(n,r,o,s):e.call(n,r,o);for(let e of a)e[0]!==r||o!==void 0&&e[1]!==o||s!==void 0&&e[2]!==s||a.delete(e)}let l=a.size===0;c&&l&&i()})(n.disconnect),n},N=(e,t,n)=>{let r=t[n];r!==void 0&&r!==e[n]&&(e[n]=r)},or=(e,t)=>{N(e,t,`channelCount`),N(e,t,`channelCountMode`),N(e,t,`channelInterpretation`)},sr=e=>typeof e.getFloatTimeDomainData==`function`,cr=e=>{e.getFloatTimeDomainData=t=>{let n=new Uint8Array(t.length);e.getByteTimeDomainData(n);let r=Math.max(n.length,e.fftSize);for(let e=0;e<r;e+=1)t[e]=(n[e]-128)*.0078125;return t}},lr=(e,t)=>(n,r)=>{let i=n.createAnalyser();if(or(i,r),!(r.maxDecibels>r.minDecibels))throw t();return N(i,r,`fftSize`),N(i,r,`maxDecibels`),N(i,r,`minDecibels`),N(i,r,`smoothingTimeConstant`),e(sr,()=>sr(i))||cr(i),i},ur=e=>e===null?null:e.hasOwnProperty(`AudioBuffer`)?e.AudioBuffer:null,P=(e,t,n)=>{let r=t[n];r!==void 0&&r!==e[n].value&&(e[n].value=r)},dr=e=>{e.start=(t=>{let n=!1;return(r=0,i=0,a)=>{if(n)throw kn();t.call(e,r,i,a),n=!0}})(e.start)},fr=e=>{e.start=(t=>(n=0,r=0,i)=>{if(typeof i==`number`&&i<0||r<0||n<0)throw RangeError(`The parameters can't be negative.`);t.call(e,n,r,i)})(e.start)},pr=e=>{e.stop=(t=>(n=0)=>{if(n<0)throw RangeError(`The parameter can't be negative.`);t.call(e,n)})(e.stop)},mr=(e,t,n,r,i,a,o,s,c,l,u)=>(d,f)=>{let p=d.createBufferSource();return or(p,f),P(p,f,`playbackRate`),N(p,f,`buffer`),N(p,f,`loop`),N(p,f,`loopEnd`),N(p,f,`loopStart`),t(n,()=>n(d))||dr(p),t(r,()=>r(d))||c(p),t(i,()=>i(d))||l(p,d),t(a,()=>a(d))||fr(p),t(o,()=>o(d))||u(p,d),t(s,()=>s(d))||pr(p),e(d,p),p},hr=e=>e===null?null:e.hasOwnProperty(`AudioContext`)?e.AudioContext:e.hasOwnProperty(`webkitAudioContext`)?e.webkitAudioContext:null,gr=(e,t)=>(n,r,i)=>{let a=n.destination;if(a.channelCount!==r)try{a.channelCount=r}catch{}i&&a.channelCountMode!==`explicit`&&(a.channelCountMode=`explicit`),a.maxChannelCount===0&&Object.defineProperty(a,"maxChannelCount",{value:r});let o=e(n,{channelCount:r,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,gain:1});return t(o,`channelCount`,e=>()=>e.call(o),e=>t=>{e.call(o,t);try{a.channelCount=t}catch(e){if(t>a.maxChannelCount)throw e}}),t(o,`channelCountMode`,e=>()=>e.call(o),e=>t=>{e.call(o,t),a.channelCountMode=t}),t(o,`channelInterpretation`,e=>()=>e.call(o),e=>t=>{e.call(o,t),a.channelInterpretation=t}),Object.defineProperty(o,"maxChannelCount",{get:()=>a.maxChannelCount}),o.connect(a),o},_r=e=>e===null?null:e.hasOwnProperty(`AudioWorkletNode`)?e.AudioWorkletNode:null,vr=e=>{let{port1:t}=new MessageChannel;try{t.postMessage(e)}finally{t.close()}},yr=(e,t,n,r,i)=>(a,o,s,c,l,u)=>{if(s!==null)try{let t=new s(a,c,u),r=new Map,o=null;if(Object.defineProperties(t,{channelCount:{get:()=>u.channelCount,set:()=>{throw e()}},channelCountMode:{get:()=>`explicit`,set:()=>{throw e()}},onprocessorerror:{get:()=>o,set:e=>{typeof o==`function`&&t.removeEventListener(`processorerror`,o),o=typeof e==`function`?e:null,typeof o==`function`&&t.addEventListener(`processorerror`,o)}}}),t.addEventListener=(e=>(...n)=>{if(n[0]===`processorerror`){let e=typeof n[1]==`function`?n[1]:typeof n[1]==`object`&&n[1]!==null&&typeof n[1].handleEvent==`function`?n[1].handleEvent:null;if(e!==null){let t=r.get(n[1]);t===void 0?(n[1]=t=>{t.type===`error`?(Object.defineProperties(t,{type:{value:`processorerror`}}),e(t)):e(new ErrorEvent(n[0],{...t}))},r.set(e,n[1])):n[1]=t}}return e.call(t,`error`,n[1],n[2]),e.call(t,...n)})(t.addEventListener),t.removeEventListener=(e=>(...n)=>{if(n[0]===`processorerror`){let e=r.get(n[1]);e!==void 0&&(r.delete(n[1]),n[1]=e)}return e.call(t,`error`,n[1],n[2]),e.call(t,n[0],n[1],n[2])})(t.removeEventListener),u.numberOfOutputs!==0){let e=n(a,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});return t.connect(e).connect(a.destination),i(t,()=>e.disconnect(),()=>e.connect(a.destination))}return t}catch(e){throw e.code===11?r():e}if(l===void 0)throw r();return vr(u),t(a,o,l,u)},br=(e,t)=>e===null?512:Math.max(512,Math.min(16384,2**Math.round(Math.log2(e*t)))),xr=e=>new Promise((t,n)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:e})=>{r.close(),i.close(),t(e)},r.onmessageerror=({data:e})=>{r.close(),i.close(),n(e)},i.postMessage(e)}),Sr=async(e,t)=>new e(await xr(t)),Cr=(e,t,n,r)=>{let i=O.get(e);i===void 0&&(i=new WeakMap,O.set(e,i));let a=Sr(n,r);return i.set(t,a),a},wr=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>(p,m,h,g)=>{if(g.numberOfInputs===0&&g.numberOfOutputs===0)throw c();let _=Array.isArray(g.outputChannelCount)?g.outputChannelCount:Array.from(g.outputChannelCount);if(_.some(e=>e<1))throw c();if(_.length!==g.numberOfOutputs)throw t();if(g.channelCountMode!==`explicit`)throw c();let v=g.channelCount*g.numberOfInputs,y=_.reduce((e,t)=>e+t,0),b=h.parameterDescriptors===void 0?0:h.parameterDescriptors.length;if(v+b>6||y>6)throw c();let x=new MessageChannel,S=[],C=[];for(let e=0;e<g.numberOfInputs;e+=1)S.push(o(p,{channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation,gain:1})),C.push(i(p,{channelCount:g.channelCount,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:g.channelCount}));let w=[];if(h.parameterDescriptors!==void 0)for(let{defaultValue:e,maxValue:t,minValue:n,name:r}of h.parameterDescriptors){let i=a(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:g.parameterData[r]===void 0?e===void 0?0:e:g.parameterData[r]});Object.defineProperties(i.offset,{defaultValue:{get:()=>e===void 0?0:e},maxValue:{get:()=>t===void 0?Ee:t},minValue:{get:()=>n===void 0?Te:n}}),w.push(i)}let T=r(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:Math.max(1,v+b)}),E=br(m,p.sampleRate),D=s(p,E,v+b,Math.max(1,y)),O=i(p,{channelCount:Math.max(1,y),channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:Math.max(1,y)}),ee=[];for(let e=0;e<g.numberOfOutputs;e+=1)ee.push(r(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:_[e]}));for(let e=0;e<g.numberOfInputs;e+=1){S[e].connect(C[e]);for(let t=0;t<g.channelCount;t+=1)C[e].connect(T,t,e*g.channelCount+t)}let te=new St(h.parameterDescriptors===void 0?[]:h.parameterDescriptors.map(({name:e},t)=>{let n=w[t];return n.connect(T,0,v+t),n.start(0),[e,n.offset]}));T.connect(D);let ne=g.channelInterpretation,re=null,ie=g.numberOfOutputs===0?[D]:ee,ae={get bufferSize(){return E},get channelCount(){return g.channelCount},set channelCount(e){throw n()},get channelCountMode(){return g.channelCountMode},set channelCountMode(e){throw n()},get channelInterpretation(){return ne},set channelInterpretation(e){for(let t of S)t.channelInterpretation=e;ne=e},get context(){return D.context},get inputs(){return S},get numberOfInputs(){return g.numberOfInputs},get numberOfOutputs(){return g.numberOfOutputs},get onprocessorerror(){return re},set onprocessorerror(e){typeof re==`function`&&ae.removeEventListener(`processorerror`,re),re=typeof e==`function`?e:null,typeof re==`function`&&ae.addEventListener(`processorerror`,re)},get parameters(){return te},get port(){return x.port2},addEventListener(...e){return D.addEventListener(e[0],e[1],e[2])},connect:e.bind(null,ie),disconnect:l.bind(null,ie),dispatchEvent(...e){return D.dispatchEvent(e[0])},removeEventListener(...e){return D.removeEventListener(e[0],e[1],e[2])}},oe=new Map;x.port1.addEventListener=(e=>(...t)=>{if(t[0]===`message`){let e=typeof t[1]==`function`?t[1]:typeof t[1]==`object`&&t[1]!==null&&typeof t[1].handleEvent==`function`?t[1].handleEvent:null;if(e!==null){let n=oe.get(t[1]);n===void 0?(t[1]=t=>{u(p.currentTime,p.sampleRate,()=>e(t))},oe.set(e,t[1])):t[1]=n}}return e.call(x.port1,t[0],t[1],t[2])})(x.port1.addEventListener),x.port1.removeEventListener=(e=>(...t)=>{if(t[0]===`message`){let e=oe.get(t[1]);e!==void 0&&(oe.delete(t[1]),t[1]=e)}return e.call(x.port1,t[0],t[1],t[2])})(x.port1.removeEventListener);let k=null;Object.defineProperty(x.port1,"onmessage",{get:()=>k,set:e=>{typeof k==`function`&&x.port1.removeEventListener(`message`,k),k=typeof e==`function`?e:null,typeof k==`function`&&(x.port1.addEventListener(`message`,k),x.port1.start())}}),h.prototype.port=x.port1;let A=null;Cr(p,ae,h,g).then(e=>A=e);let se=Dt(g.numberOfInputs,g.channelCount),ce=Dt(g.numberOfOutputs,_),le=h.parameterDescriptors===void 0?[]:h.parameterDescriptors.reduce((e,{name:t})=>({...e,[t]:new Float32Array(128)}),{}),j=!0,ue=()=>{g.numberOfOutputs>0&&D.disconnect(O);for(let e=0,t=0;e<g.numberOfOutputs;e+=1){let n=ee[e];for(let r=0;r<_[e];r+=1)O.disconnect(n,t+r,r);t+=_[e]}},de=new Map;D.onaudioprocess=({inputBuffer:e,outputBuffer:t})=>{if(A!==null){let n=d(ae);for(let r=0;r<E;r+=128){for(let t=0;t<g.numberOfInputs;t+=1)for(let n=0;n<g.channelCount;n+=1)Tt(e,se[t],n,n,r);h.parameterDescriptors!==void 0&&h.parameterDescriptors.forEach(({name:t},n)=>{Tt(e,le,t,v+n,r)});for(let e=0;e<g.numberOfInputs;e+=1)for(let t=0;t<_[e];t+=1)ce[e][t].byteLength===0&&(ce[e][t]=new Float32Array(128));try{let e=se.map((e,t)=>{if(n[t].size>0)return de.set(t,E/128),e;let r=de.get(t);return r===void 0?[]:(e.every(e=>e.every(e=>e===0))&&(r===1?de.delete(t):de.set(t,r-1)),e)});j=u(p.currentTime+r/p.sampleRate,p.sampleRate,()=>A.process(e,ce,le));for(let e=0,n=0;e<g.numberOfOutputs;e+=1){for(let i=0;i<_[e];i+=1)Et(t,ce[e],i,n+i,r);n+=_[e]}}catch(e){j=!1,ae.dispatchEvent(new ErrorEvent(`processorerror`,{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}))}if(!j){for(let e=0;e<g.numberOfInputs;e+=1){S[e].disconnect(C[e]);for(let t=0;t<g.channelCount;t+=1)C[r].disconnect(T,t,e*g.channelCount+t)}if(h.parameterDescriptors!==void 0){let e=h.parameterDescriptors.length;for(let t=0;t<e;t+=1){let e=w[t];e.disconnect(T,0,v+t),e.stop()}}T.disconnect(D),D.onaudioprocess=null,fe?ue():he();break}}}};let fe=!1,pe=o(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0}),me=()=>D.connect(pe).connect(p.destination),he=()=>{D.disconnect(pe),pe.disconnect()};return me(),f(ae,()=>{if(j){he(),g.numberOfOutputs>0&&D.connect(O);for(let e=0,t=0;e<g.numberOfOutputs;e+=1){let n=ee[e];for(let r=0;r<_[e];r+=1)O.connect(n,t+r,r);t+=_[e]}}fe=!0},()=>{j&&(me(),ue()),fe=!1})},Tr=(e,t)=>{let n=e.createBiquadFilter();return or(n,t),P(n,t,`Q`),P(n,t,`detune`),P(n,t,`frequency`),P(n,t,`gain`),N(n,t,`type`),n},Er=(e,t)=>(n,r)=>{let i=n.createChannelMerger(r.numberOfInputs);return e!==null&&e.name===`webkitAudioContext`&&t(n,i),or(i,r),i},Dr=e=>{let t=e.numberOfOutputs;Object.defineProperty(e,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw kn()}}),Object.defineProperty(e,"channelCountMode",{get:()=>`explicit`,set:e=>{if(e!==`explicit`)throw kn()}}),Object.defineProperty(e,"channelInterpretation",{get:()=>`discrete`,set:e=>{if(e!==`discrete`)throw kn()}})},Or=(e,t)=>{let n=e.createChannelSplitter(t.numberOfOutputs);return or(n,t),Dr(n),n},kr=(e,t,n,r,i)=>(a,o)=>{if(a.createConstantSource===void 0)return n(a,o);let s=a.createConstantSource();return or(s,o),P(s,o,`offset`),t(r,()=>r(a))||fr(s),t(i,()=>i(a))||pr(s),e(a,s),s},Ar=(e,t)=>(e.connect=t.connect.bind(t),e.disconnect=t.disconnect.bind(t),e),jr=(e,t,n,r)=>(i,{offset:a,...o})=>{let s=i.createBuffer(1,2,44100),c=t(i,{buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),l=n(i,{...o,gain:a}),u=s.getChannelData(0);return u[0]=1,u[1]=1,c.buffer=s,c.loop=!0,e(i,c),r(Ar({get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(e){l.channelCount=e},get channelCountMode(){return l.channelCountMode},set channelCountMode(e){l.channelCountMode=e},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(e){l.channelInterpretation=e},get context(){return l.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get offset(){return l.gain},get onended(){return c.onended},set onended(e){c.onended=e},addEventListener(...e){return c.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return c.dispatchEvent(e[0])},removeEventListener(...e){return c.removeEventListener(e[0],e[1],e[2])},start(e=0){c.start.call(c,e)},stop(e=0){c.stop.call(c,e)}},l),()=>c.connect(l),()=>c.disconnect(l))},Mr=(e,t)=>(n,r)=>{let i=n.createConvolver();if(or(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),N(i,r,`buffer`),r.channelCount>2||(t(i,`channelCount`,e=>()=>e.call(i),t=>n=>{if(n>2)throw e();return t.call(i,n)}),r.channelCountMode===`max`))throw e();return t(i,`channelCountMode`,e=>()=>e.call(i),t=>n=>{if(n===`max`)throw e();return t.call(i,n)}),i},Nr=(e,t)=>{let n=e.createDelay(t.maxDelayTime);return or(n,t),P(n,t,`delayTime`),n},Pr=e=>(t,n)=>{let r=t.createDynamicsCompressor();if(or(r,n),n.channelCount>2||n.channelCountMode===`max`)throw e();return P(r,n,`attack`),P(r,n,`knee`),P(r,n,`ratio`),P(r,n,`release`),P(r,n,`threshold`),r},Fr=(e,t)=>{let n=e.createGain();return or(n,t),P(n,t,`gain`),n},Ir=e=>(t,n,r)=>{if(t.createIIRFilter===void 0)return e(t,n,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return or(i,r),i};function Lr(e,t){let n=t[0]*t[0]+t[1]*t[1];return[(e[0]*t[0]+e[1]*t[1])/n,(e[1]*t[0]-e[0]*t[1])/n]}function Rr(e,t){return[e[0]*t[0]-e[1]*t[1],e[0]*t[1]+e[1]*t[0]]}function zr(e,t){let n=[0,0];for(let r=e.length-1;r>=0;--r)n=Rr(n,t),n[0]+=e[r];return n}var Br=(e,t,n,r)=>(i,a,{channelCount:o,channelCountMode:s,channelInterpretation:c,feedback:l,feedforward:u})=>{let d=br(a,i.sampleRate),f=l instanceof Float64Array?l:new Float64Array(l),p=u instanceof Float64Array?u:new Float64Array(u),m=f.length,h=p.length,g=Math.min(m,h);if(m===0||m>20)throw r();if(f[0]===0)throw t();if(h===0||h>20)throw r();if(p[0]===0)throw t();if(f[0]!==1){for(let e=0;e<h;e+=1)p[e]/=f[0];for(let e=1;e<m;e+=1)f[e]/=f[0]}let _=n(i,d,o,o);_.channelCount=o,_.channelCountMode=s,_.channelInterpretation=c;let v=[],y=[],b=[];for(let e=0;e<o;e+=1){v.push(0);let e=new Float32Array(32),t=new Float32Array(32);e.fill(0),t.fill(0),y.push(e),b.push(t)}_.onaudioprocess=e=>{let t=e.inputBuffer,n=e.outputBuffer,r=t.numberOfChannels;for(let e=0;e<r;e+=1){let r=t.getChannelData(e),i=n.getChannelData(e);v[e]=Ln(f,m,p,h,g,y[e],b[e],v[e],32,r,i)}};let x=i.sampleRate/2;return Ar({get bufferSize(){return d},get channelCount(){return _.channelCount},set channelCount(e){_.channelCount=e},get channelCountMode(){return _.channelCountMode},set channelCountMode(e){_.channelCountMode=e},get channelInterpretation(){return _.channelInterpretation},set channelInterpretation(e){_.channelInterpretation=e},get context(){return _.context},get inputs(){return[_]},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},addEventListener(...e){return _.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return _.dispatchEvent(e[0])},getFrequencyResponse(t,n,r){if(t.length!==n.length||n.length!==r.length)throw e();let i=t.length;for(let e=0;e<i;e+=1){let i=-Math.PI*(t[e]/x),a=[Math.cos(i),Math.sin(i)],o=Lr(zr(p,a),zr(f,a));n[e]=Math.sqrt(o[0]*o[0]+o[1]*o[1]),r[e]=Math.atan2(o[1],o[0])}},removeEventListener(...e){return _.removeEventListener(e[0],e[1],e[2])}},_)},Vr=(e,t)=>e.createMediaElementSource(t.mediaElement),Hr=(e,t)=>{let n=e.createMediaStreamDestination();return or(n,t),n.numberOfOutputs===1&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n},Ur=(e,{mediaStream:t})=>{let n=t.getAudioTracks();n.sort((e,t)=>e.id<t.id?-1:+(e.id>t.id));let r=n.slice(0,1),i=e.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i},Wr=(e,t)=>(n,{mediaStreamTrack:r})=>{if(typeof n.createMediaStreamTrackSource==`function`)return n.createMediaStreamTrackSource(r);let i=new MediaStream([r]),a=n.createMediaStreamSource(i);if(r.kind!==`audio`)throw e();if(t(n))throw TypeError();return a},Gr=e=>e===null?null:e.hasOwnProperty(`OfflineAudioContext`)?e.OfflineAudioContext:e.hasOwnProperty(`webkitOfflineAudioContext`)?e.webkitOfflineAudioContext:null,Kr=(e,t,n,r,i,a)=>(o,s)=>{let c=o.createOscillator();return or(c,s),P(c,s,`detune`),P(c,s,`frequency`),s.periodicWave===void 0?N(c,s,`type`):c.setPeriodicWave(s.periodicWave),t(n,()=>n(o))||fr(c),t(r,()=>r(o))||a(c,o),t(i,()=>i(o))||pr(c),e(o,c),c},qr=e=>(t,n)=>{let r=t.createPanner();return r.orientationX===void 0?e(t,n):(or(r,n),P(r,n,`orientationX`),P(r,n,`orientationY`),P(r,n,`orientationZ`),P(r,n,`positionX`),P(r,n,`positionY`),P(r,n,`positionZ`),N(r,n,`coneInnerAngle`),N(r,n,`coneOuterAngle`),N(r,n,`coneOuterGain`),N(r,n,`distanceModel`),N(r,n,`maxDistance`),N(r,n,`panningModel`),N(r,n,`refDistance`),N(r,n,`rolloffFactor`),r)},Jr=(e,t,n,r,i,a,o,s,c,l)=>(u,{coneInnerAngle:d,coneOuterAngle:f,coneOuterGain:p,distanceModel:m,maxDistance:h,orientationX:g,orientationY:_,orientationZ:v,panningModel:y,positionX:b,positionY:x,positionZ:S,refDistance:C,rolloffFactor:w,...T})=>{let E=u.createPanner();if(T.channelCount>2||T.channelCountMode===`max`)throw o();or(E,T);let D={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`},O=n(u,{...D,channelInterpretation:`speakers`,numberOfInputs:6}),ee=r(u,{...T,gain:1}),te=r(u,{...D,gain:1}),ne=r(u,{...D,gain:0}),re=r(u,{...D,gain:0}),ie=r(u,{...D,gain:0}),ae=r(u,{...D,gain:0}),oe=r(u,{...D,gain:0}),k=i(u,256,6,1),A=a(u,{...D,curve:new Float32Array([1,1]),oversample:`none`}),se=[g,_,v],ce=[b,x,S],le=new Float32Array(1);k.onaudioprocess=({inputBuffer:e})=>{let t=[c(e,le,0),c(e,le,1),c(e,le,2)];t.some((e,t)=>e!==se[t])&&(E.setOrientation(...t),se=t);let n=[c(e,le,3),c(e,le,4),c(e,le,5)];n.some((e,t)=>e!==ce[t])&&(E.setPosition(...n),ce=n)},Object.defineProperty(ne.gain,"defaultValue",{get:()=>0}),Object.defineProperty(re.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ie.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ae.gain,"defaultValue",{get:()=>0}),Object.defineProperty(oe.gain,"defaultValue",{get:()=>0});let j={get bufferSize(){},get channelCount(){return E.channelCount},set channelCount(e){if(e>2)throw o();ee.channelCount=e,E.channelCount=e},get channelCountMode(){return E.channelCountMode},set channelCountMode(e){if(e===`max`)throw o();ee.channelCountMode=e,E.channelCountMode=e},get channelInterpretation(){return E.channelInterpretation},set channelInterpretation(e){ee.channelInterpretation=e,E.channelInterpretation=e},get coneInnerAngle(){return E.coneInnerAngle},set coneInnerAngle(e){E.coneInnerAngle=e},get coneOuterAngle(){return E.coneOuterAngle},set coneOuterAngle(e){E.coneOuterAngle=e},get coneOuterGain(){return E.coneOuterGain},set coneOuterGain(e){if(e<0||e>1)throw t();E.coneOuterGain=e},get context(){return E.context},get distanceModel(){return E.distanceModel},set distanceModel(e){E.distanceModel=e},get inputs(){return[ee]},get maxDistance(){return E.maxDistance},set maxDistance(e){if(e<0)throw RangeError();E.maxDistance=e},get numberOfInputs(){return E.numberOfInputs},get numberOfOutputs(){return E.numberOfOutputs},get orientationX(){return te.gain},get orientationY(){return ne.gain},get orientationZ(){return re.gain},get panningModel(){return E.panningModel},set panningModel(e){E.panningModel=e},get positionX(){return ie.gain},get positionY(){return ae.gain},get positionZ(){return oe.gain},get refDistance(){return E.refDistance},set refDistance(e){if(e<0)throw RangeError();E.refDistance=e},get rolloffFactor(){return E.rolloffFactor},set rolloffFactor(e){if(e<0)throw RangeError();E.rolloffFactor=e},addEventListener(...e){return ee.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return ee.dispatchEvent(e[0])},removeEventListener(...e){return ee.removeEventListener(e[0],e[1],e[2])}};return d!==j.coneInnerAngle&&(j.coneInnerAngle=d),f!==j.coneOuterAngle&&(j.coneOuterAngle=f),p!==j.coneOuterGain&&(j.coneOuterGain=p),m!==j.distanceModel&&(j.distanceModel=m),h!==j.maxDistance&&(j.maxDistance=h),g!==j.orientationX.value&&(j.orientationX.value=g),_!==j.orientationY.value&&(j.orientationY.value=_),v!==j.orientationZ.value&&(j.orientationZ.value=v),y!==j.panningModel&&(j.panningModel=y),b!==j.positionX.value&&(j.positionX.value=b),x!==j.positionY.value&&(j.positionY.value=x),S!==j.positionZ.value&&(j.positionZ.value=S),C!==j.refDistance&&(j.refDistance=C),w!==j.rolloffFactor&&(j.rolloffFactor=w),(se[0]!==1||se[1]!==0||se[2]!==0)&&E.setOrientation(...se),(ce[0]!==0||ce[1]!==0||ce[2]!==0)&&E.setPosition(...ce),l(Ar(j,E),()=>{ee.connect(E),e(ee,A,0,0),A.connect(te).connect(O,0,0),A.connect(ne).connect(O,0,1),A.connect(re).connect(O,0,2),A.connect(ie).connect(O,0,3),A.connect(ae).connect(O,0,4),A.connect(oe).connect(O,0,5),O.connect(k).connect(u.destination)},()=>{ee.disconnect(E),s(ee,A,0,0),A.disconnect(te),te.disconnect(O),A.disconnect(ne),ne.disconnect(O),A.disconnect(re),re.disconnect(O),A.disconnect(ie),ie.disconnect(O),A.disconnect(ae),ae.disconnect(O),A.disconnect(oe),oe.disconnect(O),O.disconnect(k),k.disconnect(u.destination)})},Yr=e=>(t,{disableNormalization:n,imag:r,real:i})=>{let a=r instanceof Float32Array?r:new Float32Array(r),o=i instanceof Float32Array?i:new Float32Array(i),s=t.createPeriodicWave(o,a,{disableNormalization:n});if(Array.from(r).length<2)throw e();return s},Xr=(e,t,n,r)=>e.createScriptProcessor(t,n,r),Zr=(e,t)=>(n,r)=>{let i=r.channelCountMode;if(i===`clamped-max`)throw t();if(n.createStereoPanner===void 0)return e(n,r);let a=n.createStereoPanner();return or(a,r),P(a,r,`pan`),Object.defineProperty(a,"channelCountMode",{get:()=>i,set:e=>{if(e!==i)throw t()}}),a},Qr=(e,t,n,r,i,a)=>{let o=16385,s=new Float32Array([1,1]),c=Math.PI/2,l={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`},u={...l,oversample:`none`},d=(e,t,i,a)=>{let d=new Float32Array(o),f=new Float32Array(o);for(let e=0;e<o;e+=1){let t=e/16384*c;d[e]=Math.cos(t),f[e]=Math.sin(t)}let p=n(e,{...l,gain:0}),m=r(e,{...u,curve:d}),h=r(e,{...u,curve:s}),g=n(e,{...l,gain:0}),_=r(e,{...u,curve:f});return{connectGraph(){t.connect(p),t.connect(h.inputs===void 0?h:h.inputs[0]),t.connect(g),h.connect(i),i.connect(m.inputs===void 0?m:m.inputs[0]),i.connect(_.inputs===void 0?_:_.inputs[0]),m.connect(p.gain),_.connect(g.gain),p.connect(a,0,0),g.connect(a,0,1)},disconnectGraph(){t.disconnect(p),t.disconnect(h.inputs===void 0?h:h.inputs[0]),t.disconnect(g),h.disconnect(i),i.disconnect(m.inputs===void 0?m:m.inputs[0]),i.disconnect(_.inputs===void 0?_:_.inputs[0]),m.disconnect(p.gain),_.disconnect(g.gain),p.disconnect(a,0,0),g.disconnect(a,0,1)}}},f=(e,i,a,d)=>{let f=new Float32Array(o),p=new Float32Array(o),m=new Float32Array(o),h=new Float32Array(o),g=8192;for(let e=0;e<o;e+=1)if(e>g){let t=(e-g)/8192*c;f[e]=Math.cos(t),p[e]=Math.sin(t),m[e]=0,h[e]=1}else{let t=e/8192*c;f[e]=1,p[e]=0,m[e]=Math.cos(t),h[e]=Math.sin(t)}let _=t(e,{channelCount:2,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:2}),v=n(e,{...l,gain:0}),y=r(e,{...u,curve:f}),b=n(e,{...l,gain:0}),x=r(e,{...u,curve:p}),S=r(e,{...u,curve:s}),C=n(e,{...l,gain:0}),w=r(e,{...u,curve:m}),T=n(e,{...l,gain:0}),E=r(e,{...u,curve:h});return{connectGraph(){i.connect(_),i.connect(S.inputs===void 0?S:S.inputs[0]),_.connect(v,0),_.connect(b,0),_.connect(C,1),_.connect(T,1),S.connect(a),a.connect(y.inputs===void 0?y:y.inputs[0]),a.connect(x.inputs===void 0?x:x.inputs[0]),a.connect(w.inputs===void 0?w:w.inputs[0]),a.connect(E.inputs===void 0?E:E.inputs[0]),y.connect(v.gain),x.connect(b.gain),w.connect(C.gain),E.connect(T.gain),v.connect(d,0,0),C.connect(d,0,0),b.connect(d,0,1),T.connect(d,0,1)},disconnectGraph(){i.disconnect(_),i.disconnect(S.inputs===void 0?S:S.inputs[0]),_.disconnect(v,0),_.disconnect(b,0),_.disconnect(C,1),_.disconnect(T,1),S.disconnect(a),a.disconnect(y.inputs===void 0?y:y.inputs[0]),a.disconnect(x.inputs===void 0?x:x.inputs[0]),a.disconnect(w.inputs===void 0?w:w.inputs[0]),a.disconnect(E.inputs===void 0?E:E.inputs[0]),y.disconnect(v.gain),x.disconnect(b.gain),w.disconnect(C.gain),E.disconnect(T.gain),v.disconnect(d,0,0),C.disconnect(d,0,0),b.disconnect(d,0,1),T.disconnect(d,0,1)}}},p=(e,t,n,r,a)=>{if(t===1)return d(e,n,r,a);if(t===2)return f(e,n,r,a);throw i()};return(t,{channelCount:r,channelCountMode:o,pan:s,...c})=>{if(o===`max`)throw i();let l=e(t,{...c,channelCount:1,channelCountMode:o,numberOfInputs:2}),u=n(t,{...c,channelCount:r,channelCountMode:o,gain:1}),d=n(t,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:s}),{connectGraph:f,disconnectGraph:m}=p(t,r,u,d,l);Object.defineProperty(d.gain,"defaultValue",{get:()=>0}),Object.defineProperty(d.gain,"maxValue",{get:()=>1}),Object.defineProperty(d.gain,"minValue",{get:()=>-1});let h={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(e){u.channelCount!==e&&(g&&m(),{connectGraph:f,disconnectGraph:m}=p(t,e,u,d,l),g&&f()),u.channelCount=e},get channelCountMode(){return u.channelCountMode},set channelCountMode(e){if(e===`clamped-max`||e===`max`)throw i();u.channelCountMode=e},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(e){u.channelInterpretation=e},get context(){return u.context},get inputs(){return[u]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get pan(){return d.gain},addEventListener(...e){return u.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return u.dispatchEvent(e[0])},removeEventListener(...e){return u.removeEventListener(e[0],e[1],e[2])}},g=!1;return a(Ar(h,l),()=>{f(),g=!0},()=>{m(),g=!1})}},$r=(e,t,n,r,i,a,o)=>(s,c)=>{let l=s.createWaveShaper();if(a!==null&&a.name===`webkitAudioContext`&&s.createGain().gain.automationRate===void 0)return n(s,c);or(l,c);let u=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(u!==null&&u.length<2)throw t();N(l,{curve:u},`curve`),N(l,c,`oversample`);let d=null,f=!1;return o(l,`curve`,e=>()=>e.call(l),t=>n=>(t.call(l,n),f&&(r(n)&&d===null?d=e(s,l):!r(n)&&d!==null&&(d(),d=null)),n)),i(l,()=>{f=!0,r(l.curve)&&(d=e(s,l))},()=>{f=!1,d!==null&&(d(),d=null)})},ei=(e,t,n,r,i)=>(a,{curve:o,oversample:s,...c})=>{let l=a.createWaveShaper(),u=a.createWaveShaper();or(l,c),or(u,c);let d=n(a,{...c,gain:1}),f=n(a,{...c,gain:-1}),p=n(a,{...c,gain:1}),m=n(a,{...c,gain:-1}),h=null,g=!1,_=null,v={get bufferSize(){},get channelCount(){return l.channelCount},set channelCount(e){d.channelCount=e,f.channelCount=e,l.channelCount=e,p.channelCount=e,u.channelCount=e,m.channelCount=e},get channelCountMode(){return l.channelCountMode},set channelCountMode(e){d.channelCountMode=e,f.channelCountMode=e,l.channelCountMode=e,p.channelCountMode=e,u.channelCountMode=e,m.channelCountMode=e},get channelInterpretation(){return l.channelInterpretation},set channelInterpretation(e){d.channelInterpretation=e,f.channelInterpretation=e,l.channelInterpretation=e,p.channelInterpretation=e,u.channelInterpretation=e,m.channelInterpretation=e},get context(){return l.context},get curve(){return _},set curve(n){if(n!==null&&n.length<2)throw t();if(n===null)l.curve=n,u.curve=n;else{let e=n.length,t=new Float32Array(e+2-e%2),r=new Float32Array(e+2-e%2);t[0]=n[0],r[0]=-n[e-1];let i=Math.ceil((e+1)/2),a=(e+1)/2-1;for(let o=1;o<i;o+=1){let s=o/i*a,c=Math.floor(s),l=Math.ceil(s);t[o]=c===l?n[c]:(1-(s-c))*n[c]+(1-(l-s))*n[l],r[o]=c===l?-n[e-1-c]:-((1-(s-c))*n[e-1-c])-(1-(l-s))*n[e-1-l]}t[i]=e%2==1?n[i-1]:(n[i-2]+n[i-1])/2,l.curve=t,u.curve=r}_=n,g&&(r(_)&&h===null?h=e(a,d):h!==null&&(h(),h=null))},get inputs(){return[d]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return l.numberOfOutputs},get oversample(){return l.oversample},set oversample(e){l.oversample=e,u.oversample=e},addEventListener(...e){return d.addEventListener(e[0],e[1],e[2])},dispatchEvent(...e){return d.dispatchEvent(e[0])},removeEventListener(...e){return d.removeEventListener(e[0],e[1],e[2])}};return o!==null&&(v.curve=o instanceof Float32Array?o:new Float32Array(o)),s!==v.oversample&&(v.oversample=s),i(Ar(v,p),()=>{d.connect(l).connect(p),d.connect(f).connect(u).connect(m).connect(p),g=!0,r(_)&&(h=e(a,d))},()=>{d.disconnect(l),l.disconnect(p),d.disconnect(f),f.disconnect(u),u.disconnect(m),m.disconnect(p),g=!1,h!==null&&(h(),h=null)})},ti=()=>new DOMException(``,`NotSupportedError`),ni={numberOfChannels:1},ri=(e,t,n,r,i)=>class extends e{constructor(e,n,i){let a;if(typeof e==`number`&&n!==void 0&&i!==void 0)a={length:n,numberOfChannels:e,sampleRate:i};else if(typeof e==`object`)a=e;else throw Error(`The given parameters are not valid.`);let{length:o,numberOfChannels:s,sampleRate:c}={...ni,...a},l=r(s,o,c);t(ir,()=>ir(l))||l.addEventListener(`statechange`,(()=>{let e=0,t=n=>{this._state===`running`&&(e>0?(l.removeEventListener(`statechange`,t),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):e+=1)};return t})()),super(l,s),this._length=o,this._nativeOfflineAudioContext=l,this._state=null}get length(){return this._nativeOfflineAudioContext.length===void 0?this._length:this._nativeOfflineAudioContext.length}get state(){return this._state===null?this._nativeOfflineAudioContext.state:this._state}startRendering(){return this._state===`running`?Promise.reject(n()):(this._state=`running`,i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Be(this)}))}_waitForThePromiseToSettle(e){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(e):setTimeout(()=>this._waitForThePromiseToSettle(e))}},ii={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,detune:0,frequency:440,periodicWave:void 0,type:`sine`},ai=(e,t,n,r,i,a,o)=>class extends e{constructor(e,o){let s=i(e),c={...ii,...o},l=n(s,c),u=a(s),d=u?r():null,f=e.sampleRate/2;super(e,!1,l,d),this._detune=t(this,u,l.detune,153600,-153600),this._frequency=t(this,u,l.frequency,f,-f),this._nativeOscillatorNode=l,this._onended=null,this._oscillatorNodeRenderer=d,this._oscillatorNodeRenderer!==null&&c.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=c.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(e){let t=typeof e==`function`?o(this,e):null;this._nativeOscillatorNode.onended=t;let n=this._nativeOscillatorNode.onended;this._onended=n!==null&&n===t?e:n}get type(){return this._nativeOscillatorNode.type}set type(e){this._nativeOscillatorNode.type=e,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(e){this._nativeOscillatorNode.setPeriodicWave(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=e)}start(e=0){if(this._nativeOscillatorNode.start(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=e),this.context.state!==`closed`){le(this);let e=()=>{this._nativeOscillatorNode.removeEventListener(`ended`,e),De(this)&&ue(this)};this._nativeOscillatorNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeOscillatorNode.stop(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=e)}},oi=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=null,l=async(l,u)=>{let d=n(l),f=ve(d,u);return f||(d=t(u,{channelCount:d.channelCount,channelCountMode:d.channelCountMode,channelInterpretation:d.channelInterpretation,detune:d.detune.value,frequency:d.frequency.value,periodicWave:o===null?void 0:o,type:d.type}),s!==null&&d.start(s),c!==null&&d.stop(c)),a.set(u,d),f?(await e(u,l.detune,d.detune),await e(u,l.frequency,d.frequency)):(await r(u,l.detune,d.detune),await r(u,l.frequency,d.frequency)),await i(l,u,d),d};return{set periodicWave(e){o=e},set start(e){s=e},set stop(e){c=e},render(e,t){let n=a.get(t);return n===void 0?l(e,t):Promise.resolve(n)}}},si={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},ci=(e,t,n,r,i,a,o)=>class extends e{constructor(e,s){let c=i(e),l=n(c,{...si,...s}),u=a(c),d=u?r():null;super(e,!1,l,d),this._nativePannerNode=l,this._orientationX=t(this,u,l.orientationX,Ee,Te),this._orientationY=t(this,u,l.orientationY,Ee,Te),this._orientationZ=t(this,u,l.orientationZ,Ee,Te),this._positionX=t(this,u,l.positionX,Ee,Te),this._positionY=t(this,u,l.positionY,Ee,Te),this._positionZ=t(this,u,l.positionZ,Ee,Te),o(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(e){this._nativePannerNode.coneInnerAngle=e}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(e){this._nativePannerNode.coneOuterAngle=e}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(e){this._nativePannerNode.coneOuterGain=e}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(e){this._nativePannerNode.distanceModel=e}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(e){this._nativePannerNode.maxDistance=e}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(e){this._nativePannerNode.panningModel=e}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(e){this._nativePannerNode.refDistance=e}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(e){this._nativePannerNode.rolloffFactor=e}},li=(e,t,n,r,i,a,o,s,c,l)=>()=>{let u=new WeakMap,d=null,f=async(f,p)=>{let m=null,h=a(f),g={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation},_={...g,coneInnerAngle:h.coneInnerAngle,coneOuterAngle:h.coneOuterAngle,coneOuterGain:h.coneOuterGain,distanceModel:h.distanceModel,maxDistance:h.maxDistance,panningModel:h.panningModel,refDistance:h.refDistance,rolloffFactor:h.rolloffFactor},v=ve(h,p);if(`bufferSize`in h?m=r(p,{...g,gain:1}):v||(h=i(p,{..._,orientationX:h.orientationX.value,orientationY:h.orientationY.value,orientationZ:h.orientationZ.value,positionX:h.positionX.value,positionY:h.positionY.value,positionZ:h.positionZ.value})),u.set(p,m===null?h:m),m!==null){if(d===null){if(o===null)throw Error(`Missing the native OfflineAudioContext constructor.`);let e=new o(6,f.context.length,p.sampleRate),r=t(e,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:6});r.connect(e.destination),d=(async()=>{let t=await Promise.all([f.orientationX,f.orientationY,f.orientationZ,f.positionX,f.positionY,f.positionZ].map(async(t,r)=>{let i=n(e,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,offset:+(r===0)});return await s(e,t,i.offset),i}));for(let e=0;e<6;e+=1)t[e].connect(r,0,e),t[e].start(0);return l(e)})()}let e=await d,a=r(p,{...g,gain:1});await c(f,p,a);let u=[];for(let t=0;t<e.numberOfChannels;t+=1)u.push(e.getChannelData(t));let h=[u[0][0],u[1][0],u[2][0]],v=[u[3][0],u[4][0],u[5][0]],y=r(p,{...g,gain:1}),b=i(p,{..._,orientationX:h[0],orientationY:h[1],orientationZ:h[2],positionX:v[0],positionY:v[1],positionZ:v[2]});a.connect(y).connect(b.inputs[0]),b.connect(m);for(let t=128;t<e.length;t+=128){let e=[u[0][t],u[1][t],u[2][t]],n=[u[3][t],u[4][t],u[5][t]];if(e.some((e,t)=>e!==h[t])||n.some((e,t)=>e!==v[t])){h=e,v=n;let o=t/p.sampleRate;y.gain.setValueAtTime(0,o),y=r(p,{...g,gain:0}),b=i(p,{..._,orientationX:h[0],orientationY:h[1],orientationZ:h[2],positionX:v[0],positionY:v[1],positionZ:v[2]}),y.gain.setValueAtTime(1,o),a.connect(y).connect(b.inputs[0]),b.connect(m)}}return m}return v?(await e(p,f.orientationX,h.orientationX),await e(p,f.orientationY,h.orientationY),await e(p,f.orientationZ,h.orientationZ),await e(p,f.positionX,h.positionX),await e(p,f.positionY,h.positionY),await e(p,f.positionZ,h.positionZ)):(await s(p,f.orientationX,h.orientationX),await s(p,f.orientationY,h.orientationY),await s(p,f.orientationZ,h.orientationZ),await s(p,f.positionX,h.positionX),await s(p,f.positionY,h.positionY),await s(p,f.positionZ,h.positionZ)),Ze(h)?await c(f,p,h.inputs[0]):await c(f,p,h),h};return{render(e,t){let n=u.get(t);return n===void 0?f(e,t):Promise.resolve(n)}}},ui={disableNormalization:!1},di=(e,t,n,r)=>class i{constructor(i,a){let o=e(t(i),r({...ui,...a}));return n.add(o),o}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===i.prototype||n.has(e)}},fi=(e,t)=>(n,r,i)=>(e(r).replay(i),t(r,n,i)),pi=(e,t,n)=>async(r,i,a)=>{let o=e(r);await Promise.all(o.activeInputs.map((e,o)=>Array.from(e).map(async([e,s])=>{let c=await t(e).render(e,i),l=r.context.destination;n(e)||r===l&&n(r)||c.connect(a,s,o)})).reduce((e,t)=>[...e,...t],[]))},mi=(e,t,n)=>async(r,i,a)=>{let o=t(r);await Promise.all(Array.from(o.activeInputs).map(async([t,r])=>{let o=await e(t).render(t,i);n(t)||o.connect(a,r)}))},hi=(e,t,n,r)=>i=>e(ir,()=>ir(i))?Promise.resolve(e(r,r)).then(e=>{if(!e){let e=n(i,512,0,1);i.oncomplete=()=>{e.onaudioprocess=null,e.disconnect()},e.onaudioprocess=()=>i.currentTime,e.connect(i.destination)}return i.startRendering()}):new Promise(e=>{let n=t(i,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});i.oncomplete=t=>{n.disconnect(),e(t.renderedBuffer)},n.connect(i.destination),i.startRendering()}),gi=e=>(t,n)=>{e.set(t,n)},_i=e=>(t,n)=>e.set(t,n),vi=(e,t,n,r,i,a,o,s)=>(c,l)=>n(c).render(c,l).then(()=>Promise.all(Array.from(r(l)).map(e=>n(e).render(e,l)))).then(()=>i(l)).then(n=>(typeof n.copyFromChannel==`function`?t(a,()=>a(n))||s(n):(o(n),Se(n)),e.add(n),n)),yi={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`,pan:0},bi=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=i(e),c=n(s,{...yi,...o}),l=a(s),u=l?r():null;super(e,!1,c,u),this._pan=t(this,l,c.pan)}get pan(){return this._pan}},xi=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=ve(c,s);return l||(c=t(s,{channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value})),a.set(s,c),l?await e(s,o.pan,c.pan):await r(s,o.pan,c.pan),Ze(c)?await i(o,s,c.inputs[0]):await i(o,s,c),c};return{render(e,t){let n=a.get(t);return n===void 0?o(e,t):Promise.resolve(n)}}},Si=e=>()=>{if(e===null)return!1;try{new e({length:1,sampleRate:44100})}catch{return!1}return!0},Ci=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100).createBuffer(1,1,44100);if(t.copyToChannel===void 0)return!0;let n=new Float32Array(2);try{t.copyFromChannel(n,0,0)}catch{return!1}return!0},wi=e=>()=>{if(e===null)return!1;if(e.prototype!==void 0&&e.prototype.close!==void 0)return!0;let t=new e,n=t.close!==void 0;try{t.close()}catch{}return n},Ti=e=>()=>{if(e===null)return Promise.resolve(!1);let t=new e(1,1,44100);return new Promise(e=>{let n=!0,r=r=>{n&&(n=!1,t.startRendering(),e(r instanceof TypeError))},i;try{i=t.decodeAudioData(null,()=>{},r)}catch(e){r(e)}i!==void 0&&i.catch(r)})},Ei=e=>()=>{if(e===null)return!1;let t;try{t=new e({latencyHint:`balanced`})}catch{return!1}return t.close(),!0},Di=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100).createGain(),n=t.connect(t)===t;return t.disconnect(t),n},Oi=(e,t)=>async()=>{if(e===null)return!0;if(t===null)return!1;let n=new Blob([`let c,p;class A extends AudioWorkletProcessor{constructor(){super();this.port.onmessage=(e)=>{p=e.data;p.onmessage=()=>{p.postMessage(c);p.close()};this.port.postMessage(0)}}process(){c=1}}registerProcessor("a",A)`],{type:`application/javascript; charset=utf-8`}),r=new MessageChannel,i=new t(1,128,44100),a=URL.createObjectURL(n),o=!1;try{await i.audioWorklet.addModule(a);let t=new e(i,`a`,{numberOfOutputs:0}),n=i.createOscillator();await new Promise(e=>{t.port.onmessage=()=>e(),t.port.postMessage(r.port2,[r.port2])}),t.port.onmessage=()=>o=!0,n.connect(t),n.start(0),await i.startRendering(),o=await new Promise(e=>{r.port1.onmessage=({data:t})=>e(t===1),r.port1.postMessage(0)})}catch{}finally{r.port1.close(),URL.revokeObjectURL(a)}return o},ki=(e,t)=>async()=>{if(e===null)return!0;if(t===null)return!1;let 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`}),r=new t(1,128,44100),i=URL.createObjectURL(n),a=!1,o=!1;try{await r.audioWorklet.addModule(i);let t=new e(r,`a`,{numberOfOutputs:0}),n=r.createOscillator();t.port.onmessage=()=>a=!0,t.onprocessorerror=()=>o=!0,n.connect(t),n.start(0),await r.startRendering(),await new Promise(e=>setTimeout(e))}catch{}finally{URL.revokeObjectURL(i)}return a&&!o},Ai=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100).createChannelMerger();if(t.channelCountMode===`max`)return!0;try{t.channelCount=2}catch{return!0}return!1},ji=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100);return t.createConstantSource===void 0||t.createConstantSource().offset.maxValue!==1/0},Mi=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100),n=t.createConvolver();n.buffer=t.createBuffer(1,1,t.sampleRate);try{n.buffer=t.createBuffer(1,1,t.sampleRate)}catch{return!1}return!0},Ni=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100).createConvolver();try{t.channelCount=1}catch{return!1}return!0},Pi=e=>()=>e!==null&&e.hasOwnProperty(`isSecureContext`),Fi=e=>()=>{if(e===null)return!1;let t=new e;try{return t.createMediaStreamSource(new MediaStream),!1}catch{return!0}finally{t.close()}},Ii=(e,t)=>()=>{if(t===null)return Promise.resolve(!1);let n=new t(1,1,44100),r=e(n,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0});return new Promise(e=>{n.oncomplete=()=>{r.disconnect(),e(n.currentTime!==0)},n.startRendering()})},Li=e=>()=>{if(e===null)return Promise.resolve(!1);let t=new e(1,1,44100);if(t.createStereoPanner===void 0||t.createConstantSource===void 0)return Promise.resolve(!0);let n=t.createConstantSource(),r=t.createStereoPanner();return n.channelCount=1,n.offset.value=1,r.channelCount=1,n.start(),n.connect(r).connect(t.destination),t.startRendering().then(e=>e.getChannelData(0)[0]!==1)},Ri=()=>new DOMException(``,`UnknownError`),zi={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,curve:null,oversample:`none`},Bi=(e,t,n,r,i,a,o)=>class extends e{constructor(e,t){let s=i(e),c=n(s,{...zi,...t}),l=a(s)?r():null;super(e,!0,c,l),this._isCurveNullified=!1,this._nativeWaveShaperNode=c,o(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(e){if(e===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(e.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=e}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(e){this._nativeWaveShaperNode.oversample=e}},Vi=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return ve(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample})),r.set(a,o),Ze(o)?await n(i,a,o.inputs[0]):await n(i,a,o),o};return{render(e,t){let n=r.get(t);return n===void 0?i(e,t):Promise.resolve(n)}}},Hi=()=>typeof window>`u`?null:window,Ui=(e,t)=>n=>{n.copyFromChannel=(r,i,a=0)=>{let o=e(a),s=e(i);if(s>=n.numberOfChannels)throw t();let c=n.length,l=n.getChannelData(s),u=r.length;for(let e=o<0?-o:0;e+o<c&&e<u;e+=1)r[e]=l[e+o]},n.copyToChannel=(r,i,a=0)=>{let o=e(a),s=e(i);if(s>=n.numberOfChannels)throw t();let c=n.length,l=n.getChannelData(s),u=r.length;for(let e=o<0?-o:0;e+o<c&&e<u;e+=1)l[e+o]=r[e]}},Wi=e=>t=>{t.copyFromChannel=(n=>(r,i,a=0)=>{let o=e(a),s=e(i);if(o<t.length)return n.call(t,r,s,o)})(t.copyFromChannel),t.copyToChannel=(n=>(r,i,a=0)=>{let o=e(a),s=e(i);if(o<t.length)return n.call(t,r,s,o)})(t.copyToChannel)},Gi=e=>(t,n)=>{let r=n.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),e(t,`buffer`,e=>()=>{let n=e.call(t);return n===r?null:n},e=>n=>e.call(t,n===null?r:n))},Ki=(e,t)=>(n,r)=>{r.channelCount=1,r.channelCountMode=`explicit`,Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw e()}}),Object.defineProperty(r,"channelCountMode",{get:()=>`explicit`,set:()=>{throw e()}});let i=n.createBufferSource();t(r,()=>{let e=r.numberOfInputs;for(let t=0;t<e;t+=1)i.connect(r,0,t)},()=>i.disconnect(r))},qi=(e,t,n)=>e.copyFromChannel===void 0?e.getChannelData(n)[0]:(e.copyFromChannel(t,n),t[0]),Ji=e=>{if(e===null)return!1;let t=e.length;return t%2==0?e[t/2-1]+e[t/2]!==0:e[Math.floor(t/2)]!==0},Yi=(e,t,n,r)=>{let i=e;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:a,set:o}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,{get:n(a),set:r(o)})},Xi=e=>({...e,outputChannelCount:e.outputChannelCount===void 0?e.numberOfInputs===1&&e.numberOfOutputs===1?[e.channelCount]:Array.from({length:e.numberOfOutputs},()=>1):e.outputChannelCount}),Zi=e=>({...e,channelCount:e.numberOfOutputs}),Qi=e=>{let{imag:t,real:n}=e;return t===void 0?n===void 0?{...e,imag:[0,0],real:[0,0]}:{...e,imag:Array.from(n,()=>0),real:n}:n===void 0?{...e,imag:t,real:Array.from(t,()=>0)}:{...e,imag:t,real:n}},$i=(e,t,n)=>{try{e.setValueAtTime(t,n)}catch(r){if(r.code!==9)throw r;$i(e,t,n+1e-7)}},ea=e=>{let t=e.createBufferSource();t.start();try{t.start()}catch{return!0}return!1},ta=e=>{let t=e.createBufferSource();t.buffer=e.createBuffer(1,1,44100);try{t.start(0,1)}catch{return!1}return!0},na=e=>{let t=e.createBufferSource();t.start();try{t.stop()}catch{return!1}return!0},ra=e=>{let t=e.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1},ia=e=>{let t=e.createBuffer(1,1,44100),n=e.createBufferSource();n.buffer=t,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},aa=e=>{let t=e.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1},oa=e=>{let{port1:t,port2:n}=new MessageChannel;try{t.postMessage(e)}finally{t.close(),n.close()}},sa=()=>{try{new DOMException}catch{return!1}return!0},ca=()=>new Promise(e=>{let t=new ArrayBuffer(0),{port1:n,port2:r}=new MessageChannel;n.onmessage=({data:t})=>e(t!==null),r.postMessage(t,[t])}),la=e=>{e.start=(t=>(n=0,r=0,i)=>{let a=e.buffer,o=a===null?r:Math.min(a.duration,r);a!==null&&o>a.duration-.5/e.context.sampleRate?t.call(e,n,0,0):t.call(e,n,o,i)})(e.start)},ua=(e,t)=>{let n=t.createGain();e.connect(n);let r=(t=>()=>{t.call(e,n),e.removeEventListener(`ended`,r)})(e.disconnect);e.addEventListener(`ended`,r),Ar(e,n),e.stop=(t=>{let r=!1;return(i=0)=>{if(r)try{t.call(e,i)}catch{n.gain.setValueAtTime(0,i)}else t.call(e,i),r=!0}})(e.stop)},da=(e,t)=>n=>{let r={value:e};return Object.defineProperties(n,{currentTarget:r,target:r}),typeof t==`function`?t.call(e,n):t.handleEvent.call(e,n)},fa=g(Je),pa=pe(Je),ma=sn(A),ha=new WeakMap,ga=En(ha),_a=Ft(new Map,new WeakMap),va=Hi(),ya=lr(_a,xe),ba=Tn(Le),xa=pi(Le,ba,at),Sa=ye(ya,M,xa),F=An(w),Ca=Gr(va),I=Yn(Ca),wa=new WeakMap,Ta=vn(da),Ea=hr(va),Da=Gn(Ea),Oa=Kn(va),ka=qn(va),Aa=_r(va),L=yt(_(b),fe(fa,pa,Qe,ma,rt,Le,ga,ce,M,Je,De,at,ot),_a,Bn(E,rt,Le,M,it,De),xe,Nn,ti,nn(Qe,E,Le,M,it,F,De,I),un(wa,Le,k),Ta,F,Da,Oa,ka,I,Aa),ja=_e(L,Sa,xe,ya,F,I),Ma=new WeakSet,Na=ur(va),Pa=Jt(new Uint32Array(1)),Fa=Ui(Pa,xe),Ia=Wi(Pa),La=we(Ma,_a,ti,Na,Ca,Si(Na),Fa,Ia),Ra=me(Fr),za=mi(ba,Re,at),Ba=Ht(za),Va=mr(Ra,_a,ea,ta,na,ra,ia,aa,la,Gi(Yi),ua),Ha=fi(Dn(Re),za),Ua=Ae(Ba,Va,M,Ha,xa),Wa=bt(v(S),wa,C,xt,m.createCancelAndHoldAutomationEvent,m.createCancelScheduledValuesAutomationEvent,m.createExponentialRampToValueAutomationEvent,m.createLinearRampToValueAutomationEvent,m.createSetTargetAutomationEvent,m.createSetValueAutomationEvent,m.createSetValueCurveAutomationEvent,Ea,$i),Ga=ke(L,Ua,Wa,kn,Va,F,I,da),Ka=Ue(L,We,xe,kn,gr(Fr,Yi),F,I,xa),qa=Pt(Ba,Tr,M,Ha,xa),Ja=_i(ha),Ya=Nt(L,Wa,qa,Nn,Tr,F,I,Ja),Xa=ar(Je,Oa),Za=Er(Ea,Ki(kn,Xa)),Qa=Lt(L,Rt(Za,M,xa),Za,F,I),$a=Bt(L,Vt(Or,M,xa),Or,F,I,Zi),eo=kr(Ra,_a,jr(Ra,Va,Fr,Xa),ra,aa),to=Kt(L,Wa,qt(Ba,eo,M,Ha,xa),eo,F,I,da),no=Mr(ti,Yi),ro=Xt(L,Zt(no,M,xa),no,F,I,Ja),io=an(L,Wa,on(Ba,Nr,M,Ha,xa),Nr,F,I,Ja),ao=Pr(ti),oo=mn(L,Wa,hn(Ba,ao,M,Ha,xa),ao,ti,F,I,Ja),so=Sn(L,Wa,Cn(Ba,Fr,M,Ha,xa),Fr,F,I),co=Br(Nn,kn,Xr,ti),lo=hi(_a,Fr,Xr,Ii(Fr,Ca)),uo=zn(Va,M,Ca,xa,lo),fo=In(L,Ir(co),uo,F,I,Ja),po=Ge(Wa,Za,eo,Xr,ti,qi,I,Yi),mo=new WeakMap,ho=rr(Ka,po,Ta,I,mo,da),go=Kr(Ra,_a,ra,ia,aa,ua),_o=ai(L,Wa,go,oi(Ba,go,M,Ha,xa),F,I,da),vo=Wt(Va),yo=$r(vo,kn,ei(vo,kn,Fr,Ji,Xa),Ji,Xa,Ea,Yi),bo=qr(Jr(Qe,kn,Za,Fr,Xr,yo,ti,rt,qi,Xa)),xo=ci(L,Wa,bo,li(Ba,Za,eo,Fr,bo,M,Ca,Ha,xa,lo),F,I,Ja),So=di(Yr(xe),F,new WeakSet,Qi),Co=Zr(Qr(Za,Or,Fr,yo,ti,Xa),ti),wo=bi(L,Wa,Co,xi(Ba,Co,M,Ha,xa),F,I),To=Bi(L,kn,yo,Vi(yo,M,xa),F,I,Ja),Eo=Xn(va),Do=yn(va),Oo=new WeakMap,ko=jn(Oo,Ca),Ao=Eo?oe(_a,ti,_n(va),Do,bn(h),F,ko,I,Aa,new WeakMap,new WeakMap,ki(Aa,Ca),va):void 0,jo=Jn(Da,I),Mo=jt(Ao,ja,La,Ga,Ya,Qa,$a,to,ro,tn(Ma,_a,$t,gn,new WeakSet,F,jo,be,ir,Fa,Ia),io,oo,so,fo,ho,_o,xo,So,wo,To),No=He(Mo,kn,ti,Ri,Qn(L,Vr,F,I),er(L,Hr,F,I),tr(L,Ur,F,I),nr(L,Wr(kn,I),F),Ea),Po=Mn(mo),Fo=he(Po),Io=Ut(xe),Lo=cn(Po),Ro=fn(xe),zo=new WeakMap,Bo=yr(kn,wr(Io,xe,kn,Za,Or,eo,Fr,Xr,ti,Ro,Do,wn(zo,k),Xa),Fr,ti,Xa),Vo=At(Ba,Io,Va,Za,Or,eo,Fr,Lo,Ro,Do,M,Aa,Ca,Ha,xa,lo),Ho=On(Oo),Uo=gi(zo),Wo=Eo?wt(Fo,L,Wa,Vo,Bo,Le,Ho,F,I,Aa,Xi,Uo,oa,da):void 0,Go=ri(Mo,_a,kn,Qt(ti,Ca),vi(Ma,_a,ba,Po,lo,be,Fa,Ia)),Ko=Vn(w,Da),qo=Hn(x,Oa),Jo=Un(C,ka),Yo=Wn(w,I),Xo=()=>Zn(_a,Ci(Ca),wi(Ea),Ti(Ca),Ei(Ea),Di(Ca),Oi(Aa,Ca),Ai(Ca),ji(Ca),Mi(Ca),Ni(Ca),sa,Pi(va),Fi(Ea),Li(Ca),ca);function Zo(e){return e===void 0}function R(e){return e!==void 0}function Qo(e){return typeof e==`function`}function $o(e){return typeof e==`number`}function es(e){return Object.prototype.toString.call(e)===`[object Object]`&&e.constructor===Object}function ts(e){return typeof e==`boolean`}function ns(e){return Array.isArray(e)}function rs(e){return typeof e==`string`}function is(e){return rs(e)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(e)}var as=e({assert:()=>z,assertContextRunning:()=>os,assertRange:()=>B,assertUsedScheduleTime:()=>us,enterScheduledCallback:()=>ls,log:()=>ps,setLogger:()=>fs,warn:()=>ms});function z(e,t){if(!e)throw Error(t)}function B(e,t,n=1/0){if(!(t<=e&&e<=n))throw RangeError(`Value must be within [${t}, ${n}], got: ${e}`)}function os(e){!e.isOffline&&e.state!==`running`&&ms(`The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.`)}var ss=!1,cs=!1;function ls(e){ss=e}function us(e){Zo(e)&&ss&&!cs&&(cs=!0,ms(`Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing`))}var ds=console;function fs(e){ds=e}function ps(...e){ds.log(...e)}function ms(...e){ds.warn(...e)}function hs(e){return new No(e)}function gs(e,t,n){return new Go(e,t,n)}var _s=typeof self==`object`?self:null,vs=_s&&(_s.hasOwnProperty(`AudioContext`)||_s.hasOwnProperty(`webkitAudioContext`));function ys(e,t,n){return z(R(Wo),`AudioWorkletNode only works in a secure context (https or localhost)`),new(e instanceof _s?.BaseAudioContext?_s?.AudioWorkletNode:Wo)(e,t,n)}function bs(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function V(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var xs=class{constructor(e,t,n,r){this._callback=e,this._type=t,this._minimumUpdateInterval=Math.max(128/(r||44100),.001),this.updateInterval=n,this._createClock()}_createWorker(){let e=new Blob([`
5
+ // the initial timeout time
6
+ let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
7
+ // onmessage callback
8
+ self.onmessage = function(msg){
9
+ timeoutTime = parseInt(msg.data);
10
+ };
11
+ // the tick function which posts a message
12
+ // and schedules a new tick
13
+ function tick(){
14
+ setTimeout(tick, timeoutTime);
15
+ self.postMessage('tick');
16
+ }
17
+ // call tick initially
18
+ tick();
19
+ `],{type:`text/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type===`worker`)try{this._createWorker()}catch{this._type=`timeout`,this._createClock()}else this._type===`timeout`&&this._createTimeout()}_disposeClock(){this._timeout&&clearTimeout(this._timeout),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(e){var t;this._updateInterval=Math.max(e,this._minimumUpdateInterval),this._type===`worker`&&((t=this._worker)==null||t.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(e){this._disposeClock(),this._type=e,this._createClock()}dispose(){this._disposeClock()}};function Ss(e){return Jo(e)}function Cs(e){return qo(e)}function ws(e){return Yo(e)}function Ts(e){return Ko(e)}function Es(e){return e instanceof La}function Ds(e,t){return e===`value`||Ss(t)||Cs(t)||Es(t)}function Os(e,...t){if(!t.length)return e;let n=t.shift();if(es(e)&&es(n))for(let t in n)Ds(t,n[t])?e[t]=n[t]:es(n[t])?(e[t]||Object.assign(e,{[t]:{}}),Os(e[t],n[t])):Object.assign(e,{[t]:n[t]});return Os(e,...t)}function ks(e,t){return e.length===t.length&&e.every((e,n)=>t[n]===e)}function H(e,t,n=[],r){let i={},a=Array.from(t);if(es(a[0])&&r&&!Reflect.has(a[0],r)&&(Object.keys(a[0]).some(t=>Reflect.has(e,t))||(Os(i,{[r]:a[0]}),n.splice(n.indexOf(r),1),a.shift())),a.length===1&&es(a[0]))Os(i,a[0]);else for(let e=0;e<n.length;e++)R(a[e])&&(i[n[e]]=a[e]);return Os(e,i)}function As(e){return e.constructor.getDefaults()}function js(e,t){return Zo(e)?t:e}function Ms(e,t){return t.forEach(t=>{Reflect.has(e,t)&&delete e[t]}),e}var Ns=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||_s&&this.toString()===_s.TONE_DEBUG_CLASS)&&ps(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Ns.version=n;var Ps=1e-6;function Fs(e,t){return e>t+Ps}function Is(e,t){return Fs(e,t)||Rs(e,t)}function Ls(e,t){return e+Ps<t}function Rs(e,t){return Math.abs(e-t)<Ps}function zs(e,t,n){return Math.max(Math.min(e,n),t)}var Bs=class e extends Ns{constructor(){super(),this.name=`Timeline`,this._timeline=[];let t=H(e.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(e){if(z(Reflect.has(e,`time`),`Timeline: events must have a time attribute`),e.time=e.time.valueOf(),this.increasing&&this.length){let t=this._timeline[this.length-1];z(Is(e.time,t.time),`The time must be greater than or equal to the last scheduled time`),this._timeline.push(e)}else{let t=this._search(e.time);this._timeline.splice(t+1,0,e)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(e){let t=this._timeline.indexOf(e);return t!==-1&&this._timeline.splice(t,1),this}get(e,t=`time`){let n=this._search(e,t);return n===-1?null:this._timeline[n]}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(e,t=`time`){let n=this._search(e,t);return n+1<this._timeline.length?this._timeline[n+1]:null}getBefore(e){let t=this._timeline.length;if(t>0&&this._timeline[t-1].time<e)return this._timeline[t-1];let n=this._search(e);return n-1>=0?this._timeline[n-1]:null}cancel(e){if(this._timeline.length>1){let t=this._search(e);if(t>=0){if(Rs(this._timeline[t].time,e)){for(let n=t;n>=0&&Rs(this._timeline[n].time,e);n--)t=n;this._timeline=this._timeline.slice(0,t)}else this._timeline=this._timeline.slice(0,t+1)}else this._timeline=[]}else this._timeline.length===1&&Is(this._timeline[0].time,e)&&(this._timeline=[]);return this}cancelBefore(e){let t=this._search(e);return t>=0&&(this._timeline=this._timeline.slice(t+1)),this}previousEvent(e){let t=this._timeline.indexOf(e);return t>0?this._timeline[t-1]:null}_search(e,t=`time`){if(this._timeline.length===0)return-1;let n=0,r=this._timeline.length,i=r;if(r>0&&this._timeline[r-1][t]<=e)return r-1;for(;n<i;){let r=Math.floor(n+(i-n)/2),a=this._timeline[r],o=this._timeline[r+1];if(Rs(a[t],e)){for(let n=r;n<this._timeline.length;n++){let i=this._timeline[n];if(Rs(i[t],e))r=n;else break}return r}if(Ls(a[t],e)&&Fs(o[t],e))return r;Fs(a[t],e)?i=r:n=r+1}return-1}_iterate(e,t=0,n=this._timeline.length-1){this._timeline.slice(t,n+1).forEach(e)}forEach(e){return this._iterate(e),this}forEachBefore(e,t){let n=this._search(e);return n!==-1&&this._iterate(t,0,n),this}forEachAfter(e,t){let n=this._search(e);return this._iterate(t,n+1),this}forEachBetween(e,t,n){let r=this._search(e),i=this._search(t);return r!==-1&&i!==-1?(this._timeline[r].time!==e&&(r+=1),this._timeline[i].time===t&&--i,this._iterate(n,r,i)):r===-1&&this._iterate(n,0,i),this}forEachFrom(e,t){let n=this._search(e);for(;n>=0&&this._timeline[n].time>=e;)n--;return this._iterate(t,n+1),this}forEachAtTime(e,t){let n=this._search(e);if(n!==-1&&Rs(this._timeline[n].time,e)){let r=n;for(let t=n;t>=0&&Rs(this._timeline[t].time,e);t--)r=t;this._iterate(e=>{t(e)},r,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}},Vs=[];function Hs(e){Vs.push(e)}function Us(e){Vs.forEach(t=>t(e))}var Ws=[];function Gs(e){Ws.push(e)}function Ks(e){Ws.forEach(t=>t(e))}var qs=class e extends Ns{constructor(){super(...arguments),this.name=`Emitter`}on(e,t){return e.split(/\W+/).forEach(e=>{Zo(this._events)&&(this._events={}),this._events.hasOwnProperty(e)||(this._events[e]=[]),this._events[e].push(t)}),this}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}off(e,t){return e.split(/\W+/).forEach(e=>{if(Zo(this._events)&&(this._events={}),this._events.hasOwnProperty(e)){if(Zo(t))this._events[e]=[];else{let n=this._events[e];for(let e=n.length-1;e>=0;e--)n[e]===t&&n.splice(e,1)}}}),this}emit(e,...t){if(this._events&&this._events.hasOwnProperty(e)){let n=this._events[e].slice(0);for(let e=0,r=n.length;e<r;e++)n[e].apply(this,t)}return this}static mixin(t){[`on`,`once`,`off`,`emit`].forEach(n=>{let r=Object.getOwnPropertyDescriptor(e.prototype,n);Object.defineProperty(t.prototype,n,r)})}dispose(){return super.dispose(),this._events=void 0,this}},Js=class extends qs{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}},Ys=class e extends Js{constructor(){super(),this.name=`Context`,this._constants=new Map,this._timeouts=new Bs,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let t=H(e.getDefaults(),arguments,[`context`]);t.context?(this._context=t.context,this._latencyHint=arguments[0]?.latencyHint||``):(this._context=hs({latencyHint:t.latencyHint}),this._latencyHint=t.latencyHint),this._ticker=new xs(this.emit.bind(this,`tick`),t.clockSource,t.updateInterval,this._context.sampleRate),this.on(`tick`,this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit(`statechange`,this.state)},this[arguments[0]?.hasOwnProperty(`updateInterval`)?`_lookAhead`:`lookAhead`]=t.lookAhead}static getDefaults(){return{clockSource:`worker`,latencyHint:`interactive`,lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||=(Us(this),!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(e,t,n){return this._context.createBuffer(e,t,n)}createChannelMerger(e){return this._context.createChannelMerger(e)}createChannelSplitter(e){return this._context.createChannelSplitter(e)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(e){return this._context.createDelay(e)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(e,t){return this._context.createIIRFilter(e,t)}createPanner(){return this._context.createPanner()}createPeriodicWave(e,t,n){return this._context.createPeriodicWave(e,t,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(e){return z(Ts(this._context),`Not available if OfflineAudioContext`),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return z(Ts(this._context),`Not available if OfflineAudioContext`),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return z(Ts(this._context),`Not available if OfflineAudioContext`),this._context.createMediaStreamDestination()}decodeAudioData(e){return this._context.decodeAudioData(e)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(e){z(!this._initialized,`The listener cannot be set after initialization.`),this._listener=e}get transport(){return this.initialize(),this._transport}set transport(e){z(!this._initialized,`The transport cannot be set after initialization.`),this._transport=e}get draw(){return this.initialize(),this._draw}set draw(e){z(!this._initialized,`Draw cannot be set after initialization.`),this._draw=e}get destination(){return this.initialize(),this._destination}set destination(e){z(!this._initialized,`The destination cannot be set after initialization.`),this._destination=e}createAudioWorkletNode(e,t){return ys(this.rawContext,e,t)}addAudioWorkletModule(e){return V(this,void 0,void 0,function*(){z(R(this.rawContext.audioWorklet),`AudioWorkletNode is only available in a secure context (https or localhost)`),this._workletPromise||=this.rawContext.audioWorklet.addModule(e),yield this._workletPromise})}workletsAreReady(){return V(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(e){this._ticker.updateInterval=e}get clockSource(){return this._ticker.type}set clockSource(e){this._ticker.type=e}get lookAhead(){return this._lookAhead}set lookAhead(e){this._lookAhead=e,this.updateInterval=e?e/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return Ts(this._context)?this._context.resume():Promise.resolve()}close(){return V(this,void 0,void 0,function*(){Ts(this._context)&&this.state!==`closed`&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&Ks(this)})}getConstant(e){if(this._constants.has(e))return this._constants.get(e);{let t=this._context.createBuffer(1,128,this._context.sampleRate),n=t.getChannelData(0);for(let t=0;t<n.length;t++)n[t]=e;let r=this._context.createBufferSource();return r.channelCount=1,r.channelCountMode=`explicit`,r.buffer=t,r.loop=!0,r.start(0),this._constants.set(e,r),r}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(e=>this._constants[e].disconnect()),this.close(),this}_timeoutLoop(){let e=this.now();this._timeouts.forEachBefore(e,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(e,t){this._timeoutIds++;let n=this.now();return this._timeouts.add({callback:e,id:this._timeoutIds,time:n+t}),this._timeoutIds}clearTimeout(e){return this._timeouts.forEach(t=>{t.id===e&&this._timeouts.remove(t)}),this}clearInterval(e){return this.clearTimeout(e)}setInterval(e,t){let n=++this._timeoutIds,r=()=>{let i=this.now();this._timeouts.add({callback:()=>{e(),r()},id:n,time:i+t})};return r(),n}},Xs=class extends Js{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(e,t,n){return{}}createChannelMerger(e){return{}}createChannelSplitter(e){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(e){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(e,t){return{}}createPanner(){return{}}createPeriodicWave(e,t,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(e){return{}}createMediaElementSource(e){return{}}createMediaStreamDestination(){return{}}decodeAudioData(e){return Promise.resolve({})}createAudioWorkletNode(e,t){return{}}get rawContext(){return{}}addAudioWorkletModule(e){return V(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(e,t){return 0}clearTimeout(e){return this}setInterval(e,t){return 0}clearInterval(e){return this}getConstant(e){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(e){}get destination(){return{}}set destination(e){}now(){return 0}immediate(){return 0}};function U(e,t){ns(t)?t.forEach(t=>U(e,t)):Object.defineProperty(e,t,{enumerable:!0,writable:!1})}function Zs(e,t){ns(t)?t.forEach(t=>Zs(e,t)):Object.defineProperty(e,t,{writable:!0})}var W=()=>{},Qs=class e extends Ns{constructor(){super(),this.name=`ToneAudioBuffer`,this.onload=W;let t=H(e.getDefaults(),arguments,[`url`,`onload`,`onerror`]);this.reverse=t.reverse,this.onload=t.onload,rs(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:W,onload:W,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:G().sampleRate}set(t){return t instanceof e?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 V(this,void 0,void 0,function*(){let n=e.load(t).then(e=>{this.set(e),this.onload(this)});e.downloads.push(n);try{yield n}finally{let t=e.downloads.indexOf(n);e.downloads.splice(t,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(e){let t=ns(e)&&e[0].length>0,n=t?e.length:1,r=t?e[0].length:e.length,i=G(),a=i.createBuffer(n,r,i.sampleRate),o=!t&&n===1?[e]:e;for(let e=0;e<n;e++)a.copyToChannel(o[e],e);return this._buffer=a,this}toMono(e){if($o(e))this.fromArray(this.toArray(e));else{let e=new Float32Array(this.length),t=this.numberOfChannels;for(let n=0;n<t;n++){let t=this.toArray(n);for(let n=0;n<t.length;n++)e[n]+=t[n]}e=e.map(e=>e/t),this.fromArray(e)}return this}toArray(e){if($o(e))return this.getChannelData(e);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let t=0;t<this.numberOfChannels;t++)e[t]=this.getChannelData(t);return e}}getChannelData(e){return this._buffer?this._buffer.getChannelData(e):new Float32Array}slice(t,n=this.duration){z(this.loaded,`Buffer is not loaded`);let r=Math.floor(t*this.sampleRate),i=Math.floor(n*this.sampleRate);z(r<i,`The start time must be less than the end time`);let a=i-r,o=G().createBuffer(this.numberOfChannels,a,this.sampleRate);for(let e=0;e<this.numberOfChannels;e++)o.copyToChannel(this.getChannelData(e).subarray(r,i),e);return new e(o)}_reverse(){if(this.loaded)for(let e=0;e<this.numberOfChannels;e++)this.getChannelData(e).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(e){this._reversed!==e&&(this._reversed=e,this._reverse())}static fromArray(t){return new e().fromArray(t)}static fromUrl(t){return V(this,void 0,void 0,function*(){return yield new e().load(t)})}static load(t){return V(this,void 0,void 0,function*(){let n=e.baseUrl===``||e.baseUrl.endsWith(`/`)?e.baseUrl:e.baseUrl+`/`,r=yield fetch(n+t);if(!r.ok)throw Error(`could not load url: ${t}`);let i=yield r.arrayBuffer();return yield G().decodeAudioData(i)})}static supportsType(e){let t=e.split(`.`),n=t[t.length-1];return document.createElement(`audio`).canPlayType(`audio/`+n)!==``}static loaded(){return V(this,void 0,void 0,function*(){for(yield Promise.resolve();e.downloads.length;)yield e.downloads[0]})}};Qs.baseUrl=``,Qs.downloads=[];var $s=class extends Ys{constructor(){super({clockSource:`offline`,context:ws(arguments[0])?arguments[0]:gs(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:ws(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name=`OfflineContext`,this._currentTime=0,this.isOffline=!0,this._duration=ws(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(e){return V(this,void 0,void 0,function*(){let t=0;for(;this._duration-this._currentTime>=0;){this.emit(`tick`),this._currentTime+=128/this.sampleRate,t++;let n=Math.floor(this.sampleRate/128);e&&t%n===0&&(yield new Promise(e=>setTimeout(e,1)))}})}render(){return V(this,arguments,void 0,function*(e=!0){return yield this.workletsAreReady(),yield this._renderClock(e),new Qs(yield this._context.startRendering())})}close(){return Promise.resolve()}},ec=new Xs,tc=ec;function G(){return tc===ec&&vs&&nc(new Ys),tc}function nc(e,t=!1){t&&tc.dispose(),tc=Ts(e)?new Ys(e):ws(e)?new $s(e):e}function rc(){return tc.resume()}if(_s&&!_s.TONE_SILENCE_LOGGING){let e=` * Tone.js v${n} * `;console.log(`%c${e}`,`background: #000; color: #fff`)}function ic(e){return 10**(e/20)}function ac(e){return Math.log(e)/Math.LN10*20}function oc(e){return 2**(e/12)}var sc=440;function cc(){return sc}function lc(e){sc=e}function uc(e){return Math.round(dc(e))}function dc(e){return 69+12*Math.log2(e/sc)}function fc(e){return sc*2**((e-69)/12)}var pc=class e extends Ns{constructor(e,t,n){super(),this.defaultUnits=`s`,this._val=t,this._units=n,this.context=e,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:e=>this._frequencyToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:e=>this._ticksToUnits(parseInt(e,10)),regexp:/^(\d+)i$/i},m:{method:e=>this._beatsToUnits(parseInt(e,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(e,t)=>{let n=parseInt(e,10),r=t===`.`?1.5:1;return n===1?this._beatsToUnits(this._getTimeSignature())*r:this._beatsToUnits(4/n)*r},regexp:/^(\d+)n(\.?)$/i},number:{method:e=>this._expressions[this.defaultUnits].method.call(this,e),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:e=>this._secondsToUnits(parseFloat(e)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:e=>parseInt(e,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:e=>{let t=parseInt(e,10);return this._beatsToUnits(8/(Math.floor(t)*3))},regexp:/^(\d+)t$/i},tr:{method:(e,t,n)=>{let r=0;return e&&e!==`0`&&(r+=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!==`0`&&(r+=this._beatsToUnits(parseFloat(t))),n&&n!==`0`&&(r+=this._beatsToUnits(parseFloat(n)/4)),r},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof e&&this.fromType(this._val),Zo(this._val))return this._noArg();if(rs(this._val)&&Zo(this._units)){for(let e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(es(this._val)){let e=0;for(let t in this._val)if(R(this._val[t])){let n=this._val[t],r=new this.constructor(this.context,t).valueOf()*n;e+=r}return e}if(R(this._units)){let e=this._expressions[this._units],t=this._val.toString().trim().match(e.regexp);return t?e.method.apply(this,t.slice(1)):e.method.call(this,this._val)}return rs(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(e){return 1/e}_beatsToUnits(e){return 60/this._getBpm()*e}_secondsToUnits(e){return e}_ticksToUnits(e){return e*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(e){switch(this._units=void 0,this.defaultUnits){case`s`:this._val=e.toSeconds();break;case`i`:this._val=e.toTicks();break;case`hz`:this._val=e.toFrequency();break;case`midi`:this._val=e.toMidi()}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}},mc=class e extends pc{constructor(){super(...arguments),this.name=`TimeClass`}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:e=>this._now()+new this.constructor(this.context,e).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let n=new e(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(n))},regexp:/^@(.+)/}})}quantize(e,t=1){let n=new this.constructor(this.context,e).valueOf(),r=this.valueOf();return r+(Math.round(r/n)*n-r)*t}toNotation(){let t=this.toSeconds(),n=[`1m`];for(let e=1;e<9;e++){let t=2**e;n.push(t+`n.`),n.push(t+`n`),n.push(t+`t`)}n.push(`0`);let r=n[0],i=new e(this.context,n[0]).toSeconds();return n.forEach(n=>{let a=new e(this.context,n).toSeconds();Math.abs(a-t)<Math.abs(i-t)&&(r=n,i=a)}),r}toBarsBeatsSixteenths(){let e=this._beatsToUnits(1),t=this.valueOf()/e;t=parseFloat(t.toFixed(4));let n=Math.floor(t/this._getTimeSignature()),r=t%1*4;t=Math.floor(t)%this._getTimeSignature();let i=r.toString();return i.length>3&&(r=parseFloat(parseFloat(i).toFixed(3))),[n,t,r].join(`:`)}toTicks(){let e=this._beatsToUnits(1);return this.valueOf()/e*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return uc(this.toFrequency())}_now(){return this.context.now()}};function hc(e,t){return new mc(G(),e,t)}var gc=class e extends mc{constructor(){super(...arguments),this.name=`Frequency`,this.defaultUnits=`hz`}static get A4(){return cc()}static set A4(e){lc(e)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits===`midi`?t:e.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,n){let r=_c[t.toLowerCase()]+(parseInt(n,10)+1)*12;return this.defaultUnits===`midi`?r:e.mtof(r)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(e,t,n){let r=1;return e&&e!==`0`&&(r*=this._beatsToUnits(this._getTimeSignature()*parseFloat(e))),t&&t!==`0`&&(r*=this._beatsToUnits(parseFloat(t))),n&&n!==`0`&&(r*=this._beatsToUnits(parseFloat(n)/4)),r}}})}transpose(t){return new e(this.context,this.valueOf()*oc(t))}harmonize(e){return e.map(e=>this.transpose(e))}toMidi(){return uc(this.valueOf())}toNote(){let t=this.toFrequency(),n=Math.log2(t/e.A4),r=Math.round(12*n)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),vc[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let e=this._beatsToUnits(1),t=this.valueOf()/e;return Math.floor(t*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(e){return e}_ticksToUnits(e){return 1/(e*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(e){return 1/super._beatsToUnits(e)}_secondsToUnits(e){return 1/e}static mtof(e){return fc(e)}static ftom(e){return uc(e)}},_c={cbbb:-3,cbb:-2,cb:-1,c:0,"c#":1,cx:2,"c##":2,"c###":3,"cx#":3,"c#x":3,dbbb:-1,dbb:0,db:1,d:2,"d#":3,dx:4,"d##":4,"d###":5,"dx#":5,"d#x":5,ebbb:1,ebb:2,eb:3,e:4,"e#":5,ex:6,"e##":6,"e###":7,"ex#":7,"e#x":7,fbbb:2,fbb:3,fb:4,f:5,"f#":6,fx:7,"f##":7,"f###":8,"fx#":8,"f#x":8,gbbb:4,gbb:5,gb:6,g:7,"g#":8,gx:9,"g##":9,"g###":10,"gx#":10,"g#x":10,abbb:6,abb:7,ab:8,a:9,"a#":10,ax:11,"a##":11,"a###":12,"ax#":12,"a#x":12,bbbb:8,bbb:9,bb:10,b:11,"b#":12,bx:13,"b##":13,"b###":14,"bx#":14,"b#x":14},vc=[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`];function yc(e,t){return new gc(G(),e,t)}var K=class extends mc{constructor(){super(...arguments),this.name=`TransportTime`}_now(){return this.context.transport.seconds}};function bc(e,t){return new K(G(),e,t)}var xc=class e extends Ns{constructor(){super();let t=H(e.getDefaults(),arguments,[`context`]);this.context=this.defaultContext?this.defaultContext:t.context}static getDefaults(){return{context:G()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(e){return us(e),new mc(this.context,e).toSeconds()}toFrequency(e){return new gc(this.context,e).toFrequency()}toTicks(e){return new K(this.context,e).toTicks()}_getPartialProperties(e){let t=this.get();return Object.keys(t).forEach(n=>{Zo(e[n])&&delete t[n]}),t}get(){let t=As(this);return Object.keys(t).forEach(n=>{if(Reflect.has(this,n)){let r=this[n];R(r)&&R(r.value)&&R(r.setValueAtTime)?t[n]=r.value:r instanceof e?t[n]=r._getPartialProperties(t[n]):ns(r)||$o(r)||rs(r)||ts(r)?t[n]=r:delete t[n]}}),t}set(t){return Object.keys(t).forEach(n=>{Reflect.has(this,n)&&R(this[n])&&(this[n]&&R(this[n].value)&&R(this[n].setValueAtTime)?this[n].value!==t[n]&&(this[n].value=t[n]):this[n]instanceof e?this[n].set(t[n]):this[n]=t[n])}),this}},Sc=class extends Bs{constructor(e=`stopped`){super(),this.name=`StateTimeline`,this._initial=e,this.setStateAtTime(this._initial,0)}getValueAtTime(e){let t=this.get(e);return t===null?this._initial:t.state}setStateAtTime(e,t,n){return B(t,0),this.add(Object.assign({},n,{state:e,time:t})),this}getLastState(e,t){let n=this._search(t);for(let t=n;t>=0;t--){let n=this._timeline[t];if(n.state===e)return n}}getNextState(e,t){let n=this._search(t);if(n!==-1)for(let t=n;t<this._timeline.length;t++){let n=this._timeline[t];if(n.state===e)return n}}},q=class e extends xc{constructor(){let t=H(e.getDefaults(),arguments,[`param`,`units`,`convert`]);for(super(t),this.name=`Param`,this.overridden=!1,this._minOutput=1e-7,z(R(t.param)&&(Ss(t.param)||t.param instanceof e),`param must be an AudioParam`);!Ss(t.param);)t.param=t.param._param;this._swappable=R(t.swappable)?t.swappable:!1,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 Bs(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,R(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(xc.getDefaults(),{convert:!0,units:`number`})}get value(){let e=this.now();return this.getValueAtTime(e)}set value(e){this.cancelScheduledValues(this.now()),this.setValueAtTime(e,this.now())}get minValue(){return R(this._minValue)?this._minValue:this.units===`time`||this.units===`frequency`||this.units===`normalRange`||this.units===`positive`||this.units===`transportTime`||this.units===`ticks`||this.units===`bpm`||this.units===`hertz`||this.units===`samples`?0:this.units===`audioRange`?-1:this.units===`decibels`?-1/0:this._param.minValue}get maxValue(){return R(this._maxValue)?this._maxValue:this.units===`normalRange`||this.units===`audioRange`?1:this._param.maxValue}_is(e,t){return this.units===t}_assertRange(e){return R(this.maxValue)&&R(this.minValue)&&B(e,this._fromType(this.minValue),this._fromType(this.maxValue)),e}_fromType(e){return this.convert&&!this.overridden?this._is(e,`time`)?this.toSeconds(e):this._is(e,`decibels`)?ic(e):this._is(e,`frequency`)?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units===`decibels`?ac(e):e}setValueAtTime(e,t){let n=this.toSeconds(t),r=this._fromType(e);return z(isFinite(r)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(r),this.log(this.units,`setValueAtTime`,e,n),this._events.add({time:n,type:`setValueAtTime`,value:r}),this._param.setValueAtTime(r,n),this}getValueAtTime(e){let t=Math.max(this.toSeconds(e),0),n=this._events.getAfter(t),r=this._events.get(t),i=this._initialValue;if(r===null)i=this._initialValue;else if(r.type===`setTargetAtTime`&&(n===null||n.type===`setValueAtTime`)){let e=this._events.getBefore(r.time),n;n=e===null?this._initialValue:e.value,r.type===`setTargetAtTime`&&(i=this._exponentialApproach(r.time,n,r.value,r.constant,t))}else if(n===null)i=r.value;else if(n.type===`linearRampToValueAtTime`||n.type===`exponentialRampToValueAtTime`){let e=r.value;if(r.type===`setTargetAtTime`){let t=this._events.getBefore(r.time);e=t===null?this._initialValue:t.value}i=n.type===`linearRampToValueAtTime`?this._linearInterpolate(r.time,e,n.time,n.value,t):this._exponentialInterpolate(r.time,e,n.time,n.value,t)}else i=r.value;return this._toType(i)}setRampPoint(e){e=this.toSeconds(e);let t=this.getValueAtTime(e);return this.cancelAndHoldAtTime(e),this._fromType(t)===0&&(t=this._toType(this._minOutput)),this.setValueAtTime(t,e),this}linearRampToValueAtTime(e,t){let n=this._fromType(e),r=this.toSeconds(t);return z(isFinite(n)&&isFinite(r),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._assertRange(n),this._events.add({time:r,type:`linearRampToValueAtTime`,value:n}),this.log(this.units,`linearRampToValueAtTime`,e,r),this._param.linearRampToValueAtTime(n,r),this}exponentialRampToValueAtTime(e,t){let n=this._fromType(e);n=Rs(n,0)?this._minOutput:n,this._assertRange(n);let r=this.toSeconds(t);return z(isFinite(n)&&isFinite(r),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({time:r,type:`exponentialRampToValueAtTime`,value:n}),this.log(this.units,`exponentialRampToValueAtTime`,e,r),this._param.exponentialRampToValueAtTime(n,r),this}exponentialRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(e,n+this.toSeconds(t)),this}linearRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(e,n+this.toSeconds(t)),this}targetRampTo(e,t,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(e,n,t),this}exponentialApproachValueAtTime(e,t,n){t=this.toSeconds(t),n=this.toSeconds(n);let r=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(e,t,r),this.cancelAndHoldAtTime(t+n*.9),this.linearRampToValueAtTime(e,t+n),this}setTargetAtTime(e,t,n){let r=this._fromType(e);z(isFinite(n)&&n>0,`timeConstant must be a number greater than 0`);let i=this.toSeconds(t);return this._assertRange(r),z(isFinite(r)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(e)}, ${JSON.stringify(t)}`),this._events.add({constant:n,time:i,type:`setTargetAtTime`,value:r}),this.log(this.units,`setTargetAtTime`,e,i,n),this._param.setTargetAtTime(r,i,n),this}setValueCurveAtTime(e,t,n,r=1){n=this.toSeconds(n),t=this.toSeconds(t);let i=this._fromType(e[0])*r;this.setValueAtTime(this._toType(i),t);let a=n/(e.length-1);for(let n=1;n<e.length;n++){let i=this._fromType(e[n])*r;this.linearRampToValueAtTime(this._toType(i),t+n*a)}return this}cancelScheduledValues(e){let t=this.toSeconds(e);return z(isFinite(t),`Invalid argument to cancelScheduledValues: ${JSON.stringify(e)}`),this._events.cancel(t),this._param.cancelScheduledValues(t),this.log(this.units,`cancelScheduledValues`,t),this}cancelAndHoldAtTime(e){let t=this.toSeconds(e),n=this._fromType(this.getValueAtTime(t));z(isFinite(t),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(e)}`),this.log(this.units,`cancelAndHoldAtTime`,t,`value=`+n);let r=this._events.get(t),i=this._events.getAfter(t);return r&&Rs(r.time,t)?i?(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time)):(this._param.cancelAndHoldAtTime(t),this._events.cancel(t+this.sampleTime)):i&&(this._param.cancelScheduledValues(i.time),this._events.cancel(i.time),i.type===`linearRampToValueAtTime`?this.linearRampToValueAtTime(this._toType(n),t):i.type===`exponentialRampToValueAtTime`&&this.exponentialRampToValueAtTime(this._toType(n),t)),this._events.add({time:t,type:`setValueAtTime`,value:n}),this._param.setValueAtTime(n,t),this}rampTo(e,t=.1,n){return this.units===`frequency`||this.units===`bpm`||this.units===`decibels`?this.exponentialRampTo(e,t,n):this.linearRampTo(e,t,n),this}apply(e){let t=this.context.currentTime;e.setValueAtTime(this.getValueAtTime(t),t);let n=this._events.get(t);if(n&&n.type===`setTargetAtTime`){let r=this._events.getAfter(n.time),i=r?r.time:t+2,a=(i-t)/10;for(let n=t;n<i;n+=a)e.linearRampToValueAtTime(this.getValueAtTime(n),n)}return this._events.forEachAfter(this.context.currentTime,t=>{t.type===`cancelScheduledValues`?e.cancelScheduledValues(t.time):t.type===`setTargetAtTime`?e.setTargetAtTime(t.value,t.time,t.constant):e[t.type](t.value,t.time)}),this}setParam(e){z(this._swappable,`The Param must be assigned as 'swappable' in the constructor`);let t=this.input;return t.disconnect(this._param),this.apply(e),this._param=e,t.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(e,t,n,r,i){return n+(t-n)*Math.exp(-(i-e)/r)}_linearInterpolate(e,t,n,r,i){return t+(r-t)*((i-e)/(n-e))}_exponentialInterpolate(e,t,n,r,i){return t*(r/t)**+((i-e)/(n-e))}},J=class e extends xc{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return R(this.input)?Ss(this.input)||this.input instanceof q?1:this.input.numberOfInputs:0}get numberOfOutputs(){return R(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return R(t)&&(t instanceof e||Cs(t))}_getInternalNodes(){let e=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&e.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&e.push(this.output),e}_setChannelProperties(e){this._getInternalNodes().forEach(t=>{t.channelCount=e.channelCount,t.channelCountMode=e.channelCountMode,t.channelInterpretation=e.channelInterpretation})}_getChannelProperties(){let e=this._getInternalNodes();z(e.length>0,`ToneAudioNode does not have any internal nodes`);let t=e[0];return{channelCount:t.channelCount,channelCountMode:t.channelCountMode,channelInterpretation:t.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCount:e}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelCountMode:e}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(e){let t=this._getChannelProperties();this._setChannelProperties(Object.assign(t,{channelInterpretation:e}))}connect(e,t=0,n=0){return wc(this,e,t,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return ms(`toMaster() has been renamed toDestination()`),this.toDestination()}disconnect(e,t=0,n=0){return Tc(this,e,t,n),this}chain(...e){return Cc(this,...e),this}fan(...e){return e.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),R(this.input)&&(this.input instanceof e?this.input.dispose():Cs(this.input)&&this.input.disconnect()),R(this.output)&&(this.output instanceof e?this.output.dispose():Cs(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Cc(...e){let t=e.shift();e.reduce((e,t)=>(e instanceof J?e.connect(t):Cs(e)&&wc(e,t),t),t)}function wc(e,t,n=0,r=0){for(z(R(e),`Cannot connect from undefined node`),z(R(t),`Cannot connect to undefined node`),(t instanceof J||Cs(t))&&z(t.numberOfInputs>0,`Cannot connect to node with no inputs`),z(e.numberOfOutputs>0,`Cannot connect from node with no outputs`);t instanceof J||t instanceof q;)R(t.input)&&(t=t.input);for(;e instanceof J;)R(e.output)&&(e=e.output);Ss(t)?e.connect(t,n):e.connect(t,n,r)}function Tc(e,t,n=0,r=0){if(R(t))for(;t instanceof J;)t=t.input;for(;!Cs(e);)R(e.output)&&(e=e.output);Ss(t)?e.disconnect(t,n):Cs(t)?e.disconnect(t,n,r):e.disconnect()}function Ec(...e){let t=e.pop();R(t)&&e.forEach(e=>wc(e,t))}var Y=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`gain`,`units`]);super(t),this.name=`Gain`,this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode,this.gain=new q({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),U(this,`gain`)}static getDefaults(){return Object.assign(J.getDefaults(),{convert:!0,gain:1,units:`gain`})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}},Dc=class extends J{constructor(e){super(e),this.onended=W,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Y({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let t=this.toSeconds(e);return this._startTime!==-1&&t>=this._startTime&&(this._stopTime===-1||t<=this._stopTime)?`started`:`stopped`},this._fadeIn=e.fadeIn,this._fadeOut=e.fadeOut,this._curve=e.curve,this.onended=e.onended}static getDefaults(){return Object.assign(J.getDefaults(),{curve:`linear`,fadeIn:0,fadeOut:0,onended:W})}_startGain(e,t=1){z(this._startTime===-1,`Source cannot be started more than once`);let n=this.toSeconds(this._fadeIn);return this._startTime=e+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,e),this._curve===`linear`?this._gainNode.gain.linearRampToValueAtTime(t,e+n):this._gainNode.gain.exponentialApproachValueAtTime(t,e,n)):this._gainNode.gain.setValueAtTime(t,e),this}stop(e){return this.log(`stop`,e),this._stopGain(this.toSeconds(e)),this}_stopGain(e){z(this._startTime!==-1,`'start' must be called before 'stop'`),this.cancelStop();let t=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(e)+t,this._stopTime=Math.max(this._stopTime,this.now()),t>0?this._curve===`linear`?this._gainNode.gain.linearRampTo(0,t,e):this._gainNode.gain.targetRampTo(0,t,e):(this._gainNode.gain.cancelAndHoldAtTime(e),this._gainNode.gain.setValueAtTime(0,e)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let e=this._curve===`exponential`?t*2:0;this._stopSource(this.now()+e),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==W&&(this.onended(this),this.onended=W,!this.context.isOffline)){let e=()=>this.dispose();typeof requestIdleCallback<`u`?requestIdleCallback(e):setTimeout(e,10)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log(`cancelStop`),z(this._startTime!==-1,`Source is not started`),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.dispose(),this.onended=W,this}},Oc=class e extends Dc{constructor(){let t=H(e.getDefaults(),arguments,[`offset`]);super(t),this.name=`ToneConstantSource`,this._source=this.context.createConstantSource(),wc(this._source,this._gainNode),this.offset=new q({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(Dc.getDefaults(),{convert:!0,offset:1,units:`number`})}start(e){let t=this.toSeconds(e);return this.log(`start`,t),this._startGain(t),this._source.start(t),this}_stopSource(e){this._source.stop(e)}dispose(){return super.dispose(),this.state===`started`&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}},X=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`value`,`units`]);super(t),this.name=`Signal`,this.override=!0,this.output=this._constantSource=new Oc({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(J.getDefaults(),{convert:!0,units:`number`,value:0})}connect(e,t=0,n=0){return kc(this,e,t,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(e,t){return this._param.setValueAtTime(e,t),this}getValueAtTime(e){return this._param.getValueAtTime(e)}setRampPoint(e){return this._param.setRampPoint(e),this}linearRampToValueAtTime(e,t){return this._param.linearRampToValueAtTime(e,t),this}exponentialRampToValueAtTime(e,t){return this._param.exponentialRampToValueAtTime(e,t),this}exponentialRampTo(e,t,n){return this._param.exponentialRampTo(e,t,n),this}linearRampTo(e,t,n){return this._param.linearRampTo(e,t,n),this}targetRampTo(e,t,n){return this._param.targetRampTo(e,t,n),this}exponentialApproachValueAtTime(e,t,n){return this._param.exponentialApproachValueAtTime(e,t,n),this}setTargetAtTime(e,t,n){return this._param.setTargetAtTime(e,t,n),this}setValueCurveAtTime(e,t,n,r){return this._param.setValueCurveAtTime(e,t,n,r),this}cancelScheduledValues(e){return this._param.cancelScheduledValues(e),this}cancelAndHoldAtTime(e){return this._param.cancelAndHoldAtTime(e),this}rampTo(e,t,n){return this._param.rampTo(e,t,n),this}get value(){return this._param.value}set value(e){this._param.value=e}get convert(){return this._param.convert}set convert(e){this._param.convert=e}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(e){this._param.overridden=e}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(e){return this._param.apply(e),this}};function kc(e,t,n,r){(t instanceof q||Ss(t)||t instanceof X&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof X&&(t.overridden=!0)),wc(e,t,n,r)}var Ac=class e extends q{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`TickParam`,this._events=new Bs(1/0),this._multiplier=1,this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:`setValueAtTime`,value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(q.getDefaults(),{multiplier:1,units:`hertz`,value:1})}setTargetAtTime(e,t,n){t=this.toSeconds(t),this.setRampPoint(t);let r=this._fromType(e),i=this._events.get(t),a=Math.round(Math.max(1/n,1));for(let e=0;e<=a;e++){let a=n*e+t,o=this._exponentialApproach(i.time,i.value,r,n,a);this.linearRampToValueAtTime(this._toType(o),a)}return this}setValueAtTime(e,t){let n=this.toSeconds(t);super.setValueAtTime(e,t);let r=this._events.get(n),i=this._events.previousEvent(r),a=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(a,0),this}linearRampToValueAtTime(e,t){let n=this.toSeconds(t);super.linearRampToValueAtTime(e,t);let r=this._events.get(n),i=this._events.previousEvent(r),a=this._getTicksUntilEvent(i,n);return r.ticks=Math.max(a,0),this}exponentialRampToValueAtTime(e,t){t=this.toSeconds(t);let n=this._fromType(e),r=this._events.get(t),i=Math.round(Math.max((t-r.time)*10,1)),a=(t-r.time)/i;for(let e=0;e<=i;e++){let i=a*e+r.time,o=this._exponentialInterpolate(r.time,r.value,t,n,i);this.linearRampToValueAtTime(this._toType(o),i)}return this}_getTicksUntilEvent(e,t){if(e===null)e={ticks:0,time:0,type:`setValueAtTime`,value:0};else if(Zo(e.ticks)){let t=this._events.previousEvent(e);e.ticks=this._getTicksUntilEvent(t,e.time)}let n=this._fromType(this.getValueAtTime(e.time)),r=this._fromType(this.getValueAtTime(t)),i=this._events.get(t);return i&&i.time===t&&i.type===`setValueAtTime`&&(r=this._fromType(this.getValueAtTime(t-this.sampleTime))),.5*(t-e.time)*(n+r)+e.ticks}getTicksAtTime(e){let t=this.toSeconds(e),n=this._events.get(t);return Math.max(this._getTicksUntilEvent(n,t),0)}getDurationOfTicks(e,t){let n=this.toSeconds(t),r=this.getTicksAtTime(t);return this.getTimeOfTick(r+e)-n}getTimeOfTick(e){let t=this._events.get(e,`ticks`),n=this._events.getAfter(e,`ticks`);if(t&&t.ticks===e)return t.time;if(t&&n&&n.type===`linearRampToValueAtTime`&&t.value!==n.value){let r=this._fromType(this.getValueAtTime(t.time)),i=(this._fromType(this.getValueAtTime(n.time))-r)/(n.time-t.time),a=Math.sqrt(r**2-2*i*(t.ticks-e)),o=(-r+a)/i,s=(-r-a)/i;return(o>0?o:s)+t.time}return t?t.value===0?1/0:t.time+(e-t.ticks)/t.value:e/this._initialValue}ticksToTime(e,t){return this.getDurationOfTicks(e,t)}timeToTicks(e,t){let n=this.toSeconds(t),r=this.toSeconds(e),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+r)-i}_fromType(e){return this.units===`bpm`&&this.multiplier?1/(60/e/this.multiplier):super._fromType(e)}_toType(e){return this.units===`bpm`&&this.multiplier?e/this.multiplier*60:super._toType(e)}get multiplier(){return this._multiplier}set multiplier(e){let t=this.value;this._multiplier=e,this.cancelScheduledValues(0),this.setValueAtTime(t,0)}},jc=class e extends X{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`TickSignal`,this.input=this._param=new Ac({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(X.getDefaults(),{multiplier:1,units:`hertz`,value:1})}ticksToTime(e,t){return this._param.ticksToTime(e,t)}timeToTicks(e,t){return this._param.timeToTicks(e,t)}getTimeOfTick(e){return this._param.getTimeOfTick(e)}getDurationOfTicks(e,t){return this._param.getDurationOfTicks(e,t)}getTicksAtTime(e){return this._param.getTicksAtTime(e)}get multiplier(){return this._param.multiplier}set multiplier(e){this._param.multiplier=e}dispose(){return super.dispose(),this._param.dispose(),this}},Mc=class e extends xc{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`]);super(t),this.name=`TickSource`,this._state=new Sc,this._tickOffset=new Bs,this._ticksAtTime=new Bs,this._secondsAtTime=new Bs,this.frequency=new jc({context:this.context,units:t.units,value:t.frequency}),U(this,`frequency`),this._state.setStateAtTime(`stopped`,0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:`hertz`},xc.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(e,t){let n=this.toSeconds(e);return this._state.getValueAtTime(n)!==`started`&&(this._state.setStateAtTime(`started`,n),R(t)&&this.setTicksAtTime(t,n),this._ticksAtTime.cancel(n),this._secondsAtTime.cancel(n)),this}stop(e){let t=this.toSeconds(e);if(this._state.getValueAtTime(t)===`stopped`){let e=this._state.get(t);e&&e.time>0&&(this._tickOffset.cancel(e.time),this._state.cancel(e.time))}return this._state.cancel(t),this._state.setStateAtTime(`stopped`,t),this.setTicksAtTime(0,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)===`started`&&(this._state.setStateAtTime(`paused`,t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t)),this}cancel(e){return e=this.toSeconds(e),this._state.cancel(e),this._tickOffset.cancel(e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getTicksAtTime(e){let t=this.toSeconds(e),n=this._state.getLastState(`stopped`,t),r=this._ticksAtTime.get(t),i={state:`paused`,time:t};this._state.add(i);let a=r||n,o=r?r.ticks:0,s=null;return this._state.forEachBetween(a.time,t+this.sampleTime,e=>{let t=a.time,n=this._tickOffset.get(e.time);n&&n.time>=a.time&&(o=n.ticks,t=n.time),a.state===`started`&&e.state!==`started`&&(o+=this.frequency.getTicksAtTime(e.time)-this.frequency.getTicksAtTime(t),e.time!==i.time&&(s={state:e.state,time:e.time,ticks:o})),a=e}),this._state.remove(i),s&&this._ticksAtTime.add(s),o}get ticks(){return this.getTicksAtTime(this.now())}set ticks(e){this.setTicksAtTime(e,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(e){let t=this.now(),n=this.frequency.timeToTicks(e,t);this.setTicksAtTime(n,t)}getSecondsAtTime(e){e=this.toSeconds(e);let t=this._state.getLastState(`stopped`,e),n={state:`paused`,time:e};this._state.add(n);let r=this._secondsAtTime.get(e),i=r||t,a=r?r.seconds:0,o=null;return this._state.forEachBetween(i.time,e+this.sampleTime,e=>{let t=i.time,r=this._tickOffset.get(e.time);r&&r.time>=i.time&&(a=r.seconds,t=r.time),i.state===`started`&&e.state!==`started`&&(a+=e.time-t,e.time!==n.time&&(o={state:e.state,time:e.time,seconds:a})),i=e}),this._state.remove(n),o&&this._secondsAtTime.add(o),a}setTicksAtTime(e,t){return t=this.toSeconds(t),this._tickOffset.cancel(t),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(e,t),ticks:e,time:t}),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getStateAtTime(e){return e=this.toSeconds(e),this._state.getValueAtTime(e)}getTimeOfTick(e,t=this.now()){let n=this._tickOffset.get(t),r=this._state.get(t),i=Math.max(n.time,r.time),a=this.frequency.getTicksAtTime(i)+e-n.ticks;return this.frequency.getTimeOfTick(a)}forEachTickBetween(e,t,n){let r=this._state.get(e);this._state.forEachBetween(e,t,t=>{r&&r.state===`started`&&t.state!==`started`&&this.forEachTickBetween(Math.max(r.time,e),t.time-this.sampleTime,n),r=t});let i=null;if(r&&r.state===`started`){let a=Math.max(r.time,e),o=this.frequency.getTicksAtTime(a),s=o-this.frequency.getTicksAtTime(r.time),c=Math.ceil(s)-s;c=Rs(c,1)?0:c;let l=this.frequency.getTimeOfTick(o+c);for(;l<t;){try{n(l,Math.round(this.getTicksAtTime(l)))}catch(e){i=e;break}l+=this.frequency.getDurationOfTicks(1,l)}}if(i)throw i;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}},Nc=class e extends xc{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`frequency`]);super(t),this.name=`Clock`,this.callback=W,this._lastUpdate=0,this._state=new Sc(`stopped`),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Mc({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,U(this,`frequency`),this._state.setStateAtTime(`stopped`,0),this.context.on(`tick`,this._boundLoop)}static getDefaults(){return Object.assign(xc.getDefaults(),{callback:W,frequency:1,units:`hertz`})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){os(this.context);let n=this.toSeconds(e);return this.log(`start`,n),this._state.getValueAtTime(n)!==`started`&&(this._state.setStateAtTime(`started`,n),this._tickSource.start(n,t),n<this._lastUpdate&&this.emit(`start`,n,t)),this}stop(e){let t=this.toSeconds(e);return this.log(`stop`,t),this._state.cancel(t),this._state.setStateAtTime(`stopped`,t),this._tickSource.stop(t),t<this._lastUpdate&&this.emit(`stop`,t),this}pause(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)===`started`&&(this._state.setStateAtTime(`paused`,t),this._tickSource.pause(t),t<this._lastUpdate&&this.emit(`pause`,t)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(e){this._tickSource.ticks=e}get seconds(){return this._tickSource.seconds}set seconds(e){this._tickSource.seconds=e}getSecondsAtTime(e){return this._tickSource.getSecondsAtTime(e)}setTicksAtTime(e,t){return this._tickSource.setTicksAtTime(e,t),this}getTimeOfTick(e,t=this.now()){return this._tickSource.getTimeOfTick(e,t)}getTicksAtTime(e){return this._tickSource.getTicksAtTime(e)}nextTickTime(e,t){let n=this.toSeconds(t),r=this.getTicksAtTime(n);return this._tickSource.getTimeOfTick(r+e,n)}_loop(){let e=this._lastUpdate,t=this.now();this._lastUpdate=t,this.log(`loop`,e,t),e!==t&&(this._state.forEachBetween(e,t,e=>{switch(e.state){case`started`:let t=this._tickSource.getTicksAtTime(e.time);this.emit(`start`,e.time,t);break;case`stopped`:e.time!==0&&this.emit(`stop`,e.time);break;case`paused`:this.emit(`pause`,e.time)}}),this._tickSource.forEachTickBetween(e,t,(e,t)=>{this.callback(e,t)}))}getStateAtTime(e){let t=this.toSeconds(e);return this._state.getValueAtTime(t)}dispose(){return super.dispose(),this.context.off(`tick`,this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};qs.mixin(Nc);var Pc=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`maxDelay`]);super(t),this.name=`Delay`;let n=this.toSeconds(t.maxDelay);this._maxDelay=Math.max(n,this.toSeconds(t.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(n),this.delayTime=new q({context:this.context,param:this._delayNode.delayTime,units:`time`,value:t.delayTime,minValue:0,maxValue:this.maxDelay}),U(this,`delayTime`)}static getDefaults(){return Object.assign(J.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}},Fc=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`volume`]);super(t),this.name=`Volume`,this.input=this.output=new Y({context:this.context,gain:t.volume,units:`decibels`}),this.volume=this.output.gain,U(this,`volume`),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(J.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(e){!this.mute&&e?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!e&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}},Ic=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Destination`,this.input=new Fc({context:this.context}),this.output=new Y({context:this.context}),this.volume=this.input.volume,Cc(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(J.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(e){this.input.mute=e}chain(...e){return this.input.disconnect(),e.unshift(this.input),e.push(this.output),Cc(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Hs(e=>{e.destination=new Ic({context:e})}),Gs(e=>{e.destination.dispose()});var Lc=class extends J{constructor(){super(...arguments),this.name=`Listener`,this.positionX=new q({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new q({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new q({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new q({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new q({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new q({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new q({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new q({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new q({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(J.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}};Hs(e=>{e.listener=new Lc({context:e})}),Gs(e=>{e.listener.dispose()});function Rc(e,t){return V(this,arguments,void 0,function*(e,t,n=2,r=G().sampleRate){let i=G(),a=new $s(n,t,r);nc(a),yield e(a);let o=a.render();return nc(i),new Qs(yield o)})}var zc=class e extends Ns{constructor(){super(),this.name=`ToneAudioBuffers`,this._buffers=new Map,this._loadingCount=0;let t=H(e.getDefaults(),arguments,[`urls`,`onload`,`baseUrl`],`urls`);this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:``,onerror:W,onload:W,urls:{}}}has(e){return this._buffers.has(e.toString())}get(e){return z(this.has(e),`ToneAudioBuffers has no buffer named: ${e}`),this._buffers.get(e.toString())}_bufferLoaded(e){this._loadingCount--,this._loadingCount===0&&e&&e()}get loaded(){return Array.from(this._buffers).every(([e,t])=>t.loaded)}add(e,t,n=W,r=W){return rs(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()===`data:audio/`&&(this.baseUrl=``),this._buffers.set(e.toString(),new Qs(this.baseUrl+t,n,r))):this._buffers.set(e.toString(),new Qs(t,n,r)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}},Bc=class e extends gc{constructor(){super(...arguments),this.name=`MidiClass`,this.defaultUnits=`midi`}_frequencyToUnits(e){return uc(super._frequencyToUnits(e))}_ticksToUnits(e){return uc(super._ticksToUnits(e))}_beatsToUnits(e){return uc(super._beatsToUnits(e))}_secondsToUnits(e){return uc(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return fc(this.toMidi())}transpose(t){return new e(this.context,this.toMidi()+t)}};function Vc(e,t){return new Bc(G(),e,t)}var Z=class extends K{constructor(){super(...arguments),this.name=`Ticks`,this.defaultUnits=`i`}_now(){return this.context.transport.ticks}_beatsToUnits(e){return this._getPPQ()*e}_secondsToUnits(e){return Math.floor(e/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(e){return e}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};function Hc(e,t){return new Z(G(),e,t)}var Uc=class extends xc{constructor(){super(...arguments),this.name=`Draw`,this.expiration=.25,this.anticipation=.008,this._events=new Bs,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(e,t){return this._events.add({callback:e,time:this.toSeconds(t)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(e){return this._events.cancel(this.toSeconds(e)),this}_drawLoop(){let e=this.context.currentTime;this._events.forEachBefore(e+this.anticipation,t=>{e-t.time<=this.expiration&&t.callback(),this._events.remove(t)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};Hs(e=>{e.draw=new Uc({context:e})}),Gs(e=>{e.draw.dispose()});var Wc=class extends Ns{constructor(){super(...arguments),this.name=`IntervalTimeline`,this._root=null,this._length=0}add(e){z(R(e.time),`Events must have a time property`),z(R(e.duration),`Events must have a duration parameter`),e.time=e.time.valueOf();let t=new Gc(e.time,e.time+e.duration,e);for(this._root===null?this._root=t:this._root.insert(t),this._length++;t!==null;)t.updateHeight(),t.updateMax(),this._rebalance(t),t=t.parent;return this}remove(e){if(this._root!==null){let t=[];this._root.search(e.time,t);for(let n of t)if(n.event===e){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(e){return this.forEachFrom(e,e=>this.remove(e)),this}_setRoot(e){this._root=e,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(e,t){e.parent===null?this._setRoot(t):(e.isLeftChild()?e.parent.left=t:e.parent.right=t,this._rebalance(e.parent))}_removeNode(e){if(e.left===null&&e.right===null)this._replaceNodeInParent(e,null);else if(e.right===null)this._replaceNodeInParent(e,e.left);else if(e.left===null)this._replaceNodeInParent(e,e.right);else{let t=e.getBalance(),n,r=null;if(t>0){if(e.left.right===null)n=e.left,n.right=e.right,r=n;else{for(n=e.left.right;n.right!==null;)n=n.right;n.parent&&(n.parent.right=n.left,r=n.parent,n.left=e.left,n.right=e.right)}}else if(e.right.left===null)n=e.right,n.left=e.left,r=n;else{for(n=e.right.left;n.left!==null;)n=n.left;n.parent&&(n.parent.left=n.right,r=n.parent,n.left=e.left,n.right=e.right)}e.parent===null?this._setRoot(n):e.isLeftChild()?e.parent.left=n:e.parent.right=n,r&&this._rebalance(r)}e.dispose()}_rotateLeft(e){let t=e.parent,n=e.isLeftChild(),r=e.right;r&&(e.right=r.left,r.left=e),t===null?this._setRoot(r):n?t.left=r:t.right=r}_rotateRight(e){let t=e.parent,n=e.isLeftChild(),r=e.left;r&&(e.left=r.right,r.right=e),t===null?this._setRoot(r):n?t.left=r:t.right=r}_rebalance(e){let t=e.getBalance();t>1&&e.left?e.left.getBalance()<0?this._rotateLeft(e.left):this._rotateRight(e):t<-1&&e.right&&(e.right.getBalance()>0?this._rotateRight(e.right):this._rotateLeft(e))}get(e){if(this._root!==null){let t=[];if(this._root.search(e,t),t.length>0){let e=t[0];for(let n=1;n<t.length;n++)t[n].low>e.low&&(e=t[n]);return e.event}}return null}forEach(e){if(this._root!==null){let t=[];this._root.traverse(e=>t.push(e)),t.forEach(t=>{t.event&&e(t.event)})}return this}forEachAtTime(e,t){if(this._root!==null){let n=[];this._root.search(e,n),n.forEach(e=>{e.event&&t(e.event)})}return this}forEachFrom(e,t){if(this._root!==null){let n=[];this._root.searchAfter(e,n),n.forEach(e=>{e.event&&t(e.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(e=>e.dispose()),this._root=null,this}},Gc=class{constructor(e,t,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=e,this.high=t,this.max=this.high}insert(e){e.low<=this.low?this.left===null?this.left=e:this.left.insert(e):this.right===null?this.right=e:this.right.insert(e)}search(e,t){e>this.max||(this.left!==null&&this.left.search(e,t),this.low<=e&&this.high>e&&t.push(this),this.low>e||this.right!==null&&this.right.search(e,t))}searchAfter(e,t){this.low>=e&&(t.push(this),this.left!==null&&this.left.searchAfter(e,t)),this.right!==null&&this.right.searchAfter(e,t)}traverse(e){e(this),this.left!==null&&this.left.traverse(e),this.right!==null&&this.right.traverse(e)}updateHeight(){this.height=this.left!==null&&this.right!==null?Math.max(this.left.height,this.right.height)+1:this.right===null?this.left===null?0:this.left.height+1:this.right.height+1}updateMax(){this.max=this.high,this.left!==null&&(this.max=Math.max(this.max,this.left.max)),this.right!==null&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let e=0;return this.left!==null&&this.right!==null?e=this.left.height-this.right.height:this.left===null?this.right!==null&&(e=-(this.right.height+1)):e=this.left.height+1,e}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(e){this._left=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(e){this._right=e,e!==null&&(e.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}},Kc=e({}),qc=class extends Ns{constructor(e){super(),this.name=`TimelineValue`,this._timeline=new Bs({memory:10}),this._initialValue=e}set(e,t){return this._timeline.add({value:e,time:t}),this}get(e){let t=this._timeline.get(e);return t?t.value:this._initialValue}},Jc=class e extends J{constructor(){super(H(e.getDefaults(),arguments,[`context`]))}connect(e,t=0,n=0){return kc(this,e,t,n),this}},Yc=class e extends Jc{constructor(){let t=H(e.getDefaults(),arguments,[`mapping`,`length`]);super(t),this.name=`WaveShaper`,this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,ns(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Qo(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(X.getDefaults(),{length:1024})}setMap(e,t=1024){let n=new Float32Array(t);for(let r=0,i=t;r<i;r++){let t=r/(i-1)*2-1;n[r]=e(t,r)}return this.curve=n,this}get curve(){return this._shaper.curve}set curve(e){this._shaper.curve=e}get oversample(){return this._shaper.oversample}set oversample(e){z([`none`,`2x`,`4x`].some(t=>t.includes(e)),`oversampling must be either 'none', '2x', or '4x'`),this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.disconnect(),this}},Xc=class e extends Jc{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`Pow`,this._exponentScaler=this.input=this.output=new Yc({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(Jc.getDefaults(),{value:1})}_expFunc(e){return t=>Math.abs(t)**+e}get value(){return this._exponent}set value(e){this._exponent=e,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}},Zc=class e{constructor(t,n){this.id=e._eventId++,this._remainderTime=0;let r=Object.assign(e.getDefaults(),n);this.transport=t,this.callback=r.callback,this._once=r.once,this.time=Math.floor(r.time),this._remainderTime=r.time-this.time}static getDefaults(){return{callback:W,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(e){if(this.callback){let t=this.transport.bpm.getDurationOfTicks(1,e);this.callback(e+this._remainderTime*t),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};Zc._eventId=0;var Qc=class e extends Zc{constructor(t,n){super(t,n),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(e.getDefaults(),n);this.duration=r.duration,this._interval=r.interval,this._nextTick=r.time,this.transport.on(`start`,this._boundRestart),this.transport.on(`loopStart`,this._boundRestart),this.transport.on(`ticks`,this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Zc.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return Ls(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Z(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){Ls(this._nextTick+this._interval,this.floatTime+this.duration)&&(this._nextTick+=this._interval,this._currentId=this._nextId,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Z(this.context,this._nextTick).toSeconds()))}_restart(e){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let t=this.transport.getTicksAtTime(e);Fs(t,this.time)&&(this._nextTick=this.floatTime+Math.ceil((t-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off(`start`,this._boundRestart),this.transport.off(`loopStart`,this._boundRestart),this.transport.off(`ticks`,this._boundRestart),this}},$c=class e extends xc{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Transport`,this._loop=new qc(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Bs,this._repeatedEvents=new Wc,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new Nc({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),U(this,`bpm`),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(xc.getDefaults(),{bpm:120,loopEnd:`4m`,loopStart:0,ppq:192,swing:0,swingSubdivision:`8n`,timeSignature:4})}_processTick(e,t){if(this._loop.get(e)&&t>=this._loopEnd&&(this.emit(`loopEnd`,e),this._clock.setTicksAtTime(this._loopStart,e),t=this._loopStart,this.emit(`loopStart`,e,this._clock.getSecondsAtTime(e)),this.emit(`loop`,e)),this._swingAmount>0&&t%this._ppq!==0&&t%(this._swingTicks*2)!=0){let n=t%(this._swingTicks*2)/(this._swingTicks*2),r=Math.sin(n*Math.PI)*this._swingAmount;e+=new Z(this.context,this._swingTicks*2/3).toSeconds()*r}ls(!0),this._timeline.forEachAtTime(t,t=>t.invoke(e)),ls(!1)}schedule(e,t){let n=new Zc(this,{callback:e,time:new K(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(e,t,n,r=1/0){let i=new Qc(this,{callback:e,duration:new mc(this.context,r).toTicks(),interval:new mc(this.context,t).toTicks(),time:new K(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(e,t){let n=new Zc(this,{callback:e,once:!0,time:new K(this.context,t).toTicks()});return this._addEvent(n,this._timeline)}clear(e){if(this._scheduledEvents.hasOwnProperty(e)){let t=this._scheduledEvents[e.toString()];t.timeline.remove(t.event),t.event.dispose(),delete this._scheduledEvents[e.toString()]}return this}_addEvent(e,t){return this._scheduledEvents[e.id.toString()]={event:e,timeline:t},t.add(e),e.id}cancel(e=0){let t=this.toTicks(e);return this._timeline.forEachFrom(t,e=>this.clear(e.id)),this._repeatedEvents.forEachFrom(t,e=>this.clear(e.id)),this}_bindClockEvents(){this._clock.on(`start`,(e,t)=>{t=new Z(this.context,t).toSeconds(),this.emit(`start`,e,t)}),this._clock.on(`stop`,e=>{this.emit(`stop`,e)}),this._clock.on(`pause`,e=>{this.emit(`pause`,e)})}get state(){return this._clock.getStateAtTime(this.now())}start(e,t){this.context.resume();let n;return R(t)&&(n=this.toTicks(t)),this._clock.start(e,n),this}stop(e){return this._clock.stop(e),this}pause(e){return this._clock.pause(e),this}toggle(e){return e=this.toSeconds(e),this._clock.getStateAtTime(e)===`started`?this.stop(e):this.start(e),this}get timeSignature(){return this._timeSignature}set timeSignature(e){ns(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new mc(this.context,this._loopStart,`i`).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new mc(this.context,this._loopEnd,`i`).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e)}get loop(){return this._loop.get(this.now())}set loop(e){this._loop.set(e,this.now())}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get swing(){return this._swingAmount}set swing(e){this._swingAmount=e}get swingSubdivision(){return new Z(this.context,this._swingTicks).toNotation()}set swingSubdivision(e){this._swingTicks=this.toTicks(e)}get position(){let e=this.now(),t=this._clock.getTicksAtTime(e);return new Z(this.context,t).toBarsBeatsSixteenths()}set position(e){let t=this.toTicks(e);this.ticks=t}get seconds(){return this._clock.seconds}set seconds(e){let t=this.now(),n=this._clock.frequency.timeToTicks(e,t);this.ticks=n}get progress(){if(this.loop){let e=this.now();return(this._clock.getTicksAtTime(e)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(e){if(this._clock.ticks!==e){let t=this.now();if(this.state===`started`){let n=this._clock.getTicksAtTime(t),r=t+this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,t);this.emit(`stop`,r),this._clock.setTicksAtTime(e,r),this.emit(`start`,r,this._clock.getSecondsAtTime(r))}else this.emit(`ticks`,t),this._clock.setTicksAtTime(e,t)}}getTicksAtTime(e){return this._clock.getTicksAtTime(e)}getSecondsAtTime(e){return this._clock.getSecondsAtTime(e)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(e){this._clock.frequency.multiplier=e}nextSubdivision(e){if(e=this.toTicks(e),this.state!==`started`)return 0;{let t=this.now(),n=this.getTicksAtTime(t),r=e-n%e;return this._clock.nextTickTime(r,t)}}syncSignal(e,t){let n=this.now(),r=this.bpm,i=1/(60/r.getValueAtTime(n)/this.PPQ),a=[];if(e.units===`time`){let e=1/64/i,t=new Y(e),n=new Xc(-1),o=new Y(e);r.chain(t,n,o),r=o,i=1/i,a=[t,n,o]}t||=e.getValueAtTime(n)===0?0:e.getValueAtTime(n)/i;let o=new Y(t);return r.connect(o),o.connect(e._param),a.push(o),this._syncedSignals.push({initial:e.value,nodes:a,signal:e}),e.value=0,this}unsyncSignal(e){for(let t=this._syncedSignals.length-1;t>=0;t--){let n=this._syncedSignals[t];n.signal===e&&(n.nodes.forEach(e=>e.dispose()),n.signal.value=n.initial,this._syncedSignals.splice(t,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Zs(this,`bpm`),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};qs.mixin($c),Hs(e=>{e.transport=new $c({context:e})}),Gs(e=>{e.transport.dispose()});var Q=class extends J{constructor(e){super(e),this.input=void 0,this._state=new Sc(`stopped`),this._synced=!1,this._scheduled=[],this._syncedStart=W,this._syncedStop=W,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Fc({context:this.context,mute:e.mute,volume:e.volume}),this.volume=this._volume.volume,U(this,`volume`),this.onstop=e.onstop}static getDefaults(){return Object.assign(J.getDefaults(),{mute:!1,onstop:W,volume:0})}get state(){return this._synced?this.context.transport.state===`started`?this._state.getValueAtTime(this.context.transport.seconds):`stopped`:this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}_clampToCurrentTime(e){return this._synced?e:Math.max(e,this.context.currentTime)}start(e,t,n){let r=Zo(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(r=this._clampToCurrentTime(r),!this._synced&&this._state.getValueAtTime(r)===`started`)z(Fs(r,this._state.get(r).time),`Start time must be strictly greater than previous start time`),this._state.cancel(r),this._state.setStateAtTime(`started`,r),this.log(`restart`,r),this.restart(r,t,n);else if(this.log(`start`,r),this._state.setStateAtTime(`started`,r),this._synced){let e=this._state.get(r);e&&(e.offset=this.toSeconds(js(t,0)),e.duration=n?this.toSeconds(n):void 0);let i=this.context.transport.schedule(e=>{this._start(e,t,n)},r);this._scheduled.push(i),this.context.transport.state===`started`&&this.context.transport.getSecondsAtTime(this.immediate())>r&&this._syncedStart(this.now(),this.context.transport.seconds)}else os(this.context),this._start(r,t,n);return this}stop(e){let t=Zo(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(t=this._clampToCurrentTime(t),this._state.getValueAtTime(t)===`started`||R(this._state.getNextState(`started`,t))){if(this.log(`stop`,t),!this._synced)this._stop(t);else{let e=this.context.transport.schedule(this._stop.bind(this),t);this._scheduled.push(e)}this._state.cancel(t),this._state.setStateAtTime(`stopped`,t)}return this}restart(e,t,n){return e=this.toSeconds(e),this._state.getValueAtTime(e)===`started`&&(this._state.cancel(e),this._restart(e,t,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(e,t)=>{if(Fs(t,0)){let n=this._state.get(t);if(n&&n.state===`started`&&n.time!==t){let r=t-this.toSeconds(n.time),i;n.duration&&(i=this.toSeconds(n.duration)-r),this._start(e,this.toSeconds(n.offset)+r,i)}}},this._syncedStop=e=>{let t=this.context.transport.getSecondsAtTime(Math.max(e-this.sampleTime,0));this._state.getValueAtTime(t)===`started`&&this._stop(e)},this.context.transport.on(`start`,this._syncedStart),this.context.transport.on(`loopStart`,this._syncedStart),this.context.transport.on(`stop`,this._syncedStop),this.context.transport.on(`pause`,this._syncedStop),this.context.transport.on(`loopEnd`,this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off(`stop`,this._syncedStop),this.context.transport.off(`pause`,this._syncedStop),this.context.transport.off(`loopEnd`,this._syncedStop),this.context.transport.off(`start`,this._syncedStart),this.context.transport.off(`loopStart`,this._syncedStart)),this._synced=!1,this._scheduled.forEach(e=>this.context.transport.clear(e)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=W,this.unsync(),this._volume.dispose(),this._state.dispose(),this}},el=class e extends Dc{constructor(){let t=H(e.getDefaults(),arguments,[`url`,`onload`]);super(t),this.name=`ToneBufferSource`,this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,wc(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new q({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 Qs(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Dc.getDefaults(),{url:new Qs,loop:!1,loopEnd:0,loopStart:0,onload:W,onerror:W,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e}get curve(){return this._curve}set curve(e){this._curve=e}start(e,t,n,r=1){z(this.buffer.loaded,`buffer is either not set or not loaded`);let i=this.toSeconds(e);this._startGain(i,r),t=this.loop?js(t,this.loopStart):js(t,0);let a=Math.max(this.toSeconds(t),0);if(this.loop){let e=this.toSeconds(this.loopEnd)||this.buffer.duration,t=this.toSeconds(this.loopStart),n=e-t;Is(a,e)&&(a=(a-t)%n+t),Rs(a,this.buffer.duration)&&(a=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Ls(a,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,a)),R(n)){let e=this.toSeconds(n);e=Math.max(e,0),this.stop(i+e)}return this}_stopSource(e){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(e)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(e){this._source.loopStart=this.toSeconds(e)}get loopEnd(){return this._source.loopEnd}set loopEnd(e){this._source.loopEnd=this.toSeconds(e)}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._source.loop}set loop(e){this._source.loop=e,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}},tl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`type`]);super(t),this.name=`Noise`,this._source=null,this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Q.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:`white`})}get type(){return this._type}set type(e){if(z(e in al,`Noise: invalid type: `+e),this._type!==e&&(this._type=e,this.state===`started`)){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._source&&(this._source.playbackRate.value=e)}_start(e){let t=al[this._type];this._source=new el({url:t,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(e),Math.random()*(t.duration-.001))}_stop(e){this._source&&=(this._source.stop(this.toSeconds(e)),null)}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(e){this._stop(e),this._start(e)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},nl=220500,rl=2,il={brown:null,pink:null,white:null},al={get brown(){if(!il.brown){let e=[];for(let t=0;t<rl;t++){let n=new Float32Array(nl);e[t]=n;let r=0;for(let e=0;e<nl;e++){let t=Math.random()*2-1;n[e]=(r+.02*t)/1.02,r=n[e],n[e]*=3.5}}il.brown=new Qs().fromArray(e)}return il.brown},get pink(){if(!il.pink){let e=[];for(let t=0;t<rl;t++){let n=new Float32Array(nl);e[t]=n;let r,i,a,o,s,c,l;r=i=a=o=s=c=l=0;for(let e=0;e<nl;e++){let t=Math.random()*2-1;r=.99886*r+t*.0555179,i=.99332*i+t*.0750759,a=.969*a+t*.153852,o=.8665*o+t*.3104856,s=.55*s+t*.5329522,c=-.7616*c-t*.016898,n[e]=r+i+a+o+s+c+l+t*.5362,n[e]*=.11,l=t*.115926}}il.pink=new Qs().fromArray(e)}return il.pink},get white(){if(!il.white){let e=[];for(let t=0;t<rl;t++){let n=new Float32Array(nl);e[t]=n;for(let e=0;e<nl;e++)n[e]=Math.random()*2-1}il.white=new Qs().fromArray(e)}return il.white}},ol=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`volume`]);super(t),this.name=`UserMedia`,this._volume=this.output=new Fc({context:this.context,volume:t.volume}),this.volume=this._volume.volume,U(this,`volume`),this.mute=t.mute}static getDefaults(){return Object.assign(J.getDefaults(),{mute:!1,volume:0})}open(t){return V(this,void 0,void 0,function*(){z(e.supported,`UserMedia is not supported`),this.state===`started`&&this.close();let n=yield e.enumerateDevices();$o(t)?this._device=n[t]:(this._device=n.find(e=>e.label===t||e.deviceId===t),!this._device&&n.length>0&&(this._device=n[0]),z(R(this._device),`No matching device ${t}`));let r={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(r.audio.deviceId=this._device.deviceId);let i=yield navigator.mediaDevices.getUserMedia(r);if(!this._stream){this._stream=i;let e=this.context.createMediaStreamSource(i);wc(e,this.output),this._mediaStream=e}return this})}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach(e=>{e.stop()}),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return V(this,void 0,void 0,function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===`audioinput`)})}get state(){return this._stream&&this._stream.active?`started`:`stopped`}get deviceId(){if(this._device)return this._device.deviceId}get groupId(){if(this._device)return this._device.groupId}get label(){if(this._device)return this._device.label}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return R(navigator.mediaDevices)&&R(navigator.mediaDevices.getUserMedia)}};function sl(e,t){return V(this,void 0,void 0,function*(){let n=t/e.context.sampleRate,r=new $s(1,n,e.context.sampleRate);return new e.constructor(Object.assign(e.get(),{frequency:2/n,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var cl=class e extends Dc{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`ToneOscillatorNode`,this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],wc(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new q({context:this.context,param:this._oscillator.frequency,units:`frequency`,value:t.frequency}),this.detune=new q({context:this.context,param:this._oscillator.detune,units:`cents`,value:t.detune}),U(this,[`frequency`,`detune`])}static getDefaults(){return Object.assign(Dc.getDefaults(),{detune:0,frequency:440,type:`sine`})}start(e){let t=this.toSeconds(e);return this.log(`start`,t),this._startGain(t),this._oscillator.start(t),this}_stopSource(e){this._oscillator.stop(e)}setPeriodicWave(e){return this._oscillator.setPeriodicWave(e),this}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e}dispose(){return super.dispose(),this.state===`started`&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}},ll=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`Oscillator`,this._oscillator=null,this.frequency=new X({context:this.context,units:`frequency`,value:t.frequency}),U(this,`frequency`),this.detune=new X({context:this.context,units:`cents`,value:t.detune}),U(this,`detune`),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&t.type!==`custom`&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(Q.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:`sine`})}_start(e){let t=this.toSeconds(e),n=new cl({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(t)}_stop(e){let t=this.toSeconds(e);this._oscillator&&this._oscillator.stop(t)}_restart(e){let t=this.toSeconds(e);return this.log(`restart`,t),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(t),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type===`custom`)return e._periodicWaveCache.find(e=>e.phase===this._phase&&ks(e.partials,this._partials));{let t=e._periodicWaveCache.find(e=>e.type===this._type&&e.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;let n=[`sine`,`square`,`sawtooth`,`triangle`].indexOf(t)!==-1;if(this._phase===0&&n)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let n=this._getCachedPeriodicWave();if(R(n)){let{partials:e,wave:t}=n;this._wave=t,this._partials=e,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[n,r]=this._getRealImaginary(t,this._phase),i=this.context.createPeriodicWave(n,r);this._wave=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),e._periodicWaveCache.push({imag:r,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:n,type:this._type,wave:this._wave}),e._periodicWaveCache.length>100&&e._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),``)}set baseType(e){this.type=this.partialCount&&this._type!==`custom`&&e!==`custom`?e+this.partialCount:e}get partialCount(){return this._partialCount}set partialCount(e){B(e,0);let t=this._type,n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(t=n[1]),this._type!==`custom`)this.type=e===0?t:t+e.toString();else{let t=new Float32Array(e);this._partials.forEach((e,n)=>t[n]=e),this._partials=Array.from(t),this.type=this._type}}_getRealImaginary(e,t){let n=2048,r=new Float32Array(n),i=new Float32Array(n),a=1;if(e===`custom`){if(a=this._partials.length+1,this._partialCount=this._partials.length,n=a,this._partials.length===0)return[r,i]}else{let t=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(e);t?(a=parseInt(t[2],10)+1,this._partialCount=parseInt(t[2],10),e=t[1],a=Math.max(a,2),n=a):this._partialCount=0,this._partials=[]}for(let o=1;o<n;++o){let n=2/(o*Math.PI),s;switch(e){case`sine`:s=+(o<=a),this._partials[o-1]=s;break;case`square`:s=o&1?2*n:0,this._partials[o-1]=s;break;case`sawtooth`:s=n*(o&1?1:-1),this._partials[o-1]=s;break;case`triangle`:s=o&1?n*n*2*(o-1>>1&1?-1:1):0,this._partials[o-1]=s;break;case`custom`:s=this._partials[o-1];break;default:throw TypeError(`Oscillator: invalid type: `+e)}s===0?(r[o]=0,i[o]=0):(r[o]=-s*Math.sin(t*o),i[o]=s*Math.cos(t*o))}return[r,i]}_inverseFFT(e,t,n){let r=0,i=e.length;for(let a=0;a<i;a++)r+=e[a]*Math.cos(a*n)+t[a]*Math.sin(a*n);return r}getInitialValue(){let[e,t]=this._getRealImaginary(this._type,0),n=0,r=Math.PI*2;for(let i=0;i<32;i++)n=Math.max(this._inverseFFT(e,t,i/32*r),n);return zs(-this._inverseFFT(e,t,this._phase)/n,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this.type=`custom`)}get phase(){return this._phase*(180/Math.PI)}set phase(e){this._phase=e*Math.PI/180,this.type=this._type}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};ll._periodicWaveCache=[];var ul=class extends Jc{constructor(){super(...arguments),this.name=`AudioToGain`,this._norm=new Yc({context:this.context,mapping:e=>(e+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}},$=class e extends X{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`Multiply`,this.override=!1,this._mult=this.input=this.output=new Y({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(X.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}},dl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`,`modulationType`]);super(t),this.name=`AMOscillator`,this._modulationScale=new ul({context:this.context}),this._modulationNode=new Y({context:this.context}),this._carrier=new ll({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 ll({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new $({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),U(this,[`frequency`,`detune`,`harmonicity`])}static getDefaults(){return Object.assign(ll.getDefaults(),{harmonicity:1,modulationType:`square`})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){this._modulator.restart(e),this._carrier.restart(e)}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}},fl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`,`modulationType`]);super(t),this.name=`FMOscillator`,this._modulationNode=new Y({context:this.context,gain:0}),this._carrier=new ll({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 X({context:this.context,units:`frequency`,value:t.frequency}),this._modulator=new ll({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new $({context:this.context,units:`positive`,value:t.harmonicity}),this.modulationIndex=new $({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),U(this,[`modulationIndex`,`frequency`,`detune`,`harmonicity`])}static getDefaults(){return Object.assign(ll.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:`square`})}_start(e){this._modulator.start(e),this._carrier.start(e)}_stop(e){this._modulator.stop(e),this._carrier.stop(e)}_restart(e){return this._modulator.restart(e),this._carrier.restart(e),this}get type(){return this._carrier.type}set type(e){this._carrier.type=e}get baseType(){return this._carrier.baseType}set baseType(e){this._carrier.baseType=e}get partialCount(){return this._carrier.partialCount}set partialCount(e){this._carrier.partialCount=e}get modulationType(){return this._modulator.type}set modulationType(e){this._modulator.type=e}get phase(){return this._carrier.phase}set phase(e){this._carrier.phase=e,this._modulator.phase=e}get partials(){return this._carrier.partials}set partials(e){this._carrier.partials=e}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}},pl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`width`]);super(t),this.name=`PulseOscillator`,this._widthGate=new Y({context:this.context,gain:0}),this._thresh=new Yc({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new X({context:this.context,units:`audioRange`,value:t.width}),this._triangle=new ll({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),U(this,[`width`,`frequency`,`detune`])}static getDefaults(){return Object.assign(Q.getDefaults(),{detune:0,frequency:440,phase:0,type:`pulse`,width:.2})}_start(e){e=this.toSeconds(e),this._triangle.start(e),this._widthGate.gain.setValueAtTime(1,e)}_stop(e){e=this.toSeconds(e),this._triangle.stop(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(0,e)}_restart(e){this._triangle.restart(e),this._widthGate.gain.cancelScheduledValues(e),this._widthGate.gain.setValueAtTime(1,e)}get phase(){return this._triangle.phase}set phase(e){this._triangle.phase=e}get type(){return`pulse`}get baseType(){return`pulse`}get partials(){return[]}get partialCount(){return 0}set carrierType(e){this._triangle.type=e}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}},ml=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`,`spread`]);super(t),this.name=`FatOscillator`,this._oscillators=[],this.frequency=new X({context:this.context,units:`frequency`,value:t.frequency}),this.detune=new X({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,U(this,[`frequency`,`detune`])}static getDefaults(){return Object.assign(ll.getDefaults(),{count:3,spread:20,type:`sawtooth`})}_start(e){e=this.toSeconds(e),this._forEach(t=>t.start(e))}_stop(e){e=this.toSeconds(e),this._forEach(t=>t.stop(e))}_restart(e){this._forEach(t=>t.restart(e))}_forEach(e){for(let t=0;t<this._oscillators.length;t++)e(this._oscillators[t],t)}get type(){return this._type}set type(e){this._type=e,this._forEach(t=>t.type=e)}get spread(){return this._spread}set spread(e){if(this._spread=e,this._oscillators.length>1){let t=-e/2,n=e/(this._oscillators.length-1);this._forEach((e,r)=>e.detune.value=t+n*r)}}get count(){return this._oscillators.length}set count(e){if(B(e,1),this._oscillators.length!==e){this._forEach(e=>e.dispose()),this._oscillators=[];for(let t=0;t<e;t++){let n=new ll({context:this.context,volume:-6-e*1.1,type:this._type,phase:this._phase+t/e*360,partialCount:this._partialCount,onstop:t===0?()=>this.onstop(this):W});this.type===`custom`&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[t]=n}this.spread=this._spread,this.state===`started`&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(e){this._phase=e,this._forEach((e,t)=>e.phase=this._phase+t/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(e){this._forEach(t=>t.baseType=e),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(e){this._partials=e,this._partialCount=this._partials.length,e.length&&(this._type=`custom`,this._forEach(t=>t.partials=e))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(e){this._partialCount=e,this._forEach(t=>t.partialCount=e),this._type=this._oscillators[0].type}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}},hl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`modulationFrequency`]);super(t),this.name=`PWMOscillator`,this.sourceType=`pwm`,this._scale=new $({context:this.context,value:2}),this._pulse=new pl({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType=`sine`,this.modulationFrequency=this._pulse.frequency,this._modulator=new ll({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),U(this,[`modulationFrequency`,`frequency`,`detune`])}static getDefaults(){return Object.assign(Q.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:`pwm`})}_start(e){e=this.toSeconds(e),this._modulator.start(e),this._pulse.start(e)}_stop(e){e=this.toSeconds(e),this._modulator.stop(e),this._pulse.stop(e)}_restart(e){this._modulator.restart(e),this._pulse.restart(e)}get type(){return`pwm`}get baseType(){return`pwm`}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(e){this._modulator.phase=e}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}},gl={am:dl,fat:ml,fm:fl,oscillator:ll,pulse:pl,pwm:hl},_l=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`OmniOscillator`,this.frequency=new X({context:this.context,units:`frequency`,value:t.frequency}),this.detune=new X({context:this.context,units:`cents`,value:t.detune}),U(this,[`frequency`,`detune`]),this.set(t)}static getDefaults(){return Object.assign(ll.getDefaults(),fl.getDefaults(),dl.getDefaults(),ml.getDefaults(),pl.getDefaults(),hl.getDefaults())}_start(e){this._oscillator.start(e)}_stop(e){this._oscillator.stop(e)}_restart(e){return this._oscillator.restart(e),this}get type(){let e=``;return[`am`,`fm`,`fat`].some(e=>this._sourceType===e)&&(e=this._sourceType),e+this._oscillator.type}set type(e){e.substr(0,2)===`fm`?(this._createNewOscillator(`fm`),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,2)===`am`?(this._createNewOscillator(`am`),this._oscillator=this._oscillator,this._oscillator.type=e.substr(2)):e.substr(0,3)===`fat`?(this._createNewOscillator(`fat`),this._oscillator=this._oscillator,this._oscillator.type=e.substr(3)):e===`pwm`?(this._createNewOscillator(`pwm`),this._oscillator=this._oscillator):e===`pulse`?this._createNewOscillator(`pulse`):(this._createNewOscillator(`oscillator`),this._oscillator=this._oscillator,this._oscillator.type=e)}get partials(){return this._oscillator.partials}set partials(e){!this._getOscType(this._oscillator,`pulse`)&&!this._getOscType(this._oscillator,`pwm`)&&(this._oscillator.partials=e)}get partialCount(){return this._oscillator.partialCount}set partialCount(e){!this._getOscType(this._oscillator,`pulse`)&&!this._getOscType(this._oscillator,`pwm`)&&(this._oscillator.partialCount=e)}set(e){return Reflect.has(e,`type`)&&e.type&&(this.type=e.type),super.set(e),this}_createNewOscillator(e){if(e!==this._sourceType){this._sourceType=e;let t=gl[e],n=this.now();if(this._oscillator){let e=this._oscillator;e.stop(n),this.context.setTimeout(()=>e.dispose(),this.blockTime)}this._oscillator=new t({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state===`started`&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e}get sourceType(){return this._sourceType}set sourceType(e){let t=`sine`;this._oscillator.type!==`pwm`&&this._oscillator.type!==`pulse`&&(t=this._oscillator.type),e===`fm`?this.type=`fm`+t:e===`am`?this.type=`am`+t:e===`fat`?this.type=`fat`+t:e===`oscillator`?this.type=t:e===`pulse`?this.type=`pulse`:e===`pwm`&&(this.type=`pwm`)}_getOscType(e,t){return e instanceof gl[t]}get baseType(){return this._oscillator.baseType}set baseType(e){!this._getOscType(this._oscillator,`pulse`)&&!this._getOscType(this._oscillator,`pwm`)&&e!==`pulse`&&e!==`pwm`&&(this._oscillator.baseType=e)}get width(){if(this._getOscType(this._oscillator,`pulse`))return this._oscillator.width}get count(){if(this._getOscType(this._oscillator,`fat`))return this._oscillator.count}set count(e){this._getOscType(this._oscillator,`fat`)&&$o(e)&&(this._oscillator.count=e)}get spread(){if(this._getOscType(this._oscillator,`fat`))return this._oscillator.spread}set spread(e){this._getOscType(this._oscillator,`fat`)&&$o(e)&&(this._oscillator.spread=e)}get modulationType(){if(this._getOscType(this._oscillator,`fm`)||this._getOscType(this._oscillator,`am`))return this._oscillator.modulationType}set modulationType(e){(this._getOscType(this._oscillator,`fm`)||this._getOscType(this._oscillator,`am`))&&rs(e)&&(this._oscillator.modulationType=e)}get modulationIndex(){if(this._getOscType(this._oscillator,`fm`))return this._oscillator.modulationIndex}get harmonicity(){if(this._getOscType(this._oscillator,`fm`)||this._getOscType(this._oscillator,`am`))return this._oscillator.harmonicity}get modulationFrequency(){if(this._getOscType(this._oscillator,`pwm`))return this._oscillator.modulationFrequency}asArray(){return V(this,arguments,void 0,function*(e=1024){return sl(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}},vl=class e extends X{constructor(){super(H(e.getDefaults(),arguments,[`value`])),this.override=!1,this.name=`Add`,this._sum=new Y({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,Cc(this._constantSource,this._sum)}static getDefaults(){return Object.assign(X.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}},yl=class e extends Jc{constructor(){let t=H(e.getDefaults(),arguments,[`min`,`max`]);super(t),this.name=`Scale`,this._mult=this.input=new $({context:this.context,value:t.max-t.min}),this._add=this.output=new vl({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(Jc.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(e){this._min=e,this._setRange()}get max(){return this._max}set max(e){this._max=e,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}},bl=class e extends Jc{constructor(){super(H(e.getDefaults(),arguments)),this.name=`Zero`,this._gain=new Y({context:this.context}),this.output=this._gain,this.input=void 0,wc(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),Tc(this.context.getConstant(0),this._gain),this}},xl=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`min`,`max`]);super(t),this.name=`LFO`,this._stoppedValue=0,this._units=`number`,this.convert=!0,this._fromType=q.prototype._fromType,this._toType=q.prototype._toType,this._is=q.prototype._is,this._clampValue=q.prototype._clampValue,this._oscillator=new ll(t),this.frequency=this._oscillator.frequency,this._amplitudeGain=new Y({context:this.context,gain:t.amplitude,units:`normalRange`}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new X({context:this.context,units:`audioRange`,value:0}),this._zeros=new bl({context:this.context}),this._a2g=new ul({context:this.context}),this._scaler=this.output=new yl({context:this.context,max:t.max,min:t.min}),this.units=t.units,this.min=t.min,this.max=t.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),U(this,[`amplitude`,`frequency`]),this.phase=t.phase}static getDefaults(){return Object.assign(ll.getDefaults(),{amplitude:1,frequency:`4n`,max:1,min:0,type:`sine`,units:`number`})}start(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(0,e),this._oscillator.start(e),this}stop(e){return e=this.toSeconds(e),this._stoppedSignal.setValueAtTime(this._stoppedValue,e),this._oscillator.stop(e),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}_setStoppedValue(){this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get min(){return this._toType(this._scaler.min)}set min(e){e=this._fromType(e),this._scaler.min=e}get max(){return this._toType(this._scaler.max)}set max(e){e=this._fromType(e),this._scaler.max=e}get type(){return this._oscillator.type}set type(e){this._oscillator.type=e,this._setStoppedValue()}get partials(){return this._oscillator.partials}set partials(e){this._oscillator.partials=e,this._setStoppedValue()}get phase(){return this._oscillator.phase}set phase(e){this._oscillator.phase=e,this._setStoppedValue()}get units(){return this._units}set units(e){let t=this.min,n=this.max;this._units=e,this.min=t,this.max=n}get state(){return this._oscillator.state}connect(e,t,n){return(e instanceof q||e instanceof X)&&(this.convert=e.convert,this.units=e.units),kc(this,e,t,n),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}};function Sl(e,t=1/0){let n=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(r){B(r,e,t),n.set(this,r)}})}}function Cl(e,t=1/0){let n=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(r){B(this.toSeconds(r),e,t),n.set(this,r)}})}}var wl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`url`,`onload`]);super(t),this.name=`Player`,this._activeSources=new Set,this._buffer=new Qs({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(Q.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:W,onerror:W,playbackRate:1,reverse:!1})}load(e){return V(this,void 0,void 0,function*(){return yield this._buffer.load(e),this._onload(),this})}_onload(e=W){e(),this.autostart&&this.start()}_onSourceEnd(e){this.onstop(this),this._activeSources.delete(e),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())===`started`&&(this._state.cancel(this.now()),this._state.setStateAtTime(`stopped`,this.now()))}start(e,t,n){return super.start(e,t,n),this}_start(e,t,n){t=this._loop?js(t,this._loopStart):js(t,0);let r=this.toSeconds(t),i=n;n=js(n,Math.max(this._buffer.duration-r,0));let a=this.toSeconds(n);a/=this._playbackRate,e=this.toSeconds(e);let o=new el({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(e+a),this._state.setStateAtTime(`stopped`,e+a,{implicitEnd:!0})),this._activeSources.add(o),this._loop&&Zo(i)?o.start(e,r):o.start(e,r,a-this.toSeconds(this.fadeOut))}_stop(e){let t=this.toSeconds(e);this._activeSources.forEach(e=>e.stop(t))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){var r;(r=[...this._activeSources].pop())==null||r.stop(e),this._start(e,t,n)}seek(e,t){let n=this.toSeconds(t);if(this._state.getValueAtTime(n)===`started`){let t=this.toSeconds(e);this._stop(n),this._start(n,t)}return this}setLoopPoints(e,t){return this.loopStart=e,this.loopEnd=t,this}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this.buffer.loaded&&B(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopStart=e})}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,this.buffer.loaded&&B(this.toSeconds(e),0,this.buffer.duration),this._activeSources.forEach(t=>{t.loopEnd=e})}get buffer(){return this._buffer}set buffer(e){this._buffer.set(e)}get loop(){return this._loop}set loop(e){if(this._loop!==e&&(this._loop=e,this._activeSources.forEach(t=>{t.loop=e}),e)){let e=this._state.getNextState(`stopped`,this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e;let t=this.now(),n=this._state.getNextState(`stopped`,t);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(e=>e.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(e,t)})}get reverse(){return this._buffer.reverse}set reverse(e){this._buffer.reverse=e}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(e=>e.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};bs([Cl(0)],wl.prototype,`fadeIn`,void 0),bs([Cl(0)],wl.prototype,`fadeOut`,void 0);var Tl=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`urls`,`onload`],`urls`);super(t),this.name=`Players`,this.input=void 0,this._players=new Map,this._volume=this.output=new Fc({context:this.context,volume:t.volume}),this.volume=this._volume.volume,U(this,`volume`),this._buffers=new zc({urls:t.urls,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.mute=t.mute,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Q.getDefaults(),{baseUrl:``,fadeIn:0,fadeOut:0,mute:!1,onload:W,onerror:W,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}get fadeIn(){return this._fadeIn}set fadeIn(e){this._fadeIn=e,this._players.forEach(t=>{t.fadeIn=e})}get fadeOut(){return this._fadeOut}set fadeOut(e){this._fadeOut=e,this._players.forEach(t=>{t.fadeOut=e})}get state(){return Array.from(this._players).some(([e,t])=>t.state===`started`)?`started`:`stopped`}has(e){return this._buffers.has(e)}player(e){if(z(this.has(e),`No Player with the name ${e} exists on this object`),!this._players.has(e)){let t=new wl({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(e)}).connect(this.output);this._players.set(e,t)}return this._players.get(e)}get loaded(){return this._buffers.loaded}add(e,t,n){return z(!this._buffers.has(e),`A buffer with that name already exists on this object`),this._buffers.add(e,t,n),this}stopAll(e){return this._players.forEach(t=>t.stop(e)),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach(e=>e.dispose()),this._buffers.dispose(),this}},El=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`url`,`onload`]);super(t),this.name=`GrainPlayer`,this._loopStart=0,this._loopEnd=0,this._activeSources=[],this.buffer=new Qs({onload:t.onload,onerror:t.onerror,reverse:t.reverse,url:t.url}),this._clock=new Nc({context:this.context,callback:this._tick.bind(this),frequency:1/t.grainSize}),this._playbackRate=t.playbackRate,this._grainSize=t.grainSize,this._overlap=t.overlap,this.detune=t.detune,this.overlap=t.overlap,this.loop=t.loop,this.playbackRate=t.playbackRate,this.grainSize=t.grainSize,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.reverse=t.reverse,this._clock.on(`stop`,this._onstop.bind(this))}static getDefaults(){return Object.assign(Q.getDefaults(),{onload:W,onerror:W,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(e,t,n){t=js(t,0),t=this.toSeconds(t),e=this.toSeconds(e);let r=1/this._clock.frequency.getValueAtTime(e);this._clock.start(e,t/r),n&&this.stop(e+this.toSeconds(n))}restart(e,t,n){return super.restart(e,t,n),this}_restart(e,t,n){this._stop(e),this._start(e,t,n)}_stop(e){this._clock.stop(e)}_onstop(e){this._activeSources.forEach(t=>{t.fadeOut=0,t.stop(e)}),this.onstop(this)}_tick(e){let t=this._clock.getTicksAtTime(e),n=t*this._grainSize;if(this.log(`offset`,n),!this.loop&&n>this.buffer.duration){this.stop(e);return}let r=n<this._overlap?0:this._overlap,i=new el({context:this.context,url:this.buffer,fadeIn:r,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:oc(this.detune/100)}).connect(this.output);i.start(e,this._grainSize*t),i.stop(e+this._grainSize/this.playbackRate),this._activeSources.push(i),i.onended=()=>{let e=this._activeSources.indexOf(i);e!==-1&&this._activeSources.splice(e,1)}}get playbackRate(){return this._playbackRate}set playbackRate(e){B(e,.001),this._playbackRate=e,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(e){this.buffer.loaded&&B(this.toSeconds(e),0,this.buffer.duration),this._loopStart=this.toSeconds(e)}get loopEnd(){return this._loopEnd}set loopEnd(e){this.buffer.loaded&&B(this.toSeconds(e),0,this.buffer.duration),this._loopEnd=this.toSeconds(e)}get reverse(){return this.buffer.reverse}set reverse(e){this.buffer.reverse=e}get grainSize(){return this._grainSize}set grainSize(e){this._grainSize=this.toSeconds(e),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(e){let t=this.toSeconds(e);B(t,0),this._overlap=t}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach(e=>e.dispose()),this}},Dl=class extends Jc{constructor(){super(...arguments),this.name=`Abs`,this._abs=new Yc({context:this.context,mapping:e=>Math.abs(e)<.001?0:Math.abs(e)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}},Ol=class extends Jc{constructor(){super(...arguments),this.name=`GainToAudio`,this._norm=new Yc({context:this.context,mapping:e=>Math.abs(e)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}},kl=class extends Jc{constructor(){super(...arguments),this.name=`Negate`,this._multiply=new $({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}},Al=class e extends X{constructor(){super(H(e.getDefaults(),arguments,[`value`])),this.override=!1,this.name=`Subtract`,this._sum=new Y({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new kl({context:this.context}),this.subtrahend=this._param,Cc(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(X.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}},jl=class e extends Jc{constructor(){super(H(e.getDefaults(),arguments)),this.name=`GreaterThanZero`,this._thresh=this.output=new Yc({context:this.context,length:127,mapping:e=>e<=0?0:1}),this._scale=this.input=new $({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}},Ml=class e extends X{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`GreaterThan`,this.override=!1,this._subtract=this.input=new Al({context:this.context,value:t.value}),this._gtz=this.output=new jl({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,U(this,`comparator`),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(X.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}},Nl=class e extends yl{constructor(){let t=H(e.getDefaults(),arguments,[`min`,`max`,`exponent`]);super(t),this.name=`ScaleExp`,this.input=this._exp=new Xc({context:this.context,value:t.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(yl.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(e){this._exp.value=e}dispose(){return super.dispose(),this._exp.dispose(),this}},Pl=class extends X{constructor(){let e=H(X.getDefaults(),arguments,[`value`,`units`]);super(e),this.name=`SyncedSignal`,this.override=!1,this._lastVal=e.value,this._synced=this.context.transport.scheduleRepeat(this._onTick.bind(this),`1i`),this._syncedCallback=this._anchorValue.bind(this),this.context.transport.on(`start`,this._syncedCallback),this.context.transport.on(`pause`,this._syncedCallback),this.context.transport.on(`stop`,this._syncedCallback),this._constantSource.disconnect(),this._constantSource.stop(0),this._constantSource=this.output=new Oc({context:this.context,offset:e.value,units:e.units}).start(0),this.setValueAtTime(e.value,0)}_onTick(e){let t=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==t&&(this._lastVal=t,this._constantSource.offset.setValueAtTime(t,e))}_anchorValue(e){let t=super.getValueAtTime(this.context.transport.seconds);this._lastVal=t,this._constantSource.offset.cancelAndHoldAtTime(e),this._constantSource.offset.setValueAtTime(t,e)}getValueAtTime(e){let t=new K(this.context,e).toSeconds();return super.getValueAtTime(t)}setValueAtTime(e,t){let n=new K(this.context,t).toSeconds();return super.setValueAtTime(e,n),this}linearRampToValueAtTime(e,t){let n=new K(this.context,t).toSeconds();return super.linearRampToValueAtTime(e,n),this}exponentialRampToValueAtTime(e,t){let n=new K(this.context,t).toSeconds();return super.exponentialRampToValueAtTime(e,n),this}setTargetAtTime(e,t,n){let r=new K(this.context,t).toSeconds();return super.setTargetAtTime(e,r,n),this}cancelScheduledValues(e){let t=new K(this.context,e).toSeconds();return super.cancelScheduledValues(t),this}setValueCurveAtTime(e,t,n,r){let i=new K(this.context,t).toSeconds();return n=this.toSeconds(n),super.setValueCurveAtTime(e,i,n,r),this}cancelAndHoldAtTime(e){let t=new K(this.context,e).toSeconds();return super.cancelAndHoldAtTime(t),this}setRampPoint(e){let t=new K(this.context,e).toSeconds();return super.setRampPoint(t),this}exponentialRampTo(e,t,n){let r=new K(this.context,n).toSeconds();return super.exponentialRampTo(e,t,r),this}linearRampTo(e,t,n){let r=new K(this.context,n).toSeconds();return super.linearRampTo(e,t,r),this}targetRampTo(e,t,n){let r=new K(this.context,n).toSeconds();return super.targetRampTo(e,t,r),this}dispose(){return super.dispose(),this.context.transport.clear(this._synced),this.context.transport.off(`start`,this._syncedCallback),this.context.transport.off(`pause`,this._syncedCallback),this.context.transport.off(`stop`,this._syncedCallback),this._constantSource.dispose(),this}},Fl=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`attack`,`decay`,`sustain`,`release`]);super(t),this.name=`Envelope`,this._sig=new X({context:this.context,value:0}),this.output=this._sig,this.input=void 0,this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(J.getDefaults(),{attack:.01,attackCurve:`linear`,decay:.1,decayCurve:`exponential`,release:1,releaseCurve:`exponential`,sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(e,t){if(rs(e))return e;{let n;for(n in Il)if(Il[n][t]===e)return n;return e}}_setCurve(e,t,n){if(rs(n)&&Reflect.has(Il,n)){let r=Il[n];es(r)?e!==`_decayCurve`&&(this[e]=r[t]):this[e]=r}else if(ns(n)&&e!==`_decayCurve`)this[e]=n;else throw Error(`Envelope: invalid curve: `+n)}get attackCurve(){return this._getCurve(this._attackCurve,`In`)}set attackCurve(e){this._setCurve(`_attackCurve`,`In`,e)}get releaseCurve(){return this._getCurve(this._releaseCurve,`Out`)}set releaseCurve(e){this._setCurve(`_releaseCurve`,`Out`,e)}get decayCurve(){return this._getCurve(this._decayCurve,`Out`)}set decayCurve(e){this._setCurve(`_decayCurve`,`Out`,e)}triggerAttack(e,t=1){this.log(`triggerAttack`,e,t),e=this.toSeconds(e);let n=this.toSeconds(this.attack),r=this.toSeconds(this.decay),i=this.getValueAtTime(e);if(i>0){let e=1/n;n=(1-i)/e}if(n<this.sampleTime)this._sig.cancelScheduledValues(e),this._sig.setValueAtTime(t,e);else if(this._attackCurve===`linear`)this._sig.linearRampTo(t,n,e);else if(this._attackCurve===`exponential`)this._sig.targetRampTo(t,n,e);else{this._sig.cancelAndHoldAtTime(e);let r=this._attackCurve;for(let e=1;e<r.length;e++)if(r[e-1]<=i&&i<=r[e]){r=this._attackCurve.slice(e),r[0]=i;break}this._sig.setValueCurveAtTime(r,e,n,t)}if(r&&this.sustain<1){let i=t*this.sustain,a=e+n;this.log(`decay`,a),this._decayCurve===`linear`?this._sig.linearRampToValueAtTime(i,r+a):this._sig.exponentialApproachValueAtTime(i,a,r)}return this}triggerRelease(e){this.log(`triggerRelease`,e),e=this.toSeconds(e);let t=this.getValueAtTime(e);if(t>0){let n=this.toSeconds(this.release);n<this.sampleTime?this._sig.setValueAtTime(0,e):this._releaseCurve===`linear`?this._sig.linearRampTo(0,n,e):this._releaseCurve===`exponential`?this._sig.targetRampTo(0,n,e):(z(ns(this._releaseCurve),`releaseCurve must be either 'linear', 'exponential' or an array`),this._sig.cancelAndHoldAtTime(e),this._sig.setValueCurveAtTime(this._releaseCurve,e,n,t))}return this}getValueAtTime(e){return this._sig.getValueAtTime(e)}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),this.triggerAttack(t,n),this.triggerRelease(t+this.toSeconds(e)),this}cancel(e){return this._sig.cancelScheduledValues(this.toSeconds(e)),this}connect(e,t=0,n=0){return kc(this,e,t,n),this}asArray(){return V(this,arguments,void 0,function*(e=1024){let t=e/this.context.sampleRate,n=new $s(1,t,this.context.sampleRate),r=this.toSeconds(this.attack)+this.toSeconds(this.decay),i=r+this.toSeconds(this.release),a=i*.1,o=i+a,s=new this.constructor(Object.assign(this.get(),{attack:t*this.toSeconds(this.attack)/o,decay:t*this.toSeconds(this.decay)/o,release:t*this.toSeconds(this.release)/o,context:n}));return s._sig.toDestination(),s.triggerAttackRelease(t*(r+a)/o,0),(yield n.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};bs([Cl(0)],Fl.prototype,`attack`,void 0),bs([Cl(0)],Fl.prototype,`decay`,void 0),bs([Sl(0,1)],Fl.prototype,`sustain`,void 0),bs([Cl(0)],Fl.prototype,`release`,void 0);var Il=(()=>{let e,t,n=[];for(e=0;e<128;e++)n[e]=Math.sin(e/127*(Math.PI/2));let r=[];for(e=0;e<127;e++){t=e/127;let n=Math.sin(Math.PI*2*t*6.4-Math.PI/2)+1;r[e]=n/10+t*.83}r[127]=1;let i=[];for(e=0;e<128;e++)i[e]=Math.ceil(e/127*5)/5;let a=[];for(e=0;e<128;e++)t=e/127,a[e]=.5*(1-Math.cos(Math.PI*t));let o=[];for(e=0;e<128;e++){t=e/127;let n=t**3*4+.2,r=Math.cos(n*Math.PI*2*t);o[e]=Math.abs(r*(1-t))}function s(e){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=1-e[n];return t}function c(e){return e.slice(0).reverse()}return{bounce:{In:s(o),Out:o},cosine:{In:n,Out:c(n)},exponential:`exponential`,linear:`linear`,ripple:{In:r,Out:s(r)},sine:{In:a,Out:s(a)},step:{In:i,Out:s(i)}}})(),Ll=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this._scheduledEvents=[],this._synced=!1,this._original_triggerAttack=this.triggerAttack,this._original_triggerRelease=this.triggerRelease,this._syncedRelease=e=>this._original_triggerRelease(e),this._volume=this.output=new Fc({context:this.context,volume:t.volume}),this.volume=this._volume.volume,U(this,`volume`)}static getDefaults(){return Object.assign(J.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,1),this._syncMethod(`triggerRelease`,0),this.context.transport.on(`stop`,this._syncedRelease),this.context.transport.on(`pause`,this._syncedRelease),this.context.transport.on(`loopEnd`,this._syncedRelease)),this}_syncState(){let e=!1;return this._synced||(this._synced=!0,e=!0),e}_syncMethod(e,t){let n=this[`_original_`+e]=this[e];this[e]=(...e)=>{let r=e[t],i=this.context.transport.schedule(r=>{e[t]=r,n.apply(this,e)},r);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach(e=>this.context.transport.clear(e)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off(`stop`,this._syncedRelease),this.context.transport.off(`pause`,this._syncedRelease),this.context.transport.off(`loopEnd`,this._syncedRelease)),this}triggerAttackRelease(e,t,n,r){let i=this.toSeconds(n),a=this.toSeconds(t);return this.triggerAttack(e,i,r),this.triggerRelease(i+a),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}},Rl=class e extends Ll{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Ll.getDefaults(),{detune:0,onsilence:W,portamento:0})}triggerAttack(e,t,n=1){this.log(`triggerAttack`,e,t,n);let r=this.toSeconds(t);return this._triggerEnvelopeAttack(r,n),this.setNote(e,r),this}triggerRelease(e){this.log(`triggerRelease`,e);let t=this.toSeconds(e);return this._triggerEnvelopeRelease(t),this}setNote(e,t){let n=this.toSeconds(t),r=e instanceof gc?e.toFrequency():e;if(this.portamento>0&&this.getLevelAtTime(n)>.05){let e=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(r,e,n)}else this.frequency.setValueAtTime(r,n);return this}};bs([Cl(0)],Rl.prototype,`portamento`,void 0);var zl=class e extends Fl{constructor(){super(H(e.getDefaults(),arguments,[`attack`,`decay`,`sustain`,`release`])),this.name=`AmplitudeEnvelope`,this._gainNode=new Y({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}},Bl=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Synth`,this.oscillator=new _l(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 zl(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),U(this,[`oscillator`,`frequency`,`detune`,`envelope`])}static getDefaults(){return Object.assign(Rl.getDefaults(),{envelope:Object.assign(Ms(Fl.getDefaults(),Object.keys(J.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ms(_l.getDefaults(),[...Object.keys(Q.getDefaults()),`frequency`,`detune`]),{type:`triangle`})})}_triggerEnvelopeAttack(e,t){if(this.envelope.triggerAttack(e,t),this.oscillator.start(e),this.envelope.sustain===0){let t=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+t+n)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}},Vl=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`ModulationSynth`,this._carrier=new Bl({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new Bl({context:this.context,oscillator:t.modulation,envelope:t.modulationEnvelope,volume:-10}),this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope,this.modulation=this._modulator.oscillator,this.modulationEnvelope=this._modulator.envelope,this.frequency=new X({context:this.context,units:`frequency`}),this.detune=new X({context:this.context,value:t.detune,units:`cents`}),this.harmonicity=new $({context:this.context,value:t.harmonicity,minValue:0}),this._modulationNode=new Y({context:this.context,gain:0}),U(this,[`frequency`,`harmonicity`,`oscillator`,`envelope`,`modulation`,`modulationEnvelope`,`detune`])}static getDefaults(){return Object.assign(Rl.getDefaults(),{harmonicity:3,oscillator:Object.assign(Ms(_l.getDefaults(),[...Object.keys(Q.getDefaults()),`frequency`,`detune`]),{type:`sine`}),envelope:Object.assign(Ms(Fl.getDefaults(),Object.keys(J.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(Ms(_l.getDefaults(),[...Object.keys(Q.getDefaults()),`frequency`,`detune`]),{type:`square`}),modulationEnvelope:Object.assign(Ms(Fl.getDefaults(),Object.keys(J.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(e,t){this._carrier._triggerEnvelopeAttack(e,t),this._modulator._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this._carrier._triggerEnvelopeRelease(e),this._modulator._triggerEnvelopeRelease(e),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}},Hl=class e extends Vl{constructor(){super(H(e.getDefaults(),arguments)),this.name=`AMSynth`,this._modulationScale=new ul({context:this.context}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output)}dispose(){return super.dispose(),this._modulationScale.dispose(),this}},Ul=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`BiquadFilter`,this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new q({context:this.context,units:`number`,value:t.Q,param:this._filter.Q}),this.frequency=new q({context:this.context,units:`frequency`,value:t.frequency,param:this._filter.frequency}),this.detune=new q({context:this.context,units:`cents`,value:t.detune,param:this._filter.detune}),this.gain=new q({context:this.context,units:`decibels`,convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(J.getDefaults(),{Q:1,type:`lowpass`,frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(e){z([`lowpass`,`highpass`,`bandpass`,`lowshelf`,`highshelf`,`notch`,`allpass`,`peaking`].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._filter.type=e}getFrequencyResponse(e=128){let t=new Float32Array(e);for(let n=0;n<e;n++){let r=(n/e)**2*19980+20;t[n]=r}let n=new Float32Array(e),r=new Float32Array(e),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(t,n,r),n}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}},Wl=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`,`rolloff`]);super(t),this.name=`Filter`,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._filters=[],this._filters=[],this.Q=new X({context:this.context,units:`positive`,value:t.Q}),this.frequency=new X({context:this.context,units:`frequency`,value:t.frequency}),this.detune=new X({context:this.context,units:`cents`,value:t.detune}),this.gain=new X({context:this.context,units:`decibels`,convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,U(this,[`detune`,`frequency`,`gain`,`Q`])}static getDefaults(){return Object.assign(J.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:`lowpass`})}get type(){return this._type}set type(e){z([`lowpass`,`highpass`,`bandpass`,`lowshelf`,`highshelf`,`notch`,`allpass`,`peaking`].indexOf(e)!==-1,`Invalid filter type: ${e}`),this._type=e,this._filters.forEach(t=>t.type=e)}get rolloff(){return this._rolloff}set rolloff(e){let t=$o(e)?e:parseInt(e,10),n=[-12,-24,-48,-96],r=n.indexOf(t);z(r!==-1,`rolloff can only be ${n.join(`, `)}`),r+=1,this._rolloff=t,this.input.disconnect(),this._filters.forEach(e=>e.disconnect()),this._filters=Array(r);for(let e=0;e<r;e++){let t=new Ul({context:this.context});t.type=this._type,this.frequency.connect(t.frequency),this.detune.connect(t.detune),this.Q.connect(t.Q),this.gain.connect(t.gain),this._filters[e]=t}this._internalChannels=this._filters,Cc(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){let t=new Ul({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),n=new Float32Array(e).map(()=>1);return this._filters.forEach(()=>{t.getFrequencyResponse(e).forEach((e,t)=>n[t]*=e)}),t.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(e=>{e.dispose()}),Zs(this,[`detune`,`frequency`,`gain`,`Q`]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}},Gl=class e extends Fl{constructor(){let t=H(e.getDefaults(),arguments,[`attack`,`decay`,`sustain`,`release`]);super(t),this.name=`FrequencyEnvelope`,this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new Xc({context:this.context,value:t.exponent}),this._scale=this.output=new yl({context:this.context,min:this._baseFrequency,max:this._baseFrequency*2**this._octaves}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(Fl.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){let t=this.toFrequency(e);B(t,0),this._baseFrequency=t,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._scale.max=this._baseFrequency*2**e}get exponent(){return this._exponent.value}set exponent(e){this._exponent.value=e}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}},Kl=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MonoSynth`,this.oscillator=new _l(Object.assign(t.oscillator,{context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new Wl(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new Gl(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new zl(Object.assign(t.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),U(this,[`oscillator`,`frequency`,`detune`,`filter`,`filterEnvelope`,`envelope`])}static getDefaults(){return Object.assign(Rl.getDefaults(),{envelope:Object.assign(Ms(Fl.getDefaults(),Object.keys(J.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(Ms(Wl.getDefaults(),Object.keys(J.getDefaults())),{Q:1,rolloff:-12,type:`lowpass`}),filterEnvelope:Object.assign(Ms(Gl.getDefaults(),Object.keys(J.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(Ms(_l.getDefaults(),Object.keys(Q.getDefaults())),{type:`sawtooth`})})}_triggerEnvelopeAttack(e,t=1){if(this.envelope.triggerAttack(e,t),this.filterEnvelope.triggerAttack(e),this.oscillator.start(e),this.envelope.sustain===0){let t=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(e+t+n)}}_triggerEnvelopeRelease(e){this.envelope.triggerRelease(e),this.filterEnvelope.triggerRelease(e),this.oscillator.stop(e+this.toSeconds(this.envelope.release))}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}},ql=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`DuoSynth`,this.voice0=new Kl(Object.assign(t.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new Kl(Object.assign(t.voice1,{context:this.context})),this.harmonicity=new $({context:this.context,units:`positive`,value:t.harmonicity}),this._vibrato=new xl({frequency:t.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new Y({context:this.context,units:`normalRange`,gain:t.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new X({context:this.context,units:`frequency`,value:440}),this.detune=new X({context:this.context,units:`cents`,value:t.detune}),this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.detune.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),U(this,[`voice0`,`voice1`,`frequency`,`vibratoAmount`,`vibratoRate`])}getLevelAtTime(e){return e=this.toSeconds(e),this.voice0.envelope.getValueAtTime(e)+this.voice1.envelope.getValueAtTime(e)}static getDefaults(){return Os(Rl.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:Os(Ms(Kl.getDefaults(),Object.keys(Rl.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:Os(Ms(Kl.getDefaults(),Object.keys(Rl.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(e,t){this.voice0._triggerEnvelopeAttack(e,t),this.voice1._triggerEnvelopeAttack(e,t)}_triggerEnvelopeRelease(e){return this.voice0._triggerEnvelopeRelease(e),this.voice1._triggerEnvelopeRelease(e),this}dispose(){return super.dispose(),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this.detune.dispose(),this._vibrato.dispose(),this.vibratoRate.dispose(),this._vibratoGain.dispose(),this.harmonicity.dispose(),this}},Jl=class e extends Vl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`FMSynth`,this.modulationIndex=new $({context:this.context,value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output)}static getDefaults(){return Object.assign(Vl.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}},Yl=[1,1.483,1.932,2.546,2.63,3.897],Xl=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MetalSynth`,this._oscillators=[],this._freqMultipliers=[],this.detune=new X({context:this.context,units:`cents`,value:t.detune}),this.frequency=new X({context:this.context,units:`frequency`}),this._amplitude=new Y({context:this.context,gain:0}).connect(this.output),this._highpass=new Wl({Q:0,context:this.context,type:`highpass`}).connect(this._amplitude);for(let e=0;e<Yl.length;e++){let n=new fl({context:this.context,harmonicity:t.harmonicity,modulationIndex:t.modulationIndex,modulationType:`square`,onstop:e===0?()=>this.onsilence(this):W,type:`square`});n.connect(this._highpass),this._oscillators[e]=n;let r=new $({context:this.context,value:Yl[e]});this._freqMultipliers[e]=r,this.frequency.chain(r,n.frequency),this.detune.connect(n.detune)}this._filterFreqScaler=new yl({context:this.context,max:7e3,min:this.toFrequency(t.resonance)}),this.envelope=new Fl({attack:t.envelope.attack,attackCurve:`linear`,context:this.context,decay:t.envelope.decay,release:t.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=t.octaves,this.octaves=t.octaves}static getDefaults(){return Os(Rl.getDefaults(),{envelope:Object.assign(Ms(Fl.getDefaults(),Object.keys(J.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(e,t=1){return this.envelope.triggerAttack(e,t),this._oscillators.forEach(t=>t.start(e)),this.envelope.sustain===0&&this._oscillators.forEach(t=>{t.stop(e+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))}),this}_triggerEnvelopeRelease(e){return this.envelope.triggerRelease(e),this._oscillators.forEach(t=>t.stop(e+this.toSeconds(this.envelope.release))),this}getLevelAtTime(e){return e=this.toSeconds(e),this.envelope.getValueAtTime(e)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(e){this._oscillators.forEach(t=>t.modulationIndex.value=e)}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(e){this._oscillators.forEach(t=>t.harmonicity.value=e)}get resonance(){return this._filterFreqScaler.min}set resonance(e){this._filterFreqScaler.min=this.toFrequency(e),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._filterFreqScaler.max=this._filterFreqScaler.min*2**e}dispose(){return super.dispose(),this._oscillators.forEach(e=>e.dispose()),this._freqMultipliers.forEach(e=>e.dispose()),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}},Zl=class e extends Bl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MembraneSynth`,this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,U(this,[`oscillator`,`envelope`])}static getDefaults(){return Os(Rl.getDefaults(),Bl.getDefaults(),{envelope:{attack:.001,attackCurve:`exponential`,decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:`sine`},pitchDecay:.05})}setNote(e,t){let n=this.toSeconds(t),r=this.toFrequency(e instanceof gc?e.toFrequency():e),i=r*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(r,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};bs([Sl(0)],Zl.prototype,`octaves`,void 0),bs([Cl(0)],Zl.prototype,`pitchDecay`,void 0);var Ql=class e extends Ll{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`NoiseSynth`,this.noise=new tl(Object.assign({context:this.context},t.noise)),this.envelope=new zl(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(Ll.getDefaults(),{envelope:Object.assign(Ms(Fl.getDefaults(),Object.keys(J.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(Ms(tl.getDefaults(),Object.keys(Q.getDefaults())),{type:`white`})})}triggerAttack(e,t=1){return e=this.toSeconds(e),this.envelope.triggerAttack(e,t),this.noise.start(e),this.envelope.sustain===0&&this.noise.stop(e+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(e){return e=this.toSeconds(e),this.envelope.triggerRelease(e),this.noise.stop(e+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,0),this._syncMethod(`triggerRelease`,0)),this}triggerAttackRelease(e,t,n=1){return t=this.toSeconds(t),e=this.toSeconds(e),this.triggerAttack(t,n),this.triggerRelease(t+e),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}},$l=new Set;function eu(e){$l.add(e)}function tu(e,t){let n=`registerProcessor("${e}", ${t})`;$l.add(n)}function nu(){return Array.from($l).join(`
20
+ `)}var ru=class extends J{constructor(e){super(e),this.name=`ToneAudioWorklet`,this.workletOptions={},this.onprocessorerror=W;let t=URL.createObjectURL(new Blob([nu()],{type:`text/javascript`})),n=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(t).then(()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(n,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))})}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage(`dispose`),this._worklet.disconnect()),this}};eu(`
21
+ /**
22
+ * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
23
+ */
24
+ class ToneAudioWorkletProcessor extends AudioWorkletProcessor {
25
+
26
+ constructor(options) {
27
+
28
+ super(options);
29
+ /**
30
+ * If the processor was disposed or not. Keep alive until it's disposed.
31
+ */
32
+ this.disposed = false;
33
+ /**
34
+ * The number of samples in the processing block
35
+ */
36
+ this.blockSize = 128;
37
+ /**
38
+ * the sample rate
39
+ */
40
+ this.sampleRate = sampleRate;
41
+
42
+ this.port.onmessage = (event) => {
43
+ // when it receives a dispose
44
+ if (event.data === "dispose") {
45
+ this.disposed = true;
46
+ }
47
+ };
48
+ }
49
+ }
50
+ `),eu(`
51
+ /**
52
+ * Abstract class for a single input/output processor.
53
+ * has a 'generate' function which processes one sample at a time
54
+ */
55
+ class SingleIOProcessor extends ToneAudioWorkletProcessor {
56
+
57
+ constructor(options) {
58
+ super(Object.assign(options, {
59
+ numberOfInputs: 1,
60
+ numberOfOutputs: 1
61
+ }));
62
+ /**
63
+ * Holds the name of the parameter and a single value of that
64
+ * parameter at the current sample
65
+ * @type { [name: string]: number }
66
+ */
67
+ this.params = {}
68
+ }
69
+
70
+ /**
71
+ * Generate an output sample from the input sample and parameters
72
+ * @abstract
73
+ * @param input number
74
+ * @param channel number
75
+ * @param parameters { [name: string]: number }
76
+ * @returns number
77
+ */
78
+ generate(){}
79
+
80
+ /**
81
+ * Update the private params object with the
82
+ * values of the parameters at the given index
83
+ * @param parameters { [name: string]: Float32Array },
84
+ * @param index number
85
+ */
86
+ updateParams(parameters, index) {
87
+ for (const paramName in parameters) {
88
+ const param = parameters[paramName];
89
+ if (param.length > 1) {
90
+ this.params[paramName] = parameters[paramName][index];
91
+ } else {
92
+ this.params[paramName] = parameters[paramName][0];
93
+ }
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Process a single frame of the audio
99
+ * @param inputs Float32Array[][]
100
+ * @param outputs Float32Array[][]
101
+ */
102
+ process(inputs, outputs, parameters) {
103
+ const input = inputs[0];
104
+ const output = outputs[0];
105
+ // get the parameter values
106
+ const channelCount = Math.max(input && input.length || 0, output.length);
107
+ for (let sample = 0; sample < this.blockSize; sample++) {
108
+ this.updateParams(parameters, sample);
109
+ for (let channel = 0; channel < channelCount; channel++) {
110
+ const inputSample = input && input.length ? input[channel][sample] : 0;
111
+ output[channel][sample] = this.generate(inputSample, channel, this.params);
112
+ }
113
+ }
114
+ return !this.disposed;
115
+ }
116
+ };
117
+ `),eu(`
118
+ /**
119
+ * A multichannel buffer for use within an AudioWorkletProcessor as a delay line
120
+ */
121
+ class DelayLine {
122
+
123
+ constructor(size, channels) {
124
+ this.buffer = [];
125
+ this.writeHead = []
126
+ this.size = size;
127
+
128
+ // create the empty channels
129
+ for (let i = 0; i < channels; i++) {
130
+ this.buffer[i] = new Float32Array(this.size);
131
+ this.writeHead[i] = 0;
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Push a value onto the end
137
+ * @param channel number
138
+ * @param value number
139
+ */
140
+ push(channel, value) {
141
+ this.writeHead[channel] += 1;
142
+ if (this.writeHead[channel] > this.size) {
143
+ this.writeHead[channel] = 0;
144
+ }
145
+ this.buffer[channel][this.writeHead[channel]] = value;
146
+ }
147
+
148
+ /**
149
+ * Get the recorded value of the channel given the delay
150
+ * @param channel number
151
+ * @param delay number delay samples
152
+ */
153
+ get(channel, delay) {
154
+ let readHead = this.writeHead[channel] - Math.floor(delay);
155
+ if (readHead < 0) {
156
+ readHead += this.size;
157
+ }
158
+ return this.buffer[channel][readHead];
159
+ }
160
+ }
161
+ `);var iu=`feedback-comb-filter`;tu(iu,`
162
+ class FeedbackCombFilterWorklet extends SingleIOProcessor {
163
+
164
+ constructor(options) {
165
+ super(options);
166
+ this.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);
167
+ }
168
+
169
+ static get parameterDescriptors() {
170
+ return [{
171
+ name: "delayTime",
172
+ defaultValue: 0.1,
173
+ minValue: 0,
174
+ maxValue: 1,
175
+ automationRate: "k-rate"
176
+ }, {
177
+ name: "feedback",
178
+ defaultValue: 0.5,
179
+ minValue: 0,
180
+ maxValue: 0.9999,
181
+ automationRate: "k-rate"
182
+ }];
183
+ }
184
+
185
+ generate(input, channel, parameters) {
186
+ const delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);
187
+ this.delayLine.push(channel, input + delayedSample * parameters.feedback);
188
+ return delayedSample;
189
+ }
190
+ }
191
+ `);var au=class e extends ru{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`resonance`]);super(t),this.name=`FeedbackCombFilter`,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.delayTime=new q({context:this.context,value:t.delayTime,units:`time`,minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new q({context:this.context,value:t.resonance,units:`normalRange`,param:this._dummyParam,swappable:!0}),U(this,[`resonance`,`delayTime`])}_audioWorkletName(){return iu}static getDefaults(){return Object.assign(J.getDefaults(),{delayTime:.1,resonance:.5})}onReady(e){Cc(this.input,e,this.output);let t=e.parameters.get(`delayTime`);this.delayTime.setParam(t);let n=e.parameters.get(`feedback`);this.resonance.setParam(n)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}},ou=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`OnePoleFilter`,this._frequency=t.frequency,this._type=t.type,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign(J.getDefaults(),{frequency:880,type:`lowpass`})}_createFilter(){let e=this._filter,t=this.toFrequency(this._frequency),n=1/(2*Math.PI*t);if(this._type===`lowpass`){let e=1/(n*this.context.sampleRate),t=e-1;this._filter=this.context.createIIRFilter([e,0],[1,t])}else{let e=1/(n*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,e])}this.input.chain(this._filter,this.output),e&&this.context.setTimeout(()=>{this.disposed||(this.input.disconnect(e),e.disconnect())},this.blockTime)}get frequency(){return this._frequency}set frequency(e){this._frequency=e,this._createFilter()}get type(){return this._type}set type(e){this._type=e,this._createFilter()}getFrequencyResponse(e=128){let t=new Float32Array(e);for(let n=0;n<e;n++){let r=(n/e)**2*19980+20;t[n]=r}let n=new Float32Array(e),r=new Float32Array(e);return this._filter.getFrequencyResponse(t,n,r),n}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this._filter.disconnect(),this}},su=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`resonance`,`dampening`]);super(t),this.name=`LowpassCombFilter`,this._combFilter=this.output=new au({context:this.context,delayTime:t.delayTime,resonance:t.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new ou({context:this.context,frequency:t.dampening,type:`lowpass`}),this._lowpass.connect(this._combFilter)}static getDefaults(){return Object.assign(J.getDefaults(),{dampening:3e3,delayTime:.1,resonance:.5})}get dampening(){return this._lowpass.frequency}set dampening(e){this._lowpass.frequency=e}dispose(){return super.dispose(),this._combFilter.dispose(),this._lowpass.dispose(),this}},cu=class e extends Ll{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`PluckSynth`,this._noise=new tl({context:this.context,type:`pink`}),this.attackNoise=t.attackNoise,this._lfcf=new su({context:this.context,dampening:t.dampening,resonance:t.resonance}),this.resonance=t.resonance,this.release=t.release,this._noise.connect(this._lfcf),this._lfcf.connect(this.output)}static getDefaults(){return Os(Ll.getDefaults(),{attackNoise:1,dampening:4e3,resonance:.7,release:1})}get dampening(){return this._lfcf.dampening}set dampening(e){this._lfcf.dampening=e}triggerAttack(e,t){let n=this.toFrequency(e);t=this.toSeconds(t);let r=1/n;return this._lfcf.delayTime.setValueAtTime(r,t),this._noise.start(t),this._noise.stop(t+r*this.attackNoise),this._lfcf.resonance.cancelScheduledValues(t),this._lfcf.resonance.setValueAtTime(this.resonance,t),this}triggerRelease(e){return this._lfcf.resonance.linearRampTo(0,this.release,e),this}dispose(){return super.dispose(),this._noise.dispose(),this._lfcf.dispose(),this}},lu=class e extends Ll{constructor(){let t=H(e.getDefaults(),arguments,[`voice`,`options`]);super(t),this.name=`PolySynth`,this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=e=>this.releaseAll(e),z(!$o(t.voice),`DEPRECATED: The polyphony count is no longer the first argument.`);let n=t.voice.getDefaults();this.options=Object.assign(n,t.options),this.voice=t.voice,this.maxPolyphony=t.maxPolyphony,this._dummyVoice=this._getNextAvailableVoice();let r=this._voices.indexOf(this._dummyVoice);this._voices.splice(r,1),this._gcTimeout=this.context.setInterval(this._collectGarbage.bind(this),1)}static getDefaults(){return Object.assign(Ll.getDefaults(),{maxPolyphony:32,options:{},voice:Bl})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(e){this._availableVoices.push(e);let t=this._activeVoices.findIndex(t=>t.voice===e);this._activeVoices.splice(t,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let e=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return z(e instanceof Rl,`Voice must extend Monophonic class`),e.connect(this.output),this._voices.push(e),e}ms(`Max polyphony exceeded. Note dropped.`)}_collectGarbage(){if(this._averageActiveVoices=Math.max(this._averageActiveVoices*.95,this.activeVoices),this._availableVoices.length&&this._voices.length>Math.ceil(this._averageActiveVoices+1)){let e=this._availableVoices.shift(),t=this._voices.indexOf(e);this._voices.splice(t,1),this.context.isOffline||e.dispose()}}_triggerAttack(e,t,n){e.forEach(e=>{let r=new Bc(this.context,e).toMidi(),i=this._getNextAvailableVoice();i&&(i.triggerAttack(e,t,n),this._activeVoices.push({midi:r,voice:i,released:!1}),this.log(`triggerAttack`,e,t))})}_triggerRelease(e,t){e.forEach(e=>{let n=new Bc(this.context,e).toMidi(),r=this._activeVoices.find(({midi:e,released:t})=>e===n&&!t);r&&(r.voice.triggerRelease(t),r.released=!0,this.log(`triggerRelease`,e,t))})}_scheduleEvent(e,t,n,r){z(!this.disposed,`Synth was already disposed`),n<=this.now()?e===`attack`?this._triggerAttack(t,n,r):this._triggerRelease(t,n):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(e,t,n,r)},n-this.now())}triggerAttack(e,t,n){Array.isArray(e)||(e=[e]);let r=this.toSeconds(t);return this._scheduleEvent(`attack`,e,r,n),this}triggerRelease(e,t){Array.isArray(e)||(e=[e]);let n=this.toSeconds(t);return this._scheduleEvent(`release`,e,n),this}triggerAttackRelease(e,t,n,r){let i=this.toSeconds(n);if(this.triggerAttack(e,i,r),ns(t)){z(ns(e),`If the duration is an array, the notes must also be an array`),e=e;for(let n=0;n<e.length;n++){let r=t[Math.min(n,t.length-1)],a=this.toSeconds(r);z(a>0,`The duration must be greater than 0`),this.triggerRelease(e[n],i+a)}}else{let n=this.toSeconds(t);z(n>0,`The duration must be greater than 0`),this.triggerRelease(e,i+n)}return this}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,1),this._syncMethod(`triggerRelease`,1),this.context.transport.on(`stop`,this._syncedRelease),this.context.transport.on(`pause`,this._syncedRelease),this.context.transport.on(`loopEnd`,this._syncedRelease)),this}set(e){let t=Ms(e,[`onsilence`,`context`]);return this.options=Os(this.options,t),this._voices.forEach(e=>e.set(t)),this._dummyVoice.set(t),this}get(){return this._dummyVoice.get()}releaseAll(e){let t=this.toSeconds(e);return this._activeVoices.forEach(({voice:e})=>{e.triggerRelease(t)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(e=>e.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}},uu=class e extends Ll{constructor(){let t=H(e.getDefaults(),arguments,[`urls`,`onload`,`baseUrl`],`urls`);super(t),this.name=`Sampler`,this._activeSources=new Map;let n={};Object.keys(t.urls).forEach(e=>{let r=parseInt(e,10);if(z(is(e)||$o(r)&&isFinite(r),`url key is neither a note or midi pitch: ${e}`),is(e)){let r=new gc(this.context,e).toMidi();n[r]=t.urls[e]}else $o(r)&&isFinite(r)&&(n[r]=t.urls[r])}),this._buffers=new zc({urls:n,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(Ll.getDefaults(),{attack:0,baseUrl:``,curve:`exponential`,onload:W,onerror:W,release:.1,urls:{}})}_findClosest(e){let t=0;for(;t<96;){if(this._buffers.has(e+t))return-t;if(this._buffers.has(e-t))return t;t++}throw Error(`No available buffers for note: ${e}`)}triggerAttack(e,t,n=1){return this.log(`triggerAttack`,e,t,n),Array.isArray(e)||(e=[e]),e.forEach(e=>{let r=dc(new gc(this.context,e).toFrequency()),i=Math.round(r),a=r-i,o=this._findClosest(i),s=i-o,c=this._buffers.get(s),l=oc(o+a),u=new el({url:c,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:l}).connect(this.output);u.start(t,0,c.duration/l,n),ns(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(u),u.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){let e=this._activeSources.get(i),t=e.indexOf(u);t!==-1&&e.splice(t,1)}}}),this}triggerRelease(e,t){return this.log(`triggerRelease`,e,t),Array.isArray(e)||(e=[e]),e.forEach(e=>{let n=new gc(this.context,e).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){let e=this._activeSources.get(n);t=this.toSeconds(t),e.forEach(e=>{e.stop(t)}),this._activeSources.set(n,[])}}),this}releaseAll(e){let t=this.toSeconds(e);return this._activeSources.forEach(e=>{for(;e.length;)e.shift().stop(t)}),this}sync(){return this._syncState()&&(this._syncMethod(`triggerAttack`,1),this._syncMethod(`triggerRelease`,1)),this}triggerAttackRelease(e,t,n,r=1){let i=this.toSeconds(n);return this.triggerAttack(e,i,r),ns(t)?(z(ns(e),`notes must be an array when duration is array`),e.forEach((e,n)=>{let r=t[Math.min(n,t.length-1)];this.triggerRelease(e,i+this.toSeconds(r))})):this.triggerRelease(e,i+this.toSeconds(t)),this}add(e,t,n){if(z(is(e)||isFinite(e),`note must be a pitch or midi: ${e}`),is(e)){let r=new gc(this.context,e).toMidi();this._buffers.add(r,t,n)}else this._buffers.add(e,t,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(e=>{e.forEach(e=>e.dispose())}),this._activeSources.clear(),this}};bs([Cl(0)],uu.prototype,`attack`,void 0),bs([Cl(0)],uu.prototype,`release`,void 0);var du=class e extends xc{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`value`]);super(t),this.name=`ToneEvent`,this._state=new Sc(`stopped`),this._startOffset=0,this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(xc.getDefaults(),{callback:W,humanize:!1,loop:!1,loopEnd:`1m`,loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(e=-1){this._state.forEachFrom(e,e=>{let t;if(e.state===`started`){e.id!==-1&&this.context.transport.clear(e.id);let n=e.time+Math.round(this.startOffset/this._playbackRate);if(this._loop===!0||$o(this._loop)&&this._loop>1){t=1/0,$o(this._loop)&&(t=this._loop*this._getLoopDuration());let r=this._state.getAfter(n);r!==null&&(t=Math.min(t,r.time-n)),t!==1/0&&(t=new Z(this.context,t));let i=new Z(this.context,this._getLoopDuration());e.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new Z(this.context,n),t)}else e.id=this.context.transport.schedule(this._tick.bind(this),new Z(this.context,n))}})}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e}get probability(){return this._probability}set probability(e){this._probability=e}get humanize(){return this._humanize}set humanize(e){this._humanize=e}start(e){let t=this.toTicks(e);return this._state.getValueAtTime(t)===`stopped`&&(this._state.add({id:-1,state:`started`,time:t}),this._rescheduleEvents(t)),this}stop(e){this.cancel(e);let t=this.toTicks(e);if(this._state.getValueAtTime(t)===`started`){this._state.setStateAtTime(`stopped`,t,{id:-1});let e=this._state.getBefore(t),n=t;e!==null&&(n=e.time),this._rescheduleEvents(n)}return this}cancel(e){e=js(e,-1/0);let t=this.toTicks(e);return this._state.forEachFrom(t,e=>{this.context.transport.clear(e.id)}),this._state.cancel(t),this}_tick(e){let t=this.context.transport.getTicksAtTime(e);if(!this.mute&&this._state.getValueAtTime(t)===`started`){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let t=.02;ts(this.humanize)||(t=this.toSeconds(this.humanize)),e+=(Math.random()*2-1)*t}this.callback(e,this.value)}}_getLoopDuration(){return(this._loopEnd-this._loopStart)/this._playbackRate}get loop(){return this._loop}set loop(e){this._loop=e,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._rescheduleEvents()}get loopEnd(){return new Z(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._rescheduleEvents()}get loopStart(){return new Z(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){let e=this.context.transport.ticks,t=this._state.get(e);if(t!==null&&t.state===`started`){let n=this._getLoopDuration();return(e-t.time)%n/n}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}},fu=class e extends xc{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`interval`]);super(t),this.name=`Loop`,this._event=new du({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:t.interval,playbackRate:t.playbackRate,probability:t.probability,humanize:t.humanize}),this.callback=t.callback,this.iterations=t.iterations}static getDefaults(){return Object.assign(xc.getDefaults(),{interval:`4n`,callback:W,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(e){return this._event.start(e),this}stop(e){return this._event.stop(e),this}cancel(e){return this._event.cancel(e),this}_tick(e){this.callback(e)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(e){this._event.loopEnd=e}get playbackRate(){return this._event.playbackRate}set playbackRate(e){this._event.playbackRate=e}get humanize(){return this._event.humanize}set humanize(e){this._event.humanize=e}get probability(){return this._event.probability}set probability(e){this._event.probability=e}get mute(){return this._event.mute}set mute(e){this._event.mute=e}get iterations(){return this._event.loop===!0?1/0:this._event.loop}set iterations(e){e===1/0?this._event.loop=!0:this._event.loop=e}dispose(){return super.dispose(),this._event.dispose(),this}},pu=class e extends du{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`events`]);super(t),this.name=`Part`,this._state=new Sc(`stopped`),this._events=new Set,this._state.increasing=!0,t.events.forEach(e=>{ns(e)?this.add(e[0],e[1]):this.add(e)})}static getDefaults(){return Object.assign(du.getDefaults(),{events:[]})}start(e,t){let n=this.toTicks(e);if(this._state.getValueAtTime(n)!==`started`){t=js(t,this._loop?this._loopStart:0),t=this._loop?js(t,this._loopStart):js(t,0);let e=this.toTicks(t);this._state.add({id:-1,offset:e,state:`started`,time:n}),this._forEach(t=>{this._startNote(t,n,e)})}return this}_startNote(e,t,n){t-=n,this._loop?e.startOffset>=this._loopStart&&e.startOffset<this._loopEnd?(e.startOffset<n&&(t+=this._getLoopDuration()),e.start(new Z(this.context,t))):e.startOffset<this._loopStart&&e.startOffset>=n&&(e.loop=!1,e.start(new Z(this.context,t))):e.startOffset>=n&&e.start(new Z(this.context,t))}get startOffset(){return this._startOffset}set startOffset(e){this._startOffset=e,this._forEach(e=>{e.startOffset+=this._startOffset})}stop(e){let t=this.toTicks(e);return this._state.cancel(t),this._state.setStateAtTime(`stopped`,t),this._forEach(t=>{t.stop(e)}),this}at(e,t){let n=new K(this.context,e).toTicks(),r=new Z(this.context,1).toSeconds(),i=this._events.values(),a=i.next();for(;!a.done;){let e=a.value;if(Math.abs(n-e.startOffset)<r)return R(t)&&(e.value=t),e;a=i.next()}return R(t)?(this.add(e,t),this.at(e)):null}add(e,t){e instanceof Object&&Reflect.has(e,`time`)&&(t=e,e=t.time);let n=this.toTicks(e),r;return t instanceof du?(r=t,r.callback=this._tick.bind(this)):r=new du({callback:this._tick.bind(this),context:this.context,value:t}),r.startOffset=n,r.set({humanize:this.humanize,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,playbackRate:this.playbackRate,probability:this.probability}),this._events.add(r),this._restartEvent(r),this}_restartEvent(e){this._state.forEach(t=>{t.state===`started`?this._startNote(e,t.time,t.offset):e.stop(new Z(this.context,t.time))})}remove(e,t){return es(e)&&e.hasOwnProperty(`time`)&&(t=e,e=t.time),e=this.toTicks(e),this._events.forEach(n=>{n.startOffset===e&&(Zo(t)||R(t)&&n.value===t)&&(this._events.delete(n),n.dispose())}),this}clear(){return this._forEach(e=>e.dispose()),this._events.clear(),this}cancel(e){return this._forEach(t=>t.cancel(e)),this._state.cancel(this.toTicks(e)),this}_forEach(t){return this._events&&this._events.forEach(n=>{n instanceof e?n._forEach(t):t(n)}),this}_setAll(e,t){this._forEach(n=>{n[e]=t})}_tick(e,t){this.mute||this.callback(e,t)}_testLoopBoundries(e){this._loop&&(e.startOffset<this._loopStart||e.startOffset>=this._loopEnd)?e.cancel(0):e.state===`stopped`&&this._restartEvent(e)}get probability(){return this._probability}set probability(e){this._probability=e,this._setAll(`probability`,e)}get humanize(){return this._humanize}set humanize(e){this._humanize=e,this._setAll(`humanize`,e)}get loop(){return this._loop}set loop(e){this._loop=e,this._forEach(t=>{t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.loop=e,this._testLoopBoundries(t)})}get loopEnd(){return new Z(this.context,this._loopEnd).toSeconds()}set loopEnd(e){this._loopEnd=this.toTicks(e),this._loop&&this._forEach(t=>{t.loopEnd=e,this._testLoopBoundries(t)})}get loopStart(){return new Z(this.context,this._loopStart).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e),this._loop&&this._forEach(e=>{e.loopStart=this.loopStart,this._testLoopBoundries(e)})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this._setAll(`playbackRate`,e)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}};function*mu(e){let t=0;for(;t<e;)t=zs(t,0,e-1),yield t,t++}function*hu(e){let t=e-1;for(;t>=0;)t=zs(t,0,e-1),yield t,t--}function*gu(e,t){for(;;)yield*t(e)}function*_u(e,t){let n=t?0:e-1;for(;;)n=zs(n,0,e-1),yield n,t?(n++,n>=e-1&&(t=!1)):(n--,n<=0&&(t=!0))}function*vu(e){let t=0,n=0;for(;t<e;)t=zs(t,0,e-1),yield t,n++,t+=n%2?2:-1}function*yu(e){let t=e-1,n=0;for(;t>=0;)t=zs(t,0,e-1),yield t,n++,t+=n%2?-2:1}function*bu(e){for(;;)yield Math.floor(Math.random()*e)}function*xu(e){let t=[];for(let n=0;n<e;n++)t.push(n);for(;t.length>0;)yield zs(t.splice(Math.floor(t.length*Math.random()),1)[0],0,e-1)}function*Su(e){let t=Math.floor(Math.random()*e);for(;;)t===0?t++:t===e-1||Math.random()<.5?t--:t++,yield t}function*Cu(e,t=`up`,n=0){switch(z(e>=1,`The number of values must be at least one`),t){case`up`:yield*gu(e,mu);case`down`:yield*gu(e,hu);case`upDown`:yield*_u(e,!0);case`downUp`:yield*_u(e,!1);case`alternateUp`:yield*gu(e,vu);case`alternateDown`:yield*gu(e,yu);case`random`:yield*bu(e);case`randomOnce`:yield*gu(e,xu);case`randomWalk`:yield*Su(e)}}var wu=class e extends fu{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`values`,`pattern`]);super(t),this.name=`Pattern`,this.callback=t.callback,this._values=t.values,this._pattern=Cu(t.values.length,t.pattern),this._type=t.pattern}static getDefaults(){return Object.assign(fu.getDefaults(),{pattern:`up`,values:[],callback:W})}_tick(e){let t=this._pattern.next();this._index=t.value,this._value=this._values[t.value],this.callback(e,this._value)}get values(){return this._values}set values(e){this._values=e,this.pattern=this._type}get value(){return this._value}get index(){return this._index}get pattern(){return this._type}set pattern(e){this._type=e,this._pattern=Cu(this._values.length,this._type)}},Tu=class e extends du{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`events`,`subdivision`]);super(t),this.name=`Sequence`,this._part=new pu({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[],this._subdivision=this.toTicks(t.subdivision),this.events=t.events,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.playbackRate=t.playbackRate,this.probability=t.probability,this.humanize=t.humanize,this.mute=t.mute,this.playbackRate=t.playbackRate}static getDefaults(){return Object.assign(Ms(du.getDefaults(),[`value`]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:`8n`})}_seqCallback(e,t){t!==null&&!this.mute&&this.callback(e,t)}get events(){return this._events}set events(e){this.clear(),this._eventsArray=e,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(e,t){return this._part.start(e,t&&this._indexTime(t)),this}stop(e){return this._part.stop(e),this}get subdivision(){return new Z(this.context,this._subdivision).toSeconds()}_createSequence(e){return new Proxy(e,{get:(e,t)=>e[t],set:(e,t,n)=>(e[t]=rs(t)&&isFinite(parseInt(t,10))&&ns(n)?this._createSequence(n):n,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(e,t,n){e.forEach((e,r)=>{let i=r*t+n;if(ns(e))this._rescheduleSequence(e,t/e.length,i);else{let t=new Z(this.context,i,`i`).toSeconds();this._part.add(t,e)}})}_indexTime(e){return new Z(this.context,e*this._subdivision+this.startOffset).toSeconds()}clear(){return this._part.clear(),this}dispose(){return super.dispose(),this._part.dispose(),this}get loop(){return this._part.loop}set loop(e){this._part.loop=e}get loopStart(){return this._loopStart}set loopStart(e){this._loopStart=e,this._part.loopStart=this._indexTime(e)}get loopEnd(){return this._loopEnd}set loopEnd(e){this._loopEnd=e,e===0?this._part.loopEnd=this._indexTime(this._eventsArray.length):this._part.loopEnd=this._indexTime(e)}get startOffset(){return this._part.startOffset}set startOffset(e){this._part.startOffset=e}get playbackRate(){return this._part.playbackRate}set playbackRate(e){this._part.playbackRate=e}get probability(){return this._part.probability}set probability(e){this._part.probability=e}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(e){this._part.humanize=e}get length(){return this._part.length}},Eu=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`fade`]);super(t),this.name=`CrossFade`,this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Ol({context:this.context}),this.a=new Y({context:this.context,gain:0}),this.b=new Y({context:this.context,gain:0}),this.output=new Y({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new X({context:this.context,units:`normalRange`,value:t.fade}),U(this,`fade`),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode=`explicit`,wc(this._split,this.a.gain,0),wc(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(J.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}},Du=class extends J{constructor(e){super(e),this.name=`Effect`,this._dryWet=new Eu({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Y({context:this.context}),this.effectReturn=new Y({context:this.context}),this.input=new Y({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(e.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],U(this,`wet`)}static getDefaults(){return Object.assign(J.getDefaults(),{wet:1})}connectEffect(e){return this._internalChannels.push(e),this.effectSend.chain(e,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}},Ou=class extends Du{constructor(e){super(e),this.name=`LFOEffect`,this._lfo=new xl({context:this.context,frequency:e.frequency,amplitude:e.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=e.type,U(this,[`frequency`,`depth`])}static getDefaults(){return Object.assign(Du.getDefaults(),{frequency:1,type:`sine`,depth:1})}start(e){return this._lfo.start(e),this}stop(e){return this._lfo.stop(e),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}},ku=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`baseFrequency`,`octaves`]);super(t),this.name=`AutoFilter`,this.filter=new Wl(Object.assign(t.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=t.octaves,this.baseFrequency=t.baseFrequency}static getDefaults(){return Object.assign(Ou.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:`lowpass`,rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(e){this._lfo.min=this.toFrequency(e),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._lfo.max=this._lfo.min*2**e}dispose(){return super.dispose(),this.filter.dispose(),this}},Au=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`pan`]);super(t),this.name=`Panner`,this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new q({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode=`explicit`,U(this,`pan`)}static getDefaults(){return Object.assign(J.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}},ju=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`]);super(t),this.name=`AutoPanner`,this._panner=new Au({context:this.context,channelCount:t.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(Ou.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}},Mu=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`smoothing`]);super(t),this.name=`Follower`,this._abs=this.input=new Dl({context:this.context}),this._lowpass=this.output=new ou({context:this.context,frequency:1/this.toSeconds(t.smoothing),type:`lowpass`}),this._abs.connect(this._lowpass),this._smoothing=t.smoothing}static getDefaults(){return Object.assign(J.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(e){this._smoothing=e,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}},Nu=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`baseFrequency`,`octaves`,`sensitivity`]);super(t),this.name=`AutoWah`,this._follower=new Mu({context:this.context,smoothing:t.follower}),this._sweepRange=new Nl({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this._inputBoost=new Y({context:this.context}),this._bandpass=new Wl({context:this.context,rolloff:-48,frequency:0,Q:t.Q}),this._peaking=new Wl({context:this.context,type:`peaking`}),this._peaking.gain.value=t.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=t.sensitivity,U(this,[`gain`,`Q`])}static getDefaults(){return Object.assign(Du.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(e){this._octaves=e,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(e){this._follower.smoothing=e}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){this._baseFrequency=this.toFrequency(e),this._setSweepRange()}get sensitivity(){return ac(1/this._inputBoost.gain.value)}set sensitivity(e){this._inputBoost.gain.value=1/ic(e)}_setSweepRange(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*2**this._octaves,this.context.sampleRate/2)}dispose(){return super.dispose(),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.dispose(),this._peaking.dispose(),this._inputBoost.dispose(),this}},Pu=`bit-crusher`;tu(Pu,`
192
+ class BitCrusherWorklet extends SingleIOProcessor {
193
+
194
+ static get parameterDescriptors() {
195
+ return [{
196
+ name: "bits",
197
+ defaultValue: 12,
198
+ minValue: 1,
199
+ maxValue: 16,
200
+ automationRate: 'k-rate'
201
+ }];
202
+ }
203
+
204
+ generate(input, _channel, parameters) {
205
+ const step = Math.pow(0.5, parameters.bits - 1);
206
+ const val = step * Math.floor(input / step + 0.5);
207
+ return val;
208
+ }
209
+ }
210
+ `);var Fu=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`bits`]);super(t),this.name=`BitCrusher`,this._bitCrusherWorklet=new Iu({context:this.context,bits:t.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(Du.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}},Iu=class e extends ru{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`BitCrusherWorklet`,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.bits=new q({context:this.context,value:t.bits,units:`positive`,minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign(ru.getDefaults(),{bits:12})}_audioWorkletName(){return Pu}onReady(e){Cc(this.input,e,this.output);let t=e.parameters.get(`bits`);this.bits.setParam(t)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}},Lu=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`order`]);super(t),this.name=`Chebyshev`,this._shaper=new Yc({context:this.context,length:4096}),this._order=t.order,this.connectEffect(this._shaper),this.order=t.order,this.oversample=t.oversample}static getDefaults(){return Object.assign(Du.getDefaults(),{order:1,oversample:`none`})}_getCoefficient(e,t,n){return n.has(t)||(t===0?n.set(t,0):t===1?n.set(t,e):n.set(t,2*e*this._getCoefficient(e,t-1,n)-this._getCoefficient(e,t-2,n))),n.get(t)}get order(){return this._order}set order(e){z(Number.isInteger(e),`'order' must be an integer`),this._order=e,this._shaper.setMap(t=>this._getCoefficient(t,e,new Map))}get oversample(){return this._shaper.oversample}set oversample(e){this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.dispose(),this}},Ru=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`channels`]);super(t),this.name=`Split`,this._splitter=this.input=this.output=this.context.createChannelSplitter(t.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign(J.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}},zu=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`channels`]);super(t),this.name=`Merge`,this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(J.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}},Bu=class extends J{constructor(e){super(e),this.name=`StereoEffect`,this.input=new Y({context:this.context}),this.input.channelCount=2,this.input.channelCountMode=`explicit`,this._dryWet=this.output=new Eu({context:this.context,fade:e.wet}),this.wet=this._dryWet.fade,this._split=new Ru({context:this.context,channels:2}),this._merge=new zu({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),U(this,[`wet`])}connectEffectLeft(...e){this._split.connect(e[0],0,0),Cc(...e),wc(e[e.length-1],this._merge,0,0)}connectEffectRight(...e){this._split.connect(e[0],1,0),Cc(...e),wc(e[e.length-1],this._merge,0,1)}static getDefaults(){return Object.assign(J.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}},Vu=class extends Bu{constructor(e){super(e),this.feedback=new X({context:this.context,value:e.feedback,units:`normalRange`}),this._feedbackL=new Y({context:this.context}),this._feedbackR=new Y({context:this.context}),this._feedbackSplit=new Ru({context:this.context,channels:2}),this._feedbackMerge=new zu({context:this.context,channels:2}),this._merge.connect(this._feedbackSplit),this._feedbackMerge.connect(this._split),this._feedbackSplit.connect(this._feedbackL,0,0),this._feedbackL.connect(this._feedbackMerge,0,0),this._feedbackSplit.connect(this._feedbackR,1,0),this._feedbackR.connect(this._feedbackMerge,0,1),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),U(this,[`feedback`])}static getDefaults(){return Object.assign(Bu.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}},Hu=class e extends Vu{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`delayTime`,`depth`]);super(t),this.name=`Chorus`,this._depth=t.depth,this._delayTime=t.delayTime/1e3,this._lfoL=new xl({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new xl({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Pc({context:this.context}),this._delayNodeR=new Pc({context:this.context}),this.frequency=this._lfoL.frequency,U(this,[`frequency`]),this._lfoL.frequency.connect(this._lfoR.frequency),this.connectEffectLeft(this._delayNodeL),this.connectEffectRight(this._delayNodeR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this.depth=this._depth,this.type=t.type,this.spread=t.spread}static getDefaults(){return Object.assign(Vu.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:`sine`,spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(e){this._depth=e;let t=this._delayTime*e;this._lfoL.min=Math.max(this._delayTime-t,0),this._lfoL.max=this._delayTime+t,this._lfoR.min=Math.max(this._delayTime-t,0),this._lfoR.max=this._delayTime+t}get delayTime(){return this._delayTime*1e3}set delayTime(e){this._delayTime=e/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(e){this._lfoL.type=e,this._lfoR.type=e}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(e){this._lfoL.phase=90-e/2,this._lfoR.phase=e/2+90}start(e){return this._lfoL.start(e),this._lfoR.start(e),this}stop(e){return this._lfoL.stop(e),this._lfoR.stop(e),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.dispose(),this._delayNodeR.dispose(),this.frequency.dispose(),this}},Uu=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`distortion`]);super(t),this.name=`Distortion`,this._shaper=new Yc({context:this.context,length:4096}),this._distortion=t.distortion,this.connectEffect(this._shaper),this.distortion=t.distortion,this.oversample=t.oversample}static getDefaults(){return Object.assign(Du.getDefaults(),{distortion:.4,oversample:`none`})}get distortion(){return this._distortion}set distortion(e){this._distortion=e;let t=e*100,n=Math.PI/180;this._shaper.setMap(e=>Math.abs(e)<.001?0:(3+t)*e*20*n/(Math.PI+t*Math.abs(e)))}get oversample(){return this._shaper.oversample}set oversample(e){this._shaper.oversample=e}dispose(){return super.dispose(),this._shaper.dispose(),this}},Wu=class extends Du{constructor(e){super(e),this.name=`FeedbackEffect`,this._feedbackGain=new Y({context:this.context,gain:e.feedback,units:`normalRange`}),this.feedback=this._feedbackGain.gain,U(this,`feedback`),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(Du.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}},Gu=class e extends Wu{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`feedback`]);super(t),this.name=`FeedbackDelay`,this._delayNode=new Pc({context:this.context,delayTime:t.delayTime,maxDelay:t.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),U(this,`delayTime`)}static getDefaults(){return Object.assign(Wu.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}},Ku=class extends J{constructor(e){super(e),this.name=`PhaseShiftAllpass`,this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this.offset90=new Y({context:this.context});let t=[.6923878,.9360654322959,.988229522686,.9987488452737],n=[.4021921162426,.856171088242,.9722909545651,.9952884791278];this._bank0=this._createAllPassFilterBank(t),this._bank1=this._createAllPassFilterBank(n),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),Cc(this.input,...this._bank0,this._oneSampleDelay,this.output),Cc(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(e){return e.map(e=>{let t=[[e*e,0,-1],[1,0,-(e*e)]];return this.context.createIIRFilter(t[0],t[1])})}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach(e=>e.disconnect()),this._bank1.forEach(e=>e.disconnect()),this._oneSampleDelay.disconnect(),this}},qu=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`]);super(t),this.name=`FrequencyShifter`,this.frequency=new X({context:this.context,units:`frequency`,value:t.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new cl({context:this.context,type:`sine`}),this._cosine=new ll({context:this.context,phase:-90,type:`sine`}),this._sineMultiply=new $({context:this.context}),this._cosineMultiply=new $({context:this.context}),this._negate=new kl({context:this.context}),this._add=new vl({context:this.context}),this._phaseShifter=new Ku({context:this.context}),this.effectSend.connect(this._phaseShifter),this.frequency.fan(this._sine.frequency,this._cosine.frequency),this._phaseShifter.offset90.connect(this._cosineMultiply),this._cosine.connect(this._cosineMultiply.factor),this._phaseShifter.connect(this._sineMultiply),this._sine.connect(this._sineMultiply.factor),this._sineMultiply.connect(this._negate),this._cosineMultiply.connect(this._add),this._negate.connect(this._add.addend),this._add.connect(this.effectReturn);let n=this.immediate();this._sine.start(n),this._cosine.start(n)}static getDefaults(){return Object.assign(Du.getDefaults(),{frequency:0})}dispose(){return super.dispose(),this.frequency.dispose(),this._add.dispose(),this._cosine.dispose(),this._cosineMultiply.dispose(),this._negate.dispose(),this._phaseShifter.dispose(),this._sine.dispose(),this._sineMultiply.dispose(),this}},Ju=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],Yu=[225,556,441,341],Xu=class e extends Bu{constructor(){let t=H(e.getDefaults(),arguments,[`roomSize`,`dampening`]);super(t),this.name=`Freeverb`,this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[],this.roomSize=new X({context:this.context,value:t.roomSize,units:`normalRange`}),this._allpassFiltersL=Yu.map(e=>{let t=this.context.createBiquadFilter();return t.type=`allpass`,t.frequency.value=e,t}),this._allpassFiltersR=Yu.map(e=>{let t=this.context.createBiquadFilter();return t.type=`allpass`,t.frequency.value=e,t}),this._combFilters=Ju.map((e,n)=>{let r=new su({context:this.context,dampening:t.dampening,delayTime:e});return n<Ju.length/2?this.connectEffectLeft(r,...this._allpassFiltersL):this.connectEffectRight(r,...this._allpassFiltersR),this.roomSize.connect(r.resonance),r}),U(this,[`roomSize`])}static getDefaults(){return Object.assign(Bu.getDefaults(),{roomSize:.7,dampening:3e3})}get dampening(){return this._combFilters[0].dampening}set dampening(e){this._combFilters.forEach(t=>t.dampening=e)}dispose(){return super.dispose(),this._allpassFiltersL.forEach(e=>e.disconnect()),this._allpassFiltersR.forEach(e=>e.disconnect()),this._combFilters.forEach(e=>e.dispose()),this.roomSize.dispose(),this}},Zu=[1687/25e3,1601/25e3,2053/25e3,2251/25e3],Qu=[.773,.802,.753,.733],$u=[347,113,37],ed=class e extends Bu{constructor(){let t=H(e.getDefaults(),arguments,[`roomSize`]);super(t),this.name=`JCReverb`,this._allpassFilters=[],this._feedbackCombFilters=[],this.roomSize=new X({context:this.context,value:t.roomSize,units:`normalRange`}),this._scaleRoomSize=new yl({context:this.context,min:-.733,max:.197}),this._allpassFilters=$u.map(e=>{let t=this.context.createBiquadFilter();return t.type=`allpass`,t.frequency.value=e,t}),this._feedbackCombFilters=Zu.map((e,t)=>{let n=new au({context:this.context,delayTime:e});return this._scaleRoomSize.connect(n.resonance),n.resonance.value=Qu[t],t<Zu.length/2?this.connectEffectLeft(...this._allpassFilters,n):this.connectEffectRight(...this._allpassFilters,n),n}),this.roomSize.connect(this._scaleRoomSize),U(this,[`roomSize`])}static getDefaults(){return Object.assign(Bu.getDefaults(),{roomSize:.5})}dispose(){return super.dispose(),this._allpassFilters.forEach(e=>e.disconnect()),this._feedbackCombFilters.forEach(e=>e.dispose()),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}},td=class extends Vu{constructor(e){super(e),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),U(this,[`feedback`])}},nd=class e extends td{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`feedback`]);super(t),this.name=`PingPongDelay`,this._leftDelay=new Pc({context:this.context,maxDelay:t.maxDelay}),this._rightDelay=new Pc({context:this.context,maxDelay:t.maxDelay}),this._rightPreDelay=new Pc({context:this.context,maxDelay:t.maxDelay}),this.delayTime=new X({context:this.context,units:`time`,value:t.delayTime}),this.connectEffectLeft(this._leftDelay),this.connectEffectRight(this._rightPreDelay,this._rightDelay),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackL.disconnect(),this._feedbackL.connect(this._rightDelay),U(this,[`delayTime`])}static getDefaults(){return Object.assign(td.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}},rd=class e extends Wu{constructor(){let t=H(e.getDefaults(),arguments,[`pitch`]);super(t),this.name=`PitchShift`,this._frequency=new X({context:this.context}),this._delayA=new Pc({maxDelay:1,context:this.context}),this._lfoA=new xl({context:this.context,min:0,max:.1,type:`sawtooth`}).connect(this._delayA.delayTime),this._delayB=new Pc({maxDelay:1,context:this.context}),this._lfoB=new xl({context:this.context,min:0,max:.1,type:`sawtooth`,phase:180}).connect(this._delayB.delayTime),this._crossFade=new Eu({context:this.context}),this._crossFadeLFO=new xl({context:this.context,min:0,max:1,type:`triangle`,phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Pc({delayTime:t.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,U(this,`delayTime`),this._pitch=t.pitch,this._windowSize=t.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);let n=this.now();this._lfoA.start(n),this._lfoB.start(n),this._crossFadeLFO.start(n),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(Wu.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(e){this._pitch=e;let t=0;e<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,t=oc(e-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,t=oc(e)-1),this._frequency.value=t*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(e){this._windowSize=this.toSeconds(e),this.pitch=this._pitch}dispose(){return super.dispose(),this._frequency.dispose(),this._delayA.dispose(),this._delayB.dispose(),this._lfoA.dispose(),this._lfoB.dispose(),this._crossFade.dispose(),this._crossFadeLFO.dispose(),this._feedbackDelay.dispose(),this}},id=class e extends Bu{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`octaves`,`baseFrequency`]);super(t),this.name=`Phaser`,this._lfoL=new xl({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new xl({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this.Q=new X({context:this.context,value:t.Q,units:`positive`}),this._filtersL=this._makeFilters(t.stages,this._lfoL),this._filtersR=this._makeFilters(t.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=t.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=t.baseFrequency,this.octaves=t.octaves,this._lfoL.start(),this._lfoR.start(),U(this,[`frequency`,`Q`])}static getDefaults(){return Object.assign(Bu.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(e,t){let n=[];for(let r=0;r<e;r++){let e=this.context.createBiquadFilter();e.type=`allpass`,this.Q.connect(e.Q),t.connect(e.frequency),n.push(e)}return n}get octaves(){return this._octaves}set octaves(e){this._octaves=e;let t=this._baseFrequency*2**e;this._lfoL.max=t,this._lfoR.max=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(e){this._baseFrequency=this.toFrequency(e),this._lfoL.min=this._baseFrequency,this._lfoR.min=this._baseFrequency,this.octaves=this._octaves}dispose(){return super.dispose(),this.Q.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._filtersL.forEach(e=>e.disconnect()),this._filtersR.forEach(e=>e.disconnect()),this.frequency.dispose(),this}},ad=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`decay`]);super(t),this.name=`Reverb`,this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let n=this.toSeconds(t.decay);B(n,.001),this._decay=n;let r=this.toSeconds(t.preDelay);B(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(Du.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(e){e=this.toSeconds(e),B(e,.001),this._decay=e,this.generate()}get preDelay(){return this._preDelay}set preDelay(e){e=this.toSeconds(e),B(e,0),this._preDelay=e,this.generate()}generate(){return V(this,void 0,void 0,function*(){let e=this.ready,t=new $s(2,this._decay+this._preDelay,this.context.sampleRate),n=new tl({context:t}),r=new tl({context:t}),i=new zu({context:t});n.connect(i,0,0),r.connect(i,0,1);let a=new Y({context:t}).toDestination();i.connect(a),n.start(0),r.start(0),a.gain.setValueAtTime(0,0),a.gain.setValueAtTime(1,this._preDelay),a.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let o=t.render();return this.ready=o.then(W),yield e,this._convolver.buffer=(yield o).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}},od=class e extends J{constructor(){super(H(e.getDefaults(),arguments)),this.name=`MidSideSplit`,this._split=this.input=new Ru({channels:2,context:this.context}),this._midAdd=new vl({context:this.context}),this.mid=new $({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new Al({context:this.context}),this.side=new $({context:this.context,value:Math.SQRT1_2}),this._split.connect(this._midAdd,0),this._split.connect(this._midAdd.addend,1),this._split.connect(this._sideSubtract,0),this._split.connect(this._sideSubtract.subtrahend,1),this._midAdd.connect(this.mid),this._sideSubtract.connect(this.side)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midAdd.dispose(),this._sideSubtract.dispose(),this._split.dispose(),this}},sd=class e extends J{constructor(){super(H(e.getDefaults(),arguments)),this.name=`MidSideMerge`,this.mid=new Y({context:this.context}),this.side=new Y({context:this.context}),this._left=new vl({context:this.context}),this._leftMult=new $({context:this.context,value:Math.SQRT1_2}),this._right=new Al({context:this.context}),this._rightMult=new $({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new zu({context:this.context}),this.mid.fan(this._left),this.side.connect(this._left.addend),this.mid.connect(this._right),this.side.connect(this._right.subtrahend),this._left.connect(this._leftMult),this._right.connect(this._rightMult),this._leftMult.connect(this._merge,0,0),this._rightMult.connect(this._merge,0,1)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._leftMult.dispose(),this._rightMult.dispose(),this._left.dispose(),this._right.dispose(),this}},cd=class extends Du{constructor(e){super(e),this.name=`MidSideEffect`,this._midSideMerge=new sd({context:this.context}),this._midSideSplit=new od({context:this.context}),this._midSend=this._midSideSplit.mid,this._sideSend=this._midSideSplit.side,this._midReturn=this._midSideMerge.mid,this._sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)}connectEffectMid(...e){this._midSend.chain(...e,this._midReturn)}connectEffectSide(...e){this._sideSend.chain(...e,this._sideReturn)}dispose(){return super.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this._midSend.dispose(),this._sideSend.dispose(),this._midReturn.dispose(),this._sideReturn.dispose(),this}},ld=class e extends cd{constructor(){let t=H(e.getDefaults(),arguments,[`width`]);super(t),this.name=`StereoWidener`,this.width=new X({context:this.context,value:t.width,units:`normalRange`}),U(this,[`width`]),this._twoTimesWidthMid=new $({context:this.context,value:2}),this._twoTimesWidthSide=new $({context:this.context,value:2}),this._midMult=new $({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new Al({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),wc(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new $({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(cd.getDefaults(),{width:.5})}dispose(){return super.dispose(),this.width.dispose(),this._midMult.dispose(),this._sideMult.dispose(),this._twoTimesWidthMid.dispose(),this._twoTimesWidthSide.dispose(),this._oneMinusWidth.dispose(),this}},ud=class e extends Bu{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`depth`]);super(t),this.name=`Tremolo`,this._lfoL=new xl({context:this.context,type:t.type,min:1,max:0}),this._lfoR=new xl({context:this.context,type:t.type,min:1,max:0}),this._amplitudeL=new Y({context:this.context}),this._amplitudeR=new Y({context:this.context}),this.frequency=new X({context:this.context,value:t.frequency,units:`frequency`}),this.depth=new X({context:this.context,value:t.depth,units:`normalRange`}),U(this,[`frequency`,`depth`]),this.connectEffectLeft(this._amplitudeL),this.connectEffectRight(this._amplitudeR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.spread=t.spread}static getDefaults(){return Object.assign(Bu.getDefaults(),{frequency:10,type:`sine`,depth:.5,spread:180})}start(e){return this._lfoL.start(e),this._lfoR.start(e),this}stop(e){return this._lfoL.stop(e),this._lfoR.stop(e),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this.context.transport.syncSignal(this.frequency),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this.context.transport.unsyncSignal(this.frequency),this}get type(){return this._lfoL.type}set type(e){this._lfoL.type=e,this._lfoR.type=e}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(e){this._lfoL.phase=90-e/2,this._lfoR.phase=e/2+90}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._amplitudeL.dispose(),this._amplitudeR.dispose(),this.frequency.dispose(),this.depth.dispose(),this}},dd=class e extends Du{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`depth`]);super(t),this.name=`Vibrato`,this._delayNode=new Pc({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new xl({context:this.context,type:t.type,min:0,max:t.maxDelay,frequency:t.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=t.depth,U(this,[`frequency`,`depth`]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(Du.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:`sine`})}get type(){return this._lfo.type}set type(e){this._lfo.type=e}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}},fd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`type`,`size`]);super(t),this.name=`Analyser`,this._analysers=[],this._buffers=[],this.input=this.output=this._gain=new Y({context:this.context}),this._split=new Ru({context:this.context,channels:t.channels}),this.input.connect(this._split),B(t.channels,1);for(let e=0;e<t.channels;e++)this._analysers[e]=this.context.createAnalyser(),this._split.connect(this._analysers[e],e,0);this.size=t.size,this.type=t.type,this.smoothing=t.smoothing}static getDefaults(){return Object.assign(J.getDefaults(),{size:1024,smoothing:.8,type:`fft`,channels:1})}getValue(){return this._analysers.forEach((e,t)=>{let n=this._buffers[t];this._type===`fft`?e.getFloatFrequencyData(n):this._type===`waveform`&&e.getFloatTimeDomainData(n)}),this.channels===1?this._buffers[0]:this._buffers}get size(){return this._analysers[0].frequencyBinCount}set size(e){this._analysers.forEach((t,n)=>{t.fftSize=e*2,this._buffers[n]=new Float32Array(e)})}get channels(){return this._analysers.length}get type(){return this._type}set type(e){z(e===`waveform`||e===`fft`,`Analyser: invalid type: ${e}`),this._type=e}get smoothing(){return this._analysers[0].smoothingTimeConstant}set smoothing(e){this._analysers.forEach(t=>t.smoothingTimeConstant=e)}dispose(){return super.dispose(),this._analysers.forEach(e=>e.disconnect()),this._split.dispose(),this._gain.dispose(),this}},pd=class e extends J{constructor(){super(H(e.getDefaults(),arguments)),this.name=`MeterBase`,this.input=this.output=this._analyser=new fd({context:this.context,size:256,type:`waveform`})}dispose(){return super.dispose(),this._analyser.dispose(),this}},md=class e extends pd{constructor(){let t=H(e.getDefaults(),arguments,[`smoothing`]);super(t),this.name=`Meter`,this.input=this.output=this._analyser=new fd({context:this.context,size:256,type:`waveform`,channels:t.channelCount}),this.smoothing=t.smoothing,this.normalRange=t.normalRange,this._rms=Array(t.channelCount),this._rms.fill(0)}static getDefaults(){return Object.assign(pd.getDefaults(),{smoothing:.8,normalRange:!1,channelCount:1})}getLevel(){return ms(`'getLevel' has been changed to 'getValue'`),this.getValue()}getValue(){let e=this._analyser.getValue(),t=(this.channels===1?[e]:e).map((e,t)=>{let n=e.reduce((e,t)=>e+t*t,0),r=Math.sqrt(n/e.length);return this._rms[t]=Math.max(r,this._rms[t]*this.smoothing),this.normalRange?this._rms[t]:ac(this._rms[t])});return this.channels===1?t[0]:t}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}},hd=class e extends pd{constructor(){let t=H(e.getDefaults(),arguments,[`size`]);super(t),this.name=`FFT`,this.normalRange=t.normalRange,this._analyser.type=`fft`,this.size=t.size}static getDefaults(){return Object.assign(J.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map(e=>this.normalRange?ic(e):e)}get size(){return this._analyser.size}set size(e){this._analyser.size=e}get smoothing(){return this._analyser.smoothing}set smoothing(e){this._analyser.smoothing=e}getFrequencyOfIndex(e){return z(0<=e&&e<this.size,`index must be greater than or equal to 0 and less than ${this.size}`),e*this.context.sampleRate/(this.size*2)}},gd=class e extends pd{constructor(){super(H(e.getDefaults(),arguments)),this.name=`DCMeter`,this._analyser.type=`waveform`,this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}},_d=class e extends pd{constructor(){let t=H(e.getDefaults(),arguments,[`size`]);super(t),this.name=`Waveform`,this._analyser.type=`waveform`,this.size=t.size}static getDefaults(){return Object.assign(pd.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(e){this._analyser.size=e}},vd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`solo`]);super(t),this.name=`Solo`,this.input=this.output=new Y({context:this.context}),e._allSolos.has(this.context)||e._allSolos.set(this.context,new Set),e._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(J.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),e._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){e._soloed.has(this.context)||e._soloed.set(this.context,new Set),e._soloed.get(this.context).add(this)}_removeSolo(){e._soloed.has(this.context)&&e._soloed.get(this.context).delete(this)}_isSoloed(){return e._soloed.has(this.context)&&e._soloed.get(this.context).has(this)}_noSolos(){return!e._soloed.has(this.context)||e._soloed.has(this.context)&&e._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),e._allSolos.get(this.context).delete(this),this._removeSolo(),this}};vd._allSolos=new Map,vd._soloed=new Map;var yd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`pan`,`volume`]);super(t),this.name=`PanVol`,this._panner=this.input=new Au({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Fc({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,U(this,[`pan`,`volume`])}static getDefaults(){return Object.assign(J.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(e){this._volume.mute=e}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}},bd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`volume`,`pan`]);super(t),this.name=`Channel`,this._solo=this.input=new vd({solo:t.solo,context:this.context}),this._panVol=this.output=new yd({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),U(this,[`pan`,`volume`])}static getDefaults(){return Object.assign(J.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(e){this._solo.solo=e}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(e){this._panVol.mute=e}_getBus(t){return e.buses.has(t)||e.buses.set(t,new Y({context:this.context})),e.buses.get(t)}send(e,t=0){let n=this._getBus(e),r=new Y({context:this.context,units:`decibels`,gain:t});return this.connect(r),r.connect(n),r}receive(e){return this._getBus(e).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};bd.buses=new Map;var xd=class e extends J{constructor(){super(H(e.getDefaults(),arguments)),this.name=`Mono`,this.input=new Y({context:this.context}),this._merge=this.output=new zu({channels:2,context:this.context}),this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1)}dispose(){return super.dispose(),this._merge.dispose(),this.input.dispose(),this}},Sd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`lowFrequency`,`highFrequency`]);super(t),this.name=`MultibandSplit`,this.input=new Y({context:this.context}),this.output=void 0,this.low=new Wl({context:this.context,frequency:0,type:`lowpass`}),this._lowMidFilter=new Wl({context:this.context,frequency:0,type:`highpass`}),this.mid=new Wl({context:this.context,frequency:0,type:`lowpass`}),this.high=new Wl({context:this.context,frequency:0,type:`highpass`}),this._internalChannels=[this.low,this.mid,this.high],this.lowFrequency=new X({context:this.context,units:`frequency`,value:t.lowFrequency}),this.highFrequency=new X({context:this.context,units:`frequency`,value:t.highFrequency}),this.Q=new X({context:this.context,units:`positive`,value:t.Q}),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.fan(this.low.frequency,this._lowMidFilter.frequency),this.highFrequency.fan(this.mid.frequency,this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),U(this,[`high`,`mid`,`low`,`highFrequency`,`lowFrequency`])}static getDefaults(){return Object.assign(J.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),Zs(this,[`high`,`mid`,`low`,`highFrequency`,`lowFrequency`]),this.low.dispose(),this._lowMidFilter.dispose(),this.mid.dispose(),this.high.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this.Q.dispose(),this}},Cd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`positionX`,`positionY`,`positionZ`]);super(t),this.name=`Panner3D`,this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=t.panningModel,this.maxDistance=t.maxDistance,this.distanceModel=t.distanceModel,this.coneOuterGain=t.coneOuterGain,this.coneOuterAngle=t.coneOuterAngle,this.coneInnerAngle=t.coneInnerAngle,this.refDistance=t.refDistance,this.rolloffFactor=t.rolloffFactor,this.positionX=new q({context:this.context,param:this._panner.positionX,value:t.positionX}),this.positionY=new q({context:this.context,param:this._panner.positionY,value:t.positionY}),this.positionZ=new q({context:this.context,param:this._panner.positionZ,value:t.positionZ}),this.orientationX=new q({context:this.context,param:this._panner.orientationX,value:t.orientationX}),this.orientationY=new q({context:this.context,param:this._panner.orientationY,value:t.orientationY}),this.orientationZ=new q({context:this.context,param:this._panner.orientationZ,value:t.orientationZ})}static getDefaults(){return Object.assign(J.getDefaults(),{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:`inverse`,maxDistance:1e4,orientationX:0,orientationY:0,orientationZ:0,panningModel:`equalpower`,positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1})}setPosition(e,t,n){return this.positionX.value=e,this.positionY.value=t,this.positionZ.value=n,this}setOrientation(e,t,n){return this.orientationX.value=e,this.orientationY.value=t,this.orientationZ.value=n,this}get panningModel(){return this._panner.panningModel}set panningModel(e){this._panner.panningModel=e}get refDistance(){return this._panner.refDistance}set refDistance(e){this._panner.refDistance=e}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(e){this._panner.rolloffFactor=e}get distanceModel(){return this._panner.distanceModel}set distanceModel(e){this._panner.distanceModel=e}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(e){this._panner.coneInnerAngle=e}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(e){this._panner.coneOuterAngle=e}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(e){this._panner.coneOuterGain=e}get maxDistance(){return this._panner.maxDistance}set maxDistance(e){this._panner.maxDistance=e}dispose(){return super.dispose(),this._panner.disconnect(),this.orientationX.dispose(),this.orientationY.dispose(),this.orientationZ.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this}},wd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Recorder`,this.input=new Y({context:this.context}),z(e.supported,`Media Recorder API is not available`),this._stream=this.context.createMediaStreamDestination(),this.input.connect(this._stream),this._recorder=new MediaRecorder(this._stream.stream,{mimeType:t.mimeType})}static getDefaults(){return J.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return _s!==null&&Reflect.has(_s,`MediaRecorder`)}get state(){return this._recorder.state===`inactive`?`stopped`:this._recorder.state===`paused`?`paused`:`started`}start(){return V(this,void 0,void 0,function*(){z(this.state!==`started`,`Recorder is already started`);let e=new Promise(e=>{let t=()=>{this._recorder.removeEventListener(`start`,t,!1),e()};this._recorder.addEventListener(`start`,t,!1)});return this.state===`stopped`?this._recorder.start():this._recorder.resume(),yield e})}stop(){return V(this,void 0,void 0,function*(){z(this.state!==`stopped`,`Recorder is not started`);let e=new Promise(e=>{let t=n=>{this._recorder.removeEventListener(`dataavailable`,t,!1),e(n.data)};this._recorder.addEventListener(`dataavailable`,t,!1)});return this._recorder.stop(),yield e})}pause(){return z(this.state===`started`,`Recorder must be started`),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}},Td=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`threshold`,`ratio`]);super(t),this.name=`Compressor`,this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor,this.threshold=new q({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:`decibels`,value:t.threshold}),this.attack=new q({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:`time`,value:t.attack}),this.release=new q({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:`time`,value:t.release}),this.knee=new q({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:`decibels`,value:t.knee}),this.ratio=new q({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:`positive`,value:t.ratio}),U(this,[`knee`,`release`,`attack`,`ratio`,`threshold`])}static getDefaults(){return Object.assign(J.getDefaults(),{attack:.003,knee:30,ratio:12,release:.25,threshold:-24})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.disconnect(),this.attack.dispose(),this.release.dispose(),this.threshold.dispose(),this.ratio.dispose(),this.knee.dispose(),this}},Ed=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`threshold`,`smoothing`]);super(t),this.name=`Gate`,this._follower=new Mu({context:this.context,smoothing:t.smoothing}),this._gt=new Ml({context:this.context,value:ic(t.threshold)}),this.input=new Y({context:this.context}),this._gate=this.output=new Y({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign(J.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return ac(this._gt.value)}set threshold(e){this._gt.value=ic(e)}get smoothing(){return this._follower.smoothing}set smoothing(e){this._follower.smoothing=e}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}},Dd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`threshold`]);super(t),this.name=`Limiter`,this._compressor=this.input=this.output=new Td({context:this.context,ratio:20,attack:.003,release:.01,threshold:t.threshold}),this.threshold=this._compressor.threshold,U(this,`threshold`)}static getDefaults(){return Object.assign(J.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}},Od=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MidSideCompressor`,this._midSideSplit=this.input=new od({context:this.context}),this._midSideMerge=this.output=new sd({context:this.context}),this.mid=new Td(Object.assign(t.mid,{context:this.context})),this.side=new Td(Object.assign(t.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),U(this,[`mid`,`side`])}static getDefaults(){return Object.assign(J.getDefaults(),{mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}})}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this}},kd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MultibandCompressor`,this._splitter=this.input=new Sd({context:this.context,lowFrequency:t.lowFrequency,highFrequency:t.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new Y({context:this.context}),this.low=new Td(Object.assign(t.low,{context:this.context})),this.mid=new Td(Object.assign(t.mid,{context:this.context})),this.high=new Td(Object.assign(t.high,{context:this.context})),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),U(this,[`high`,`mid`,`low`,`highFrequency`,`lowFrequency`])}static getDefaults(){return Object.assign(J.getDefaults(),{lowFrequency:250,highFrequency:2e3,low:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10},mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},high:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16}})}dispose(){return super.dispose(),this._splitter.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.output.dispose(),this}},Ad=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`low`,`mid`,`high`]);super(t),this.name=`EQ3`,this.output=new Y({context:this.context}),this._internalChannels=[],this.input=this._multibandSplit=new Sd({context:this.context,highFrequency:t.highFrequency,lowFrequency:t.lowFrequency}),this._lowGain=new Y({context:this.context,gain:t.low,units:`decibels`}),this._midGain=new Y({context:this.context,gain:t.mid,units:`decibels`}),this._highGain=new Y({context:this.context,gain:t.high,units:`decibels`}),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),U(this,[`low`,`mid`,`high`,`lowFrequency`,`highFrequency`]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign(J.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),Zs(this,[`low`,`mid`,`high`,`lowFrequency`,`highFrequency`]),this._multibandSplit.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this._lowGain.dispose(),this._midGain.dispose(),this._highGain.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.Q.dispose(),this}},jd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`url`,`onload`]);super(t),this.name=`Convolver`,this._convolver=this.context.createConvolver(),this._buffer=new Qs(t.url,e=>{this.buffer=e,t.onload()}),this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=t.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign(J.getDefaults(),{normalize:!0,onload:W})}load(e){return V(this,void 0,void 0,function*(){this.buffer=yield this._buffer.load(e)})}get buffer(){return this._buffer.length?this._buffer:null}set buffer(e){e&&this._buffer.set(e),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));let t=this._buffer.get();this._convolver.buffer=t||null}get normalize(){return this._convolver.normalize}set normalize(e){this._convolver.normalize=e}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}},Md=e({AMOscillator:()=>dl,AMSynth:()=>Hl,Abs:()=>Dl,Add:()=>vl,AmplitudeEnvelope:()=>zl,Analyser:()=>fd,AudioToGain:()=>ul,AutoFilter:()=>ku,AutoPanner:()=>ju,AutoWah:()=>Nu,BaseContext:()=>Js,BiquadFilter:()=>Ul,BitCrusher:()=>Fu,Buffer:()=>Kd,BufferSource:()=>Jd,Buffers:()=>qd,Channel:()=>bd,Chebyshev:()=>Lu,Chorus:()=>Hu,Clock:()=>Nc,Compressor:()=>Td,Context:()=>Ys,Convolver:()=>jd,CrossFade:()=>Eu,DCMeter:()=>gd,Delay:()=>Pc,Destination:()=>Ld,Distortion:()=>Uu,Draw:()=>Hd,DuoSynth:()=>ql,EQ3:()=>Ad,Emitter:()=>qs,Envelope:()=>Fl,FFT:()=>hd,FMOscillator:()=>fl,FMSynth:()=>Jl,FatOscillator:()=>ml,FeedbackCombFilter:()=>au,FeedbackDelay:()=>Gu,Filter:()=>Wl,Follower:()=>Mu,Freeverb:()=>Xu,Frequency:()=>yc,FrequencyClass:()=>gc,FrequencyEnvelope:()=>Gl,FrequencyShifter:()=>qu,Gain:()=>Y,GainToAudio:()=>Ol,Gate:()=>Ed,GrainPlayer:()=>El,GreaterThan:()=>Ml,GreaterThanZero:()=>jl,IntervalTimeline:()=>Wc,JCReverb:()=>ed,LFO:()=>xl,Limiter:()=>Dd,Listener:()=>Bd,Loop:()=>fu,LowpassCombFilter:()=>su,Master:()=>Rd,MembraneSynth:()=>Zl,Merge:()=>zu,MetalSynth:()=>Xl,Meter:()=>md,MidSideCompressor:()=>Od,MidSideMerge:()=>sd,MidSideSplit:()=>od,Midi:()=>Vc,MidiClass:()=>Bc,Mono:()=>xd,MonoSynth:()=>Kl,MultibandCompressor:()=>kd,MultibandSplit:()=>Sd,Multiply:()=>$,Negate:()=>kl,Noise:()=>tl,NoiseSynth:()=>Ql,Offline:()=>Rc,OfflineContext:()=>$s,OmniOscillator:()=>_l,OnePoleFilter:()=>ou,Oscillator:()=>ll,PWMOscillator:()=>hl,PanVol:()=>yd,Panner:()=>Au,Panner3D:()=>Cd,Param:()=>q,Part:()=>pu,Pattern:()=>wu,Phaser:()=>id,PingPongDelay:()=>nd,PitchShift:()=>rd,Player:()=>wl,Players:()=>Tl,PluckSynth:()=>cu,PolySynth:()=>lu,Pow:()=>Xc,PulseOscillator:()=>pl,Recorder:()=>wd,Reverb:()=>ad,Sampler:()=>uu,Scale:()=>yl,ScaleExp:()=>Nl,Sequence:()=>Tu,Signal:()=>X,Solo:()=>vd,Split:()=>Ru,StateTimeline:()=>Sc,StereoWidener:()=>ld,Subtract:()=>Al,SyncedSignal:()=>Pl,Synth:()=>Bl,Ticks:()=>Hc,TicksClass:()=>Z,Time:()=>hc,TimeClass:()=>mc,Timeline:()=>Bs,ToneAudioBuffer:()=>Qs,ToneAudioBuffers:()=>zc,ToneAudioNode:()=>J,ToneBufferSource:()=>el,ToneEvent:()=>du,ToneOscillatorNode:()=>cl,Transport:()=>Fd,TransportTime:()=>bc,TransportTimeClass:()=>K,Tremolo:()=>ud,Unit:()=>Kc,UserMedia:()=>ol,Vibrato:()=>dd,Volume:()=>Fc,WaveShaper:()=>Yc,Waveform:()=>_d,Zero:()=>bl,connect:()=>wc,connectSeries:()=>Cc,connectSignal:()=>kc,context:()=>Wd,dbToGain:()=>ic,debug:()=>as,defaultArg:()=>js,disconnect:()=>Tc,fanIn:()=>Ec,ftom:()=>uc,gainToDb:()=>ac,getContext:()=>G,getDestination:()=>zd,getDraw:()=>Ud,getListener:()=>Vd,getTransport:()=>Id,immediate:()=>Pd,intervalToFrequencyRatio:()=>oc,isArray:()=>ns,isBoolean:()=>ts,isDefined:()=>R,isFunction:()=>Qo,isNote:()=>is,isNumber:()=>$o,isObject:()=>es,isString:()=>rs,isUndef:()=>Zo,loaded:()=>Gd,mtof:()=>fc,now:()=>Nd,optionsFromArguments:()=>H,setContext:()=>nc,start:()=>rc,supported:()=>Xo,version:()=>n});function Nd(){return G().now()}function Pd(){return G().immediate()}var Fd=G().transport;function Id(){return G().transport}var Ld=G().destination,Rd=G().destination;function zd(){return G().destination}var Bd=G().listener;function Vd(){return G().listener}var Hd=G().draw;function Ud(){return G().draw}var Wd=G();function Gd(){return Qs.loaded()}var Kd=Qs,qd=zc,Jd=el;export{G as C,ac as S,el as _,bd as a,Y as b,pu as c,Jl as d,Kl as f,tl as g,wl as h,Td as i,uu as l,Bl as m,zd as n,dd as o,Wl as p,Dd as r,ad as s,Md as t,lu as u,Yc as v,Qs as w,yc as x,Rc as y};