libre-webui 0.19.2 → 0.19.3

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 (91) hide show
  1. package/backend/dist/index.d.ts.map +1 -1
  2. package/backend/dist/index.js +61 -2
  3. package/backend/dist/index.js.map +1 -1
  4. package/backend/dist/routes/artifacts.d.ts +3 -0
  5. package/backend/dist/routes/artifacts.d.ts.map +1 -0
  6. package/backend/dist/routes/artifacts.js +167 -0
  7. package/backend/dist/routes/artifacts.js.map +1 -0
  8. package/backend/package.json +1 -1
  9. package/frontend/dist/apple-touch-icon.png +0 -0
  10. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -0
  11. package/frontend/dist/artifact-runtime/babel.js +613 -0
  12. package/frontend/dist/artifact-runtime/chart.js +3 -0
  13. package/frontend/dist/artifact-runtime/d3.js +5 -0
  14. package/frontend/dist/artifact-runtime/fonts.js +255 -0
  15. package/frontend/dist/artifact-runtime/framer-motion.js +10 -0
  16. package/frontend/dist/artifact-runtime/lodash.js +20 -0
  17. package/frontend/dist/artifact-runtime/lucide-react.js +1 -0
  18. package/frontend/dist/artifact-runtime/mathjs.js +54 -0
  19. package/frontend/dist/artifact-runtime/mermaid.js +3535 -0
  20. package/frontend/dist/artifact-runtime/papaparse.js +10 -0
  21. package/frontend/dist/artifact-runtime/plotly.js +3790 -0
  22. package/frontend/dist/artifact-runtime/react.js +9 -0
  23. package/frontend/dist/artifact-runtime/recharts.js +69 -0
  24. package/frontend/dist/artifact-runtime/runtime.js +1 -0
  25. package/frontend/dist/artifact-runtime/tailwind.js +952 -0
  26. package/frontend/dist/artifact-runtime/three.js +5271 -0
  27. package/frontend/dist/artifact-runtime/tone.js +210 -0
  28. package/frontend/dist/assets/index-ZxtmHZ3Y.js +83 -0
  29. package/frontend/dist/assets/index-mBbb8flG.css +1 -0
  30. package/frontend/dist/favicon-dark.png +0 -0
  31. package/frontend/dist/favicon-light.png +0 -0
  32. package/frontend/dist/favicon.svg +1 -0
  33. package/frontend/dist/fonts/inter.css +254 -0
  34. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa0ZL7W0Q5n-wU.woff2 +0 -0
  35. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7W0Q5nw.woff2 +0 -0
  36. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1pL7W0Q5n-wU.woff2 +0 -0
  37. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa25L7W0Q5n-wU.woff2 +0 -0
  38. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7W0Q5n-wU.woff2 +0 -0
  39. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2ZL7W0Q5n-wU.woff2 +0 -0
  40. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2pL7W0Q5n-wU.woff2 +0 -0
  41. package/frontend/dist/icon-192.png +0 -0
  42. package/frontend/dist/icon-512.png +0 -0
  43. package/frontend/dist/index.html +15 -10
  44. package/frontend/dist/js/ArtifactContainer-DZV5ZT6g.js +1 -0
  45. package/frontend/dist/js/{ArtifactDemoPage-BlVBMy6a.js → ArtifactDemoPage-BX6d2sWa.js} +58 -2
  46. package/frontend/dist/js/ArtifactSandboxFrame-CSDSSxMI.js +151 -0
  47. package/frontend/dist/js/ArtifactSlideOutPanel-BYy4Yv_U.js +1 -0
  48. package/frontend/dist/js/ChatPage-Bk1fO2xt.js +16 -0
  49. package/frontend/dist/js/FirstTimeSetup-ByfcKmYo.js +1 -0
  50. package/frontend/dist/js/{GalleryPage-BnaFZERr.js → GalleryPage-DLLiZj6X.js} +1 -1
  51. package/frontend/dist/js/{HomePage-BvpoUzGG.js → HomePage-DHuuGx-r.js} +1 -1
  52. package/frontend/dist/js/{LibreClawPage-B-6rO5Jl.js → LibreClawPage-BfCXrQ-e.js} +1 -1
  53. package/frontend/dist/js/{ModelSelector-BV1kuaVg.js → ModelSelector-BET34RYg.js} +1 -1
  54. package/frontend/dist/js/{ModelsPage-D5H70fs3.js → ModelsPage-BxLpqELH.js} +1 -1
  55. package/frontend/dist/js/{NotesPage-D9b3JxCx.js → NotesPage-BC62unJU.js} +1 -1
  56. package/frontend/dist/js/{PersonasPage-CJOGnyQV.js → PersonasPage-BsOyNy8l.js} +2 -2
  57. package/frontend/dist/js/{PluginUsagePage-DHNMWquK.js → PluginUsagePage-CLpKYGwg.js} +1 -1
  58. package/frontend/dist/js/{RichMessageContent-C7NG7gs-.js → RichMessageContent-BTcjK7f1.js} +1 -1
  59. package/frontend/dist/js/SettingsModal-ao0lVJHy.js +1 -0
  60. package/frontend/dist/js/{SystemPage-BsPen2Qb.js → SystemPage-ZMCqqgBt.js} +1 -1
  61. package/frontend/dist/js/{UserManagementPage-I9i5r0V3.js → UserManagementPage-6PsAs-Uy.js} +1 -1
  62. package/frontend/dist/js/WorkPage-t7NVWt81.js +5 -0
  63. package/frontend/dist/js/api-F_fsjYA7.js +19 -0
  64. package/frontend/dist/js/{appStore-CLIS0fvz.js → appStore-ne0eCPTX.js} +2 -2
  65. package/frontend/dist/js/{authStore-CsCkBmaG.js → authStore-DqsiGpyN.js} +1 -1
  66. package/frontend/dist/js/{chatStore-DRY8C0J1.js → chatStore-DRg2vRDS.js} +2 -2
  67. package/frontend/dist/js/config-DZsEwEPX.js +1 -0
  68. package/frontend/dist/js/{estree-CrfVSazx.js → estree-CWs-Kavs.js} +1 -1
  69. package/frontend/dist/js/{html-BbJLJMaV.js → html-DrDcdqPC.js} +1 -1
  70. package/frontend/dist/js/{markdown-DiMg1QLf.js → markdown-CbB02VPB.js} +1 -1
  71. package/frontend/dist/js/{messageCodeStyles-CfzjQF-R.js → messageCodeStyles-D1gR4Bnk.js} +1 -1
  72. package/frontend/dist/js/{standalone-Vs6LnjM6.js → standalone-BIvqjowG.js} +1 -1
  73. package/frontend/dist/js/{typescript-BhVG1zGU.js → typescript-kUuRGkxH.js} +1 -1
  74. package/frontend/dist/js/{ui-Dj9IFugT.js → ui-D4PVoJDa.js} +2 -2
  75. package/frontend/dist/logo-dark.png +0 -0
  76. package/frontend/dist/logo-dark.svg +1 -0
  77. package/frontend/dist/logo-light.png +0 -0
  78. package/frontend/dist/logo-light.svg +1 -0
  79. package/frontend/dist/logo.svg +1 -6
  80. package/frontend/dist/maskable-512.png +0 -0
  81. package/package.json +2 -2
  82. package/frontend/dist/assets/index-B9H3vQ-n.css +0 -1
  83. package/frontend/dist/assets/index-D4LhtFTX.js +0 -38
  84. package/frontend/dist/js/ArtifactContainer-DvuGeXXu.js +0 -1
  85. package/frontend/dist/js/ArtifactSlideOutPanel-CaPMk1Qj.js +0 -1
  86. package/frontend/dist/js/ChatPage-D4UBhGLk.js +0 -16
  87. package/frontend/dist/js/FirstTimeSetup-DJiDNTXY.js +0 -1
  88. package/frontend/dist/js/SettingsModal-DEBxDPne.js +0 -1
  89. package/frontend/dist/js/WorkPage-e30yqvJe.js +0 -5
  90. package/frontend/dist/js/api-jwjnjqx6.js +0 -19
  91. package/frontend/dist/js/artifactHtml-C0Hu9I1u.js +0 -41
@@ -0,0 +1,210 @@
1
+ (function(){var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=`15.1.22`,i=t(((e,t)=>{function n(e){if(Array.isArray(e))return e}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),a=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})),o=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})),s=t(((e,t)=>{var n=o();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})),c=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})),l=t(((e,t)=>{var n=i(),r=a(),o=s(),l=c();function u(e,t){return n(e)||r(e,t)||o(e,t)||l()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})),u=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})),d=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})),f=t(((e,t)=>{var n=d().default;function r(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==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})),p=t(((e,t)=>{var n=d().default,r=f();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})),m=t(((e,t)=>{var n=p();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})),h=t(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e,l(),u(),m()):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))})(e,(function(e,t,n,r){"use strict";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}))}))(),g=()=>new DOMException(``,`AbortError`),_=e=>(t,n,[r,i,a],o)=>{e(t[i],[n,r,a],e=>e[0]===n&&e[1]===r,o)},v=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})},y=e=>(t,n)=>{e.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:n})},b=new WeakSet,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=new WeakMap,te={construct(){return te}},ne=e=>{try{new new Proxy(e,te)}catch{return!1}return!0},re=/^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]*);?/,ie=(e,t)=>{let n=[],r=e.replace(/^[\s]+/,``),i=r.match(re);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(re)}return[n.join(`;`),r]},ae=e=>{if(e!==void 0&&!Array.isArray(e))throw TypeError(`The parameterDescriptors property of given value for processorCtor is not an array.`)},oe=e=>{if(!ne(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.`)},se=(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]=ie(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=O.get(y);if(r!==void 0){if(r.has(e))throw t();oe(n),ae(n.parameterDescriptors),r.set(e,n)}else oe(n),ae(n.parameterDescriptors),O.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]=ie(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},ce=(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},le=(e,t,n,r)=>{let i=k(e,t),a=ce(i,e=>e[0]===n&&e[1]===r);return i.size===0&&e.delete(t),a},ue=e=>k(E,e),A=e=>{if(b.has(e))throw Error(`The AudioNode is already stored.`);b.add(e),ue(e).forEach(e=>e(!0))},de=e=>`port`in e,fe=e=>{if(!b.has(e))throw Error(`The AudioNode is not stored.`);b.delete(e),ue(e).forEach(e=>e(!1))},pe=(e,t)=>{!de(e)&&t.every(e=>e.size===0)&&fe(e)},me=(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=le(b,m,g,_);e(y,m,t,!1),!v&&!d(m)&&n(l,s,g,_),f(h)&&A(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)&&pe(h,y);else{let e=p.get(h);e!==void 0&&clearTimeout(e),p.set(h,setTimeout(()=>{u(h)&&pe(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}},he=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)},ge=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)},_e=e=>(t,n)=>{e(t).add(n)},ve={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},ye=(e,t,n,r,i,a)=>class extends e{constructor(e,n){let o=i(e),s=r(o,{...ve,...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)}},be=(e,t)=>e.context===t,xe=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return be(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)}}},Se=e=>{try{e.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},Ce=()=>new DOMException(``,`IndexSizeError`),we=e=>{e.getChannelData=(t=>n=>{try{return t.call(e,n)}catch(e){throw e.code===12?Ce():e}})(e.getChannelData)},Te={numberOfChannels:1},Ee=(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}={...Te,...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(Se,()=>Se(p))||s(p):(o(p),we(p)),e.add(p),p}static[Symbol.hasInstance](t){return typeof t==`object`&&!!t&&Object.getPrototypeOf(t)===l.prototype||e.has(t)}}},De=-34028234663852886e22,Oe=34028234663852886e22,ke=e=>b.has(e),Ae={buffer:null,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,loop:!1,loopEnd:0,loopStart:0,playbackRate:1},je=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,r){let s=a(e),c={...Ae,...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,Oe,De)}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`){A(this);let e=()=>{this._nativeAudioBufferSourceNode.removeEventListener(`ended`,e),ke(this)&&fe(this)};this._nativeAudioBufferSourceNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeAudioBufferSourceNode.stop(e),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=e)}},Me=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=async(c,l)=>{let u=n(c),d=be(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)}}},Ne=e=>`playbackRate`in e,Pe=e=>`frequency`in e&&`gain`in e,Fe=e=>`offset`in e,Ie=e=>!(`frequency`in e)&&`gain`in e,Le=e=>`detune`in e&&`frequency`in e&&!(`gain`in e),Re=e=>`pan`in e,ze=e=>k(x,e),Be=e=>k(C,e),Ve=(e,t)=>{let{activeInputs:n}=ze(e);n.forEach(n=>n.forEach(([n])=>{t.includes(e)||Ve(n,[...t,e])}));let r=Ne(e)?[e.playbackRate]:de(e)?Array.from(e.parameters.values()):Pe(e)?[e.Q,e.detune,e.frequency,e.gain]:Fe(e)?[e.offset]:Ie(e)?[e.gain]:Le(e)?[e.detune,e.frequency]:Re(e)?[e.pan]:[];for(let e of r){let n=Be(e);n!==void 0&&n.activeInputs.forEach(([e])=>Ve(e,t))}ke(e)&&fe(e)},He=e=>{Ve(e.destination,[])},Ue=e=>e===void 0||typeof e==`number`||typeof e==`string`&&(e===`balanced`||e===`interactive`||e===`playback`),We=(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(!Ue(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()),He(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})}},Ge=(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}},Ke=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)}}},qe=(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,Oe,De);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}}},Je=e=>`context`in e,Ye=e=>Je(e[0]),Xe=(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},Ze=(e,t,[n,r],i)=>{Xe(e,[t,n,r],e=>e[0]===t&&e[1]===n,i)},Qe=(e,[t,n,r],i)=>{let a=e.get(t);a===void 0?e.set(t,new Set([[n,r]])):Xe(a,[n,r],e=>e[0]===n,i)},$e=e=>`inputs`in e,et=(e,t,n,r)=>{if($e(t)){let i=t.inputs[r];return e.connect(i,n,0),[i,n,0]}return e.connect(t,n,r),[t,n,r]},tt=(e,t,n)=>{for(let r of e)if(r[0]===t&&r[1]===n)return e.delete(r),r;return null},nt=(e,t,n)=>ce(e,e=>e[0]===t&&e[1]===n),rt=(e,t)=>{if(!ue(e).delete(t))throw Error(`Missing the expected event listener.`)},it=(e,t,n)=>{let r=k(e,t),i=ce(r,e=>e[0]===n);return r.size===0&&e.delete(t),i},at=(e,t,n,r)=>{$e(t)?e.disconnect(t.inputs[r],n,0):e.disconnect(t,n,r)},j=e=>k(S,e),ot=e=>k(w,e),st=e=>D.has(e),ct=e=>!b.has(e),lt=(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()}}),ut=(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))},dt=e=>`context`in e,ft=e=>{let t=new Map;e.connect=(e=>(n,r=0,i=0)=>{let a=dt(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=>{dt(n)?e.connect(n,t.output,t.input):e.connect(n,t.output)})})(e.disconnect)},pt=(e,t,n,r)=>{let{activeInputs:i,passiveInputs:a}=Be(t),{outputs:o}=ze(e),s=ue(e),c=o=>{let s=j(e),c=ot(t);if(o){let t=it(a,e,n);Ze(i,e,t,!1),!r&&!st(e)&&s.connect(c,n)}else{let t=nt(i,e,n);Qe(a,t,!1),!r&&!st(e)&&s.disconnect(c,n)}};return Xe(o,[t,n],e=>e[0]===t&&e[1]===n,!0)?(s.add(c),ke(e)?Ze(i,e,[n,c],!0):Qe(a,[e,n,c],!0),!0):!1},mt=(e,t,n,r)=>{let{activeInputs:i,passiveInputs:a}=ze(t),o=tt(i[r],e,n);return o===null?[le(a,e,n,r)[2],!1]:[o[2],!0]},ht=(e,t,n)=>{let{activeInputs:r,passiveInputs:i}=Be(t),a=tt(r,e,n);return a===null?[it(i,e,n)[1],!1]:[a[2],!0]},gt=(e,t,n,r,i)=>{let[a,o]=mt(e,n,r,i);if(a!==null&&(rt(e,a),o&&!t&&!st(e)&&at(j(e),j(n),r,i)),ke(n)){let{activeInputs:e}=ze(n);pe(n,e)}},_t=(e,t,n,r)=>{let[i,a]=ht(e,n,r);i!==null&&(rt(e,i),a&&!t&&!st(e)&&j(e).disconnect(ot(n),r))},vt=(e,t)=>{let n=ze(e),r=[];for(let i of n.outputs)Ye(i)?gt(e,t,...i):_t(e,t,...i),r.push(i[0]);return n.outputs.clear(),r},yt=(e,t,n)=>{let r=ze(e),i=[];for(let a of r.outputs)a[1]===n&&(Ye(a)?gt(e,t,...a):_t(e,t,...a),i.push(a[0]),r.outputs.delete(a));return i},bt=(e,t,n,r,i)=>{let a=ze(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=>(Ye(n)?gt(e,t,...n):_t(e,t,...n),a.outputs.delete(n),n[0]))},xt=(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(lt,()=>lt(o,h))&&ft(i),S.set(this,i),E.set(this,new Set),t.state!==`closed`&&r&&A(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(Je(e)){let i=j(e);try{let t=et(this._nativeAudioNode,i,n,s),r=ct(this);(l||r)&&this._nativeAudioNode.disconnect(...t),this.context.state!==`closed`&&!r&&ct(e)&&A(e)}catch(e){throw e.code===12?a():e}return t(this,e,n,s,l)&&ut(c([this],e),r(l)),e}let d=ot(e);if(d.name===`playbackRate`&&d.maxValue===1024)throw o();try{this._nativeAudioNode.connect(d,n),(l||ct(this))&&this._nativeAudioNode.disconnect(d,n)}catch(e){throw e.code===12?a():e}pt(this,e,n,l)&&ut(c([this],e),r(l))}disconnect(e,t,n){let r,o=m(u(this._context));if(e===void 0)r=vt(this,o);else if(typeof e==`number`){if(e<0||e>=this.numberOfOutputs)throw i();r=yt(this,o,e)}else{if(t!==void 0&&(t<0||t>=this.numberOfOutputs)||Je(e)&&n!==void 0&&(n<0||n>=e.numberOfInputs))throw i();if(r=bt(this,o,e,t,n),r.length===0)throw a()}for(let e of r)ut(c([this],e),s)}},St=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>(p,m,g,_=null,v=null)=>{let y=g.value,b=new h.AutomationEventList(y),x=m?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},Ct=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.`)}}),wt=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()}},Tt={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},Et=(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({...Tt,...m});f(_);let v=O.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 wt(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 Dt(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 Ot=(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)},kt=(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},At=(e,t)=>k(k(ee,e),j(t)),jt=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=ze(e),f=await At(n,e),p=kt(r.numberOfInputs,r.channelCount),m=kt(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)Dt(t,p[e],n,n,l);a.parameterDescriptors!==void 0&&t!==null&&a.parameterDescriptors.forEach(({name:e},n)=>{Dt(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)Ot(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},Mt=(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=be(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=jt(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)}}},Nt=(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})}},Pt={Q:1,channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,detune:0,frequency:350,gain:0,type:`lowpass`},Ft=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,r){let c=a(e),l=i(c,{...Pt,...r}),u=o(c),d=u?n():null;super(e,!1,l,d),this._Q=t(this,u,l.Q,Oe,De),this._detune=t(this,u,l.detune,1200*Math.log2(Oe),-1200*Math.log2(Oe)),this._frequency=t(this,u,l.frequency,e.sampleRate/2,0),this._gain=t(this,u,l.gain,40*Math.log10(Oe),De),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()}},It=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=be(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)}}},Lt=(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}},Rt={channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:6},zt=(e,t,n,r,i)=>class extends e{constructor(e,a){let o=r(e),s=n(o,{...Rt,...a}),c=i(o)?t():null;super(e,!1,s,c)}},Bt=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return be(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)}}},Vt={channelCount:6,channelCountMode:`explicit`,channelInterpretation:`discrete`,numberOfOutputs:6},Ht=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c=n(s,a({...Vt,...o})),l=i(s)?t():null;super(e,!1,c,l)}},Ut=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return be(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)}}},Wt=e=>(t,n,r)=>e(n,t,r),Gt=e=>(t,n,r=0,i=0)=>{let a=t[r];if(a===void 0)throw e();return dt(n)?a.connect(n,0,i):a.connect(n,0)},Kt=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)}},qt={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,offset:1},Jt=(e,t,n,r,i,a,o)=>class extends e{constructor(e,o){let s=i(e),c=r(s,{...qt,...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,Oe,De),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`){A(this);let e=()=>{this._nativeConstantSourceNode.removeEventListener(`ended`,e),ke(this)&&fe(this)};this._nativeConstantSourceNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeConstantSourceNode.stop(e),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=e)}},Yt=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=async(c,l)=>{let u=n(c),d=be(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)}}},Xt=e=>t=>(e[0]=t,e[0]),Zt={buffer:null,channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,disableNormalization:!1},Qt=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c={...Zt,...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}},$t=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return be(o,a)||(o=e(a,{buffer:o.buffer,channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,disableNormalization:!o.normalize})),r.set(a,o),$e(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)}}},en=(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}},tn=()=>new DOMException(``,`DataCloneError`),nn=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()}})},rn=(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=>(nn(f).catch(()=>{}),t(s,()=>s(n))||u(n),e.add(n),n)):new Promise((t,n)=>{let i=async()=>{try{await nn(f)}catch{}},a=e=>{n(e),i()};try{p.decodeAudioData(f,n=>{typeof n.copyFromChannel!=`function`&&(l(n),we(n)),e.add(n),i().then(()=>t(n))},e=>{a(e===null?r():e)})}catch(e){a(e)}})},an=(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(Ye(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)},on={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,delayTime:0,maxDelayTime:1},sn=(e,t,n,r,i,a,o)=>class extends e{constructor(e,s){let c=i(e),l={...on,...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}},cn=(e,t,n,r,i)=>a=>{let o=new WeakMap,s=async(s,c)=>{let l=n(s),u=be(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)}}},ln=e=>(t,n,r,i)=>e(t[i],e=>e[0]===n&&e[1]===r),un=e=>(t,n)=>{e(t).delete(n)},dn=e=>`delayTime`in e,fn=(e,t,n)=>function r(i,a){let o=Je(a)?a:n(e,a);if(dn(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),[])},pn=(e,t,n)=>{let r=t[n];if(r===void 0)throw e();return r},mn=e=>(t,n=void 0,r=void 0,i=0)=>n===void 0?t.forEach(e=>e.disconnect()):typeof n==`number`?pn(e,t,n).disconnect():dt(n)?r===void 0?t.forEach(e=>e.disconnect(n)):i===void 0?pn(e,t,r).disconnect(n,0):pn(e,t,r).disconnect(n,0,i):r===void 0?t.forEach(e=>e.disconnect(n)):pn(e,t,r).disconnect(n,0),hn={attack:.003,channelCount:2,channelCountMode:`clamped-max`,channelInterpretation:`speakers`,knee:30,ratio:12,release:.25,threshold:-24},gn=(e,t,n,r,i,a,o,s)=>class extends e{constructor(e,i){let c=a(e),l=r(c,{...hn,...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}},_n=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=be(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)}}},vn=()=>new DOMException(``,`EncodingError`),yn=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)}}),bn=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)}},xn=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)}},Sn=e=>async t=>{try{let e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw e()},Cn={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,gain:1},wn=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=i(e),c=r(s,{...Cn,...o}),l=a(s),u=l?n():null;super(e,!1,c,u),this._gain=t(this,l,c.gain,Oe,De)}get gain(){return this._gain}},Tn=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=be(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)}}},En=(e,t)=>n=>t(e,n),Dn=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},On=e=>t=>e.get(t)??0,kn=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},An=e=>t=>e.get(t),jn=()=>new DOMException(``,`InvalidStateError`),Mn=e=>t=>{let n=e.get(t);if(n===void 0)throw jn();return n},Nn=(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},Pn=e=>t=>{let n=e.get(t);if(n===void 0)throw Error(`The context has no set of AudioWorkletNodes.`);return n},Fn=()=>new DOMException(``,`InvalidAccessError`),In=e=>{e.getFrequencyResponse=(t=>(n,r,i)=>{if(n.length!==r.length||r.length!==i.length)throw Fn();return t.call(e,n,r,i)})(e.getFrequencyResponse)},Ln={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`},Rn=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=r(e),c=i(s),l={...Ln,...o},u=t(s,c?null:e.baseLatency,l),d=c?n(l.feedback,l.feedforward):null;super(e,!1,u,d),In(u),this._nativeIIRFilterNode=u,a(this,1)}getFrequencyResponse(e,t,n){return this._nativeIIRFilterNode.getFrequencyResponse(e,t,n)}},zn=(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},Bn=(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),zn(i,o,a,s,c,l,u,0,32,n,r)}return d},Vn=(e,t,n,r,i)=>(a,o)=>{let s=new WeakMap,c=null,l=async(l,u)=>{let d=null,f=t(l),p=be(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),Bn(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)}}},Hn=(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(Ye(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)},Un=(e,t)=>n=>t(e.get(n))||t(n),Wn=(e,t)=>n=>e.has(n)||t(n),Gn=(e,t)=>n=>e.has(n)||t(n),Kn=(e,t)=>n=>t(e.get(n))||t(n),qn=e=>t=>e!==null&&t instanceof e,Jn=e=>t=>e!==null&&typeof e.AudioNode==`function`&&t instanceof e.AudioNode,Yn=e=>t=>e!==null&&typeof e.AudioParam==`function`&&t instanceof e.AudioParam,Xn=(e,t)=>n=>e(n)||t(n),Zn=e=>t=>e!==null&&t instanceof e,Qn=e=>e!==null&&e.isSecureContext,$n=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,er=(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}},tr={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`},nr=(e,t,n,r)=>class extends e{constructor(e,i){let a=n(e);if(r(a))throw TypeError();let o=t(a,{...tr,...i});super(e,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}},rr=(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}},ir=(e,t,n)=>class extends e{constructor(e,r){let i=t(n(e),r);super(e,!0,i,null)}},ar=(e,t,n,r,i,a)=>class extends n{constructor(n,a){super(n),this._nativeContext=n,T.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}},or=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},sr=(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},M=(e,t,n)=>{let r=t[n];r!==void 0&&r!==e[n]&&(e[n]=r)},N=(e,t)=>{M(e,t,`channelCount`),M(e,t,`channelCountMode`),M(e,t,`channelInterpretation`)},cr=e=>typeof e.getFloatTimeDomainData==`function`,lr=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}},ur=(e,t)=>(n,r)=>{let i=n.createAnalyser();if(N(i,r),!(r.maxDecibels>r.minDecibels))throw t();return M(i,r,`fftSize`),M(i,r,`maxDecibels`),M(i,r,`minDecibels`),M(i,r,`smoothingTimeConstant`),e(cr,()=>cr(i))||lr(i),i},dr=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)},fr=e=>{e.start=(t=>{let n=!1;return(r=0,i=0,a)=>{if(n)throw jn();t.call(e,r,i,a),n=!0}})(e.start)},pr=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)},mr=e=>{e.stop=(t=>(n=0)=>{if(n<0)throw RangeError(`The parameter can't be negative.`);t.call(e,n)})(e.stop)},hr=(e,t,n,r,i,a,o,s,c,l,u)=>(d,f)=>{let p=d.createBufferSource();return N(p,f),P(p,f,`playbackRate`),M(p,f,`buffer`),M(p,f,`loop`),M(p,f,`loopEnd`),M(p,f,`loopStart`),t(n,()=>n(d))||fr(p),t(r,()=>r(d))||c(p),t(i,()=>i(d))||l(p,d),t(a,()=>a(d))||pr(p),t(o,()=>o(d))||u(p,d),t(s,()=>s(d))||mr(p),e(d,p),p},gr=e=>e===null?null:e.hasOwnProperty(`AudioContext`)?e.AudioContext:e.hasOwnProperty(`webkitAudioContext`)?e.webkitAudioContext:null,_r=(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},vr=e=>e===null?null:e.hasOwnProperty(`AudioWorkletNode`)?e.AudioWorkletNode:null,yr=e=>{let{port1:t}=new MessageChannel;try{t.postMessage(e)}finally{t.close()}},br=(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 yr(u),t(a,o,l,u)},xr=(e,t)=>e===null?512:Math.max(512,Math.min(16384,2**Math.round(Math.log2(e*t)))),Sr=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)}),Cr=async(e,t)=>new e(await Sr(t)),wr=(e,t,n,r)=>{let i=ee.get(e);i===void 0&&(i=new WeakMap,ee.set(e,i));let a=Cr(n,r);return i.set(t,a),a},Tr=(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?Oe:t},minValue:{get:()=>n===void 0?De:n}}),w.push(i)}let T=r(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`speakers`,numberOfInputs:Math.max(1,v+b)}),E=xr(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 wt(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 se=null;Object.defineProperty(x.port1,"onmessage",{get:()=>se,set:e=>{typeof se==`function`&&x.port1.removeEventListener(`message`,se),se=typeof e==`function`?e:null,typeof se==`function`&&(x.port1.addEventListener(`message`,se),x.port1.start())}}),h.prototype.port=x.port1;let k=null;wr(p,ae,h,g).then(e=>k=e);let ce=kt(g.numberOfInputs,g.channelCount),le=kt(g.numberOfOutputs,_),ue=h.parameterDescriptors===void 0?[]:h.parameterDescriptors.reduce((e,{name:t})=>({...e,[t]:new Float32Array(128)}),{}),A=!0,de=()=>{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]}},fe=new Map;D.onaudioprocess=({inputBuffer:e,outputBuffer:t})=>{if(k!==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)Dt(e,ce[t],n,n,r);h.parameterDescriptors!==void 0&&h.parameterDescriptors.forEach(({name:t},n)=>{Dt(e,ue,t,v+n,r)});for(let e=0;e<g.numberOfInputs;e+=1)for(let t=0;t<_[e];t+=1)le[e][t].byteLength===0&&(le[e][t]=new Float32Array(128));try{let e=ce.map((e,t)=>{if(n[t].size>0)return fe.set(t,E/128),e;let r=fe.get(t);return r===void 0?[]:(e.every(e=>e.every(e=>e===0))&&(r===1?fe.delete(t):fe.set(t,r-1)),e)});A=u(p.currentTime+r/p.sampleRate,p.sampleRate,()=>k.process(e,le,ue));for(let e=0,n=0;e<g.numberOfOutputs;e+=1){for(let i=0;i<_[e];i+=1)Ot(t,le[e],i,n+i,r);n+=_[e]}}catch(e){A=!1,ae.dispatchEvent(new ErrorEvent(`processorerror`,{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}))}if(!A){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,pe?de():ge();break}}}};let pe=!1,me=o(p,{channelCount:1,channelCountMode:`explicit`,channelInterpretation:`discrete`,gain:0}),he=()=>D.connect(me).connect(p.destination),ge=()=>{D.disconnect(me),me.disconnect()};return he(),f(ae,()=>{if(A){ge(),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]}}pe=!0},()=>{A&&(he(),de()),pe=!1})},Er=(e,t)=>{let n=e.createBiquadFilter();return N(n,t),P(n,t,`Q`),P(n,t,`detune`),P(n,t,`frequency`),P(n,t,`gain`),M(n,t,`type`),n},Dr=(e,t)=>(n,r)=>{let i=n.createChannelMerger(r.numberOfInputs);return e!==null&&e.name===`webkitAudioContext`&&t(n,i),N(i,r),i},Or=e=>{let t=e.numberOfOutputs;Object.defineProperty(e,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw jn()}}),Object.defineProperty(e,"channelCountMode",{get:()=>`explicit`,set:e=>{if(e!==`explicit`)throw jn()}}),Object.defineProperty(e,"channelInterpretation",{get:()=>`discrete`,set:e=>{if(e!==`discrete`)throw jn()}})},kr=(e,t)=>{let n=e.createChannelSplitter(t.numberOfOutputs);return N(n,t),Or(n),n},Ar=(e,t,n,r,i)=>(a,o)=>{if(a.createConstantSource===void 0)return n(a,o);let s=a.createConstantSource();return N(s,o),P(s,o,`offset`),t(r,()=>r(a))||pr(s),t(i,()=>i(a))||mr(s),e(a,s),s},jr=(e,t)=>(e.connect=t.connect.bind(t),e.disconnect=t.disconnect.bind(t),e),Mr=(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(jr({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))},Nr=(e,t)=>(n,r)=>{let i=n.createConvolver();if(N(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),M(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},Pr=(e,t)=>{let n=e.createDelay(t.maxDelayTime);return N(n,t),P(n,t,`delayTime`),n},Fr=e=>(t,n)=>{let r=t.createDynamicsCompressor();if(N(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},Ir=(e,t)=>{let n=e.createGain();return N(n,t),P(n,t,`gain`),n},Lr=e=>(t,n,r)=>{if(t.createIIRFilter===void 0)return e(t,n,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return N(i,r),i};function Rr(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 zr(e,t){return[e[0]*t[0]-e[1]*t[1],e[0]*t[1]+e[1]*t[0]]}function Br(e,t){let n=[0,0];for(let r=e.length-1;r>=0;--r)n=zr(n,t),n[0]+=e[r];return n}var Vr=(e,t,n,r)=>(i,a,{channelCount:o,channelCountMode:s,channelInterpretation:c,feedback:l,feedforward:u})=>{let d=xr(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]=zn(f,m,p,h,g,y[e],b[e],v[e],32,r,i)}};let x=i.sampleRate/2;return jr({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=Rr(Br(p,a),Br(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])}},_)},Hr=(e,t)=>e.createMediaElementSource(t.mediaElement),Ur=(e,t)=>{let n=e.createMediaStreamDestination();return N(n,t),n.numberOfOutputs===1&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n},Wr=(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},Gr=(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},Kr=e=>e===null?null:e.hasOwnProperty(`OfflineAudioContext`)?e.OfflineAudioContext:e.hasOwnProperty(`webkitOfflineAudioContext`)?e.webkitOfflineAudioContext:null,qr=(e,t,n,r,i,a)=>(o,s)=>{let c=o.createOscillator();return N(c,s),P(c,s,`detune`),P(c,s,`frequency`),s.periodicWave===void 0?M(c,s,`type`):c.setPeriodicWave(s.periodicWave),t(n,()=>n(o))||pr(c),t(r,()=>r(o))||a(c,o),t(i,()=>i(o))||mr(c),e(o,c),c},Jr=e=>(t,n)=>{let r=t.createPanner();return r.orientationX===void 0?e(t,n):(N(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`),M(r,n,`coneInnerAngle`),M(r,n,`coneOuterAngle`),M(r,n,`coneOuterGain`),M(r,n,`distanceModel`),M(r,n,`maxDistance`),M(r,n,`panningModel`),M(r,n,`refDistance`),M(r,n,`rolloffFactor`),r)},Yr=(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();N(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}),se=i(u,256,6,1),k=a(u,{...D,curve:new Float32Array([1,1]),oversample:`none`}),ce=[g,_,v],le=[b,x,S],ue=new Float32Array(1);se.onaudioprocess=({inputBuffer:e})=>{let t=[c(e,ue,0),c(e,ue,1),c(e,ue,2)];t.some((e,t)=>e!==ce[t])&&(E.setOrientation(...t),ce=t);let n=[c(e,ue,3),c(e,ue,4),c(e,ue,5)];n.some((e,t)=>e!==le[t])&&(E.setPosition(...n),le=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 A={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!==A.coneInnerAngle&&(A.coneInnerAngle=d),f!==A.coneOuterAngle&&(A.coneOuterAngle=f),p!==A.coneOuterGain&&(A.coneOuterGain=p),m!==A.distanceModel&&(A.distanceModel=m),h!==A.maxDistance&&(A.maxDistance=h),g!==A.orientationX.value&&(A.orientationX.value=g),_!==A.orientationY.value&&(A.orientationY.value=_),v!==A.orientationZ.value&&(A.orientationZ.value=v),y!==A.panningModel&&(A.panningModel=y),b!==A.positionX.value&&(A.positionX.value=b),x!==A.positionY.value&&(A.positionY.value=x),S!==A.positionZ.value&&(A.positionZ.value=S),C!==A.refDistance&&(A.refDistance=C),w!==A.rolloffFactor&&(A.rolloffFactor=w),(ce[0]!==1||ce[1]!==0||ce[2]!==0)&&E.setOrientation(...ce),(le[0]!==0||le[1]!==0||le[2]!==0)&&E.setPosition(...le),l(jr(A,E),()=>{ee.connect(E),e(ee,k,0,0),k.connect(te).connect(O,0,0),k.connect(ne).connect(O,0,1),k.connect(re).connect(O,0,2),k.connect(ie).connect(O,0,3),k.connect(ae).connect(O,0,4),k.connect(oe).connect(O,0,5),O.connect(se).connect(u.destination)},()=>{ee.disconnect(E),s(ee,k,0,0),k.disconnect(te),te.disconnect(O),k.disconnect(ne),ne.disconnect(O),k.disconnect(re),re.disconnect(O),k.disconnect(ie),ie.disconnect(O),k.disconnect(ae),ae.disconnect(O),k.disconnect(oe),oe.disconnect(O),O.disconnect(se),se.disconnect(u.destination)})},Xr=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},Zr=(e,t,n,r)=>e.createScriptProcessor(t,n,r),Qr=(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 N(a,r),P(a,r,`pan`),Object.defineProperty(a,"channelCountMode",{get:()=>i,set:e=>{if(e!==i)throw t()}}),a},$r=(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(jr(h,l),()=>{f(),g=!0},()=>{m(),g=!1})}},ei=(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);N(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();M(l,{curve:u},`curve`),M(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)})},ti=(e,t,n,r,i)=>(a,{curve:o,oversample:s,...c})=>{let l=a.createWaveShaper(),u=a.createWaveShaper();N(l,c),N(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(jr(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)})},ni=()=>new DOMException(``,`NotSupportedError`),ri={numberOfChannels:1},ii=(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}={...ri,...a},l=r(s,o,c);t(or,()=>or(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,He(this)}))}_waitForThePromiseToSettle(e){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(e):setTimeout(()=>this._waitForThePromiseToSettle(e))}},ai={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,detune:0,frequency:440,periodicWave:void 0,type:`sine`},oi=(e,t,n,r,i,a,o)=>class extends e{constructor(e,o){let s=i(e),c={...ai,...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`){A(this);let e=()=>{this._nativeOscillatorNode.removeEventListener(`ended`,e),ke(this)&&fe(this)};this._nativeOscillatorNode.addEventListener(`ended`,e)}}stop(e=0){this._nativeOscillatorNode.stop(e),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=e)}},si=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=null,s=null,c=null,l=async(l,u)=>{let d=n(l),f=be(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)}}},ci={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},li=(e,t,n,r,i,a,o)=>class extends e{constructor(e,s){let c=i(e),l=n(c,{...ci,...s}),u=a(c),d=u?r():null;super(e,!1,l,d),this._nativePannerNode=l,this._orientationX=t(this,u,l.orientationX,Oe,De),this._orientationY=t(this,u,l.orientationY,Oe,De),this._orientationZ=t(this,u,l.orientationZ,Oe,De),this._positionX=t(this,u,l.positionX,Oe,De),this._positionY=t(this,u,l.positionY,Oe,De),this._positionZ=t(this,u,l.positionZ,Oe,De),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}},ui=(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=be(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)),$e(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)}}},di={disableNormalization:!1},fi=(e,t,n,r)=>class i{constructor(i,a){let o=e(t(i),r({...di,...a}));return n.add(o),o}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===i.prototype||n.has(e)}},pi=(e,t)=>(n,r,i)=>(e(r).replay(i),t(r,n,i)),mi=(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],[]))},hi=(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)}))},gi=(e,t,n,r)=>i=>e(or,()=>or(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()}),_i=e=>(t,n)=>{e.set(t,n)},vi=e=>(t,n)=>e.set(t,n),yi=(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),we(n)),e.add(n),n)),bi={channelCount:2,channelCountMode:`explicit`,channelInterpretation:`speakers`,pan:0},xi=(e,t,n,r,i,a)=>class extends e{constructor(e,o){let s=i(e),c=n(s,{...bi,...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}},Si=(e,t,n,r,i)=>()=>{let a=new WeakMap,o=async(o,s)=>{let c=n(o),l=be(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),$e(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)}}},Ci=e=>()=>{if(e===null)return!1;try{new e({length:1,sampleRate:44100})}catch{return!1}return!0},wi=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},Ti=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},Ei=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)})},Di=e=>()=>{if(e===null)return!1;let t;try{t=new e({latencyHint:`balanced`})}catch{return!1}return t.close(),!0},Oi=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100).createGain(),n=t.connect(t)===t;return t.disconnect(t),n},ki=(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},Ai=(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},ji=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},Mi=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100);return t.createConstantSource===void 0||t.createConstantSource().offset.maxValue!==1/0},Ni=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},Pi=e=>()=>{if(e===null)return!1;let t=new e(1,1,44100).createConvolver();try{t.channelCount=1}catch{return!1}return!0},Fi=e=>()=>e!==null&&e.hasOwnProperty(`isSecureContext`),Ii=e=>()=>{if(e===null)return!1;let t=new e;try{return t.createMediaStreamSource(new MediaStream),!1}catch{return!0}finally{t.close()}},Li=(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()})},Ri=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)},zi=()=>new DOMException(``,`UnknownError`),Bi={channelCount:2,channelCountMode:`max`,channelInterpretation:`speakers`,curve:null,oversample:`none`},Vi=(e,t,n,r,i,a,o)=>class extends e{constructor(e,t){let s=i(e),c=n(s,{...Bi,...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}},Hi=(e,t,n)=>()=>{let r=new WeakMap,i=async(i,a)=>{let o=t(i);return be(o,a)||(o=e(a,{channelCount:o.channelCount,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,curve:o.curve,oversample:o.oversample})),r.set(a,o),$e(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)}}},Ui=()=>typeof window>`u`?null:window,Wi=(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]}},Gi=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)},Ki=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))},qi=(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))},Ji=(e,t,n)=>e.copyFromChannel===void 0?e.getChannelData(n)[0]:(e.copyFromChannel(t,n),t[0]),Yi=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},Xi=(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)})},Zi=e=>({...e,outputChannelCount:e.outputChannelCount===void 0?e.numberOfInputs===1&&e.numberOfOutputs===1?[e.channelCount]:Array.from({length:e.numberOfOutputs},()=>1):e.outputChannelCount}),Qi=e=>({...e,channelCount:e.numberOfOutputs}),$i=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}},ea=(e,t,n)=>{try{e.setValueAtTime(t,n)}catch(r){if(r.code!==9)throw r;ea(e,t,n+1e-7)}},ta=e=>{let t=e.createBufferSource();t.start();try{t.start()}catch{return!0}return!1},na=e=>{let t=e.createBufferSource();t.buffer=e.createBuffer(1,1,44100);try{t.start(0,1)}catch{return!1}return!0},ra=e=>{let t=e.createBufferSource();t.start();try{t.stop()}catch{return!1}return!0},ia=e=>{let t=e.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1},aa=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}},oa=e=>{let t=e.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1},sa=e=>{let{port1:t,port2:n}=new MessageChannel;try{t.postMessage(e)}finally{t.close(),n.close()}},ca=()=>{try{new DOMException}catch{return!1}return!0},la=()=>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])}),ua=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)},da=(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),jr(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)},fa=(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)},pa=_(Xe),ma=he(Xe),ha=ln(ce),ga=new WeakMap,_a=On(ga),va=Lt(new Map,new WeakMap),ya=Ui(),ba=ur(va,Ce),xa=Dn(ze),Sa=mi(ze,xa,st),Ca=xe(ba,j,Sa),F=Mn(T),wa=Kr(ya),I=Zn(wa),Ta=new WeakMap,Ea=bn(fa),Da=gr(ya),Oa=qn(Da),ka=Jn(ya),Aa=Yn(ya),ja=vr(ya),L=xt(v(x),me(pa,ma,et,ha,at,ze,_a,ue,j,Xe,ke,st,ct),va,Hn(D,at,ze,j,ot,ke),Ce,Fn,ni,an(et,D,ze,j,ot,F,ke,I),fn(Ta,ze,k),Ea,F,Oa,ka,Aa,I,ja),Ma=ye(L,Ca,Ce,ba,F,I),Na=new WeakSet,Pa=dr(ya),Fa=Xt(new Uint32Array(1)),Ia=Wi(Fa,Ce),La=Gi(Fa),Ra=Ee(Na,va,ni,Pa,wa,Ci(Pa),Ia,La),za=ge(Ir),Ba=hi(xa,Be,st),Va=Wt(Ba),Ha=hr(za,va,ta,na,ra,ia,aa,oa,ua,Ki(Xi),da),Ua=pi(kn(Be),Ba),Wa=Me(Va,Ha,j,Ua,Sa),Ga=St(y(C),Ta,w,Ct,h.createCancelAndHoldAutomationEvent,h.createCancelScheduledValuesAutomationEvent,h.createExponentialRampToValueAutomationEvent,h.createLinearRampToValueAutomationEvent,h.createSetTargetAutomationEvent,h.createSetValueAutomationEvent,h.createSetValueCurveAutomationEvent,Da,ea),Ka=je(L,Wa,Ga,jn,Ha,F,I,fa),qa=Ge(L,Ke,Ce,jn,_r(Ir,Xi),F,I,Sa),Ja=It(Va,Er,j,Ua,Sa),Ya=vi(ga),Xa=Ft(L,Ga,Ja,Fn,Er,F,I,Ya),Za=sr(Xe,ka),Qa=Dr(Da,qi(jn,Za)),$a=zt(L,Bt(Qa,j,Sa),Qa,F,I),eo=Ht(L,Ut(kr,j,Sa),kr,F,I,Qi),to=Ar(za,va,Mr(za,Ha,Ir,Za),ia,oa),no=Jt(L,Ga,Yt(Va,to,j,Ua,Sa),to,F,I,fa),ro=Nr(ni,Xi),io=Qt(L,$t(ro,j,Sa),ro,F,I,Ya),ao=sn(L,Ga,cn(Va,Pr,j,Ua,Sa),Pr,F,I,Ya),oo=Fr(ni),so=gn(L,Ga,_n(Va,oo,j,Ua,Sa),oo,ni,F,I,Ya),co=wn(L,Ga,Tn(Va,Ir,j,Ua,Sa),Ir,F,I),lo=Vr(Fn,jn,Zr,ni),uo=gi(va,Ir,Zr,Li(Ir,wa)),fo=Vn(Ha,j,wa,Sa,uo),po=Rn(L,Lr(lo),fo,F,I,Ya),mo=qe(Ga,Qa,to,Zr,ni,Ji,I,Xi),ho=new WeakMap,go=ar(qa,mo,Ea,I,ho,fa),_o=qr(za,va,ia,aa,oa,da),vo=oi(L,Ga,_o,si(Va,_o,j,Ua,Sa),F,I,fa),yo=Kt(Ha),bo=ei(yo,jn,ti(yo,jn,Ir,Yi,Za),Yi,Za,Da,Xi),xo=Jr(Yr(et,jn,Qa,Ir,Zr,bo,ni,at,Ji,Za)),So=li(L,Ga,xo,ui(Va,Qa,to,Ir,xo,j,wa,Ua,Sa,uo),F,I,Ya),Co=fi(Xr(Ce),F,new WeakSet,$i),wo=Qr($r(Qa,kr,Ir,bo,ni,Za),ni),To=xi(L,Ga,wo,Si(Va,wo,j,Ua,Sa),F,I),Eo=Vi(L,jn,bo,Hi(bo,j,Sa),F,I,Ya),Do=Qn(ya),Oo=xn(ya),ko=new WeakMap,Ao=Nn(ko,wa),jo=Do?se(va,ni,yn(ya),Oo,Sn(g),F,Ao,I,ja,new WeakMap,new WeakMap,Ai(ja,wa),ya):void 0,Mo=Xn(Oa,I),No=Nt(jo,Ma,Ra,Ka,Xa,$a,eo,no,io,rn(Na,va,tn,vn,new WeakSet,F,Mo,Se,or,Ia,La),ao,so,co,po,go,vo,So,Co,To,Eo),Po=We(No,jn,ni,zi,er(L,Hr,F,I),nr(L,Ur,F,I),rr(L,Wr,F,I),ir(L,Gr(jn,I),F),Da),Fo=Pn(ho),Io=_e(Fo),Lo=Gt(Ce),Ro=un(Fo),zo=mn(Ce),Bo=new WeakMap,Vo=br(jn,Tr(Lo,Ce,jn,Qa,kr,to,Ir,Zr,ni,zo,Oo,En(Bo,k),Za),Ir,ni,Za),Ho=Mt(Va,Lo,Ha,Qa,kr,to,Ir,Ro,zo,Oo,j,ja,wa,Ua,Sa,uo),Uo=An(ko),Wo=_i(Bo),Go=Do?Et(Io,L,Ga,Ho,Vo,ze,Uo,F,I,ja,Zi,Wo,sa,fa):void 0,Ko=ii(No,va,jn,en(ni,wa),yi(Na,va,xa,Fo,uo,Se,Ia,La)),qo=Un(T,Oa),Jo=Wn(S,ka),Yo=Gn(w,Aa),Xo=Kn(T,I),Zo=()=>$n(va,wi(wa),Ti(Da),Ei(wa),Di(Da),Oi(wa),ki(ja,wa),ji(wa),Mi(wa),Ni(wa),Pi(wa),ca,Fi(ya),Ii(Da),Ri(wa),la);function Qo(e){return e===void 0}function R(e){return e!==void 0}function $o(e){return typeof e==`function`}function es(e){return typeof e==`number`}function ts(e){return Object.prototype.toString.call(e)===`[object Object]`&&e.constructor===Object}function ns(e){return typeof e==`boolean`}function rs(e){return Array.isArray(e)}function is(e){return typeof e==`string`}function as(e){return is(e)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(e)}var os=n({assert:()=>z,assertContextRunning:()=>ss,assertRange:()=>B,assertUsedScheduleTime:()=>ds,enterScheduledCallback:()=>us,log:()=>ms,setLogger:()=>ps,warn:()=>hs});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 ss(e){!e.isOffline&&e.state!==`running`&&hs(`The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.`)}var cs=!1,ls=!1;function us(e){cs=e}function ds(e){Qo(e)&&cs&&!ls&&(ls=!0,hs(`Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing`))}var fs=console;function ps(e){fs=e}function ms(...e){fs.log(...e)}function hs(...e){fs.warn(...e)}function gs(e){return new Po(e)}function _s(e,t,n){return new Ko(e,t,n)}var vs=typeof self==`object`?self:null,ys=vs&&(vs.hasOwnProperty(`AudioContext`)||vs.hasOwnProperty(`webkitAudioContext`));function bs(e,t,n){return z(R(Go),`AudioWorkletNode only works in a secure context (https or localhost)`),new(e instanceof vs?.BaseAudioContext?vs?.AudioWorkletNode:Go)(e,t,n)}function xs(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 Ss=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 Cs(e){return Yo(e)}function ws(e){return Jo(e)}function Ts(e){return Xo(e)}function Es(e){return qo(e)}function Ds(e){return e instanceof Ra}function Os(e,t){return e===`value`||Cs(t)||ws(t)||Ds(t)}function ks(e,...t){if(!t.length)return e;let n=t.shift();if(ts(e)&&ts(n))for(let t in n)Os(t,n[t])?e[t]=n[t]:ts(n[t])?(e[t]||Object.assign(e,{[t]:{}}),ks(e[t],n[t])):Object.assign(e,{[t]:n[t]});return ks(e,...t)}function As(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(ts(a[0])&&r&&!Reflect.has(a[0],r)&&(Object.keys(a[0]).some(t=>Reflect.has(e,t))||(ks(i,{[r]:a[0]}),n.splice(n.indexOf(r),1),a.shift())),a.length===1&&ts(a[0]))ks(i,a[0]);else for(let e=0;e<n.length;e++)R(a[e])&&(i[n[e]]=a[e]);return ks(e,i)}function js(e){return e.constructor.getDefaults()}function Ms(e,t){return Qo(e)?t:e}function Ns(e,t){return t.forEach(t=>{Reflect.has(e,t)&&delete e[t]}),e}var Ps=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...e){(this.debug||vs&&this.toString()===vs.TONE_DEBUG_CLASS)&&ms(this,...e)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Ps.version=r;var Fs=1e-6;function Is(e,t){return e>t+Fs}function Ls(e,t){return Is(e,t)||zs(e,t)}function Rs(e,t){return e+Fs<t}function zs(e,t){return Math.abs(e-t)<Fs}function Bs(e,t,n){return Math.max(Math.min(e,n),t)}var Vs=class e extends Ps{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(Ls(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(zs(this._timeline[t].time,e)){for(let n=t;n>=0&&zs(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&&Ls(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(zs(a[t],e)){for(let n=r;n<this._timeline.length;n++){let i=this._timeline[n];if(zs(i[t],e))r=n;else break}return r}if(Rs(a[t],e)&&Is(o[t],e))return r;Is(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&&zs(this._timeline[n].time,e)){let r=n;for(let t=n;t>=0&&zs(this._timeline[t].time,e);t--)r=t;this._iterate(e=>{t(e)},r,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}},Hs=[];function Us(e){Hs.push(e)}function Ws(e){Hs.forEach(t=>t(e))}var Gs=[];function Ks(e){Gs.push(e)}function qs(e){Gs.forEach(t=>t(e))}var Js=class e extends Ps{constructor(){super(...arguments),this.name=`Emitter`}on(e,t){return e.split(/\W+/).forEach(e=>{Qo(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(Qo(this._events)&&(this._events={}),this._events.hasOwnProperty(e))if(Qo(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}},Ys=class extends Js{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}},Xs=class e extends Ys{constructor(){super(),this.name=`Context`,this._constants=new Map,this._timeouts=new Vs,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=gs({latencyHint:t.latencyHint}),this._latencyHint=t.latencyHint),this._ticker=new Ss(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||=(Ws(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(Es(this._context),`Not available if OfflineAudioContext`),this._context.createMediaStreamSource(e)}createMediaElementSource(e){return z(Es(this._context),`Not available if OfflineAudioContext`),this._context.createMediaElementSource(e)}createMediaStreamDestination(){return z(Es(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 bs(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 Es(this._context)?this._context.resume():Promise.resolve()}close(){return V(this,void 0,void 0,function*(){Es(this._context)&&this.state!==`closed`&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&qs(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}},Zs=class extends Ys{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){rs(t)?t.forEach(t=>U(e,t)):Object.defineProperty(e,t,{enumerable:!0,writable:!1})}function Qs(e,t){rs(t)?t.forEach(t=>Qs(e,t)):Object.defineProperty(e,t,{writable:!0})}var W=()=>{},$s=class e extends Ps{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,is(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=rs(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(es(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(es(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]})}};$s.baseUrl=``,$s.downloads=[];var ec=class extends Xs{constructor(){super({clockSource:`offline`,context:Ts(arguments[0])?arguments[0]:_s(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Ts(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name=`OfflineContext`,this._currentTime=0,this.isOffline=!0,this._duration=Ts(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 $s(yield this._context.startRendering())})}close(){return Promise.resolve()}},tc=new Zs,nc=tc;function G(){return nc===tc&&ys&&rc(new Xs),nc}function rc(e,t=!1){t&&nc.dispose(),nc=Es(e)?new Xs(e):Ts(e)?new ec(e):e}function ic(){return nc.resume()}if(vs&&!vs.TONE_SILENCE_LOGGING){let e=` * Tone.js v${r} * `;console.log(`%c${e}`,`background: #000; color: #fff`)}function ac(e){return 10**(e/20)}function oc(e){return Math.log(e)/Math.LN10*20}function sc(e){return 2**(e/12)}var cc=440;function lc(){return cc}function uc(e){cc=e}function dc(e){return Math.round(fc(e))}function fc(e){return 69+12*Math.log2(e/cc)}function pc(e){return cc*2**((e-69)/12)}var mc=class e extends Ps{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),Qo(this._val))return this._noArg();if(is(this._val)&&Qo(this._units)){for(let e in this._expressions)if(this._expressions[e].regexp.test(this._val.trim())){this._units=e;break}}else if(ts(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 is(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}},hc=class e extends mc{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 dc(this.toFrequency())}_now(){return this.context.now()}};function gc(e,t){return new hc(G(),e,t)}var _c=class e extends hc{constructor(){super(...arguments),this.name=`Frequency`,this.defaultUnits=`hz`}static get A4(){return lc()}static set A4(e){uc(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=vc[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()*sc(t))}harmonize(e){return e.map(e=>this.transpose(e))}toMidi(){return dc(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),yc[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 pc(e)}static ftom(e){return dc(e)}},vc={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},yc=[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`];function bc(e,t){return new _c(G(),e,t)}var K=class extends hc{constructor(){super(...arguments),this.name=`TransportTime`}_now(){return this.context.transport.seconds}};function xc(e,t){return new K(G(),e,t)}var Sc=class e extends Ps{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 ds(e),new hc(this.context,e).toSeconds()}toFrequency(e){return new _c(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=>{Qo(e[n])&&delete t[n]}),t}get(){let t=js(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]):rs(r)||es(r)||is(r)||ns(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}},Cc=class extends Vs{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 Sc{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)&&(Cs(t.param)||t.param instanceof e),`param must be an AudioParam`);!Cs(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 Vs(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(Sc.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`)?ac(e):this._is(e,`frequency`)?this.toFrequency(e):e:this.overridden?0:e}_toType(e){return this.convert&&this.units===`decibels`?oc(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=zs(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&&zs(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 Sc{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return R(this.input)?Cs(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||ws(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 Tc(this,e,t,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return hs(`toMaster() has been renamed toDestination()`),this.toDestination()}disconnect(e,t=0,n=0){return Ec(this,e,t,n),this}chain(...e){return wc(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():ws(this.input)&&this.input.disconnect()),R(this.output)&&(this.output instanceof e?this.output.dispose():ws(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function wc(...e){let t=e.shift();e.reduce((e,t)=>(e instanceof J?e.connect(t):ws(e)&&Tc(e,t),t),t)}function Tc(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||ws(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);Cs(t)?e.connect(t,n):e.connect(t,n,r)}function Ec(e,t,n=0,r=0){if(R(t))for(;t instanceof J;)t=t.input;for(;!ws(e);)R(e.output)&&(e=e.output);Cs(t)?e.disconnect(t,n):ws(t)?e.disconnect(t,n,r):e.disconnect()}function Dc(...e){let t=e.pop();R(t)&&e.forEach(e=>Tc(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}},Oc=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}},kc=class e extends Oc{constructor(){let t=H(e.getDefaults(),arguments,[`offset`]);super(t),this.name=`ToneConstantSource`,this._source=this.context.createConstantSource(),Tc(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(Oc.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 kc({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 Ac(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 Ac(e,t,n,r){(t instanceof q||Cs(t)||t instanceof X&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof X&&(t.overridden=!0)),Tc(e,t,n,r)}var jc=class e extends q{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`TickParam`,this._events=new Vs(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(Qo(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)}},Mc=class e extends X{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`TickSignal`,this.input=this._param=new jc({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}},Nc=class e extends Sc{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`]);super(t),this.name=`TickSource`,this._state=new Cc,this._tickOffset=new Vs,this._ticksAtTime=new Vs,this._secondsAtTime=new Vs,this.frequency=new Mc({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`},Sc.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=zs(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}},Pc=class e extends Sc{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`frequency`]);super(t),this.name=`Clock`,this.callback=W,this._lastUpdate=0,this._state=new Cc(`stopped`),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Nc({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(Sc.getDefaults(),{callback:W,frequency:1,units:`hertz`})}get state(){return this._state.getValueAtTime(this.now())}start(e,t){ss(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}};Js.mixin(Pc);var Fc=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}},Ic=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}},Lc=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Destination`,this.input=new Ic({context:this.context}),this.output=new Y({context:this.context}),this.volume=this.input.volume,wc(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),wc(...e),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Us(e=>{e.destination=new Lc({context:e})}),Ks(e=>{e.destination.dispose()});var Rc=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}};Us(e=>{e.listener=new Rc({context:e})}),Ks(e=>{e.listener.dispose()});function zc(e,t){return V(this,arguments,void 0,function*(e,t,n=2,r=G().sampleRate){let i=G(),a=new ec(n,t,r);rc(a),yield e(a);let o=a.render();return rc(i),new $s(yield o)})}var Bc=class e extends Ps{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 is(t)?(this.baseUrl&&t.trim().substring(0,11).toLowerCase()===`data:audio/`&&(this.baseUrl=``),this._buffers.set(e.toString(),new $s(this.baseUrl+t,n,r))):this._buffers.set(e.toString(),new $s(t,n,r)),this}dispose(){return super.dispose(),this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this}},Vc=class e extends _c{constructor(){super(...arguments),this.name=`MidiClass`,this.defaultUnits=`midi`}_frequencyToUnits(e){return dc(super._frequencyToUnits(e))}_ticksToUnits(e){return dc(super._ticksToUnits(e))}_beatsToUnits(e){return dc(super._beatsToUnits(e))}_secondsToUnits(e){return dc(super._secondsToUnits(e))}toMidi(){return this.valueOf()}toFrequency(){return pc(this.toMidi())}transpose(t){return new e(this.context,this.toMidi()+t)}};function Hc(e,t){return new Vc(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 Uc(e,t){return new Z(G(),e,t)}var Wc=class extends Sc{constructor(){super(...arguments),this.name=`Draw`,this.expiration=.25,this.anticipation=.008,this._events=new Vs,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}};Us(e=>{e.draw=new Wc({context:e})}),Ks(e=>{e.draw.dispose()});var Gc=class extends Ps{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 Kc(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}},Kc=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}},qc=n({}),Jc=class extends Ps{constructor(e){super(),this.name=`TimelineValue`,this._timeline=new Vs({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}},Yc=class e extends J{constructor(){super(H(e.getDefaults(),arguments,[`context`]))}connect(e,t=0,n=0){return Ac(this,e,t,n),this}},Xc=class e extends Yc{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,rs(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):$o(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}},Zc=class e extends Yc{constructor(){let t=H(e.getDefaults(),arguments,[`value`]);super(t),this.name=`Pow`,this._exponentScaler=this.input=this.output=new Xc({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(Yc.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}},Qc=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}};Qc._eventId=0;var $c=class e extends Qc{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({},Qc.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(e){this._createEvents(e),super.invoke(e)}_createEvent(){return Rs(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Z(this.context,this._nextTick).toSeconds()):-1}_createEvents(e){Rs(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);Is(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}},el=class e extends Sc{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Transport`,this._loop=new Jc(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Vs,this._repeatedEvents=new Gc,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new Pc({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(Sc.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}us(!0),this._timeline.forEachAtTime(t,t=>t.invoke(e)),us(!1)}schedule(e,t){let n=new Qc(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 $c(this,{callback:e,duration:new hc(this.context,r).toTicks(),interval:new hc(this.context,t).toTicks(),time:new K(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(e,t){let n=new Qc(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){rs(e)&&(e=e[0]/e[1]*4),this._timeSignature=e}get loopStart(){return new hc(this.context,this._loopStart,`i`).toSeconds()}set loopStart(e){this._loopStart=this.toTicks(e)}get loopEnd(){return new hc(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 Zc(-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(),Qs(this,`bpm`),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};Js.mixin(el),Us(e=>{e.transport=new el({context:e})}),Ks(e=>{e.transport.dispose()});var Q=class extends J{constructor(e){super(e),this.input=void 0,this._state=new Cc(`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 Ic({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=Qo(e)&&this._synced?this.context.transport.seconds:this.toSeconds(e);if(r=this._clampToCurrentTime(r),!this._synced&&this._state.getValueAtTime(r)===`started`)z(Is(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(Ms(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 ss(this.context),this._start(r,t,n);return this}stop(e){let t=Qo(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(Is(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}},tl=class e extends Oc{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,Tc(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 $s(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Oc.getDefaults(),{url:new $s,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?Ms(t,this.loopStart):Ms(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;Ls(a,e)&&(a=(a-t)%n+t),zs(a,this.buffer.duration)&&(a=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Rs(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}},nl=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 ol,`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=ol[this._type];this._source=new tl({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}},rl=220500,il=2,al={brown:null,pink:null,white:null},ol={get brown(){if(!al.brown){let e=[];for(let t=0;t<il;t++){let n=new Float32Array(rl);e[t]=n;let r=0;for(let e=0;e<rl;e++){let t=Math.random()*2-1;n[e]=(r+.02*t)/1.02,r=n[e],n[e]*=3.5}}al.brown=new $s().fromArray(e)}return al.brown},get pink(){if(!al.pink){let e=[];for(let t=0;t<il;t++){let n=new Float32Array(rl);e[t]=n;let r,i,a,o,s,c,l;r=i=a=o=s=c=l=0;for(let e=0;e<rl;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}}al.pink=new $s().fromArray(e)}return al.pink},get white(){if(!al.white){let e=[];for(let t=0;t<il;t++){let n=new Float32Array(rl);e[t]=n;for(let e=0;e<rl;e++)n[e]=Math.random()*2-1}al.white=new $s().fromArray(e)}return al.white}},sl=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`volume`]);super(t),this.name=`UserMedia`,this._volume=this.output=new Ic({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();es(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);Tc(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 cl(e,t){return V(this,void 0,void 0,function*(){let n=t/e.context.sampleRate,r=new ec(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 ll=class e extends Oc{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`]);super(t),this.name=`ToneOscillatorNode`,this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],Tc(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(Oc.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}},ul=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 ll({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&&As(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=4096/2,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 Bs(-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 cl(this,e)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};ul._periodicWaveCache=[];var dl=class extends Yc{constructor(){super(...arguments),this.name=`AudioToGain`,this._norm=new Xc({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}},fl=class e extends Q{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`type`,`modulationType`]);super(t),this.name=`AMOscillator`,this._modulationScale=new dl({context:this.context}),this._modulationNode=new Y({context:this.context}),this._carrier=new ul({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 ul({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(ul.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 cl(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}},pl=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 ul({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 ul({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(ul.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 cl(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}},ml=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 Xc({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new X({context:this.context,units:`audioRange`,value:t.width}),this._triangle=new ul({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 cl(this,e)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}},hl=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(ul.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 ul({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 cl(this,e)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(e=>e.dispose()),this}},gl=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 ml({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType=`sine`,this.modulationFrequency=this._pulse.frequency,this._modulator=new ul({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 cl(this,e)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}},_l={am:fl,fat:hl,fm:pl,oscillator:ul,pulse:ml,pwm:gl},vl=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(ul.getDefaults(),pl.getDefaults(),fl.getDefaults(),hl.getDefaults(),ml.getDefaults(),gl.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=_l[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 _l[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`)&&es(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`)&&es(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`))&&is(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 cl(this,e)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}},yl=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,wc(this._constantSource,this._sum)}static getDefaults(){return Object.assign(X.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}},bl=class e extends Yc{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 yl({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(Yc.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}},xl=class e extends Yc{constructor(){super(H(e.getDefaults(),arguments)),this.name=`Zero`,this._gain=new Y({context:this.context}),this.output=this._gain,this.input=void 0,Tc(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),Ec(this.context.getConstant(0),this._gain),this}},Sl=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 ul(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 xl({context:this.context}),this._a2g=new dl({context:this.context}),this._scaler=this.output=new bl({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(ul.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),Ac(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 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(r,e,t),n.set(this,r)}})}}function wl(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 Tl=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 $s({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?Ms(t,this._loopStart):Ms(t,0);let r=this.toSeconds(t),i=n;n=Ms(n,Math.max(this._buffer.duration-r,0));let a=this.toSeconds(n);a/=this._playbackRate,e=this.toSeconds(e);let o=new tl({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&&Qo(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}};xs([wl(0)],Tl.prototype,`fadeIn`,void 0),xs([wl(0)],Tl.prototype,`fadeOut`,void 0);var El=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 Ic({context:this.context,volume:t.volume}),this.volume=this._volume.volume,U(this,`volume`),this._buffers=new Bc({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 Tl({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}},Dl=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 $s({onload:t.onload,onerror:t.onerror,reverse:t.reverse,url:t.url}),this._clock=new Pc({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=Ms(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 tl({context:this.context,url:this.buffer,fadeIn:r,fadeOut:this._overlap,loop:this.loop,loopStart:this._loopStart,loopEnd:this._loopEnd,playbackRate:sc(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}},Ol=class extends Yc{constructor(){super(...arguments),this.name=`Abs`,this._abs=new Xc({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}},kl=class extends Yc{constructor(){super(...arguments),this.name=`GainToAudio`,this._norm=new Xc({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}},Al=class extends Yc{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}},jl=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 Al({context:this.context}),this.subtrahend=this._param,wc(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}},Ml=class e extends Yc{constructor(){super(H(e.getDefaults(),arguments)),this.name=`GreaterThanZero`,this._thresh=this.output=new Xc({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}},Nl=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 jl({context:this.context,value:t.value}),this._gtz=this.output=new Ml({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}},Pl=class e extends bl{constructor(){let t=H(e.getDefaults(),arguments,[`min`,`max`,`exponent`]);super(t),this.name=`ScaleExp`,this.input=this._exp=new Zc({context:this.context,value:t.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(bl.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(e){this._exp.value=e}dispose(){return super.dispose(),this._exp.dispose(),this}},Fl=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 kc({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}},Il=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(is(e))return e;{let n;for(n in Ll)if(Ll[n][t]===e)return n;return e}}_setCurve(e,t,n){if(is(n)&&Reflect.has(Ll,n)){let r=Ll[n];ts(r)?e!==`_decayCurve`&&(this[e]=r[t]):this[e]=r}else if(rs(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(rs(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 Ac(this,e,t,n),this}asArray(){return V(this,arguments,void 0,function*(e=1024){let t=e/this.context.sampleRate,n=new ec(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}};xs([wl(0)],Il.prototype,`attack`,void 0),xs([wl(0)],Il.prototype,`decay`,void 0),xs([Cl(0,1)],Il.prototype,`sustain`,void 0),xs([wl(0)],Il.prototype,`release`,void 0);var Ll=(()=>{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)}}})(),Rl=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 Ic({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}},zl=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Rl.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 _c?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}};xs([wl(0)],zl.prototype,`portamento`,void 0);var Bl=class e extends Il{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}},Vl=class e extends zl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`Synth`,this.oscillator=new vl(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 Bl(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(zl.getDefaults(),{envelope:Object.assign(Ns(Il.getDefaults(),Object.keys(J.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ns(vl.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}},Hl=class e extends zl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`ModulationSynth`,this._carrier=new Vl({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new Vl({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(zl.getDefaults(),{harmonicity:3,oscillator:Object.assign(Ns(vl.getDefaults(),[...Object.keys(Q.getDefaults()),`frequency`,`detune`]),{type:`sine`}),envelope:Object.assign(Ns(Il.getDefaults(),Object.keys(J.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(Ns(vl.getDefaults(),[...Object.keys(Q.getDefaults()),`frequency`,`detune`]),{type:`square`}),modulationEnvelope:Object.assign(Ns(Il.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}},Ul=class e extends Hl{constructor(){super(H(e.getDefaults(),arguments)),this.name=`AMSynth`,this._modulationScale=new dl({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}},Wl=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}},Gl=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=es(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 Wl({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,wc(this.input,...this._internalChannels,this.output)}getFrequencyResponse(e=128){let t=new Wl({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()}),Qs(this,[`detune`,`frequency`,`gain`,`Q`]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}},Kl=class e extends Il{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 Zc({context:this.context,value:t.exponent}),this._scale=this.output=new bl({context:this.context,min:this._baseFrequency,max:this._baseFrequency*2**this._octaves}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(Il.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}},ql=class e extends zl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MonoSynth`,this.oscillator=new vl(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 Gl(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new Kl(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new Bl(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(zl.getDefaults(),{envelope:Object.assign(Ns(Il.getDefaults(),Object.keys(J.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(Ns(Gl.getDefaults(),Object.keys(J.getDefaults())),{Q:1,rolloff:-12,type:`lowpass`}),filterEnvelope:Object.assign(Ns(Kl.getDefaults(),Object.keys(J.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(Ns(vl.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}},Jl=class e extends zl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`DuoSynth`,this.voice0=new ql(Object.assign(t.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new ql(Object.assign(t.voice1,{context:this.context})),this.harmonicity=new $({context:this.context,units:`positive`,value:t.harmonicity}),this._vibrato=new Sl({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 ks(zl.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:ks(Ns(ql.getDefaults(),Object.keys(zl.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:ks(Ns(ql.getDefaults(),Object.keys(zl.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}},Yl=class e extends Hl{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(Hl.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}},Xl=[1,1.483,1.932,2.546,2.63,3.897],Zl=class e extends zl{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 Gl({Q:0,context:this.context,type:`highpass`}).connect(this._amplitude);for(let e=0;e<Xl.length;e++){let n=new pl({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:Xl[e]});this._freqMultipliers[e]=r,this.frequency.chain(r,n.frequency),this.detune.connect(n.detune)}this._filterFreqScaler=new bl({context:this.context,max:7e3,min:this.toFrequency(t.resonance)}),this.envelope=new Il({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 ks(zl.getDefaults(),{envelope:Object.assign(Ns(Il.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}},Ql=class e extends Vl{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 ks(zl.getDefaults(),Vl.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 _c?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}};xs([Cl(0)],Ql.prototype,`octaves`,void 0),xs([wl(0)],Ql.prototype,`pitchDecay`,void 0);var $l=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`NoiseSynth`,this.noise=new nl(Object.assign({context:this.context},t.noise)),this.envelope=new Bl(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(Rl.getDefaults(),{envelope:Object.assign(Ns(Il.getDefaults(),Object.keys(J.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(Ns(nl.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}},eu=new Set;function tu(e){eu.add(e)}function nu(e,t){let n=`registerProcessor("${e}", ${t})`;eu.add(n)}function ru(){return Array.from(eu).join(`
20
+ `)}var iu=class extends J{constructor(e){super(e),this.name=`ToneAudioWorklet`,this.workletOptions={},this.onprocessorerror=W;let t=URL.createObjectURL(new Blob([ru()],{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}};tu(`
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
+ `),tu(`
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
+ `),tu(`
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 au=`feedback-comb-filter`;nu(au,`
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 ou=class e extends iu{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 au}static getDefaults(){return Object.assign(J.getDefaults(),{delayTime:.1,resonance:.5})}onReady(e){wc(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}},su=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}},cu=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`resonance`,`dampening`]);super(t),this.name=`LowpassCombFilter`,this._combFilter=this.output=new ou({context:this.context,delayTime:t.delayTime,resonance:t.resonance}),this.delayTime=this._combFilter.delayTime,this.resonance=this._combFilter.resonance,this._lowpass=this.input=new su({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}},lu=class e extends Rl{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`PluckSynth`,this._noise=new nl({context:this.context,type:`pink`}),this.attackNoise=t.attackNoise,this._lfcf=new cu({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 ks(Rl.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}},uu=class e extends Rl{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(!es(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(Rl.getDefaults(),{maxPolyphony:32,options:{},voice:Vl})}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 zl,`Voice must extend Monophonic class`),e.connect(this.output),this._voices.push(e),e}hs(`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 Vc(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 Vc(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),rs(t)){z(rs(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=Ns(e,[`onsilence`,`context`]);return this.options=ks(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}},du=class e extends Rl{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(as(e)||es(r)&&isFinite(r),`url key is neither a note or midi pitch: ${e}`),as(e)){let r=new _c(this.context,e).toMidi();n[r]=t.urls[e]}else es(r)&&isFinite(r)&&(n[r]=t.urls[r])}),this._buffers=new Bc({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(Rl.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=fc(new _c(this.context,e).toFrequency()),i=Math.round(r),a=r-i,o=this._findClosest(i),s=i-o,c=this._buffers.get(s),l=sc(o+a),u=new tl({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),rs(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 _c(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),rs(t)?(z(rs(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(as(e)||isFinite(e),`note must be a pitch or midi: ${e}`),as(e)){let r=new _c(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}};xs([wl(0)],du.prototype,`attack`,void 0),xs([wl(0)],du.prototype,`release`,void 0);var fu=class e extends Sc{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`value`]);super(t),this.name=`ToneEvent`,this._state=new Cc(`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(Sc.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||es(this._loop)&&this._loop>1){t=1/0,es(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=Ms(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;ns(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}},pu=class e extends Sc{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`interval`]);super(t),this.name=`Loop`,this._event=new fu({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(Sc.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}},mu=class e extends fu{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`events`]);super(t),this.name=`Part`,this._state=new Cc(`stopped`),this._events=new Set,this._state.increasing=!0,t.events.forEach(e=>{rs(e)?this.add(e[0],e[1]):this.add(e)})}static getDefaults(){return Object.assign(fu.getDefaults(),{events:[]})}start(e,t){let n=this.toTicks(e);if(this._state.getValueAtTime(n)!==`started`){t=Ms(t,this._loop?this._loopStart:0),t=this._loop?Ms(t,this._loopStart):Ms(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 fu?(r=t,r.callback=this._tick.bind(this)):r=new fu({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 ts(e)&&e.hasOwnProperty(`time`)&&(t=e,e=t.time),e=this.toTicks(e),this._events.forEach(n=>{n.startOffset===e&&(Qo(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*hu(e){let t=0;for(;t<e;)t=Bs(t,0,e-1),yield t,t++}function*gu(e){let t=e-1;for(;t>=0;)t=Bs(t,0,e-1),yield t,t--}function*_u(e,t){for(;;)yield*t(e)}function*vu(e,t){let n=t?0:e-1;for(;;)n=Bs(n,0,e-1),yield n,t?(n++,n>=e-1&&(t=!1)):(n--,n<=0&&(t=!0))}function*yu(e){let t=0,n=0;for(;t<e;)t=Bs(t,0,e-1),yield t,n++,t+=n%2?2:-1}function*bu(e){let t=e-1,n=0;for(;t>=0;)t=Bs(t,0,e-1),yield t,n++,t+=n%2?-2:1}function*xu(e){for(;;)yield Math.floor(Math.random()*e)}function*Su(e){let t=[];for(let n=0;n<e;n++)t.push(n);for(;t.length>0;)yield Bs(t.splice(Math.floor(t.length*Math.random()),1)[0],0,e-1)}function*Cu(e){let t=Math.floor(Math.random()*e);for(;;)t===0?t++:t===e-1||Math.random()<.5?t--:t++,yield t}function*wu(e,t=`up`,n=0){switch(z(e>=1,`The number of values must be at least one`),t){case`up`:yield*_u(e,hu);case`down`:yield*_u(e,gu);case`upDown`:yield*vu(e,!0);case`downUp`:yield*vu(e,!1);case`alternateUp`:yield*_u(e,yu);case`alternateDown`:yield*_u(e,bu);case`random`:yield*xu(e);case`randomOnce`:yield*_u(e,Su);case`randomWalk`:yield*Cu(e)}}var Tu=class e extends pu{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=wu(t.values.length,t.pattern),this._type=t.pattern}static getDefaults(){return Object.assign(pu.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=wu(this._values.length,this._type)}},Eu=class e extends fu{constructor(){let t=H(e.getDefaults(),arguments,[`callback`,`events`,`subdivision`]);super(t),this.name=`Sequence`,this._part=new mu({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(Ns(fu.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]=is(t)&&isFinite(parseInt(t,10))&&rs(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(rs(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}},Du=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 kl({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`,Tc(this._split,this.a.gain,0),Tc(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}},Ou=class extends J{constructor(e){super(e),this.name=`Effect`,this._dryWet=new Du({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}},ku=class extends Ou{constructor(e){super(e),this.name=`LFOEffect`,this._lfo=new Sl({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(Ou.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}},Au=class e extends ku{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`baseFrequency`,`octaves`]);super(t),this.name=`AutoFilter`,this.filter=new Gl(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(ku.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}},ju=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}},Mu=class e extends ku{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`]);super(t),this.name=`AutoPanner`,this._panner=new ju({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(ku.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}},Nu=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`smoothing`]);super(t),this.name=`Follower`,this._abs=this.input=new Ol({context:this.context}),this._lowpass=this.output=new su({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}},Pu=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`baseFrequency`,`octaves`,`sensitivity`]);super(t),this.name=`AutoWah`,this._follower=new Nu({context:this.context,smoothing:t.follower}),this._sweepRange=new Pl({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 Gl({context:this.context,rolloff:-48,frequency:0,Q:t.Q}),this._peaking=new Gl({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(Ou.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 oc(1/this._inputBoost.gain.value)}set sensitivity(e){this._inputBoost.gain.value=1/ac(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}},Fu=`bit-crusher`;nu(Fu,`
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 Iu=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`bits`]);super(t),this.name=`BitCrusher`,this._bitCrusherWorklet=new Lu({context:this.context,bits:t.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(Ou.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}},Lu=class e extends iu{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(iu.getDefaults(),{bits:12})}_audioWorkletName(){return Fu}onReady(e){wc(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}},Ru=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`order`]);super(t),this.name=`Chebyshev`,this._shaper=new Xc({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(Ou.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}},zu=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}},Bu=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}},Vu=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 Du({context:this.context,fade:e.wet}),this.wet=this._dryWet.fade,this._split=new zu({context:this.context,channels:2}),this._merge=new Bu({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),wc(...e),Tc(e[e.length-1],this._merge,0,0)}connectEffectRight(...e){this._split.connect(e[0],1,0),wc(...e),Tc(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}},Hu=class extends Vu{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 zu({context:this.context,channels:2}),this._feedbackMerge=new Bu({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(Vu.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}},Uu=class e extends Hu{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 Sl({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new Sl({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Fc({context:this.context}),this._delayNodeR=new Fc({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(Hu.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}},Wu=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`distortion`]);super(t),this.name=`Distortion`,this._shaper=new Xc({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(Ou.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}},Gu=class extends Ou{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(Ou.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}},Ku=class e extends Gu{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`feedback`]);super(t),this.name=`FeedbackDelay`,this._delayNode=new Fc({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(Gu.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}},qu=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]),wc(this.input,...this._bank0,this._oneSampleDelay,this.output),wc(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}},Ju=class e extends Ou{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 ll({context:this.context,type:`sine`}),this._cosine=new ul({context:this.context,phase:-90,type:`sine`}),this._sineMultiply=new $({context:this.context}),this._cosineMultiply=new $({context:this.context}),this._negate=new Al({context:this.context}),this._add=new yl({context:this.context}),this._phaseShifter=new qu({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(Ou.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}},Yu=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],Xu=[225,556,441,341],Zu=class e extends Vu{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=Xu.map(e=>{let t=this.context.createBiquadFilter();return t.type=`allpass`,t.frequency.value=e,t}),this._allpassFiltersR=Xu.map(e=>{let t=this.context.createBiquadFilter();return t.type=`allpass`,t.frequency.value=e,t}),this._combFilters=Yu.map((e,n)=>{let r=new cu({context:this.context,dampening:t.dampening,delayTime:e});return n<Yu.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(Vu.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}},Qu=[1687/25e3,1601/25e3,2053/25e3,2251/25e3],$u=[.773,.802,.753,.733],ed=[347,113,37],td=class e extends Vu{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 bl({context:this.context,min:-.733,max:.197}),this._allpassFilters=ed.map(e=>{let t=this.context.createBiquadFilter();return t.type=`allpass`,t.frequency.value=e,t}),this._feedbackCombFilters=Qu.map((e,t)=>{let n=new ou({context:this.context,delayTime:e});return this._scaleRoomSize.connect(n.resonance),n.resonance.value=$u[t],t<Qu.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(Vu.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}},nd=class extends Hu{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`])}},rd=class e extends nd{constructor(){let t=H(e.getDefaults(),arguments,[`delayTime`,`feedback`]);super(t),this.name=`PingPongDelay`,this._leftDelay=new Fc({context:this.context,maxDelay:t.maxDelay}),this._rightDelay=new Fc({context:this.context,maxDelay:t.maxDelay}),this._rightPreDelay=new Fc({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(nd.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}},id=class e extends Gu{constructor(){let t=H(e.getDefaults(),arguments,[`pitch`]);super(t),this.name=`PitchShift`,this._frequency=new X({context:this.context}),this._delayA=new Fc({maxDelay:1,context:this.context}),this._lfoA=new Sl({context:this.context,min:0,max:.1,type:`sawtooth`}).connect(this._delayA.delayTime),this._delayB=new Fc({maxDelay:1,context:this.context}),this._lfoB=new Sl({context:this.context,min:0,max:.1,type:`sawtooth`,phase:180}).connect(this._delayB.delayTime),this._crossFade=new Du({context:this.context}),this._crossFadeLFO=new Sl({context:this.context,min:0,max:1,type:`triangle`,phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Fc({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(Gu.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=sc(e-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,t=sc(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}},ad=class e extends Vu{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`octaves`,`baseFrequency`]);super(t),this.name=`Phaser`,this._lfoL=new Sl({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new Sl({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(Vu.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}},od=class e extends Ou{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(Ou.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 ec(2,this._decay+this._preDelay,this.context.sampleRate),n=new nl({context:t}),r=new nl({context:t}),i=new Bu({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}},sd=class e extends J{constructor(){super(H(e.getDefaults(),arguments)),this.name=`MidSideSplit`,this._split=this.input=new zu({channels:2,context:this.context}),this._midAdd=new yl({context:this.context}),this.mid=new $({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new jl({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}},cd=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 yl({context:this.context}),this._leftMult=new $({context:this.context,value:Math.SQRT1_2}),this._right=new jl({context:this.context}),this._rightMult=new $({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Bu({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}},ld=class extends Ou{constructor(e){super(e),this.name=`MidSideEffect`,this._midSideMerge=new cd({context:this.context}),this._midSideSplit=new sd({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}},ud=class e extends ld{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 jl({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),Tc(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(ld.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}},dd=class e extends Vu{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`depth`]);super(t),this.name=`Tremolo`,this._lfoL=new Sl({context:this.context,type:t.type,min:1,max:0}),this._lfoR=new Sl({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(Vu.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}},fd=class e extends Ou{constructor(){let t=H(e.getDefaults(),arguments,[`frequency`,`depth`]);super(t),this.name=`Vibrato`,this._delayNode=new Fc({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new Sl({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(Ou.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}},pd=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 zu({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}},md=class e extends J{constructor(){super(H(e.getDefaults(),arguments)),this.name=`MeterBase`,this.input=this.output=this._analyser=new pd({context:this.context,size:256,type:`waveform`})}dispose(){return super.dispose(),this._analyser.dispose(),this}},hd=class e extends md{constructor(){let t=H(e.getDefaults(),arguments,[`smoothing`]);super(t),this.name=`Meter`,this.input=this.output=this._analyser=new pd({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(md.getDefaults(),{smoothing:.8,normalRange:!1,channelCount:1})}getLevel(){return hs(`'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]:oc(this._rms[t])});return this.channels===1?t[0]:t}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}},gd=class e extends md{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?ac(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)}},_d=class e extends md{constructor(){super(H(e.getDefaults(),arguments)),this.name=`DCMeter`,this._analyser.type=`waveform`,this._analyser.size=256}getValue(){return this._analyser.getValue()[0]}},vd=class e extends md{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(md.getDefaults(),{size:1024})}getValue(){return this._analyser.getValue()}get size(){return this._analyser.size}set size(e){this._analyser.size=e}},yd=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}};yd._allSolos=new Map,yd._soloed=new Map;var bd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`pan`,`volume`]);super(t),this.name=`PanVol`,this._panner=this.input=new ju({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Ic({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}},xd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`volume`,`pan`]);super(t),this.name=`Channel`,this._solo=this.input=new yd({solo:t.solo,context:this.context}),this._panVol=this.output=new bd({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}};xd.buses=new Map;var Sd=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 Bu({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}},Cd=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 Gl({context:this.context,frequency:0,type:`lowpass`}),this._lowMidFilter=new Gl({context:this.context,frequency:0,type:`highpass`}),this.mid=new Gl({context:this.context,frequency:0,type:`lowpass`}),this.high=new Gl({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(),Qs(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}},wd=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}},Td=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 vs!==null&&Reflect.has(vs,`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}},Ed=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}},Dd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`threshold`,`smoothing`]);super(t),this.name=`Gate`,this._follower=new Nu({context:this.context,smoothing:t.smoothing}),this._gt=new Nl({context:this.context,value:ac(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 oc(this._gt.value)}set threshold(e){this._gt.value=ac(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}},Od=class e extends J{constructor(){let t=H(e.getDefaults(),arguments,[`threshold`]);super(t),this.name=`Limiter`,this._compressor=this.input=this.output=new Ed({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}},kd=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MidSideCompressor`,this._midSideSplit=this.input=new sd({context:this.context}),this._midSideMerge=this.output=new cd({context:this.context}),this.mid=new Ed(Object.assign(t.mid,{context:this.context})),this.side=new Ed(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}},Ad=class e extends J{constructor(){let t=H(e.getDefaults(),arguments);super(t),this.name=`MultibandCompressor`,this._splitter=this.input=new Cd({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 Ed(Object.assign(t.low,{context:this.context})),this.mid=new Ed(Object.assign(t.mid,{context:this.context})),this.high=new Ed(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}},jd=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 Cd({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(),Qs(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}},Md=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 $s(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}},Nd=n({AMOscillator:()=>fl,AMSynth:()=>Ul,Abs:()=>Ol,Add:()=>yl,AmplitudeEnvelope:()=>Bl,Analyser:()=>pd,AudioToGain:()=>dl,AutoFilter:()=>Au,AutoPanner:()=>Mu,AutoWah:()=>Pu,BaseContext:()=>Ys,BiquadFilter:()=>Wl,BitCrusher:()=>Iu,Buffer:()=>qd,BufferSource:()=>Yd,Buffers:()=>Jd,Channel:()=>xd,Chebyshev:()=>Ru,Chorus:()=>Uu,Clock:()=>Pc,Compressor:()=>Ed,Context:()=>Xs,Convolver:()=>Md,CrossFade:()=>Du,DCMeter:()=>_d,Delay:()=>Fc,Destination:()=>Rd,Distortion:()=>Wu,Draw:()=>Ud,DuoSynth:()=>Jl,EQ3:()=>jd,Emitter:()=>Js,Envelope:()=>Il,FFT:()=>gd,FMOscillator:()=>pl,FMSynth:()=>Yl,FatOscillator:()=>hl,FeedbackCombFilter:()=>ou,FeedbackDelay:()=>Ku,Filter:()=>Gl,Follower:()=>Nu,Freeverb:()=>Zu,Frequency:()=>bc,FrequencyClass:()=>_c,FrequencyEnvelope:()=>Kl,FrequencyShifter:()=>Ju,Gain:()=>Y,GainToAudio:()=>kl,Gate:()=>Dd,GrainPlayer:()=>Dl,GreaterThan:()=>Nl,GreaterThanZero:()=>Ml,IntervalTimeline:()=>Gc,JCReverb:()=>td,LFO:()=>Sl,Limiter:()=>Od,Listener:()=>Vd,Loop:()=>pu,LowpassCombFilter:()=>cu,Master:()=>zd,MembraneSynth:()=>Ql,Merge:()=>Bu,MetalSynth:()=>Zl,Meter:()=>hd,MidSideCompressor:()=>kd,MidSideMerge:()=>cd,MidSideSplit:()=>sd,Midi:()=>Hc,MidiClass:()=>Vc,Mono:()=>Sd,MonoSynth:()=>ql,MultibandCompressor:()=>Ad,MultibandSplit:()=>Cd,Multiply:()=>$,Negate:()=>Al,Noise:()=>nl,NoiseSynth:()=>$l,Offline:()=>zc,OfflineContext:()=>ec,OmniOscillator:()=>vl,OnePoleFilter:()=>su,Oscillator:()=>ul,PWMOscillator:()=>gl,PanVol:()=>bd,Panner:()=>ju,Panner3D:()=>wd,Param:()=>q,Part:()=>mu,Pattern:()=>Tu,Phaser:()=>ad,PingPongDelay:()=>rd,PitchShift:()=>id,Player:()=>Tl,Players:()=>El,PluckSynth:()=>lu,PolySynth:()=>uu,Pow:()=>Zc,PulseOscillator:()=>ml,Recorder:()=>Td,Reverb:()=>od,Sampler:()=>du,Scale:()=>bl,ScaleExp:()=>Pl,Sequence:()=>Eu,Signal:()=>X,Solo:()=>yd,Split:()=>zu,StateTimeline:()=>Cc,StereoWidener:()=>ud,Subtract:()=>jl,SyncedSignal:()=>Fl,Synth:()=>Vl,Ticks:()=>Uc,TicksClass:()=>Z,Time:()=>gc,TimeClass:()=>hc,Timeline:()=>Vs,ToneAudioBuffer:()=>$s,ToneAudioBuffers:()=>Bc,ToneAudioNode:()=>J,ToneBufferSource:()=>tl,ToneEvent:()=>fu,ToneOscillatorNode:()=>ll,Transport:()=>Id,TransportTime:()=>xc,TransportTimeClass:()=>K,Tremolo:()=>dd,Unit:()=>qc,UserMedia:()=>sl,Vibrato:()=>fd,Volume:()=>Ic,WaveShaper:()=>Xc,Waveform:()=>vd,Zero:()=>xl,connect:()=>Tc,connectSeries:()=>wc,connectSignal:()=>Ac,context:()=>Gd,dbToGain:()=>ac,debug:()=>os,defaultArg:()=>Ms,disconnect:()=>Ec,fanIn:()=>Dc,ftom:()=>dc,gainToDb:()=>oc,getContext:()=>G,getDestination:()=>Bd,getDraw:()=>Wd,getListener:()=>Hd,getTransport:()=>Ld,immediate:()=>Fd,intervalToFrequencyRatio:()=>sc,isArray:()=>rs,isBoolean:()=>ns,isDefined:()=>R,isFunction:()=>$o,isNote:()=>as,isNumber:()=>es,isObject:()=>ts,isString:()=>is,isUndef:()=>Qo,loaded:()=>Kd,mtof:()=>pc,now:()=>Pd,optionsFromArguments:()=>H,setContext:()=>rc,start:()=>ic,supported:()=>Zo,version:()=>r});function Pd(){return G().now()}function Fd(){return G().immediate()}var Id=G().transport;function Ld(){return G().transport}var Rd=G().destination,zd=G().destination;function Bd(){return G().destination}var Vd=G().listener;function Hd(){return G().listener}var Ud=G().draw;function Wd(){return G().draw}var Gd=G();function Kd(){return $s.loaded()}var qd=$s,Jd=Bc,Yd=tl,Xd=window.__libreArtifactRuntime=window.__libreArtifactRuntime||{modules:{},register(e,t){for(let n of e)this.modules[n]=t},require(e){let t=this.modules[e];if(t===void 0)throw Error(`"`+e+`" is not one of the libraries available to artifacts.`);return t}},Zd=Nd;Xd.register([`tone`],Zd),window.Tone=Zd})();