@tspro/web-music-score 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/audio/index.d.mts +40 -1
- package/dist/audio/index.d.ts +40 -1
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +2 -2
- package/dist/audio-cg/index.d.mts +3 -0
- package/dist/audio-cg/index.d.ts +3 -0
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +2 -2
- package/dist/{chunk-D643HZHM.mjs → chunk-YFPLOHP2.mjs} +2 -2
- package/dist/core/index.d.mts +12 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +3 -2
- package/dist/core/index.mjs +4 -3
- package/dist/guitar-CaZJDA05.d.ts +35 -0
- package/dist/guitar-DdexKdN6.d.mts +35 -0
- package/dist/iife/index.global.js +11 -11
- package/dist/{interface-XoKiryoV.d.mts → music-objects-DJQ4d2OA.d.mts} +549 -53
- package/dist/{interface-7k8qGG44.d.ts → music-objects-Dc3kR-XF.d.ts} +549 -53
- package/dist/note-eA2xPPiG.d.mts +294 -0
- package/dist/note-eA2xPPiG.d.ts +294 -0
- package/dist/pieces/index.d.mts +22 -3
- package/dist/pieces/index.d.ts +22 -3
- package/dist/pieces/index.js +5 -2
- package/dist/pieces/index.mjs +6 -3
- package/dist/react-ui/index.d.mts +166 -17
- package/dist/react-ui/index.d.ts +166 -17
- package/dist/react-ui/index.js +78 -1
- package/dist/react-ui/index.mjs +79 -2
- package/dist/scale-B2Icbetz.d.ts +230 -0
- package/dist/scale-BbDJTbrG.d.mts +230 -0
- package/dist/score/index.d.mts +299 -46
- package/dist/score/index.d.ts +299 -46
- package/dist/score/index.js +553 -76
- package/dist/score/index.mjs +550 -75
- package/dist/{tempo-BAYoZ_Li.d.mts → tempo-CtUhvJbr.d.mts} +187 -5
- package/dist/{tempo-r2sb6Ku2.d.ts → tempo-Dt8aHpol.d.ts} +187 -5
- package/dist/theory/index.d.mts +29 -13
- package/dist/theory/index.d.ts +29 -13
- package/dist/theory/index.js +369 -25
- package/dist/theory/index.mjs +370 -26
- package/package.json +1 -1
- package/dist/guitar-DggbM2UL.d.mts +0 -17
- package/dist/guitar-cNmE-EvH.d.ts +0 -17
- package/dist/note-BFa43I86.d.mts +0 -85
- package/dist/note-CcVdUFqS.d.ts +0 -85
- package/dist/scale-C2pCNxdE.d.mts +0 -75
- package/dist/scale-CvPbJvfN.d.ts +0 -75
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* WebMusicScore v4.0.
|
|
2
|
-
"use strict";var WebMusicScore=(()=>{var Yo=Object.defineProperty,Dm=Object.defineProperties,Em=Object.getOwnPropertyDescriptor,km=Object.getOwnPropertyDescriptors,jm=Object.getOwnPropertyNames,zo=Object.getOwnPropertySymbols;var za=Object.prototype.hasOwnProperty,wu=Object.prototype.propertyIsEnumerable;var Tu=Math.pow,Ua=(n,t,e)=>t in n?Yo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,M=(n,t)=>{for(var e in t||(t={}))za.call(t,e)&&Ua(n,e,t[e]);if(zo)for(var e of zo(t))wu.call(t,e)&&Ua(n,e,t[e]);return n},Z=(n,t)=>Dm(n,km(t));var Mr=(n,t)=>{var e={};for(var r in n)za.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&zo)for(var r of zo(n))t.indexOf(r)<0&&wu.call(n,r)&&(e[r]=n[r]);return e};var Ni=(n,t)=>{for(var e in t)Yo(n,e,{get:t[e],enumerable:!0})},Lm=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jm(t))!za.call(n,i)&&i!==e&&Yo(n,i,{get:()=>t[i],enumerable:!(r=Em(t,i))||r.enumerable});return n};var Pm=n=>Lm(Yo({},"__esModule",{value:!0}),n);var d=(n,t,e)=>Ua(n,typeof t!="symbol"?t+"":t,e);var Q=(n,t,e)=>new Promise((r,i)=>{var o=c=>{try{a(e.next(c))}catch(u){i(u)}},s=c=>{try{a(e.throw(c))}catch(u){i(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((e=e.apply(n,t)).next())});var jb={};Ni(jb,{Audio:()=>so,Core:()=>Ka,Pieces:()=>Su,Score:()=>Iu,Theory:()=>cc});var so={};Ni(so,{getCurrentInstrument:()=>ib,getInstrumentList:()=>rb,playNote:()=>Us,registerInstrument:()=>nb,setInstrument:()=>Cm,stop:()=>pu});var cc={};Ni(cc,{AccidentalType:()=>$a,Chord:()=>tc,DefaultGuitarNoteLabel:()=>fg,DefaultHandedness:()=>Vg,DefaultPitchNotation:()=>dg,DefaultTuningName:()=>Wg,GuitarNoteLabel:()=>Zo,GuitarNoteLabelList:()=>gg,Handedness:()=>rc,Interval:()=>En,KeySignature:()=>Fe,Mode:()=>Ja,Note:()=>W,NoteLength:()=>Zt,NoteLengthProps:()=>Xt,PitchNotation:()=>Er,PitchNotationList:()=>pg,RhythmProps:()=>Qt,Scale:()=>jr,ScaleFactory:()=>zt,ScaleType:()=>ri,SymbolSet:()=>Dr,TimeSignature:()=>gr,TuningNameList:()=>jn,Tuplet:()=>fr,alterTempoSpeed:()=>ac,getDefaultKeySignature:()=>Xo,getDefaultScale:()=>Eg,getDefaultTempo:()=>ts,getDefaultTimeSignature:()=>$o,getPitchNotationName:()=>mg,getScale:()=>dr,getScaleFactory:()=>$u,getScaleFactoryList:()=>Mg,getTempoString:()=>sc,getTuningStrings:()=>Ko,validateGuitarNoteLabel:()=>yg,validateHandedness:()=>qg,validateIntervalQuality:()=>wg,validateNoteLength:()=>ni,validatePitchNotation:()=>Uu,validateScaleType:()=>kn,validateTuningName:()=>ic,validateTupletRatio:()=>Jo});var Ou=Object.defineProperty,Fm=(n,t,e)=>t in n?Ou(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,pr=(n,t)=>{for(var e in t)Ou(n,e,{get:t[e],enumerable:!0})},tr=(n,t,e)=>Fm(n,typeof t!="symbol"?t+"":t,e),A={};pr(A,{Arr:()=>Ru,Dom:()=>ku,Enum:()=>ju,Is:()=>Lu,Map:()=>Fu,Math:()=>Mu,Obj:()=>Bu,Str:()=>Gu});var Ru={};pr(Ru,{arrayContains:()=>ef,chunckArray:()=>rf,duplicate:()=>Xm,fillArray:()=>Jm,getRangeArray:()=>tf,getSequenceArray:()=>$m,isArray:()=>Ha,mapRangeArray:()=>Eu,mapSequenceArray:()=>Du,removeDuplicates:()=>Qm,removeDuplicatesCmp:()=>Km,toArray:()=>Zm});var Mu={};pr(Mu,{calcNormal:()=>Ym,clamp:()=>zm,interpolateCoord:()=>Wm,interpolateY:()=>Um,isInteger:()=>we,linearToDecibels:()=>Bm,mod:()=>Gm,romanize:()=>Vm,sum:()=>Hm,toOrdinalNumber:()=>qm});function we(n){return typeof n=="number"&&isFinite(n)&&n===Math.trunc(n)}function Bm(n){if(isFinite(n))return n<=0?-1/0:20*Math.log10(n);throw new Error("linearToDecibel: Invalid linearVolume = "+n)}function Gm(n,t){return(n%t+t)%t}function Vm(n){if(!we(n)||n<0)throw new Error("romanize: Invalid n = "+n);for(var t=String(+n).split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",i=3;i--;)r=(e[+t.pop()+i*10]||"")+r;return Array(+t.join("")+1).join("M")+r}function qm(n){if(!we(n))throw new Error("toOrdinalNumber: Invalid n = "+n);let t=n.toString(),e=Number(t.charAt(t.length-1));return n===1||n>=20&&e===1?t+"st":n===2||n>=20&&e===2?t+"nd":n===3||n>=20&&e===3?t+"rd":t+"th"}function Wm(n,t,e,r,i){return{x:n+(e-n)*i,y:t+(r-t)*i}}function Um(n,t,e,r,i){let o=(i-n)/(e-n);return t+(r-t)*o}function zm(n,t,e){return Math.min(Math.max(n,t),e)}function Ym(n,t,e,r){let i=e-n,s=-(r-t),a=i,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function Hm(n){return n.reduce((t,e)=>e+t,0)}function Ha(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function Zm(n){return Ha(n)?n:[n]}function Xm(n){return n===void 0?n:n.slice()}function Qm(n){return n.filter((t,e,r)=>r.indexOf(t)===e)}function Km(n,t){return n.filter((e,r,i)=>r===i.findIndex(o=>t(e,o)))}function Jm(n,t){if(!we(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(n)}function Du(n,t){if(!we(n)||n<0)throw new Error("mapSequenceArray: Invalid len = "+n);let e=new Array(n);for(let r=0;r<n;r++)e[r]=t(r);return e}function $m(n){return Du(n,t=>t)}function Eu(n,t,e){if(!we(n))throw new Error("mapRangeArray: Invalid start = "+t);if(!we(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-n)+1,i=new Array(r);for(let o=0,s=n,a=Math.sign(t-n);o<r;s+=a,o++)i[o]=e(s);return i}function tf(n,t){return Eu(n,t,e=>e)}function ef(n,t){return n.indexOf(t)>=0}function rf(n,t){if(!we(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}var ku={};pr(ku,{addClass:()=>nf,appendTo:()=>pf,getButton:()=>gf,getCanvas:()=>yf,getCanvasTextWidth:()=>Cf,getDimension:()=>bf,getHeight:()=>lf,getOffset:()=>af,getPadding:()=>xf,getWidth:()=>cf,hasClass:()=>Za,removeClass:()=>of,removeFromParent:()=>df,setHeight:()=>hf,setOffset:()=>sf,setRect:()=>ff,setVisibility:()=>mf,setWidth:()=>uf,styleLayoutChanged:()=>Af});var ju={};pr(ju,{getEnumValues:()=>Ho});function Ho(n){return Object.keys(n).filter(t=>Number.isNaN(Number(t))).map(t=>n[t])}var Ya;(n=>{let t=Error;function e(x){t=x!=null?x:Error}n.setErrorClass=e;function r(x,N){throw new t("Assertion Error: "+x+(N?" "+N:""))}function i(x){return typeof x=="number"&&isFinite(x)&&x===Math.trunc(x)}function o(x){return typeof x=="number"}function s(x,N){x||r(N!=null?N:"Assertion failed!")}n.assert=s;function a(x,N,j="value"){if(!Ho(N).some(R=>R===x))throw new TypeError(`Invalid ${j} enum value: ${x}`)}n.assertEnum=a;function c(x){r(x!=null?x:"Interrupted!")}n.interrupt=c;function u(x,N){return i(x)||r(`Expected ${x} to be integer.`,N),x}n.int=u;function l(x,N,j){return x!==N&&r(`Expected ${x} to equal ${N}.`,j),x}n.eq=l;function h(x,N,j){return i(x)&&o(N)&&x===N||r(`Expected ${x} to be integer equal to ${N}.`,j),x}n.int_eq=h;function p(x,N,j){return i(x)&&o(N)&&x<N||r(`Expected ${x} to be integer less than ${N}.`,j),x}n.int_lt=p;function m(x,N,j){return i(x)&&o(N)&&x<=N||r(`Expected ${x} to be integer less than or equal to ${N}.`,j),x}n.int_lte=m;function f(x,N,j){return i(x)&&o(N)&&x>N||r(`Expected ${x} to be integer greater than ${N}.`,j),x}n.int_gt=f;function g(x,N,j){return i(x)&&o(N)&&x>=N||r(`Expected ${x} to be integer greater than or equal to ${N}.`,j),x}n.int_gte=g;function y(x,N,j,R){return i(x)&&o(N)&&o(j)&&x>=N&&x<=j||r(`Expected ${x} to be integer between ${N} and ${j}.`,R),x}n.int_between=y;function b(x,N){return i(x)&&x%2===1||r(`Expected ${x} to be odd number.`,N),x}n.odd=b;function I(x,N){return i(x)&&x%2===0||r(`Expected ${x} to be even number.`,N),x}n.even=I;function S(x,N,j){if(!N.some(R=>R===x)){let R=N.map(D=>String(D)).join(", ");r(`Expected ${x} to be in group [${R}].`,j)}return x}n.in_group=S;function w(x,N){return o(x)&&isFinite(x)||r(`Expected ${x} to be finite number.`,N),x}n.finite=w;function _(x,N,j){return i(N)&&N>=0&&N<x.length||r(`Expected ${N} to be array index in bounds [0..${x.length-1}].`,j),N}n.array_id=_;function v(x,N,j){return x[_(x,N,j)]}n.array_elem=v;function C(x,N){if(x===void 0)r("Required value is undefined.",N);else return x}n.require=C})(Ya||(Ya={}));var Mn;(n=>{function t(){let p=document.createElement("div");p.style.width="1in",document.body.appendChild(p);let m=p.offsetWidth;return p.remove(),m||96}function e(){try{let p=document.createElement("div");p.style.visibility="hidden",p.style.width="100px",document.body.appendChild(p);let m=p.offsetWidth;p.style.overflow="scroll";let f=document.createElement("div");f.style.width="100%",p.appendChild(f);let g=f.offsetWidth;return p.parentNode&&p.parentNode.removeChild(p),m-g}catch(p){return 0}}function r(){let p=document.createElement("div");p.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",p.appendChild(document.createTextNode("M")),document.body.appendChild(p);let m=p.offsetHeight;return document.body.removeChild(p),m}function i(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var p=" -webkit- -moz- -o- -ms- ".split(" "),m=function(g){return window.matchMedia(g).matches},f=["(",p.join("touch-enabled),("),"heartz",")"].join("");return m(f)}function o(){let p=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(p)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(p.substr(0,4))}function s(){return location.protocol+"//"+location.host}let a=/^(mm|cm|in|inch|px|em)$/,c=/^([0-9\\.]+)(.*)$/;n.DPI=t(),n.PxPerMm=n.DPI/25.4,n.ScrollbarWidth=e(),n.FontSize=r(),n.IsTouchDevice=i(),n.IsMobileDevice=o(),n.HostAddress=s();function u(p){return p/n.PxPerMm}n.pxToMm=u;function l(p){return p*n.PxPerMm}n.mmToPx=l;function h(p){if(typeof p=="number")return p;let m=NaN,f,g=p.toString().match(c);if(g&&g[1]){m=parseFloat(g[1]);let y=g[2]?g[2].toLowerCase():"undefined";f=a.test(y)?y:void 0,f||console.log("Unknown unit '"+y+"' => using 'px'.")}else m=parseFloat(p);switch(Ya.finite(m,"value in function toPx"),f){case"mm":return l(m);case"cm":return l(m)*10;case"in":case"inch":return l(m)*25.4;case"em":return n.FontSize*m;default:case"px":return m}}n.toPx=h})(Mn||(Mn={}));function It(n){return n===void 0?void 0:Mn.toPx(n)}function Za(n,t){return t.length===0?!1:n.classList?n.classList.contains(t):!!n.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function nf(n,t){t.length!==0&&(n.classList?n.classList.add(t):Za(n,t)||(n.className+=" "+t))}function of(n,t){if(t.length!==0){if(n.classList)n.classList.remove(t);else if(Za(n,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");n.className=n.className.replace(e," ")}}}function sf(n,t,e,r="px"){n.style.left=t+r,n.style.top=e+r}function af(n){let t=n.getBoundingClientRect(),e=document.documentElement;return{top:t.top+window.pageYOffset-e.clientTop,left:t.left+window.pageXOffset-e.clientLeft}}function cf(n){if(n instanceof Window)return n.innerWidth;{let t=parseFloat(getComputedStyle(n,null).width.replace("px",""));return isNaN(t)?0:t}}function uf(n,t){n.style.width=t+"px"}function lf(n){if(n instanceof Window)return n.innerHeight;{let t=parseFloat(getComputedStyle(n,null).height.replace("px",""));return isNaN(t)?0:t}}function hf(n,t){n.style.height=t+"px"}function pf(n,t){t.appendChild(n)}function df(n){n.remove()}function mf(n,t){n.style.display=t?"block":"none"}function ff(n,t,e,r,i,o="px"){n.style.left=t+o,n.style.top=e+o,n.style.width=r+o,n.style.height=i+o}function gf(n){let t=typeof n=="string"?document.getElementById(n):n;return t instanceof HTMLButtonElement?t:void 0}function yf(n){let t=typeof n=="string"?document.getElementById(n):n;return t instanceof HTMLCanvasElement?t:void 0}function xf(n){var s;if(!n)return{top:0,right:0,bottom:0,left:0};let t=It(n.paddingTop),e=It(n.paddingRight),r=It(n.paddingBottom),i=It(n.paddingLeft),o=((s=n.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:t!=null||(t=It(o[0])),e!=null||(e=It(o[0])),r!=null||(r=It(o[0])),i!=null||(i=It(o[0]));break;case 2:t!=null||(t=It(o[0])),e!=null||(e=It(o[1])),r!=null||(r=It(o[0])),i!=null||(i=It(o[1]));break;case 3:t!=null||(t=It(o[0])),e!=null||(e=It(o[1])),r!=null||(r=It(o[2])),i!=null||(i=It(o[1]));break;case 4:default:t!=null||(t=It(o[0])),e!=null||(e=It(o[1])),r!=null||(r=It(o[2])),i!=null||(i=It(o[3]));break}return t!=null||(t=0),e!=null||(e=0),r!=null||(r=0),i!=null||(i=0),{top:t,right:e,bottom:r,left:i}}function bf(n){let t=It(n==null?void 0:n.left),e=It(n==null?void 0:n.right),r=It(n==null?void 0:n.top),i=It(n==null?void 0:n.bottom),o=It(n==null?void 0:n.width),s=It(n==null?void 0:n.height);return o===void 0&&t!==void 0&&e!==void 0&&(o=e-t),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:t,top:r,width:o,height:s}}function Af(n,t){return!n&&!t?!1:!n||!t?!0:n.left!==t.left||n.top!==t.top||n.right!==t.right||n.bottom!==t.bottom||n.width!==t.width||n.height!==t.height}var On;function Cf(n,t){On!=null||(On=document.createElement("canvas"));let e=On.getContext("2d");return e?(e.font=t,e.measureText(n).width):0}var Lu={};pr(Lu,{isArray:()=>$r,isArrayOrUndefined:()=>wf,isBoolean:()=>Pf,isBooleanOrUndefined:()=>Ff,isEmptyArray:()=>Tf,isEmptyArrayOrUndefined:()=>Of,isEmptyString:()=>Df,isEmptyStringOrUndefined:()=>jf,isEnumValue:()=>Vf,isEnumValueOrUndefined:()=>qf,isFinite:()=>Xa,isFunction:()=>Bf,isFunctionOrUndefined:()=>Gf,isInfinity:()=>$f,isInteger:()=>ti,isIntegerBetween:()=>Kf,isIntegerEq:()=>Yf,isIntegerGt:()=>Hf,isIntegerGte:()=>Zf,isIntegerLt:()=>Xf,isIntegerLte:()=>Qf,isIntegerOrUndefined:()=>zf,isNaNValue:()=>Jf,isNegInfinity:()=>eg,isNonEmptyArray:()=>Nf,isNonEmptyArrayOrUndefined:()=>Rf,isNonEmptyString:()=>Ef,isNonEmptyStringOrUndefined:()=>Lf,isNull:()=>vf,isNullish:()=>If,isNumber:()=>Wf,isNumberOrUndefined:()=>Uf,isObject:()=>Pu,isObjectOrUndefined:()=>Sf,isPosInfinity:()=>tg,isString:()=>Mf,isStringOrUndefined:()=>kf,isUndefined:()=>_f});function _f(n){return n===void 0}function vf(n){return n===null}function If(n){return n==null}function Pu(n){return typeof n=="object"&&n!==null&&!$r(n)}function Sf(n){return n===void 0||Pu(n)}function $r(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function wf(n){return n===void 0||$r(n)}function Tf(n){return $r(n)&&n.length===0}function Nf(n){return $r(n)&&n.length>0}function Of(n){return $r(n)&&n.length===0||n===void 0}function Rf(n){return $r(n)&&n.length>0||n===void 0}function Mf(n){return typeof n=="string"}function Df(n){return typeof n=="string"&&n.length===0}function Ef(n){return typeof n=="string"&&n.length>0}function kf(n){return n===void 0||typeof n=="string"}function jf(n){return typeof n=="string"&&n.length===0||n===void 0}function Lf(n){return typeof n=="string"&&n.length>0||n===void 0}function Pf(n){return typeof n=="boolean"}function Ff(n){return n===void 0||typeof n=="boolean"}function Bf(n){return typeof n=="function"}function Gf(n){return n===void 0||typeof n=="function"}function Vf(n,t,e="value"){return Ho(t).some(r=>r===n)}function qf(n,t,e="value"){return n===void 0||Ho(t).some(r=>r===n)}function Wf(n){return typeof n=="number"}function Uf(n){return typeof n=="number"||n===void 0}function Xa(n){return typeof n=="number"&&Number.isFinite(n)}function ti(n){return typeof n=="number"&&Xa(n)&&n===Math.trunc(n)}function zf(n){return typeof n=="number"&&Xa(n)&&n===Math.trunc(n)||n===void 0}function Yf(n,t){return ti(n)&&n===t}function Hf(n,t){return ti(n)&&n>t}function Zf(n,t){return ti(n)&&n>=t}function Xf(n,t){return ti(n)&&n<t}function Qf(n,t){return ti(n)&&n<=t}function Kf(n,t,e){return ti(n)&&n>=t&&n<=e}function Jf(n){return typeof n=="number"&&Number.isNaN(n)}function $f(n){return typeof n=="number"&&Math.abs(n)===1/0}function tg(n){return typeof n=="number"&&n===1/0}function eg(n){return typeof n=="number"&&n===-1/0}var Fu={};pr(Fu,{getMapKeys:()=>rg});function rg(n){let t=[];return n.forEach((e,r)=>t.push(r)),t}var Bu={};pr(Bu,{isObject:()=>ig});function ig(n){return typeof n=="object"&&n!==null&&!Ha(n)}var Gu={};pr(Gu,{charCount:()=>ug,chunkString:()=>sg,insertAt:()=>ag,makeSentenceFromPascal:()=>lg,removeAt:()=>cg,repeatString:()=>og,replaceAt:()=>Qa,toCharArray:()=>ng});function ng(n){return n.split("")}function og(n,t){if(!we(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(n)}function sg(n,t){if(!we(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}function Qa(n,t,e,r){if(!we(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!we(t)||t<0||t+e>n.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+n.length);return n.substring(0,t)+r+n.substring(t+e)}function ag(n,t,e){return Qa(n,t,0,e)}function cg(n,t,e){return Qa(n,t,e,"")}function ug(n,t){if(t.length!==1||n.length===0)return 0;let e=0;for(let r=0;r<n.length;r++)n[r]===t&&e++;return e}function lg(n){if(n==="")return"";let t=n.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},i=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<n.length;o++){let s=n.charAt(o);i(s)&&r(),t+=s.toLowerCase()}return r(),e}var Nu;(n=>{let t="ConsentCookie",e;(w=>{w.Accept="accept",w.Decline="decline"})(e||(e={}));let r,i,o=p(t);r=o==="accept"||o==="decline"?o:void 0;function s(w){i=new Date,i.setDate(i.getDate()+w)}n.setExpireDays=s;function a(){return r===void 0}n.isConsentPending=a;function c(){r="accept",h(t,r)}n.accept=c;function u(){r="decline",h(t,r)}n.decline=u;function l(){return document.cookie.split(";").map(_=>_.trim())}function h(w,_){let v=w+"="+_.toString()+";sameSite=Lax;";return i&&(v+="expires="+i.toUTCString()+";"),document.cookie=v,_}function p(w,_){let v=l().find(C=>C.startsWith(w+"="));return v===void 0?_:v.substring(w.length+1)}function m(w){document.cookie=w+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(w,_){return r==="accept"&&h(w,_),_}n.save=f;function g(w,_){return r==="accept"&&p(w,_)||_}n.read=g;function y(w,_){if(r==="accept"){let v=p(w);return v===void 0?_:parseInt(v)}else return _}n.readInt=y;function b(w,_){if(r==="accept"){let v=p(w);return v===void 0?_:/true|1/i.test(v)}else return _}n.readBool=b;function I(w){(r==="accept"||w===t)&&m(w)}n.erase=I;function S(){document.cookie.split(";").forEach(w=>I(w.trim().split("=")[0]))}n.eraseAll=S})(Nu||(Nu={}));var Vu=class Rn{constructor(t,e){tr(this,"x"),tr(this,"y"),this.x=t!=null?t:0,this.y=e!=null?e:0}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}add(t){return new Rn(this.x+t.x,this.y+t.y)}sub(t){return new Rn(this.x-t.x,this.y-t.y)}mul(t){return new Rn(this.x*t,this.y*t)}div(t){return new Rn(this.x/t,this.y/t)}},qu=class{constructor(n,t=1/0){tr(this,"cache"),tr(this,"next"),tr(this,"prev"),tr(this,"head"),tr(this,"tail"),tr(this,"capacity"),tr(this,"size"),tr(this,"maxKeyLength"),this.cache=Object.create(null),this.next=Object.create(null),this.prev=Object.create(null),this.head=null,this.tail=null,this.capacity=n,this.size=0,this.maxKeyLength=t}get(n){if(!(n.length>this.maxKeyLength)&&this.cache[n]!==void 0)return this.touch(n),this.cache[n]}set(n,t){if(!(n.length>this.maxKeyLength)){if(this.cache[n]!==void 0){this.cache[n]=t,this.touch(n);return}this.size>=this.capacity&&this.evict(),this.cache[n]=t,this.addToTail(n),this.size++}}touch(n){this.tail!==n&&(this.removeKey(n),this.addToTail(n))}evict(){if(this.head!==null){let n=this.head;this.removeKey(n),delete this.cache[n],this.size--}}removeKey(n){let t=this.prev[n],e=this.next[n];t!==void 0?this.next[t]=e:this.head=e!=null?e:null,e!==void 0?this.prev[e]=t:this.tail=t!=null?t:null,delete this.prev[n],delete this.next[n]}addToTail(n){this.tail!==null?(this.next[this.tail]=n,this.prev[n]=this.tail):this.head=n,this.tail=n}};var Ka={};Ni(Ka,{MusicError:()=>O,MusicErrorType:()=>gt,init:()=>ei});var gt=(a=>(a[a.Unknown=0]="Unknown",a[a.InvalidArg=1]="InvalidArg",a[a.Note=2]="Note",a[a.Scale=3]="Scale",a[a.KeySignature=4]="KeySignature",a[a.Timesignature=5]="Timesignature",a[a.Score=6]="Score",a))(gt||{});function hg(n){return n===void 0?"":`[${gt[n]}] `}var O=class extends Error{constructor(...e){let[r,i]=e.length===1?[0,e[0]]:e;super(hg(r)+i);d(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var Wu=!1;function ei(){Wu||(Wu=!0,console.log("%cWebMusicScore v4.0.0 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Dr=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(Dr||{}),Er=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(Er||{}),pg=A.Enum.getEnumValues(Er),dg=0;function Uu(n){if(A.Is.isEnumValue(n,Er))return n;throw new O(1,`Invalid pitchNotation: ${n}`)}function mg(n){return Er[Uu(n)]}var Zo=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Zo||{}),fg="Default",gg=A.Enum.getEnumValues(Zo);function yg(n){if(A.Is.isEnumValue(n,Zo))return n;throw new O(5,`Invalid guitarNoteLabel: ${n}`)}function zu(n,t){return(n%t+t)%t}var Yu=12,Hu=7,xg=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),bg=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Zu=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),Dn=["C","D","E","F","G","A","B"],Xu=[0,2,4,5,7,9,11],Qu=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,st=class st{constructor(t,e,r){d(this,"diatonicClass");d(this,"accidental");d(this,"octave");if(typeof t=="number"&&typeof e=="number"&&r===void 0)st.validateDiatonicId(t),this.diatonicClass=st.getDiatonicClass(t),this.accidental=st.validateAccidental(e),this.octave=st.getOctaveFromDiatonicId(t);else if(typeof t=="number"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=st.validateDiatonicClass(t),this.accidental=st.validateAccidental(e),this.octave=st.validateOctave(r);else if(typeof t=="string"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=st.getDiatonicClass(t),this.accidental=st.validateAccidental(e),this.octave=st.validateOctave(r);else throw new O(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return st.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return st.getChromaticIdInOctave(Xu[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return st.getChromaticClass(Xu[this.diatonicClass]+this.accidental)}get noteLetter(){return Dn[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:i}=this,o=st.getAccidentalSymbol(this.accidental,e);return t===1?i>=3?r.toLowerCase()+o+"\u2032".repeat(i-3):r.toUpperCase()+o+"\u0375".repeat(2-i):r+o+i}formatOmitOctave(t){let e=Dn[this.diatonicClass],r=st.getAccidentalSymbol(this.accidental,t);return e+r}static getNote(t){let e=this.noteByNameCache.get(t);if(e===void 0){let r=st.parseNote(t);if(!r)throw new O(2,`Invalid noteName: ${t}`);if(r.octave===void 0)throw new O(2,"Octave is required for note.");e=new st(r.noteLetter,r.accidental,r.octave),this.noteByNameCache.set(t,e)}return e}static getChromaticNote(t){let e=this.chromaticNoteCache.get(t);if(e===void 0){let i=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][st.getChromaticClass(t)].split("/")[0]+st.getOctaveFromChromaticId(t),o=st.parseNote(i);if(!o)throw new O(2,`Invalid noteName: ${i}`);if(o.octave===void 0)throw new O(2,"Octave is required for note.");e=new st(o.noteLetter,o.accidental,o.octave),this.chromaticNoteCache.set(t,e)}return e}static getDiatonicClass(t){if(typeof t=="number")return zu(t,7);if(typeof t=="string"&&t.length>0)return Dn.indexOf(st.validateNoteLetter(t[0]));throw new O(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-Hu)/7)}static getDiatonicIdInOctave(t,e){return st.getDiatonicClass(t)+e*7+Hu}static getChromaticClass(t){return zu(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-Yu)/12)}static getChromaticIdInOctave(t,e){return st.getChromaticClass(t)+e*12+Yu}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.diatonicId===e.diatonicId&&t.accidental===e.accidental}static replaceAccidentalSymbols(t,e){return e===1?t.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):t.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(t){return Qu.test(t)}static parseNote(t){var c;let e=Qu.exec(t);if(!e)return;let r=st.validateNoteLetter(e[1]),i=e[2],o=st.validateAccidental((c=Zu.get(i))!=null?c:0),s=e[3],a=s?st.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(t,e){let r=st.parseNote(t);if(!r)throw new O(2,`Invalid noteName: ${t}`);let{noteLetter:i,accidental:o,octave:s}=r;return i+st.getAccidentalSymbol(o,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?bg.get(t):xg.get(t)}static getAccidental(t){let e=Zu.get(t);if(e===void 0)throw new O(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return Dn[st.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let i=st.getDiatonicClass(t),o=st.getDiatonicClass(e),s=r?i<=o?1:0:i<o?1:0;return st.getDiatonicIdInOctave(i,st.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(A.Is.isInteger(t))return t;throw new O(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(A.Is.isInteger(t)&&t>=0&&t<7)return t;throw new O(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(A.Is.isInteger(t))return t;throw new O(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(A.Is.isInteger(t)&&t>=0&&t<12)return t;throw new O(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(Dn.some(e=>e===t))return t;throw new O(2,`Invalid note: ${t}`)}static validateOctave(t){if(A.Is.isInteger(t))return t;throw new O(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(A.Is.isInteger(t)&&t>=-2&&t<=2)return t;throw new O(2,`Invalid accidental: ${t}`)}static sort(t){return t.slice().sort(st.compareFunc)}static removeDuplicates(t){let e=[];return t.forEach(r=>{e.find(i=>st.equals(r,i))===void 0&&e.push(r)}),e}static compareFunc(t,e){return t.diatonicId<e.diatonicId?-1:t.diatonicId>e.diatonicId?1:t.accidental<e.accidental?-1:t.accidental>e.accidental?1:0}};d(st,"noteByNameCache",new Map),d(st,"chromaticNoteCache",new Map);var W=st;function Ag(n,t){let e=W.getChromaticClass(n)-new W(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return W.validateAccidental(e)}var Cg=/^(bb?|b?|#?|x?)([0-9]*)$/;function _g(n){var i,o;let t=Cg.exec(""+n);if(!t)throw new O(4,`Invalid degree: ${n}`);let e=(o=W.getAccidental((i=t[1])!=null?i:""))!=null?o:0,r=+t[2];if(!A.Is.isInteger(e)||e<-2||e>2||!A.Is.isInteger(r)||r<1)throw new O(4,`Invalid degree: ${n}`);return{deg:r,acc:e}}var Ja=(a=>(a[a.Ionian=1]="Ionian",a[a.Dorian=2]="Dorian",a[a.Phrygian=3]="Phrygian",a[a.Lydian=4]="Lydian",a[a.Mixolydian=5]="Mixolydian",a[a.Aeolian=6]="Aeolian",a[a.Locrian=7]="Locrian",a))(Ja||{}),$a=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))($a||{});function Xo(){return dr("C","Major")}var kr=class kr{constructor(t,e){this.tonic=t;this.mode=e;d(this,"naturalScaleNotes");d(this,"accidentalByDiatonicClass");d(this,"orderedAccidentedNotes");if(!A.Is.isEnumValue(e,Ja))throw new O(4,`Invalid mode: ${e}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<e;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let i=W.getDiatonicClass(t[0]),o=W.getNote(t+"0").chromaticId;for(let c=0;c<7;i++,o+=r[c],c++){let u=new W(W.getDiatonicClass(i),Ag(o,i));if(Math.abs(u.accidental)>=2)throw new O(4,"Key signature contains double accidental.");this.naturalScaleNotes[c]=u,this.accidentalByDiatonicClass[u.diatonicClass]=u.accidental}let s=this.naturalScaleNotes.filter(c=>c.accidental>0).sort((c,u)=>{let l=kr.OrderOfSharps.indexOf(c.noteLetter),h=kr.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=kr.OrderOfFlats.indexOf(c.noteLetter),h=kr.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new O(4,"Key Signature has both sharps and flats.");this.orderedAccidentedNotes=a.length>0?a:s}getAccidentalType(){return this.orderedAccidentedNotes.length===0?0:this.orderedAccidentedNotes[0].accidental<0?1:2}getNaturalScaleNotes(){return this.naturalScaleNotes}getAccidental(t){var e;return(e=this.accidentalByDiatonicClass[W.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=_g(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let i=this.naturalScaleNotes[(e-1)%7];return new W(i.diatonicId,i.accidental+r)}}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.tonic===e.tonic&&t.mode===e.mode}};d(kr,"OrderOfSharps","FCGDAEB"),d(kr,"OrderOfFlats","BEADGCF");var Fe=kr;var vg=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),Ig={1:{0:"Perfect",1:"Augmented","-1":"diminished",2:"Doubly Augmented","-2":"doubly diminished"},2:{2:"Major",1:"minor",3:"Augmented",0:"diminished",4:"Doubly Augmented","-1":"doubly diminished"},3:{4:"Major",3:"minor",5:"Augmented",2:"diminished",6:"Doubly Augmented",1:"doubly diminished"},4:{5:"Perfect",6:"Augmented",4:"diminished",7:"Doubly Augmented",3:"doubly diminished"},5:{7:"Perfect",8:"Augmented",6:"diminished",9:"Doubly Augmented",5:"doubly diminished"},6:{9:"Major",8:"minor",10:"Augmented",7:"diminished",11:"Doubly Augmented",6:"doubly diminished"},7:{11:"Major",10:"minor",12:"Augmented",9:"diminished",13:"Doubly Augmented",8:"doubly diminished"},8:{12:"Perfect",13:"Augmented",11:"diminished",14:"Doubly Augmented",10:"doubly diminished"}};function Sg(n,t){for(;n<1;)n+=7,t+=12;for(;n>8;)n-=7,t-=12;let e=Ig[n];if(e)return e[t]}function wg(n){if(n==="Perfect"||n==="Major"||n==="minor"||n==="Augmented"||n==="diminished"||n==="Doubly Augmented"||n==="doubly diminished")return n;throw new O(1,`Invalid interval quality: ${n}`)}function Tg(n){if(A.Is.isIntegerGte(n,1))return A.Math.toOrdinalNumber(n);throw new O(1,`Invalid interval quantity: ${n}`)}var Qo=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},En=class n{constructor(t,e){this.note1=t;this.note2=e;d(this,"direction");d(this,"semitones");d(this,"quantity");d(this,"quality");e.diatonicId>=t.diatonicId?(this.direction=e.diatonicId===t.diatonicId?"Unison":"Ascending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId):(this.direction="Descending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId);let r=Sg(this.quantity,this.semitones);if(r)this.quality=r;else throw new Qo("Unknown interval quality")}static get(t,e){try{return new n(t,e)}catch(r){if(r instanceof Qo)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":Tg(this.quantity);return t+e+r}toAbbrString(){var i;let t=this.direction==="Descending"?"\u2193":"",e=(i=vg.get(this.quality))!=null?i:"?",r=this.quantity;return t+e+r}};function Ng(n){let t=W.getDiatonicClass("CCDDEFFGGAAB"[W.getChromaticClass(n)]),e=W.getOctaveFromChromaticId(n);return W.getDiatonicIdInOctave(t,e)}var Og=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],ri=(g=>(g.Major="Major",g.NaturalMinor="Natural Minor",g.HarmonicMinor="Harmonic Minor",g.Ionian="Ionian",g.Dorian="Dorian",g.Phrygian="Phrygian",g.Lydian="Lydian",g.Mixolydian="Mixolydian",g.Aeolian="Aeolian",g.Locrian="Locrian",g.MajorPentatonic="Major Pentatonic",g.MinorPentatonic="Minor Pentatonic",g.MajorHexatonicBlues="Major Hexatonic Blues",g.MinorHexatonicBlues="Minor Hexatonic Blues",g.HeptatonicBlues="Heptatonic Blues",g))(ri||{});function Rg(n){switch(n){case"Major":return 1;case"Natural Minor":return 6;case"Harmonic Minor":return 6;case"Ionian":return 1;case"Dorian":return 2;case"Phrygian":return 3;case"Lydian":return 4;case"Mixolydian":return 5;case"Aeolian":return 6;case"Locrian":return 7;case"Major Pentatonic":return 1;case"Minor Pentatonic":return 6;case"Major Hexatonic Blues":return 1;case"Minor Hexatonic Blues":return 6;case"Heptatonic Blues":return 1;default:throw new O(3,`Invalid scaleType: ${n}`)}}var jr=class extends Fe{constructor(e,r){super(e,Rg(r));this.tonic=e;this.scaleType=r;d(this,"scaleDegrees");d(this,"scaleNotes");d(this,"chromaticClassDegree");d(this,"preferredChromaticNoteCache",new Map);switch(r){case"Harmonic Minor":this.scaleDegrees=[1,2,3,4,5,6,"#7"];break;case"Major Pentatonic":this.scaleDegrees=[1,2,3,5,6];break;case"Minor Pentatonic":this.scaleDegrees=[1,3,4,5,7];break;case"Major Hexatonic Blues":this.scaleDegrees=[1,2,"b3",3,5,6];break;case"Minor Hexatonic Blues":this.scaleDegrees=[1,3,4,"b5",5,7];break;case"Heptatonic Blues":this.scaleDegrees=[1,2,"b3",4,"b5",6,"b7"];break;default:this.scaleDegrees=[1,2,3,4,5,6,7];break}this.scaleNotes=this.scaleDegrees.map(i=>this.getNoteByDegree(i)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(i=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===i);return o>=0?this.scaleDegrees[o]:void 0})}static equals(e,r){return e==null&&r==null?!0:e==null||r==null?!1:e===r||e.getScaleName()===r.getScaleName()}getScaleName(e){switch(e){case 1:return W.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!A.Is.isIntegerGte(r,1))throw new O(3,`Invalid numOctaves: ${r}`);let i=[];for(let s=1;s<=r;s++)i=[...i,...this.scaleNotes];i.push(this.scaleNotes[0]);let o=W.getNote(e).diatonicId;return i.map(s=>(o=W.findNextDiatonicIdAbove(s.diatonicId,o,!1),new W(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(e=>e.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let e=this.getScaleNotes("C4",1).map(i=>i.chromaticId),r=[];for(let i=0;i<e.length-1;i++)r.push(A.Math.mod(e[i+1]-e[i],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(e=>e===1?"H":e===2?"W":e.toString()+"H")}isScaleNote(e){return this.chromaticClassDegree[e.chromaticClass]!==void 0}isScaleRootNote(e){return String(this.chromaticClassDegree[e.chromaticClass])==="1"}getIntervalFromRootNote(e){let r=this.getScaleNotes("C0",1)[0];for(;e.chromaticId>=r.chromaticId+12;)e=new W(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new O(3,"Note is below rootNote.");let i=En.get(r,e);if(i===void 0)throw new O(3,"Interval is undefined.");return i}getPreferredChromaticNote(e){W.validateChromaticId(e);let r=this.preferredChromaticNoteCache.get(e);if(r)return r;let i=W.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new W(h.diatonicClass,h.accidental,i+1):h.noteLetter==="B"&&h.accidental>0?new W(h.diatonicClass,h.accidental,i-1):new W(h.diatonicClass,h.accidental,i)).find(h=>W.getChromaticClass(e)===h.chromaticClass),r)return this.preferredChromaticNoteCache.set(e,r),r;let s=Ng(e),a=s-2,c=s+2,l=this.getAccidentalType()===1?[0,-1,1,-2,2]:[0,1,-1,2,-2];for(let h=0;h<l.length;h++){let p=l[h];for(let m=Math.max(0,a);m<=c;m++)if(r=new W(m,p),e===r.chromaticId)return this.preferredChromaticNoteCache.set(e,r),r}return r=W.getChromaticNote(e),this.preferredChromaticNoteCache.set(e,r),r}},zt=class{constructor(t){this.type=t;d(this,"tonicList",[]);d(this,"scaleMap",new Map);let e=[],r=[],i=[];if(Og.forEach(s=>{try{let a=new jr(s,this.type);switch(a.getAccidentalType()){case 0:e.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;i.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),e.length===0)throw new O(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...i.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(t){let e=this.scaleMap.get(t);if(e)return e;throw new O(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},Ku=[new zt("Major"),new zt("Natural Minor"),new zt("Harmonic Minor"),"- Modes -",new zt("Ionian"),new zt("Dorian"),new zt("Phrygian"),new zt("Lydian"),new zt("Mixolydian"),new zt("Aeolian"),new zt("Locrian"),"- Pentatonic -",new zt("Major Pentatonic"),new zt("Minor Pentatonic"),"- Blues -",new zt("Major Hexatonic Blues"),new zt("Minor Hexatonic Blues"),new zt("Heptatonic Blues")];function Mg(){return Ku}var Ju=new Map;Ku.forEach(n=>{n instanceof zt&&Ju.set(n.getType(),n)});function $u(n){let t=Ju.get(n);if(t)return t;throw new O(3,`Invalid scaleType: ${n}`)}function kn(n){if(A.Is.isEnumValue(n,ri))return n;throw new O(3,`Invalid scaleType: "${n}"`)}function dr(n,t){let e,r;return t!==void 0?(e=n,r=kn(t)):(e=n.split(" ")[0],r=kn(n.substring(e.length+1))),$u(r).getScale(e)}var Dg=dr("C","Major");function Eg(){return Dg}var mr=(n,t)=>n.chromaticClass===t.chromaticClass,kg=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(n=>W.getNote(n+"0")),tl=new Map;function jg(n){let t=n.chromaticClass,e=tl.get(t);if(!e){if(e=kg.find(r=>mr(r,n)),!e)throw new O(1,`Invalid chord root note: ${n.formatOmitOctave(1)}`);tl.set(t,e)}return e}function Lg(n,t){let e=n.formatOmitOctave(0);return dr(e,"Major").getNoteByDegree(t)}function Pg(n){return A.Arr.removeDuplicatesCmp(n,mr)}var Fg=[{name:"5",degrees:[1,5]},{name:"",degrees:[1,3,5]},{name:"m",degrees:[1,"b3",5]},{name:"dim",degrees:[1,"b3","b5"]},{name:"aug",degrees:[1,3,"#5"]},{name:"sus2",degrees:[1,2,5]},{name:"sus4",degrees:[1,4,5]},{name:"6",degrees:[1,3,5,6]},{name:"m6",degrees:[1,"b3",5,6]},{name:"m(maj7)",degrees:[1,"b3",5,7]},{name:"7",degrees:[1,3,5,"b7"]},{name:"7\u266D5",degrees:[1,3,"b5","b7"]},{name:"7\u266F5",degrees:[1,3,"#5","b7"]},{name:"7sus2",degrees:[1,2,5,"b7"]},{name:"7sus4",degrees:[1,4,5,"b7"]},{name:"dim7",degrees:[1,"b3","b5","bb7"]},{name:"maj7",degrees:[1,3,5,7]},{name:"maj7\u266D5",degrees:[1,3,"b5",7]},{name:"maj7\u266F5",degrees:[1,3,"#5",7]},{name:"m7",degrees:[1,"b3",5,"b7"]},{name:"m7\u266D5",degrees:[1,"b3","b5","b7"]},{name:"m7\u266F5",degrees:[1,"b3","#5","b7"]},{name:"9",degrees:[1,3,5,"b7",9]},{name:"m9",degrees:[1,"b3",5,"b7",9]},{name:"7\u266F9",degrees:[1,3,5,"b7","#9"]},{name:"7\u266D9",degrees:[1,3,5,"b7","b9"]},{name:"11",degrees:[1,3,5,"b7",9,11]},{name:"m11",degrees:[1,"b3",5,"b7",9,11]},{name:"13",degrees:[1,3,5,"b7",9,11,13]},{name:"m13",degrees:[1,"b3",5,"b7",9,11,13]}];function Bg(n,t){return n.degrees.every(e=>e!==t)?!0:n.degrees.length>=4&&t===5||n.degrees.length>=6&&t===9||n.degrees.length>=7&&t===11}var Oi=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},tc=class n{constructor(t,e,r,i){this.chordInfo=t;this.rootNote=r;d(this,"name");d(this,"notes");d(this,"omitNotes");d(this,"slashBassNote");this.name=t.name;let o=e.slice();!o.some(a=>mr(a,i))&&o.push(i),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<t.degrees.length;a++){let c=t.degrees[a],u=this.notes[a]=Lg(this.rootNote,c),l=o.findIndex(h=>mr(h,u));if(l>=0)this.omitNotes[a]=!1,o.splice(l,1);else if(Bg(t,c))this.omitNotes[a]=!0;else throw new Oi("Missing chord note!");mr(i,u)&&(i=u)}if(o.length>0)if(o.every(a=>mr(a,i)))this.slashBassNote=i;else throw new Oi("Got some extra notes that are not bass note!");else this.slashBassNote=mr(i,this.rootNote)?void 0:i;if(t.name==="5"&&this.slashBassNote)throw new Oi("Power chord no bass note allowed!")}static getChords(t){let e=[],r=W.sort(t),i=r[0],o=Pg(r);for(let s=0;s<o.length;s++){let a=jg(o[s]);Fg.forEach(c=>{try{let u=new n(c,o,a,i),l=e.findIndex(h=>h.replaceWith(u));l>=0?e[l]=u:e.push(u)}catch(u){if(!(u instanceof Oi))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!mr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!mr(t.notes[e],this.notes[e])||t.omitNotes[e]!==this.omitNotes[e])return!1;return!0}toString(){let t=1,e=this.rootNote.formatOmitOctave(t),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(t):"";return e+this.name+r}getDegreeNotationString(){let t=1,e=this.slashBassNote?this.slashBassNote.formatOmitOctave(t)+" - ":"",r=this.omitNotes.map((i,o)=>this.getDegreeStr(o)+"("+(i?"-":this.getNoteStr(o))+")").join(" - ");return e+r}getOmittedDegreesString(){let t=this.omitNotes.map((e,r)=>e?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(e=>e!==void 0);return t.length>0?"Omits "+t.join(", "):""}getDegreeStr(t){return W.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var ec={list:[{name:"Standard",strings:["E2","A2","D3","G3","B3","E4"]},{name:"B Standard",strings:["B1","E2","A2","D3","F#3","B3"]},{name:"C Standard",strings:["C2","F2","A#2","D#3","G3","C4"]},{name:"D Modal",strings:["D2","A2","D3","G3","A3","D4"]},{name:"D Standard",strings:["D2","G2","C3","F3","A3","D4"]},{name:"D# Standard",strings:["D#2","G#2","C#3","F#3","A#3","D#4"]},{name:"Double Drop D",strings:["D2","A2","D3","G3","B3","D4"]},{name:"Drop B",strings:["B1","F#2","B2","E3","G#3","C#4"]},{name:"Drop C",strings:["C2","G2","C3","F3","A3","D4"]},{name:"Drop D",strings:["D2","A2","D3","G3","B3","E4"]},{name:"Low C",strings:["C2","G2","D3","G3","A3","D4"]},{name:"New Standard",strings:["C2","G2","D3","A3","E4","G4"]},{name:"Open A",strings:["E2","A2","C#3","E3","A3","E4"]},{name:"Open A Minor",strings:["E2","A2","E3","A3","C4","E4"]},{name:"Open C",strings:["C2","G2","C3","G3","C4","E4"]},{name:"Open C Minor",strings:["C2","G2","C3","G3","C4","D#4"]},{name:"Open D",strings:["D2","A2","D3","F#3","A3","D4"]},{name:"Open D Minor",strings:["D2","A2","D3","F3","A3","D4"]},{name:"Open E",strings:["E2","B2","E3","G#3","B3","E4"]},{name:"Open E Minor",strings:["E2","B2","E3","G3","B3","E4"]},{name:"Open G",strings:["D2","G2","D3","G3","B3","D4"]},{name:"Open G Minor",strings:["D2","G2","D3","G3","A#3","D4"]}]};var rc=(e=>(e[e.RightHanded=0]="RightHanded",e[e.LeftHanded=1]="LeftHanded",e))(rc||{}),Vg=0;function qg(n){if(A.Is.isEnumValue(n,rc))return n;throw new O(1,`Invalid handedness: ${n}`)}var jn=ec.list.map(n=>n.name),Wg=jn[0];function ic(n){if(jn.indexOf(n)<0)throw new O(1,`Invalid tuning name: ${n}`);return n}var el=new qu(100);function Ko(n){let t=el.get(n);if(!t){let e=ec.list.find(r=>r.name===n);if(!e)throw new O(1,`Invalid tuningName: ${n}`);if(t=e.strings.slice().reverse().map(r=>W.getNote(r)),!A.Is.isIntegerEq(t.length,6))throw new O(0,`Tuning has ${t.length} strings.`);el.set(n,t)}return t}var il=(n,t)=>n===t?0:n<t?-1:1,rl=12,Ug=12*11*9*7*5,Zt=(E=>(E.Whole="1n",E.WholeTriplet="1t",E.WholeDot="1.",E.Whole12Dots="1..",E.Whole3Dots="1...",E.Whole4Dots="1....",E.Whole5Dots="1.....",E.Whole6Dots="1......",E.Half="2n",E.HalfTriplet="2t",E.HalfDot="2.",E.Half2Dots="2..",E.Half3Dots="2...",E.Half4Dots="2....",E.Half5Dots="2.....",E.Quarter="4n",E.QuarterTriplet="4t",E.QuarterDot="4.",E.Quarter2Dots="4..",E.Quarter3Dots="4...",E.Quarter4Dots="4....",E.Eighth="8n",E.EighthTriplet="8t",E.EighthDot="8.",E.Eighth2Dots="8..",E.Eighth3Dots="8...",E.Sixteenth="16n",E.SixteenthTriplet="16t",E.SixteenthDot="16.",E.Sixteenth2Dots="16..",E.ThirtySecond="32n",E.ThirtySecondTriplet="32t",E.ThirtySecondDot="32.",E.SixtyFourth="64n",E.SixtyFourthTriplet="64t",E))(Zt||{});function ni(n){if(A.Is.isEnumValue(n,Zt))return n;throw new O(1,`Invalid noteLength: ${n}`)}var ee=class ee{constructor(t){d(this,"noteLength");d(this,"noteSize");d(this,"ticks");d(this,"flagCount");d(this,"dotCount");d(this,"maxDotCount");d(this,"isTriplet");d(this,"hasStem");d(this,"isSolid");if(this.noteLength=ni(t),this.noteSize=parseInt(t),this.isTriplet=t.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(ee.ShortestNoteSize/this.noteSize)),this.dotCount=A.Str.charCount(t,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=Ug*ee.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new O(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new O(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(t){let e=this.cache.get(t);return e||this.cache.set(t,e=new ee(t)),e}static create(t,e=0){let r=typeof t=="number"?t:this.get(t).noteSize;return this.get(r+(A.Is.isIntegerGte(e,1)?".".repeat(e):"n"))}static cmp(t,e){let r=t instanceof ee?t.noteSize:typeof t=="number"?t:ee.get(t).noteSize,i=e instanceof ee?e.noteSize:typeof e=="number"?e:ee.get(e).noteSize;return il(i,r)}static equals(t,e){let r=t instanceof ee?t.noteSize:typeof t=="number"?t:ee.get(t).noteSize,i=e instanceof ee?e.noteSize:typeof e=="number"?e:ee.get(e).noteSize;return r===i}};d(ee,"LongestNoteSize",Math.min(...A.Enum.getEnumValues(Zt).map(t=>parseInt(t)))),d(ee,"ShortestNoteSize",Math.max(...A.Enum.getEnumValues(Zt).map(t=>parseInt(t)))),d(ee,"cache",new Map);var Xt=ee;function Jo(n){if(A.Is.isObject(n)&&A.Is.isIntegerBetween(n.parts,2,rl)&&A.Is.isIntegerBetween(n.inTimeOf,2,rl))return n;throw new O(2,`Invalid tupletRatio ${JSON.stringify(n)}`)}var fr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},ii=class ii{constructor(t,e,r){d(this,"noteLength");d(this,"noteSize");d(this,"dotCount");d(this,"tupletRatio");d(this,"ticks");d(this,"flagCount");d(this,"hasStem");d(this,"isSolidNoteHead");this.noteLength=ni(t);let i=Xt.get(t);if(this.noteSize=i.noteSize,this.ticks=i.ticks,this.flagCount=i.flagCount,this.dotCount=e!=null?e:i.dotCount,this.hasStem=i.hasStem,this.isSolidNoteHead=i.isSolid,A.Is.isObject(r)?this.tupletRatio=Jo(r):i.isTriplet?this.tupletRatio=fr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new O(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>i.maxDotCount)throw new O(2,`Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);for(let o=this.ticks/2,s=1;s<=this.dotCount;s++,o/=2)this.ticks+=o;this.tupletRatio&&(this.ticks*=this.tupletRatio.inTimeOf/this.tupletRatio.parts)}toString(){let t=ii.NoteSymbolMap.get(this.noteSize),e=".".repeat(this.dotCount);return t?t+e:""+this.noteSize+(e.length>0?e:"n")}static get(t,e,r){if(e!==void 0||r!==void 0)return new ii(t,e,r);{let i=this.cache.get(t);return i||this.cache.set(t,i=new ii(t)),i}}static cmp(t,e){return il(t.ticks,e.ticks)}static equals(t,e){return t.ticks===e.ticks}};d(ii,"NoteSymbolMap",new Map([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),d(ii,"cache",new Map);var Qt=ii;var gr=class{constructor(...t){d(this,"beatCount");d(this,"beatSize");d(this,"beatLength");d(this,"measureTicks");d(this,"beamGroupCount");d(this,"beamGroupLength");if(t.length===1&&typeof t[0]=="string"){let r=t[0].split("/");this.beatCount=+r[0],this.beatSize=+r[1]}else if(t.length===2&&typeof t[0]=="number"&&typeof t[1]=="number")this.beatCount=t[0],this.beatSize=t[1];else throw new O(5,`Invalid args: ${t}`);if(A.Is.isIntegerGte(this.beatCount,1)){if(!A.Is.isIntegerGte(this.beatSize,1))throw new O(5,`Invalid beatSize: ${this.beatSize}`)}else throw new O(5,`Invalid beatCount: ${this.beatCount}`);let e=Xt.create(this.beatSize);if(this.beatLength=e.noteLength,this.measureTicks=this.beatCount*e.ticks,this.is(2,4)||this.is(3,4)||this.is(4,4)?this.beamGroupCount=this.beatCount:this.is(6,8)||this.is(9,8)?this.beamGroupCount=this.beatCount/3:(console.warn("Not necessarily an error, but unsupported time signature: "+this.toString()),this.beamGroupCount=1),this.beamGroupLength=this.measureTicks/this.beamGroupCount,!A.Is.isIntegerGte(this.beamGroupLength,1))throw new O(5,`Invalid beamGroupLength: ${this.beamGroupLength}`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},nc;function $o(){return nc||(nc=new gr(4,4)),nc}var oc;function ts(){return oc||(oc={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),oc}function sc(n){return Qt.get(n.options.beatLength,n.options.dotCount).toString()+"="+n.beatsPerMinute}function ac(n,t){return{beatsPerMinute:n.beatsPerMinute*t,options:{beatLength:n.options.beatLength,dotCount:n.options.dotCount}}}ei();var Ln="15.1.22";var uc=(n,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:n});var lc=(n,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:n});var Ri=(n,t)=>({startTime:t,type:"setValue",value:n});var Pn=(n,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:n});var es=(n,t,{startTime:e,target:r,timeConstant:i})=>r+(t-r)*Math.exp((e-n)/i);var yr=n=>n.type==="exponentialRampToValue";var oi=n=>n.type==="linearRampToValue";var Be=n=>yr(n)||oi(n);var Mi=n=>n.type==="setValue";var Te=n=>n.type==="setValueCurve";var Di=(n,t,e,r)=>{let i=n[t];return i===void 0?r:Be(i)||Mi(i)?i.value:Te(i)?i.values[i.values.length-1]:es(e,Di(n,t-1,i.startTime,r),i)};var hc=(n,t,e,r,i)=>e===void 0?[r.insertTime,i]:Be(e)?[e.endTime,e.value]:Mi(e)?[e.startTime,e.value]:Te(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,Di(n,t-1,e.startTime,i)];var Fn=n=>n.type==="cancelAndHold";var Bn=n=>n.type==="cancelScheduledValues";var xr=n=>Fn(n)||Bn(n)?n.cancelTime:yr(n)||oi(n)?n.endTime:n.startTime;var pc=(n,t,e,{endTime:r,value:i})=>e===i?i:0<e&&0<i||e<0&&i<0?e*Tu(i/e,(n-t)/(r-t)):0;var dc=(n,t,e,{endTime:r,value:i})=>e+(n-t)/(r-t)*(i-e);var nl=(n,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?n[e]:(1-(t-e))*n[e]+(1-(r-t))*n[r]};var ol=(n,{duration:t,startTime:e,values:r})=>{let i=(n-e)/t*(r.length-1);return nl(r,i)};var Gn=n=>n.type==="setTarget";var Vn=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=xr(t);if(Fn(t)||Bn(t)){let r=this._automationEvents.findIndex(o=>Bn(t)&&Te(o)?o.startTime+o.duration>=e:xr(o)>=e),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),Fn(t)){let o=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Be(i)){if(o!==void 0&&Gn(o))throw new Error("The internal list is malformed.");let s=o===void 0?i.insertTime:Te(o)?o.startTime+o.duration:xr(o),a=o===void 0?this._defaultValue:Te(o)?o.values[o.values.length-1]:o.value,c=yr(i)?pc(e,s,a,i):dc(e,s,a,i),u=yr(i)?uc(c,e,this._currenTime):lc(c,e,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Gn(o)&&this._automationEvents.push(Ri(this.getValue(e),e)),o!==void 0&&Te(o)&&o.startTime+o.duration>e){let s=e-o.startTime,a=(o.values.length-1)/o.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,l=o.values.slice(0,c);if(u<1)for(let h=1;h<c;h+=1){let p=u*h%1;l[h]=o.values[h-1]*(1-p)+o.values[h]*p}this._automationEvents[this._automationEvents.length-1]=Pn(l,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>xr(s)>e),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&Te(i)&&xr(i)+i.duration>e)return!1;let o=yr(t)?uc(t.value,t.endTime,this._currenTime):oi(t)?lc(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(o);else{if(Te(t)&&e+t.duration>xr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>xr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),i=r[0];Gn(i)&&r.unshift(Ri(Di(this._automationEvents,e-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=r}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;let e=this._automationEvents.findIndex(s=>xr(s)>t),r=this._automationEvents[e],i=(e===-1?this._automationEvents.length:e)-1,o=this._automationEvents[i];if(o!==void 0&&Gn(o)&&(r===void 0||!Be(r)||r.insertTime>t))return es(t,Di(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(o!==void 0&&Mi(o)&&(r===void 0||!Be(r)))return o.value;if(o!==void 0&&Te(o)&&(r===void 0||!Be(r)||o.startTime+o.duration>t))return t<o.startTime+o.duration?ol(t,o):o.values[o.values.length-1];if(o!==void 0&&Be(o)&&(r===void 0||!Be(r)))return o.value;if(r!==void 0&&yr(r)){let[s,a]=hc(this._automationEvents,i,o,r,this._defaultValue);return pc(t,s,a,r)}if(r!==void 0&&oi(r)){let[s,a]=hc(this._automationEvents,i,o,r,this._defaultValue);return dc(t,s,a,r)}return this._defaultValue}};var mc=n=>({cancelTime:n,type:"cancelAndHold"});var fc=n=>({cancelTime:n,type:"cancelScheduledValues"});var gc=(n,t)=>({endTime:t,type:"exponentialRampToValue",value:n});var yc=(n,t)=>({endTime:t,type:"linearRampToValue",value:n});var xc=(n,t,e)=>({startTime:t,target:n,timeConstant:e,type:"setTarget"});var sl=()=>new DOMException("","AbortError");var al=n=>(t,e,[r,i,o],s)=>{n(t[i],[e,r,o],a=>a[0]===e&&a[1]===r,s)};var cl=n=>(t,e,r)=>{let i=[];for(let o=0;o<r.numberOfInputs;o+=1)i.push(new Set);n.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var ul=n=>(t,e)=>{n.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var er=new WeakSet,rs=new WeakMap,Ei=new WeakMap,is=new WeakMap,qn=new WeakMap,ki=new WeakMap,ns=new WeakMap,Wn=new WeakMap,Un=new WeakMap,zn=new WeakMap;var ll={construct(){return ll}},hl=n=>{try{let t=new Proxy(n,ll);new t}catch(t){return!1}return!0};var pl=/^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]*);?/,bc=(n,t)=>{let e=[],r=n.replace(/^[\s]+/,""),i=r.match(pl);for(;i!==null;){let o=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,t).toString());e.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(pl)}return[e.join(";"),r]};var dl=n=>{if(n!==void 0&&!Array.isArray(n))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},ml=n=>{if(!hl(n))throw new TypeError("The given value for processorCtor should be a constructor.");if(n.prototype===null||typeof n.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},fl=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>{let m=0;return(f,g,y={credentials:"omit"})=>{let b=l.get(f);if(b!==void 0&&b.has(g))return Promise.resolve();let I=u.get(f);if(I!==void 0){let _=I.get(g);if(_!==void 0)return _}let S=o(f),w=S.audioWorklet===void 0?i(g).then(([_,v])=>{let[C,x]=bc(_,v),N=`${C};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${x}
|
|
3
|
-
})})(window,'_AWGS')`;return e(N)}).then(()=>{let _=p._AWGS.pop();if(_===void 0)throw new SyntaxError;r(S.currentTime,S.sampleRate,()=>_(class{},void 0,(v,C)=>{if(v.trim()==="")throw t();let x=
|
|
4
|
-
})(${C?"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{${C?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${C?"":"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${x}',class extends AudioWorkletProcessor{process(){return !1}})`,P=new Blob([k],{type:"application/javascript; charset=utf-8"}),F=URL.createObjectURL(P);return S.audioWorklet.addModule(F,y).then(()=>{if(a(S))return S;let V=s(S);return V.audioWorklet.addModule(F,y).then(()=>V)}).then(V=>{if(c===null)throw new SyntaxError;try{new c(V,`__sac${x}`)}catch(X){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(F))});return I===void 0?u.set(f,new Map([[g,w]])):I.set(g,w),w.then(()=>{let _=l.get(f);_===void 0?l.set(f,new Set([g])):_.add(g)}).finally(()=>{let _=u.get(f);_!==void 0&&_.delete(g)}),w}};var Gt=(n,t)=>{let e=n.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var Lr=(n,t)=>{let e=Array.from(n).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");let[r]=e;return n.delete(r),r};var os=(n,t,e,r)=>{let i=Gt(n,t),o=Lr(i,s=>s[0]===e&&s[1]===r);return i.size===0&&n.delete(t),o};var rr=n=>Gt(ns,n);var Ge=n=>{if(er.has(n))throw new Error("The AudioNode is already stored.");er.add(n),rr(n).forEach(t=>t(!0))};var ss=n=>"port"in n;var ir=n=>{if(!er.has(n))throw new Error("The AudioNode is not stored.");er.delete(n),rr(n).forEach(t=>t(!1))};var Yn=(n,t)=>{!ss(n)&&t.every(e=>e.size===0)&&ir(n)};var gl=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>{let m=new WeakMap;return(f,g,y,b,I)=>{let{activeInputs:S,passiveInputs:w}=o(g),{outputs:_}=o(f),v=a(f),C=x=>{let N=c(g),j=c(f);if(x){let R=os(w,f,y,b);n(S,f,R,!1),!I&&!h(f)&&e(j,N,y,b),p(g)&&Ge(g)}else{let R=r(S,f,y,b);t(w,b,R,!1),!I&&!h(f)&&i(j,N,y,b);let D=s(g);if(D===0)l(g)&&Yn(g,S);else{let U=m.get(g);U!==void 0&&clearTimeout(U),m.set(g,setTimeout(()=>{l(g)&&Yn(g,S)},D*1e3))}}};return u(_,[g,y,b],x=>x[0]===g&&x[1]===y&&x[2]===b,!0)?(v.add(C),l(f)?n(S,f,[y,b,C],!0):t(w,b,[f,y,C],!0),!0):!1}};var yl=n=>(t,e,[r,i,o],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[i,e,o]])):n(a,[i,e,o],c=>c[0]===i&&c[1]===e,s)};var xl=n=>(t,e)=>{let r=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(r).connect(t.destination);let i=()=>{e.removeEventListener("ended",i),e.disconnect(r),r.disconnect()};e.addEventListener("ended",i)};var bl=n=>(t,e)=>{n(t).add(e)};var zg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Al=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=M(M({},zg),c),h=r(u,l),p=o(u)?t():null;super(a,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){let c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){let c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}};var pt=(n,t)=>n.context===t;var Cl=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>Q(null,null,function*(){let a=t(o);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=n(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var ji=n=>{try{n.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var Ne=()=>new DOMException("","IndexSizeError");var Li=n=>{n.getChannelData=(t=>e=>{try{return t.call(n,e)}catch(r){throw r.code===12?Ne():r}})(n.getChannelData)};var Yg={numberOfChannels:1},_l=(n,t,e,r,i,o,s,a)=>{let c=null;return class vl{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:p,sampleRate:m}=M(M({},Yg),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&t(o,o)?new r({length:h,numberOfChannels:p,sampleRate:m}):c.createBuffer(p,h,m);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),Li(f)):t(ji,()=>ji(f))||a(f),n.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===vl.prototype||n.has(l)}}};var Lt=-34028234663852886e22,Dt=-Lt;var ae=n=>er.has(n);var Hg={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},Il=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=M(M({},Hg),l),m=i(h,p),f=s(h),g=f?t():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=e(this,f,m.playbackRate,Dt,Lt)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(u){if(this._nativeAudioBufferSourceNode.buffer=u,u!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(u){this._nativeAudioBufferSourceNode.loop=u}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(u){this._nativeAudioBufferSourceNode.loopEnd=u}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(u){this._nativeAudioBufferSourceNode.loopStart=u}get onended(){return this._onended}set onended(u){let l=typeof u=="function"?a(this,u):null;this._nativeAudioBufferSourceNode.onended=l;let h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===l?u:h}get playbackRate(){return this._playbackRate}start(u=0,l=0,h){if(this._nativeAudioBufferSourceNode.start(u,l,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[u,l]:[u,l,h]),this.context.state!=="closed"){Ge(this);let p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),ae(this)&&ir(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var Sl=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>Q(null,null,function*(){let h=e(u),p=pt(h,l);if(!p){let m={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=t(l,m),s!==null&&h.start(...s),a!==null&&h.stop(a)}return o.set(l,h),p?yield n(l,u.playbackRate,h.playbackRate):yield r(l,u.playbackRate,h.playbackRate),yield i(u,l,h),h});return{set start(u){s=u},set stop(u){a=u},render(u,l){let h=o.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var wl=n=>"playbackRate"in n;var Tl=n=>"frequency"in n&&"gain"in n;var Nl=n=>"offset"in n;var Ol=n=>!("frequency"in n)&&"gain"in n;var Rl=n=>"detune"in n&&"frequency"in n&&!("gain"in n);var Ml=n=>"pan"in n;var Yt=n=>Gt(rs,n);var Pr=n=>Gt(is,n);var as=(n,t)=>{let{activeInputs:e}=Yt(n);e.forEach(i=>i.forEach(([o])=>{t.includes(n)||as(o,[...t,n])}));let r=wl(n)?[n.playbackRate]:ss(n)?Array.from(n.parameters.values()):Tl(n)?[n.Q,n.detune,n.frequency,n.gain]:Nl(n)?[n.offset]:Ol(n)?[n.gain]:Rl(n)?[n.detune,n.frequency]:Ml(n)?[n.pan]:[];for(let i of r){let o=Pr(i);o!==void 0&&o.activeInputs.forEach(([s])=>as(s,t))}ae(n)&&ir(n)};var Fr=n=>{as(n.destination,[])};var cs=n=>n===void 0||typeof n=="number"||typeof n=="string"&&(n==="balanced"||n==="interactive"||n==="playback");var Dl=(n,t,e,r,i,o,s,a,c)=>class extends n{constructor(l={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(l)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?e():f}if(h===null)throw r();if(!cs(l.latencyHint))throw new TypeError(`The provided value '${l.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(l.sampleRate!==void 0&&h.sampleRate!==l.sampleRate)throw e();super(h,2);let{latencyHint:p}=l,{sampleRate:m}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/m:p==="interactive"||p===void 0?256/m:p==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(p*m/128)))*128/m,this._nativeAudioContext=h,c.name==="webkitAudioContext"?(this._nativeGainNode=h.createGain(),this._nativeOscillatorNode=h.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(h.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,h.state==="running"){this._state="suspended";let f=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",f)};h.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.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()),Fr(this)}))}createMediaElementSource(l){return new i(this,{mediaElement:l})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(l){return new s(this,{mediaStream:l})}createMediaStreamTrackSource(l){return new a(this,{mediaStreamTrack:l})}resume(){return this._state==="suspended"?new Promise((l,h)=>{let p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?l():this.resume().then(l,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(l=>{throw l===void 0||l.code===15?t():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?t():l})}};var El=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=s(h),m=i(h,l,p),f=p?t(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}};var kl=n=>{let t=new WeakMap,e=(r,i)=>Q(null,null,function*(){let o=i.destination;return t.set(i,o),yield n(r,i,o),o});return{render(r,i){let o=t.get(i);return o!==void 0?Promise.resolve(o):e(r,i)}}};var jl=(n,t,e,r,i,o,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let _=new Float32Array(1),v=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),C=s(u),x=!1,N=[0,0,-1,0,1,0],j=[0,0,0],R=()=>{if(x)return;x=!0;let P=r(u,256,9,0);P.onaudioprocess=({inputBuffer:F})=>{let V=[o(F,_,0),o(F,_,1),o(F,_,2),o(F,_,3),o(F,_,4),o(F,_,5)];V.some((E,tt)=>E!==N[tt])&&(l.setOrientation(...V),N=V);let X=[o(F,_,6),o(F,_,7),o(F,_,8)];X.some((E,tt)=>E!==j[tt])&&(l.setPosition(...X),j=X)},v.connect(P)},D=P=>F=>{F!==N[P]&&(N[P]=F,l.setOrientation(...N))},U=P=>F=>{F!==j[P]&&(j[P]=F,l.setPosition(...j))},k=(P,F,V)=>{let X=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:F});X.connect(v,0,P),X.start(),Object.defineProperty(X.offset,"defaultValue",{get(){return F}});let E=n({context:c},C,X.offset,Dt,Lt);return a(E,"value",tt=>()=>tt.call(E),tt=>ct=>{try{tt.call(E,ct)}catch(xt){if(xt.code!==9)throw xt}R(),C&&V(ct)}),E.cancelAndHoldAtTime=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.cancelAndHoldAtTime),E.cancelScheduledValues=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.cancelScheduledValues),E.exponentialRampToValueAtTime=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.exponentialRampToValueAtTime),E.linearRampToValueAtTime=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.linearRampToValueAtTime),E.setTargetAtTime=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.setTargetAtTime),E.setValueAtTime=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.setValueAtTime),E.setValueCurveAtTime=(tt=>C?()=>{throw i()}:(...ct)=>{let xt=tt.apply(E,ct);return R(),xt})(E.setValueCurveAtTime),E};return{forwardX:k(0,0,D(0)),forwardY:k(1,0,D(1)),forwardZ:k(2,-1,D(2)),positionX:k(6,0,U(0)),positionY:k(7,0,U(1)),positionZ:k(8,0,U(2)),upX:k(3,0,D(3)),upY:k(4,1,D(4)),upZ:k(5,0,D(5))}},{forwardX:p,forwardY:m,forwardZ:f,positionX:g,positionY:y,positionZ:b,upX:I,upY:S,upZ:w}=l.forwardX===void 0?h():l;return{get forwardX(){return p},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return y},get positionZ(){return b},get upX(){return I},get upY(){return S},get upZ(){return w}}};var si=n=>"context"in n;var Br=n=>si(n[0]);var Ve=(n,t,e,r)=>{for(let i of n)if(e(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return n.add(t),!0};var Ac=(n,t,[e,r],i)=>{Ve(n,[t,e,r],o=>o[0]===t&&o[1]===e,i)};var Cc=(n,[t,e,r],i)=>{let o=n.get(t);o===void 0?n.set(t,new Set([[e,r]])):Ve(o,[e,r],s=>s[0]===e,i)};var Oe=n=>"inputs"in n;var Pi=(n,t,e,r)=>{if(Oe(t)){let i=t.inputs[r];return n.connect(i,e,0),[i,e,0]}return n.connect(t,e,r),[t,e,r]};var _c=(n,t,e)=>{for(let r of n)if(r[0]===t&&r[1]===e)return n.delete(r),r;return null};var Ll=(n,t,e)=>Lr(n,r=>r[0]===t&&r[1]===e);var vc=(n,t)=>{if(!rr(n).delete(t))throw new Error("Missing the expected event listener.")};var Ic=(n,t,e)=>{let r=Gt(n,t),i=Lr(r,o=>o[0]===e);return r.size===0&&n.delete(t),i};var Fi=(n,t,e,r)=>{Oe(t)?n.disconnect(t.inputs[r],e,0):n.disconnect(t,e,r)};var Ct=n=>Gt(Ei,n);var ai=n=>Gt(qn,n);var br=n=>Wn.has(n);var Bi=n=>!er.has(n);var Sc=(n,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=n.createScriptProcessor(256,1,1),i=n.createGain(),o=n.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=n.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(n.destination),a.connect(i),a.disconnect(i),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,l=>l===1)?e(!0):e(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(n.destination)},a.start()}});var us=(n,t)=>{let e=new Map;for(let r of n)for(let i of r){let o=e.get(i);e.set(i,o===void 0?1:o+1)}e.forEach((r,i)=>t(i,r))};var ci=n=>"context"in n;var Pl=n=>{let t=new Map;n.connect=(e=>(r,i=0,o=0)=>{let s=ci(r)?e(r,i,o):e(r,i),a=t.get(r);return a===void 0?t.set(r,[{input:o,output:i}]):a.every(c=>c.input!==o||c.output!==i)&&a.push({input:o,output:i}),s})(n.connect.bind(n)),n.disconnect=(e=>(r,i,o)=>{if(e.apply(n),r===void 0)t.clear();else if(typeof r=="number")for(let[s,a]of t){let c=a.filter(u=>u.output!==r);c.length===0?t.delete(s):t.set(s,c)}else if(t.has(r))if(i===void 0)t.delete(r);else{let s=t.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==i&&(c.input!==o||o===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{ci(s)?n.connect(s,c.output,c.input):n.connect(s,c.output)})})(n.disconnect)};var Zg=(n,t,e,r)=>{let{activeInputs:i,passiveInputs:o}=Pr(t),{outputs:s}=Yt(n),a=rr(n),c=u=>{let l=Ct(n),h=ai(t);if(u){let p=Ic(o,n,e);Ac(i,n,p,!1),!r&&!br(n)&&l.connect(h,e)}else{let p=Ll(i,n,e);Cc(o,p,!1),!r&&!br(n)&&l.disconnect(h,e)}};return Ve(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),ae(n)?Ac(i,n,[e,c],!0):Cc(o,[n,e,c],!0),!0):!1},Xg=(n,t,e,r)=>{let{activeInputs:i,passiveInputs:o}=Yt(t),s=_c(i[r],n,e);return s===null?[os(o,n,e,r)[2],!1]:[s[2],!0]},Qg=(n,t,e)=>{let{activeInputs:r,passiveInputs:i}=Pr(t),o=_c(r,n,e);return o===null?[Ic(i,n,e)[1],!1]:[o[2],!0]},wc=(n,t,e,r,i)=>{let[o,s]=Xg(n,e,r,i);if(o!==null&&(vc(n,o),s&&!t&&!br(n)&&Fi(Ct(n),Ct(e),r,i)),ae(e)){let{activeInputs:a}=Yt(e);Yn(e,a)}},Tc=(n,t,e,r)=>{let[i,o]=Qg(n,e,r);i!==null&&(vc(n,i),o&&!t&&!br(n)&&Ct(n).disconnect(ai(e),r))},Kg=(n,t)=>{let e=Yt(n),r=[];for(let i of e.outputs)Br(i)?wc(n,t,...i):Tc(n,t,...i),r.push(i[0]);return e.outputs.clear(),r},Jg=(n,t,e)=>{let r=Yt(n),i=[];for(let o of r.outputs)o[1]===e&&(Br(o)?wc(n,t,...o):Tc(n,t,...o),i.push(o[0]),r.outputs.delete(o));return i},$g=(n,t,e,r,i)=>{let o=Yt(n);return Array.from(o.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Br(s)?wc(n,t,...s):Tc(n,t,...s),o.outputs.delete(s),s[0]))},Fl=(n,t,e,r,i,o,s,a,c,u,l,h,p,m,f,g)=>class extends u{constructor(b,I,S,w){super(S),this._context=b,this._nativeAudioNode=S;let _=l(b);h(_)&&e(Sc,()=>Sc(_,g))!==!0&&Pl(S),Ei.set(this,S),ns.set(this,new Set),b.state!=="closed"&&I&&Ge(this),n(this,w,S)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(b){this._nativeAudioNode.channelCount=b}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(b){this._nativeAudioNode.channelCountMode=b}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(b){this._nativeAudioNode.channelInterpretation=b}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(b,I=0,S=0){if(I<0||I>=this._nativeAudioNode.numberOfOutputs)throw i();let w=l(this._context),_=f(w);if(p(b)||m(b))throw o();if(si(b)){let x=Ct(b);try{let j=Pi(this._nativeAudioNode,x,I,S),R=Bi(this);(_||R)&&this._nativeAudioNode.disconnect(...j),this.context.state!=="closed"&&!R&&Bi(b)&&Ge(b)}catch(j){throw j.code===12?o():j}if(t(this,b,I,S,_)){let j=c([this],b);us(j,r(_))}return b}let v=ai(b);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,I),(_||Bi(this))&&this._nativeAudioNode.disconnect(v,I)}catch(x){throw x.code===12?o():x}if(Zg(this,b,I,_)){let x=c([this],b);us(x,r(_))}}disconnect(b,I,S){let w,_=l(this._context),v=f(_);if(b===void 0)w=Kg(this,v);else if(typeof b=="number"){if(b<0||b>=this.numberOfOutputs)throw i();w=Jg(this,v,b)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||si(b)&&S!==void 0&&(S<0||S>=b.numberOfInputs))throw i();if(w=$g(this,v,b,I,S),w.length===0)throw o()}for(let C of w){let x=c([this],C);us(x,a)}}};var Bl=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>(m,f,g,y=null,b=null)=>{let I=g.value,S=new Vn(I),w=f?r(S):null,_={get defaultValue(){return I},get maxValue(){return y===null?g.maxValue:y},get minValue(){return b===null?g.minValue:b},get value(){return g.value},set value(v){g.value=v,_.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")w===null&&S.flush(m.context.currentTime),S.add(i(v)),g.cancelAndHoldAtTime(v);else{let C=Array.from(S).pop();w===null&&S.flush(m.context.currentTime),S.add(i(v));let x=Array.from(S).pop();g.cancelScheduledValues(v),C!==x&&x!==void 0&&(x.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(x.value,x.endTime):x.type==="linearRampToValue"?g.linearRampToValueAtTime(x.value,x.endTime):x.type==="setValue"?g.setValueAtTime(x.value,x.startTime):x.type==="setValueCurve"&&g.setValueCurveAtTime(x.values,x.startTime,x.duration))}return _},cancelScheduledValues(v){return w===null&&S.flush(m.context.currentTime),S.add(o(v)),g.cancelScheduledValues(v),_},exponentialRampToValueAtTime(v,C){if(v===0)throw new RangeError;if(!Number.isFinite(C)||C<0)throw new RangeError;let x=m.context.currentTime;return w===null&&S.flush(x),Array.from(S).length===0&&(S.add(u(I,x)),g.setValueAtTime(I,x)),S.add(s(v,C)),g.exponentialRampToValueAtTime(v,C),_},linearRampToValueAtTime(v,C){let x=m.context.currentTime;return w===null&&S.flush(x),Array.from(S).length===0&&(S.add(u(I,x)),g.setValueAtTime(I,x)),S.add(a(v,C)),g.linearRampToValueAtTime(v,C),_},setTargetAtTime(v,C,x){return w===null&&S.flush(m.context.currentTime),S.add(c(v,C,x)),g.setTargetAtTime(v,C,x),_},setValueAtTime(v,C){return w===null&&S.flush(m.context.currentTime),S.add(u(v,C)),g.setValueAtTime(v,C),_},setValueCurveAtTime(v,C,x){let N=v instanceof Float32Array?v:new Float32Array(v);if(h!==null&&h.name==="webkitAudioContext"){let j=C+x,R=m.context.sampleRate,D=Math.ceil(C*R),U=Math.floor(j*R),k=U-D,P=new Float32Array(k);for(let V=0;V<k;V+=1){let X=(N.length-1)/x*((D+V)/R-C),E=Math.floor(X),tt=Math.ceil(X);P[V]=E===tt?N[E]:(1-(X-E))*N[E]+(1-(tt-X))*N[tt]}w===null&&S.flush(m.context.currentTime),S.add(l(P,C,x)),g.setValueCurveAtTime(P,C,x);let F=U/R;F<j&&p(_,P[P.length-1],F),p(_,N[N.length-1],j)}else w===null&&S.flush(m.context.currentTime),S.add(l(N,C,x)),g.setValueCurveAtTime(N,C,x);return _}};return e.set(_,g),t.set(_,m),n(_,w),_};var Gl=n=>({replay(t){for(let e of n)if(e.type==="exponentialRampToValue"){let{endTime:r,value:i}=e;t.exponentialRampToValueAtTime(i,r)}else if(e.type==="linearRampToValue"){let{endTime:r,value:i}=e;t.linearRampToValueAtTime(i,r)}else if(e.type==="setTarget"){let{startTime:r,target:i,timeConstant:o}=e;t.setTargetAtTime(i,r,o)}else if(e.type==="setValue"){let{startTime:r,value:i}=e;t.setValueAtTime(i,r)}else if(e.type==="setValueCurve"){let{duration:r,startTime:i,values:o}=e;t.setValueCurveAtTime(o,i,r)}else throw new Error("Can't apply an unknown automation.")}});var Gi=class{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((r,i)=>t.call(e,r,i,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}};var ty={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},Vl=(n,t,e,r,i,o,s,a,c,u,l,h,p,m)=>class extends t{constructor(g,y,b){var I;let S=a(g),w=c(S),_=l(M(M({},ty),b));p(_);let v=Un.get(S),C=v==null?void 0:v.get(y),x=w||S.state!=="closed"?S:(I=s(S))!==null&&I!==void 0?I:S,N=i(x,w?null:g.baseLatency,u,y,C,_),j=w?r(y,_,C):null;super(g,!0,N,j);let R=[];N.parameters.forEach((U,k)=>{let P=e(this,w,U);R.push([k,P])}),this._nativeAudioWorkletNode=N,this._onprocessorerror=null,this._parameters=new Gi(R),w&&n(S,this);let{activeInputs:D}=o(this);h(N,D)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let y=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=y;let b=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=b!==null&&b===y?g:b}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Vi(n,t,e,r,i){if(typeof n.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),n.copyFromChannel(t[e],r,i);else{let o=n.getChannelData(r);if(t[e].byteLength===0)t[e]=o.slice(i,i+128);else{let s=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var ls=(n,t,e,r,i)=>{typeof n.copyToChannel=="function"?t[e].byteLength!==0&&n.copyToChannel(t[e],r,i):t[e].byteLength!==0&&n.getChannelData(r).set(t[e],i)};var qi=(n,t)=>{let e=[];for(let r=0;r<n;r+=1){let i=[],o=typeof t=="number"?t:t[r];for(let s=0;s<o;s+=1)i.push(new Float32Array(128));e.push(i)}return e};var ql=(n,t)=>{let e=Gt(zn,n),r=Ct(t);return Gt(e,r)};var ey=(n,t,e,r,i,o,s)=>Q(null,null,function*(){let a=t===null?Math.ceil(n.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((y,b)=>y+b,0),l=u===0?null:e.createBuffer(u,a,e.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let h=Yt(n),p=yield ql(e,n),m=qi(r.numberOfInputs,r.channelCount),f=qi(r.numberOfOutputs,i),g=Array.from(n.parameters.keys()).reduce((y,b)=>Z(M({},y),{[b]:new Float32Array(128)}),{});for(let y=0;y<a;y+=128){if(r.numberOfInputs>0&&t!==null)for(let b=0;b<r.numberOfInputs;b+=1)for(let I=0;I<r.channelCount;I+=1)Vi(t,m[b],I,I,y);o.parameterDescriptors!==void 0&&t!==null&&o.parameterDescriptors.forEach(({name:b},I)=>{Vi(t,g,b,c+I,y)});for(let b=0;b<r.numberOfInputs;b+=1)for(let I=0;I<i[b];I+=1)f[b][I].byteLength===0&&(f[b][I]=new Float32Array(128));try{let b=m.map((S,w)=>h.activeInputs[w].size===0?[]:S),I=s(y/e.sampleRate,e.sampleRate,()=>p.process(b,f,g));if(l!==null)for(let S=0,w=0;S<r.numberOfOutputs;S+=1){for(let _=0;_<i[S];_+=1)ls(l,f[S],_,w+_,y);w+=i[S]}if(!I)break}catch(b){n.dispatchEvent(new ErrorEvent("processorerror",{colno:b.colno,filename:b.filename,lineno:b.lineno,message:b.message}));break}}return l}),Wl=(n,t,e,r,i,o,s,a,c,u,l,h,p,m,f,g)=>(y,b,I)=>{let S=new WeakMap,w=null,_=(v,C)=>Q(null,null,function*(){let x=l(v),N=null,j=pt(x,C),R=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(h===null){let D=R.reduce((F,V)=>F+V,0),U=i(C,{channelCount:Math.max(1,D),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,D)}),k=[];for(let F=0;F<v.numberOfOutputs;F+=1)k.push(r(C,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:R[F]}));let P=s(C,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1});P.connect=t.bind(null,k),P.disconnect=c.bind(null,k),N=[U,k,P]}else j||(x=new h(C,y));if(S.set(C,N===null?x:N[2]),N!==null){if(w===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let V=v.channelCount*v.numberOfInputs,X=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,E=V+X;w=ey(v,E===0?null:yield Q(null,null,function*(){let ct=new p(E,Math.ceil(v.context.length/128)*128,C.sampleRate),xt=[],jt=[];for(let At=0;At<b.numberOfInputs;At+=1)xt.push(s(ct,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),jt.push(i(ct,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let be=yield Promise.all(Array.from(v.parameters.values()).map(At=>Q(null,null,function*(){let nt=o(ct,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:At.value});return yield m(ct,At,nt.offset),nt}))),Ae=r(ct,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,V+X)});for(let At=0;At<b.numberOfInputs;At+=1){xt[At].connect(jt[At]);for(let nt=0;nt<b.channelCount;nt+=1)jt[At].connect(Ae,nt,At*b.channelCount+nt)}for(let[At,nt]of be.entries())nt.connect(Ae,0,V+At),nt.start(0);return Ae.connect(ct.destination),yield Promise.all(xt.map(At=>f(v,ct,At))),g(ct)}),C,b,R,I,u)}let D=yield w,U=e(C,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[k,P,F]=N;D!==null&&(U.buffer=D,U.start(0)),U.connect(k);for(let V=0,X=0;V<v.numberOfOutputs;V+=1){let E=P[V];for(let tt=0;tt<R[V];tt+=1)k.connect(E,X+tt,tt);X+=R[V]}return F}if(j)for(let[D,U]of v.parameters.entries())yield n(C,U,x.parameters.get(D));else for(let[D,U]of v.parameters.entries())yield m(C,U,x.parameters.get(D));return yield f(v,C,x),x});return{render(v,C){a(C,v);let x=S.get(C);return x!==void 0?Promise.resolve(x):_(v,C)}}};var Ul=(n,t,e,r,i,o,s,a,c,u,l,h,p,m,f,g,y,b,I,S)=>class extends f{constructor(_,v){super(_,v),this._nativeContext=_,this._audioWorklet=n===void 0?void 0:{addModule:(C,x)=>n(this,C,x)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(_,v,C){return new e({length:v,numberOfChannels:_,sampleRate:C})}createBufferSource(){return new r(this)}createChannelMerger(_=6){return new o(this,{numberOfInputs:_})}createChannelSplitter(_=6){return new s(this,{numberOfOutputs:_})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(_=1){return new l(this,{maxDelayTime:_})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(_,v){return new m(this,{feedback:v,feedforward:_})}createOscillator(){return new g(this)}createPanner(){return new y(this)}createPeriodicWave(_,v,C={disableNormalization:!1}){return new b(this,Z(M({},C),{imag:v,real:_}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new S(this)}decodeAudioData(_,v,C){return u(this._nativeContext,_).then(x=>(typeof v=="function"&&v(x),x),x=>{throw typeof C=="function"&&C(x),x})}};var ry={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},zl=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=M(M({},ry),l),m=i(h,p),f=s(h),g=f?e():null;super(u,!1,m,g),this._Q=t(this,f,m.Q,Dt,Lt),this._detune=t(this,f,m.detune,1200*Math.log2(Dt),-1200*Math.log2(Dt)),this._frequency=t(this,f,m.frequency,u.sampleRate/2,0),this._gain=t(this,f,m.gain,40*Math.log10(Dt),Lt),this._nativeBiquadFilterNode=m,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(u){this._nativeBiquadFilterNode.type=u}getFrequencyResponse(u,l,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(u,l,h)}catch(p){throw p.code===11?r():p}if(u.length!==l.length||l.length!==h.length)throw r()}};var Yl=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>Q(null,null,function*(){let u=e(a),l=pt(u,c);if(!l){let h={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,h)}return o.set(c,u),l?(yield n(c,a.Q,u.Q),yield n(c,a.detune,u.detune),yield n(c,a.frequency,u.frequency),yield n(c,a.gain,u.gain)):(yield r(c,a.Q,u.Q),yield r(c,a.detune,u.detune),yield r(c,a.frequency,u.frequency),yield r(c,a.gain,u.gain)),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Hl=(n,t)=>(e,r)=>{let i=t.get(e);if(i!==void 0)return i;let o=n.get(e);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(n.set(e,s),s.catch(()=>!1).then(a=>(n.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var iy={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Zl=(n,t,e,r,i)=>class extends n{constructor(s,a){let c=r(s),u=M(M({},iy),a),l=e(c,u),h=i(c)?t():null;super(s,!1,l,h)}};var Xl=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>Q(null,null,function*(){let a=t(o);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=n(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var ny={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Ql=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=o(M(M({},ny),c)),h=e(u,l),p=i(u)?t():null;super(a,!1,h,p)}};var Kl=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>Q(null,null,function*(){let a=t(o);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=n(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var Jl=n=>(t,e,r)=>n(e,t,r);var $l=n=>(t,e,r=0,i=0)=>{let o=t[r];if(o===void 0)throw n();return ci(e)?o.connect(e,0,i):o.connect(e,0)};var th=n=>(t,e)=>{let r=n(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=t.createBuffer(1,2,44100);return r.buffer=i,r.loop=!0,r.connect(e),r.start(),()=>{r.stop(),r.disconnect(e)}};var oy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},eh=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},oy),u),p=r(l,h),m=o(l),f=m?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,m,p.offset,Dt,Lt),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeConstantSourceNode.onended=u;let l=this._nativeConstantSourceNode.onended;this._onended=l!==null&&l===u?c:l}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){Ge(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),ae(this)&&ir(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var rh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>Q(null,null,function*(){let h=e(u),p=pt(h,l);if(!p){let m={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,m),s!==null&&h.start(s),a!==null&&h.stop(a)}return o.set(l,h),p?yield n(l,u.offset,h.offset):yield r(l,u.offset,h.offset),yield i(u,l,h),h});return{set start(u){s=u},set stop(u){a=u},render(u,l){let h=o.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var ih=n=>t=>(n[0]=t,n[0]);var sy={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},nh=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=M(M({},sy),c),h=e(u,l),m=i(u)?t():null;super(a,!1,h,m),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&o(this,l.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){let c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var oh=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>Q(null,null,function*(){let a=t(o);if(!pt(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=n(s,u)}return r.set(s,a),Oe(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var sh=(n,t)=>(e,r,i)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,i)}catch(o){throw o.name==="SyntaxError"?n():o}};var ah=()=>new DOMException("","DataCloneError");var Nc=n=>{let{port1:t,port2:e}=new MessageChannel;return new Promise(r=>{let i=()=>{e.onmessage=null,t.close(),e.close(),r()};e.onmessage=()=>i();try{t.postMessage(n,[n])}catch(o){}finally{i()}})};var ch=(n,t,e,r,i,o,s,a,c,u,l)=>(h,p)=>{let m=s(h)?h:o(h);if(i.has(p)){let f=e();return Promise.reject(f)}try{i.add(p)}catch(f){}return t(c,()=>c(m))?m.decodeAudioData(p).then(f=>(Nc(p).catch(()=>{}),t(a,()=>a(f))||l(f),n.add(f),f)):new Promise((f,g)=>{let y=()=>Q(null,null,function*(){try{yield Nc(p)}catch(I){}}),b=I=>{g(I),y()};try{m.decodeAudioData(p,I=>{typeof I.copyFromChannel!="function"&&(u(I),Li(I)),n.add(I),y().then(()=>f(I))},I=>{b(I===null?r():I)})}catch(I){b(I)}})};var uh=(n,t,e,r,i,o,s,a)=>(c,u)=>{let l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=o(c.context),p=a(h);if(l===u){if(t.delete(c),!p&&s(c)){let m=r(c),{outputs:f}=e(c);for(let g of f)if(Br(g)){let y=r(g[0]);n(m,y,g[1],g[2])}else{let y=i(g[0]);m.connect(y,g[1])}}}else t.set(c,l-u)};var ay={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},lh=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},ay),u),p=r(l,h),m=o(l),f=m?e(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,m,p.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var hh=(n,t,e,r,i)=>o=>{let s=new WeakMap,a=(c,u)=>Q(null,null,function*(){let l=e(c),h=pt(l,u);if(!h){let p={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=t(u,p)}return s.set(u,l),h?yield n(u,c.delayTime,l.delayTime):yield r(u,c.delayTime,l.delayTime),yield i(c,u,l),l});return{render(c,u){let l=s.get(u);return l!==void 0?Promise.resolve(l):a(c,u)}}};var ph=n=>(t,e,r,i)=>n(t[i],o=>o[0]===e&&o[1]===r);var dh=n=>(t,e)=>{n(t).delete(e)};var mh=n=>"delayTime"in n;var fh=(n,t,e)=>function r(i,o){let s=si(o)?o:e(n,o);if(mh(s))return[];if(i[0]===s)return[i];if(i.includes(s))return[];let{outputs:a}=t(s);return Array.from(a).map(c=>r([...i,s],c[0])).reduce((c,u)=>c.concat(u),[])};var hs=(n,t,e)=>{let r=t[e];if(r===void 0)throw n();return r},gh=n=>(t,e=void 0,r=void 0,i=0)=>e===void 0?t.forEach(o=>o.disconnect()):typeof e=="number"?hs(n,t,e).disconnect():ci(e)?r===void 0?t.forEach(o=>o.disconnect(e)):i===void 0?hs(n,t,r).disconnect(e,0):hs(n,t,r).disconnect(e,0,i):r===void 0?t.forEach(o=>o.disconnect(e)):hs(n,t,r).disconnect(e,0);var cy={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},yh=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=M(M({},cy),l),m=r(h,p),f=s(h),g=f?e():null;super(u,!1,m,g),this._attack=t(this,f,m.attack),this._knee=t(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=t(this,f,m.ratio),this._release=t(this,f,m.release),this._threshold=t(this,f,m.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){let l=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=l,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(u){let l=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=u,u==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=l,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}};var xh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>Q(null,null,function*(){let u=e(a),l=pt(u,c);if(!l){let h={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,h)}return o.set(c,u),l?(yield n(c,a.attack,u.attack),yield n(c,a.knee,u.knee),yield n(c,a.ratio,u.ratio),yield n(c,a.release,u.release),yield n(c,a.threshold,u.threshold)):(yield r(c,a.attack,u.attack),yield r(c,a.knee,u.knee),yield r(c,a.ratio,u.ratio),yield r(c,a.release,u.release),yield r(c,a.threshold,u.threshold)),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var bh=()=>new DOMException("","EncodingError");var Ah=n=>t=>new Promise((e,r)=>{if(n===null){r(new SyntaxError);return}let i=n.document.head;if(i===null)r(new SyntaxError);else{let o=n.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=n.onerror,u=()=>{n.onerror=c,URL.revokeObjectURL(a)};n.onerror=(l,h,p,m,f)=>{if(h===a||h===n.location.href&&p===1&&m===1)return u(),r(f),!1;if(c!==null)return c(l,h,p,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),e()},o.src=a,o.type="module",i.appendChild(o)}});var Ch=n=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,i){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=n(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(e,o,i)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,i){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,o===void 0?null:o,i)}};var _h=n=>(t,e,r)=>{Object.defineProperties(n,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{n!==null&&(delete n.currentFrame,delete n.currentTime)}};var vh=n=>t=>Q(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw n()});var uy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Ih=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=M(M({},uy),c),h=r(u,l),p=o(u),m=p?e():null;super(a,!1,h,m),this._gain=t(this,p,h.gain,Dt,Lt)}get gain(){return this._gain}};var Sh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>Q(null,null,function*(){let u=e(a),l=pt(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,h)}return o.set(c,u),l?yield n(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var wh=(n,t)=>e=>t(n,e);var Th=n=>t=>{let e=n(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var Nh=n=>t=>{var e;return(e=n.get(t))!==null&&e!==void 0?e:0};var Oh=n=>t=>{let e=n(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var Rh=n=>t=>n.get(t);var wt=()=>new DOMException("","InvalidStateError");var Mh=n=>t=>{let e=n.get(t);if(e===void 0)throw wt();return e};var Dh=(n,t)=>e=>{let r=n.get(e);if(r!==void 0)return r;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new t(1,1,44100),n.set(e,r),r};var Eh=n=>t=>{let e=n.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var Wi=()=>new DOMException("","InvalidAccessError");var kh=n=>{n.getFrequencyResponse=(t=>(e,r,i)=>{if(e.length!==r.length||r.length!==i.length)throw Wi();return t.call(n,e,r,i)})(n.getFrequencyResponse)};var ly={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},jh=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=i(u),h=M(M({},ly),c),p=t(u,l?null:a.baseLatency,h),m=l?e(h.feedback,h.feedforward):null;super(a,!1,p,m),kh(p),this._nativeIIRFilterNode=p,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var ps=(n,t,e,r,i,o,s,a,c,u,l)=>{let h=u.length,p=a;for(let m=0;m<h;m+=1){let f=e[0]*u[m];for(let g=1;g<i;g+=1){let y=p-g&c-1;f+=e[g]*o[y],f-=n[g]*s[y]}for(let g=i;g<r;g+=1)f+=e[g]*o[p-g&c-1];for(let g=i;g<t;g+=1)f-=n[g]*s[p-g&c-1];o[p]=u[m],s[p]=f,p=p+1&c-1,l[m]=f}return p};var hy=(n,t,e,r)=>{let i=e instanceof Float64Array?e:new Float64Array(e),o=r instanceof Float64Array?r:new Float64Array(r),s=i.length,a=o.length,c=Math.min(s,a);if(i[0]!==1){for(let f=0;f<s;f+=1)o[f]/=i[0];for(let f=1;f<a;f+=1)i[f]/=i[0]}let u=32,l=new Float32Array(u),h=new Float32Array(u),p=t.createBuffer(n.numberOfChannels,n.length,n.sampleRate),m=n.numberOfChannels;for(let f=0;f<m;f+=1){let g=n.getChannelData(f),y=p.getChannelData(f);l.fill(0),h.fill(0),ps(i,s,o,a,c,l,h,0,u,g,y)}return p},Lh=(n,t,e,r,i)=>(o,s)=>{let a=new WeakMap,c=null,u=(l,h)=>Q(null,null,function*(){let p=null,m=t(l),f=pt(m,h);if(h.createIIRFilter===void 0?p=n(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(m=h.createIIRFilter(s,o)),a.set(h,p===null?m:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let y=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=Q(null,null,function*(){yield r(l,y,y.destination);let b=yield i(y);return hy(b,h,o,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(l,h,m),m});return{render(l,h){let p=a.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Ph=(n,t,e,r,i,o)=>s=>(a,c)=>{let u=n.get(a);if(u===void 0){if(!s&&o(a)){let l=r(a),{outputs:h}=e(a);for(let p of h)if(Br(p)){let m=r(p[0]);t(l,m,p[1],p[2])}else{let m=i(p[0]);l.disconnect(m,p[1])}}n.set(a,c)}else n.set(a,u+c)};var Fh=(n,t)=>e=>{let r=n.get(e);return t(r)||t(e)};var Bh=(n,t)=>e=>n.has(e)||t(e);var Gh=(n,t)=>e=>n.has(e)||t(e);var Vh=(n,t)=>e=>{let r=n.get(e);return t(r)||t(e)};var qh=n=>t=>n!==null&&t instanceof n;var Wh=n=>t=>n!==null&&typeof n.AudioNode=="function"&&t instanceof n.AudioNode;var Uh=n=>t=>n!==null&&typeof n.AudioParam=="function"&&t instanceof n.AudioParam;var zh=(n,t)=>e=>n(e)||t(e);var Yh=n=>t=>n!==null&&t instanceof n;var Hh=n=>n!==null&&n.isSecureContext;var Zh=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var py={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Xh=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o);if(r(a))throw new TypeError;let c=M(M({},py),s),u=t(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Qh=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var Kh=(n,t,e)=>class extends n{constructor(i,o){let s=e(i),a=t(s,o);super(i,!0,a,null)}};var Jh=(n,t,e,r,i)=>class extends r{constructor(s={}){if(i===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new i(s)}catch(l){throw l.code===12&&l.message==="sampleRate is not in range"?t():l}if(a===null)throw e();if(!cs(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw t();super(a,2);let{latencyHint:c}=s,{sampleRate:u}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/u:c==="interactive"||c===void 0?256/u:c==="playback"?1024/u:Math.max(2,Math.min(128,Math.round(c*u/128)))*128/u,this._nativeAudioContext=a,i.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";let l=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",l)};a.addEventListener("statechange",l)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw n()}):(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()),Fr(this)}))}resume(){return this._state==="suspended"?new Promise((s,a)=>{let c=()=>{this._nativeAudioContext.removeEventListener("statechange",c),this._nativeAudioContext.state==="running"?s():this.resume().then(s,a)};this._nativeAudioContext.addEventListener("statechange",c)}):this._nativeAudioContext.resume().catch(s=>{throw s===void 0||s.code===15?n():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?n():s})}};var $h=(n,t,e,r,i,o)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,ki.set(this,a),r(a)&&i.set(a,new Set),this._destination=new n(this,c),this._listener=t(this,a),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(a){let c=typeof a=="function"?o(this,a):null;this._nativeContext.onstatechange=c;let u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?a:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}};var qe=n=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=n.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var dy={numberOfChannels:1},tp=(n,t,e,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=M(M({},dy),s),l=e(c,a,u);n(qe,()=>qe(l))||l.addEventListener("statechange",(()=>{let h=0,p=m=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",p),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):h+=1)};return p})()),super(l,c),this._length=a,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(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Fr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var ep=(n,t)=>(e,r,i)=>{let o=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let l=o.size===0;if(t(a))return s.call(e,a,c,u),n(o,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(e,a,c),n(o,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let l=o.size>0;if(a===void 0)s.apply(e),o.clear();else if(typeof a=="number"){s.call(e,a);for(let p of o)p[1]===a&&o.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of o)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&o.delete(p)}let h=o.size===0;l&&h&&i()})(e.disconnect),e};var dt=(n,t,e)=>{let r=t[e];r!==void 0&&r!==n[e]&&(n[e]=r)};var ut=(n,t)=>{dt(n,t,"channelCount"),dt(n,t,"channelCountMode"),dt(n,t,"channelInterpretation")};var Oc=n=>typeof n.getFloatTimeDomainData=="function";var rp=n=>{n.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);n.getByteTimeDomainData(e);let r=Math.max(e.length,n.fftSize);for(let i=0;i<r;i+=1)t[i]=(e[i]-128)*.0078125;return t}};var ip=(n,t)=>(e,r)=>{let i=e.createAnalyser();if(ut(i,r),!(r.maxDecibels>r.minDecibels))throw t();return dt(i,r,"fftSize"),dt(i,r,"maxDecibels"),dt(i,r,"minDecibels"),dt(i,r,"smoothingTimeConstant"),n(Oc,()=>Oc(i))||rp(i),i};var np=n=>n===null?null:n.hasOwnProperty("AudioBuffer")?n.AudioBuffer:null;var yt=(n,t,e)=>{let r=t[e];r!==void 0&&r!==n[e].value&&(n[e].value=r)};var op=n=>{n.start=(t=>{let e=!1;return(r=0,i=0,o)=>{if(e)throw wt();t.call(n,r,i,o),e=!0}})(n.start)};var Ui=n=>{n.start=(t=>(e=0,r=0,i)=>{if(typeof i=="number"&&i<0||r<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(n,e,r,i)})(n.start)};var zi=n=>{n.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(n,e)})(n.stop)};var sp=(n,t,e,r,i,o,s,a,c,u,l)=>(h,p)=>{let m=h.createBufferSource();return ut(m,p),yt(m,p,"playbackRate"),dt(m,p,"buffer"),dt(m,p,"loop"),dt(m,p,"loopEnd"),dt(m,p,"loopStart"),t(e,()=>e(h))||op(m),t(r,()=>r(h))||c(m),t(i,()=>i(h))||u(m,h),t(o,()=>o(h))||Ui(m),t(s,()=>s(h))||l(m,h),t(a,()=>a(h))||zi(m),n(h,m),m};var ap=n=>n===null?null:n.hasOwnProperty("AudioContext")?n.AudioContext:n.hasOwnProperty("webkitAudioContext")?n.webkitAudioContext:null;var cp=(n,t)=>(e,r,i)=>{let o=e.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}i&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=n(e,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>o.maxChannelCount}),s.connect(o),s};var up=n=>n===null?null:n.hasOwnProperty("AudioWorkletNode")?n.AudioWorkletNode:null;var lp=n=>{let{port1:t}=new MessageChannel;try{t.postMessage(n)}finally{t.close()}};var hp=(n,t,e,r,i)=>(o,s,a,c,u,l)=>{if(a!==null)try{let h=new a(o,c,l),p=new Map,m=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw n()}},channelCountMode:{get:()=>"explicit",set:()=>{throw n()}},onprocessorerror:{get:()=>m,set:f=>{typeof m=="function"&&h.removeEventListener("processorerror",m),m=typeof f=="function"?f:null,typeof m=="function"&&h.addEventListener("processorerror",m)}}}),h.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let y=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(y!==null){let b=p.get(g[1]);b!==void 0?g[1]=b:(g[1]=I=>{I.type==="error"?(Object.defineProperties(I,{type:{value:"processorerror"}}),y(I)):y(new ErrorEvent(g[0],M({},I)))},p.set(y,g[1]))}}return f.call(h,"error",g[1],g[2]),f.call(h,...g)})(h.addEventListener),h.removeEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let y=p.get(g[1]);y!==void 0&&(p.delete(g[1]),g[1]=y)}return f.call(h,"error",g[1],g[2]),f.call(h,g[0],g[1],g[2])})(h.removeEventListener),l.numberOfOutputs!==0){let f=e(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(o.destination),i(h,()=>f.disconnect(),()=>f.connect(o.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return lp(l),t(o,s,u,l)};var ds=(n,t)=>n===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(n*t)))));var pp=n=>new Promise((t,e)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),i.close(),t(o)},r.onmessageerror=({data:o})=>{r.close(),i.close(),e(o)},i.postMessage(n)});var dp=(n,t)=>Q(null,null,function*(){let e=yield pp(t);return new n(e)});var mp=(n,t,e,r)=>{let i=zn.get(n);i===void 0&&(i=new WeakMap,zn.set(n,i));let o=dp(e,r);return i.set(t,o),o};var fp=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>(m,f,g,y)=>{if(y.numberOfInputs===0&&y.numberOfOutputs===0)throw c();let b=Array.isArray(y.outputChannelCount)?y.outputChannelCount:Array.from(y.outputChannelCount);if(b.some(Y=>Y<1))throw c();if(b.length!==y.numberOfOutputs)throw t();if(y.channelCountMode!=="explicit")throw c();let I=y.channelCount*y.numberOfInputs,S=b.reduce((Y,rt)=>Y+rt,0),w=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+w>6||S>6)throw c();let _=new MessageChannel,v=[],C=[];for(let Y=0;Y<y.numberOfInputs;Y+=1)v.push(s(m,{channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation,gain:1})),C.push(i(m,{channelCount:y.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:y.channelCount}));let x=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:Y,maxValue:rt,minValue:Ut,name:Nt}of g.parameterDescriptors){let ft=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:y.parameterData[Nt]!==void 0?y.parameterData[Nt]:Y===void 0?0:Y});Object.defineProperties(ft.offset,{defaultValue:{get:()=>Y===void 0?0:Y},maxValue:{get:()=>rt===void 0?Dt:rt},minValue:{get:()=>Ut===void 0?Lt:Ut}}),x.push(ft)}let N=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+w)}),j=ds(f,m.sampleRate),R=a(m,j,I+w,Math.max(1,S)),D=i(m,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),U=[];for(let Y=0;Y<y.numberOfOutputs;Y+=1)U.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:b[Y]}));for(let Y=0;Y<y.numberOfInputs;Y+=1){v[Y].connect(C[Y]);for(let rt=0;rt<y.channelCount;rt+=1)C[Y].connect(N,rt,Y*y.channelCount+rt)}let k=new Gi(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:Y},rt)=>{let Ut=x[rt];return Ut.connect(N,0,I+rt),Ut.start(0),[Y,Ut.offset]}));N.connect(R);let P=y.channelInterpretation,F=null,V=y.numberOfOutputs===0?[R]:U,X={get bufferSize(){return j},get channelCount(){return y.channelCount},set channelCount(Y){throw e()},get channelCountMode(){return y.channelCountMode},set channelCountMode(Y){throw e()},get channelInterpretation(){return P},set channelInterpretation(Y){for(let rt of v)rt.channelInterpretation=Y;P=Y},get context(){return R.context},get inputs(){return v},get numberOfInputs(){return y.numberOfInputs},get numberOfOutputs(){return y.numberOfOutputs},get onprocessorerror(){return F},set onprocessorerror(Y){typeof F=="function"&&X.removeEventListener("processorerror",F),F=typeof Y=="function"?Y:null,typeof F=="function"&&X.addEventListener("processorerror",F)},get parameters(){return k},get port(){return _.port2},addEventListener(...Y){return R.addEventListener(Y[0],Y[1],Y[2])},connect:n.bind(null,V),disconnect:u.bind(null,V),dispatchEvent(...Y){return R.dispatchEvent(Y[0])},removeEventListener(...Y){return R.removeEventListener(Y[0],Y[1],Y[2])}},E=new Map;_.port1.addEventListener=(Y=>(...rt)=>{if(rt[0]==="message"){let Ut=typeof rt[1]=="function"?rt[1]:typeof rt[1]=="object"&&rt[1]!==null&&typeof rt[1].handleEvent=="function"?rt[1].handleEvent:null;if(Ut!==null){let Nt=E.get(rt[1]);Nt!==void 0?rt[1]=Nt:(rt[1]=ft=>{l(m.currentTime,m.sampleRate,()=>Ut(ft))},E.set(Ut,rt[1]))}}return Y.call(_.port1,rt[0],rt[1],rt[2])})(_.port1.addEventListener),_.port1.removeEventListener=(Y=>(...rt)=>{if(rt[0]==="message"){let Ut=E.get(rt[1]);Ut!==void 0&&(E.delete(rt[1]),rt[1]=Ut)}return Y.call(_.port1,rt[0],rt[1],rt[2])})(_.port1.removeEventListener);let tt=null;Object.defineProperty(_.port1,"onmessage",{get:()=>tt,set:Y=>{typeof tt=="function"&&_.port1.removeEventListener("message",tt),tt=typeof Y=="function"?Y:null,typeof tt=="function"&&(_.port1.addEventListener("message",tt),_.port1.start())}}),g.prototype.port=_.port1;let ct=null;mp(m,X,g,y).then(Y=>ct=Y);let jt=qi(y.numberOfInputs,y.channelCount),be=qi(y.numberOfOutputs,b),Ae=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((Y,{name:rt})=>Z(M({},Y),{[rt]:new Float32Array(128)}),{}),At=!0,nt=()=>{y.numberOfOutputs>0&&R.disconnect(D);for(let Y=0,rt=0;Y<y.numberOfOutputs;Y+=1){let Ut=U[Y];for(let Nt=0;Nt<b[Y];Nt+=1)D.disconnect(Ut,rt+Nt,Nt);rt+=b[Y]}},Si=new Map;R.onaudioprocess=({inputBuffer:Y,outputBuffer:rt})=>{if(ct!==null){let Ut=h(X);for(let Nt=0;Nt<j;Nt+=128){for(let ft=0;ft<y.numberOfInputs;ft+=1)for(let Mt=0;Mt<y.channelCount;Mt+=1)Vi(Y,jt[ft],Mt,Mt,Nt);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:ft},Mt)=>{Vi(Y,Ae,ft,I+Mt,Nt)});for(let ft=0;ft<y.numberOfInputs;ft+=1)for(let Mt=0;Mt<b[ft];Mt+=1)be[ft][Mt].byteLength===0&&(be[ft][Mt]=new Float32Array(128));try{let ft=jt.map((Se,Rr)=>{if(Ut[Rr].size>0)return Si.set(Rr,j/128),Se;let Wa=Si.get(Rr);return Wa===void 0?[]:(Se.every(Rm=>Rm.every(Mm=>Mm===0))&&(Wa===1?Si.delete(Rr):Si.set(Rr,Wa-1)),Se)});At=l(m.currentTime+Nt/m.sampleRate,m.sampleRate,()=>ct.process(ft,be,Ae));for(let Se=0,Rr=0;Se<y.numberOfOutputs;Se+=1){for(let Nn=0;Nn<b[Se];Nn+=1)ls(rt,be[Se],Nn,Rr+Nn,Nt);Rr+=b[Se]}}catch(ft){At=!1,X.dispatchEvent(new ErrorEvent("processorerror",{colno:ft.colno,filename:ft.filename,lineno:ft.lineno,message:ft.message}))}if(!At){for(let ft=0;ft<y.numberOfInputs;ft+=1){v[ft].disconnect(C[ft]);for(let Mt=0;Mt<y.channelCount;Mt+=1)C[Nt].disconnect(N,Mt,ft*y.channelCount+Mt)}if(g.parameterDescriptors!==void 0){let ft=g.parameterDescriptors.length;for(let Mt=0;Mt<ft;Mt+=1){let Se=x[Mt];Se.disconnect(N,0,I+Mt),Se.stop()}}N.disconnect(R),R.onaudioprocess=null,Sn?nt():Ti();break}}}};let Sn=!1,K=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),wi=()=>R.connect(K).connect(m.destination),Ti=()=>{R.disconnect(K),K.disconnect()},wn=()=>{if(At){Ti(),y.numberOfOutputs>0&&R.connect(D);for(let Y=0,rt=0;Y<y.numberOfOutputs;Y+=1){let Ut=U[Y];for(let Nt=0;Nt<b[Y];Nt+=1)D.connect(Ut,rt+Nt,Nt);rt+=b[Y]}}Sn=!0},Tn=()=>{At&&(wi(),nt()),Sn=!1};return wi(),p(X,wn,Tn)};var Rc=(n,t)=>{let e=n.createBiquadFilter();return ut(e,t),yt(e,t,"Q"),yt(e,t,"detune"),yt(e,t,"frequency"),yt(e,t,"gain"),dt(e,t,"type"),e};var gp=(n,t)=>(e,r)=>{let i=e.createChannelMerger(r.numberOfInputs);return n!==null&&n.name==="webkitAudioContext"&&t(e,i),ut(i,r),i};var yp=n=>{let t=n.numberOfOutputs;Object.defineProperty(n,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw wt()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw wt()}}),Object.defineProperty(n,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw wt()}})};var Yi=(n,t)=>{let e=n.createChannelSplitter(t.numberOfOutputs);return ut(e,t),yp(e),e};var xp=(n,t,e,r,i)=>(o,s)=>{if(o.createConstantSource===void 0)return e(o,s);let a=o.createConstantSource();return ut(a,s),yt(a,s,"offset"),t(r,()=>r(o))||Ui(a),t(i,()=>i(o))||zi(a),n(o,a),a};var Re=(n,t)=>(n.connect=t.connect.bind(t),n.disconnect=t.disconnect.bind(t),n);var bp=(n,t,e,r)=>(i,a)=>{var c=a,{offset:o}=c,s=Mr(c,["offset"]);let u=i.createBuffer(1,2,44100),l=t(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=e(i,Z(M({},s),{gain:o})),p=u.getChannelData(0);p[0]=1,p[1]=1,l.buffer=u,l.loop=!0;let m={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(y){h.channelCount=y},get channelCountMode(){return h.channelCountMode},set channelCountMode(y){h.channelCountMode=y},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(y){h.channelInterpretation=y},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return l.onended},set onended(y){l.onended=y},addEventListener(...y){return l.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return l.dispatchEvent(y[0])},removeEventListener(...y){return l.removeEventListener(y[0],y[1],y[2])},start(y=0){l.start.call(l,y)},stop(y=0){l.stop.call(l,y)}},f=()=>l.connect(h),g=()=>l.disconnect(h);return n(i,l),r(Re(m,h),f,g)};var Ap=(n,t)=>(e,r)=>{let i=e.createConvolver();if(ut(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),dt(i,r,"buffer"),r.channelCount>2||(t(i,"channelCount",o=>()=>o.call(i),o=>s=>{if(s>2)throw n();return o.call(i,s)}),r.channelCountMode==="max"))throw n();return t(i,"channelCountMode",o=>()=>o.call(i),o=>s=>{if(s==="max")throw n();return o.call(i,s)}),i};var Mc=(n,t)=>{let e=n.createDelay(t.maxDelayTime);return ut(e,t),yt(e,t,"delayTime"),e};var Cp=n=>(t,e)=>{let r=t.createDynamicsCompressor();if(ut(r,e),e.channelCount>2||e.channelCountMode==="max")throw n();return yt(r,e,"attack"),yt(r,e,"knee"),yt(r,e,"ratio"),yt(r,e,"release"),yt(r,e,"threshold"),r};var ce=(n,t)=>{let e=n.createGain();return ut(e,t),yt(e,t,"gain"),e};var _p=n=>(t,e,r)=>{if(t.createIIRFilter===void 0)return n(t,e,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return ut(i,r),i};function my(n,t){let e=t[0]*t[0]+t[1]*t[1];return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]}function fy(n,t){return[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]]}function vp(n,t){let e=[0,0];for(let r=n.length-1;r>=0;r-=1)e=fy(e,t),e[0]+=n[r];return e}var Ip=(n,t,e,r)=>(i,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=ds(o,i.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),m=l instanceof Float64Array?l:new Float64Array(l),f=p.length,g=m.length,y=Math.min(f,g);if(f===0||f>20)throw r();if(p[0]===0)throw t();if(g===0||g>20)throw r();if(m[0]===0)throw t();if(p[0]!==1){for(let x=0;x<g;x+=1)m[x]/=p[0];for(let x=1;x<f;x+=1)p[x]/=p[0]}let b=e(i,h,s,s);b.channelCount=s,b.channelCountMode=a,b.channelInterpretation=c;let I=32,S=[],w=[],_=[];for(let x=0;x<s;x+=1){S.push(0);let N=new Float32Array(I),j=new Float32Array(I);N.fill(0),j.fill(0),w.push(N),_.push(j)}b.onaudioprocess=x=>{let N=x.inputBuffer,j=x.outputBuffer,R=N.numberOfChannels;for(let D=0;D<R;D+=1){let U=N.getChannelData(D),k=j.getChannelData(D);S[D]=ps(p,f,m,g,y,w[D],_[D],S[D],I,U,k)}};let v=i.sampleRate/2;return Re({get bufferSize(){return h},get channelCount(){return b.channelCount},set channelCount(x){b.channelCount=x},get channelCountMode(){return b.channelCountMode},set channelCountMode(x){b.channelCountMode=x},get channelInterpretation(){return b.channelInterpretation},set channelInterpretation(x){b.channelInterpretation=x},get context(){return b.context},get inputs(){return[b]},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},addEventListener(...x){return b.addEventListener(x[0],x[1],x[2])},dispatchEvent(...x){return b.dispatchEvent(x[0])},getFrequencyResponse(x,N,j){if(x.length!==N.length||N.length!==j.length)throw n();let R=x.length;for(let D=0;D<R;D+=1){let U=-Math.PI*(x[D]/v),k=[Math.cos(U),Math.sin(U)],P=vp(m,k),F=vp(p,k),V=my(P,F);N[D]=Math.sqrt(V[0]*V[0]+V[1]*V[1]),j[D]=Math.atan2(V[1],V[0])}},removeEventListener(...x){return b.removeEventListener(x[0],x[1],x[2])}},b)};var Sp=(n,t)=>n.createMediaElementSource(t.mediaElement);var wp=(n,t)=>{let e=n.createMediaStreamDestination();return ut(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var Tp=(n,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=e.slice(0,1),i=n.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i};var Np=(n,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let i=new MediaStream([r]),o=e.createMediaStreamSource(i);if(r.kind!=="audio")throw n();if(t(e))throw new TypeError;return o};var Op=n=>n===null?null:n.hasOwnProperty("OfflineAudioContext")?n.OfflineAudioContext:n.hasOwnProperty("webkitOfflineAudioContext")?n.webkitOfflineAudioContext:null;var Rp=(n,t,e,r,i,o)=>(s,a)=>{let c=s.createOscillator();return ut(c,a),yt(c,a,"detune"),yt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):dt(c,a,"type"),t(e,()=>e(s))||Ui(c),t(r,()=>r(s))||o(c,s),t(i,()=>i(s))||zi(c),n(s,c),c};var Mp=n=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?n(t,e):(ut(r,e),yt(r,e,"orientationX"),yt(r,e,"orientationY"),yt(r,e,"orientationZ"),yt(r,e,"positionX"),yt(r,e,"positionY"),yt(r,e,"positionZ"),dt(r,e,"coneInnerAngle"),dt(r,e,"coneOuterAngle"),dt(r,e,"coneOuterGain"),dt(r,e,"distanceModel"),dt(r,e,"maxDistance"),dt(r,e,"panningModel"),dt(r,e,"refDistance"),dt(r,e,"rolloffFactor"),r)};var Dp=(n,t,e,r,i,o,s,a,c,u)=>(l,j)=>{var R=j,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:y,orientationY:b,orientationZ:I,panningModel:S,positionX:w,positionY:_,positionZ:v,refDistance:C,rolloffFactor:x}=R,N=Mr(R,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let D=l.createPanner();if(N.channelCount>2||N.channelCountMode==="max")throw s();ut(D,N);let U={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},k=e(l,Z(M({},U),{channelInterpretation:"speakers",numberOfInputs:6})),P=r(l,Z(M({},N),{gain:1})),F=r(l,Z(M({},U),{gain:1})),V=r(l,Z(M({},U),{gain:0})),X=r(l,Z(M({},U),{gain:0})),E=r(l,Z(M({},U),{gain:0})),tt=r(l,Z(M({},U),{gain:0})),ct=r(l,Z(M({},U),{gain:0})),xt=i(l,256,6,1),jt=o(l,Z(M({},U),{curve:new Float32Array([1,1]),oversample:"none"})),be=[y,b,I],Ae=[w,_,v],At=new Float32Array(1);xt.onaudioprocess=({inputBuffer:K})=>{let wi=[c(K,At,0),c(K,At,1),c(K,At,2)];wi.some((wn,Tn)=>wn!==be[Tn])&&(D.setOrientation(...wi),be=wi);let Ti=[c(K,At,3),c(K,At,4),c(K,At,5)];Ti.some((wn,Tn)=>wn!==Ae[Tn])&&(D.setPosition(...Ti),Ae=Ti)},Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(X.gain,"defaultValue",{get:()=>0}),Object.defineProperty(E.gain,"defaultValue",{get:()=>0}),Object.defineProperty(tt.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ct.gain,"defaultValue",{get:()=>0});let nt={get bufferSize(){},get channelCount(){return D.channelCount},set channelCount(K){if(K>2)throw s();P.channelCount=K,D.channelCount=K},get channelCountMode(){return D.channelCountMode},set channelCountMode(K){if(K==="max")throw s();P.channelCountMode=K,D.channelCountMode=K},get channelInterpretation(){return D.channelInterpretation},set channelInterpretation(K){P.channelInterpretation=K,D.channelInterpretation=K},get coneInnerAngle(){return D.coneInnerAngle},set coneInnerAngle(K){D.coneInnerAngle=K},get coneOuterAngle(){return D.coneOuterAngle},set coneOuterAngle(K){D.coneOuterAngle=K},get coneOuterGain(){return D.coneOuterGain},set coneOuterGain(K){if(K<0||K>1)throw t();D.coneOuterGain=K},get context(){return D.context},get distanceModel(){return D.distanceModel},set distanceModel(K){D.distanceModel=K},get inputs(){return[P]},get maxDistance(){return D.maxDistance},set maxDistance(K){if(K<0)throw new RangeError;D.maxDistance=K},get numberOfInputs(){return D.numberOfInputs},get numberOfOutputs(){return D.numberOfOutputs},get orientationX(){return F.gain},get orientationY(){return V.gain},get orientationZ(){return X.gain},get panningModel(){return D.panningModel},set panningModel(K){D.panningModel=K},get positionX(){return E.gain},get positionY(){return tt.gain},get positionZ(){return ct.gain},get refDistance(){return D.refDistance},set refDistance(K){if(K<0)throw new RangeError;D.refDistance=K},get rolloffFactor(){return D.rolloffFactor},set rolloffFactor(K){if(K<0)throw new RangeError;D.rolloffFactor=K},addEventListener(...K){return P.addEventListener(K[0],K[1],K[2])},dispatchEvent(...K){return P.dispatchEvent(K[0])},removeEventListener(...K){return P.removeEventListener(K[0],K[1],K[2])}};h!==nt.coneInnerAngle&&(nt.coneInnerAngle=h),p!==nt.coneOuterAngle&&(nt.coneOuterAngle=p),m!==nt.coneOuterGain&&(nt.coneOuterGain=m),f!==nt.distanceModel&&(nt.distanceModel=f),g!==nt.maxDistance&&(nt.maxDistance=g),y!==nt.orientationX.value&&(nt.orientationX.value=y),b!==nt.orientationY.value&&(nt.orientationY.value=b),I!==nt.orientationZ.value&&(nt.orientationZ.value=I),S!==nt.panningModel&&(nt.panningModel=S),w!==nt.positionX.value&&(nt.positionX.value=w),_!==nt.positionY.value&&(nt.positionY.value=_),v!==nt.positionZ.value&&(nt.positionZ.value=v),C!==nt.refDistance&&(nt.refDistance=C),x!==nt.rolloffFactor&&(nt.rolloffFactor=x),(be[0]!==1||be[1]!==0||be[2]!==0)&&D.setOrientation(...be),(Ae[0]!==0||Ae[1]!==0||Ae[2]!==0)&&D.setPosition(...Ae);let Si=()=>{P.connect(D),n(P,jt,0,0),jt.connect(F).connect(k,0,0),jt.connect(V).connect(k,0,1),jt.connect(X).connect(k,0,2),jt.connect(E).connect(k,0,3),jt.connect(tt).connect(k,0,4),jt.connect(ct).connect(k,0,5),k.connect(xt).connect(l.destination)},Sn=()=>{P.disconnect(D),a(P,jt,0,0),jt.disconnect(F),F.disconnect(k),jt.disconnect(V),V.disconnect(k),jt.disconnect(X),X.disconnect(k),jt.disconnect(E),E.disconnect(k),jt.disconnect(tt),tt.disconnect(k),jt.disconnect(ct),ct.disconnect(k),k.disconnect(xt),xt.disconnect(l.destination)};return u(Re(nt,D),Si,Sn)};var Ep=n=>(t,{disableNormalization:e,imag:r,real:i})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=t.createPeriodicWave(s,o,{disableNormalization:e});if(Array.from(r).length<2)throw n();return a};var Hi=(n,t,e,r)=>n.createScriptProcessor(t,e,r);var kp=(n,t)=>(e,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw t();if(e.createStereoPanner===void 0)return n(e,r);let o=e.createStereoPanner();return ut(o,r),yt(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw t()}}),o};var jp=(n,t,e,r,i,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=Z(M({},u),{oversample:"none"}),h=(f,g,y,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385);for(let N=0;N<16385;N+=1){let j=N/16384*c;I[N]=Math.cos(j),S[N]=Math.sin(j)}let w=e(f,Z(M({},u),{gain:0})),_=r(f,Z(M({},l),{curve:I})),v=r(f,Z(M({},l),{curve:a})),C=e(f,Z(M({},u),{gain:0})),x=r(f,Z(M({},l),{curve:S}));return{connectGraph(){g.connect(w),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(C),v.connect(y),y.connect(_.inputs===void 0?_:_.inputs[0]),y.connect(x.inputs===void 0?x:x.inputs[0]),_.connect(w.gain),x.connect(C.gain),w.connect(b,0,0),C.connect(b,0,1)},disconnectGraph(){g.disconnect(w),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(C),v.disconnect(y),y.disconnect(_.inputs===void 0?_:_.inputs[0]),y.disconnect(x.inputs===void 0?x:x.inputs[0]),_.disconnect(w.gain),x.disconnect(C.gain),w.disconnect(b,0,0),C.disconnect(b,0,1)}}},p=(f,g,y,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385),w=new Float32Array(16385),_=new Float32Array(16385),v=Math.floor(16385/2);for(let V=0;V<16385;V+=1)if(V>v){let X=(V-v)/(16384-v)*c;I[V]=Math.cos(X),S[V]=Math.sin(X),w[V]=0,_[V]=1}else{let X=V/(16384-v)*c;I[V]=1,S[V]=0,w[V]=Math.cos(X),_[V]=Math.sin(X)}let C=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),x=e(f,Z(M({},u),{gain:0})),N=r(f,Z(M({},l),{curve:I})),j=e(f,Z(M({},u),{gain:0})),R=r(f,Z(M({},l),{curve:S})),D=r(f,Z(M({},l),{curve:a})),U=e(f,Z(M({},u),{gain:0})),k=r(f,Z(M({},l),{curve:w})),P=e(f,Z(M({},u),{gain:0})),F=r(f,Z(M({},l),{curve:_}));return{connectGraph(){g.connect(C),g.connect(D.inputs===void 0?D:D.inputs[0]),C.connect(x,0),C.connect(j,0),C.connect(U,1),C.connect(P,1),D.connect(y),y.connect(N.inputs===void 0?N:N.inputs[0]),y.connect(R.inputs===void 0?R:R.inputs[0]),y.connect(k.inputs===void 0?k:k.inputs[0]),y.connect(F.inputs===void 0?F:F.inputs[0]),N.connect(x.gain),R.connect(j.gain),k.connect(U.gain),F.connect(P.gain),x.connect(b,0,0),U.connect(b,0,0),j.connect(b,0,1),P.connect(b,0,1)},disconnectGraph(){g.disconnect(C),g.disconnect(D.inputs===void 0?D:D.inputs[0]),C.disconnect(x,0),C.disconnect(j,0),C.disconnect(U,1),C.disconnect(P,1),D.disconnect(y),y.disconnect(N.inputs===void 0?N:N.inputs[0]),y.disconnect(R.inputs===void 0?R:R.inputs[0]),y.disconnect(k.inputs===void 0?k:k.inputs[0]),y.disconnect(F.inputs===void 0?F:F.inputs[0]),N.disconnect(x.gain),R.disconnect(j.gain),k.disconnect(U.gain),F.disconnect(P.gain),x.disconnect(b,0,0),U.disconnect(b,0,0),j.disconnect(b,0,1),P.disconnect(b,0,1)}}},m=(f,g,y,b,I)=>{if(g===1)return h(f,y,b,I);if(g===2)return p(f,y,b,I);throw i()};return(f,S)=>{var w=S,{channelCount:g,channelCountMode:y,pan:b}=w,I=Mr(w,["channelCount","channelCountMode","pan"]);if(y==="max")throw i();let _=n(f,Z(M({},I),{channelCount:1,channelCountMode:y,numberOfInputs:2})),v=e(f,Z(M({},I),{channelCount:g,channelCountMode:y,gain:1})),C=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:b}),{connectGraph:x,disconnectGraph:N}=m(f,g,v,C,_);Object.defineProperty(C.gain,"defaultValue",{get:()=>0}),Object.defineProperty(C.gain,"maxValue",{get:()=>1}),Object.defineProperty(C.gain,"minValue",{get:()=>-1});let j={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(k){v.channelCount!==k&&(R&&N(),{connectGraph:x,disconnectGraph:N}=m(f,k,v,C,_),R&&x()),v.channelCount=k},get channelCountMode(){return v.channelCountMode},set channelCountMode(k){if(k==="clamped-max"||k==="max")throw i();v.channelCountMode=k},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(k){v.channelInterpretation=k},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return C.gain},addEventListener(...k){return v.addEventListener(k[0],k[1],k[2])},dispatchEvent(...k){return v.dispatchEvent(k[0])},removeEventListener(...k){return v.removeEventListener(k[0],k[1],k[2])}},R=!1,D=()=>{x(),R=!0},U=()=>{N(),R=!1};return o(Re(j,_),D,U)}};var Lp=(n,t,e,r,i,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return e(a,c);ut(u,c);let l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw t();dt(u,{curve:l},"curve"),dt(u,c,"oversample");let h=null,p=!1;return s(u,"curve",g=>()=>g.call(u),g=>y=>(g.call(u,y),p&&(r(y)&&h===null?h=n(a,u):!r(y)&&h!==null&&(h(),h=null)),y)),i(u,()=>{p=!0,r(u.curve)&&(h=n(a,u))},()=>{p=!1,h!==null&&(h(),h=null)})};var Pp=(n,t,e,r,i)=>(o,u)=>{var l=u,{curve:s,oversample:a}=l,c=Mr(l,["curve","oversample"]);let h=o.createWaveShaper(),p=o.createWaveShaper();ut(h,c),ut(p,c);let m=e(o,Z(M({},c),{gain:1})),f=e(o,Z(M({},c),{gain:-1})),g=e(o,Z(M({},c),{gain:1})),y=e(o,Z(M({},c),{gain:-1})),b=null,I=!1,S=null,w={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(C){m.channelCount=C,f.channelCount=C,h.channelCount=C,g.channelCount=C,p.channelCount=C,y.channelCount=C},get channelCountMode(){return h.channelCountMode},set channelCountMode(C){m.channelCountMode=C,f.channelCountMode=C,h.channelCountMode=C,g.channelCountMode=C,p.channelCountMode=C,y.channelCountMode=C},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(C){m.channelInterpretation=C,f.channelInterpretation=C,h.channelInterpretation=C,g.channelInterpretation=C,p.channelInterpretation=C,y.channelInterpretation=C},get context(){return h.context},get curve(){return S},set curve(C){if(C!==null&&C.length<2)throw t();if(C===null)h.curve=C,p.curve=C;else{let x=C.length,N=new Float32Array(x+2-x%2),j=new Float32Array(x+2-x%2);N[0]=C[0],j[0]=-C[x-1];let R=Math.ceil((x+1)/2),D=(x+1)/2-1;for(let U=1;U<R;U+=1){let k=U/R*D,P=Math.floor(k),F=Math.ceil(k);N[U]=P===F?C[P]:(1-(k-P))*C[P]+(1-(F-k))*C[F],j[U]=P===F?-C[x-1-P]:-((1-(k-P))*C[x-1-P])-(1-(F-k))*C[x-1-F]}N[R]=x%2===1?C[R-1]:(C[R-2]+C[R-1])/2,h.curve=N,p.curve=j}S=C,I&&(r(S)&&b===null?b=n(o,m):b!==null&&(b(),b=null))},get inputs(){return[m]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(C){h.oversample=C,p.oversample=C},addEventListener(...C){return m.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return m.dispatchEvent(C[0])},removeEventListener(...C){return m.removeEventListener(C[0],C[1],C[2])}};s!==null&&(w.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==w.oversample&&(w.oversample=a);let _=()=>{m.connect(h).connect(g),m.connect(f).connect(p).connect(y).connect(g),I=!0,r(S)&&(b=n(o,m))},v=()=>{m.disconnect(h),h.disconnect(g),m.disconnect(f),f.disconnect(p),p.disconnect(y),y.disconnect(g),I=!1,b!==null&&(b(),b=null)};return i(Re(w,g),_,v)};var Kt=()=>new DOMException("","NotSupportedError");var gy={numberOfChannels:1},Fp=(n,t,e,r,i)=>class extends n{constructor(s,a,c){let u;if(typeof s=="number"&&a!==void 0&&c!==void 0)u={length:a,numberOfChannels:s,sampleRate:c};else if(typeof s=="object")u=s;else throw new Error("The given parameters are not valid.");let{length:l,numberOfChannels:h,sampleRate:p}=M(M({},gy),u),m=r(h,l,p);t(qe,()=>qe(m))||m.addEventListener("statechange",(()=>{let f=0,g=y=>{this._state==="running"&&(f>0?(m.removeEventListener("statechange",g),y.stopImmediatePropagation(),this._waitForThePromiseToSettle(y)):f+=1)};return g})()),super(m,h),this._length=l,this._nativeOfflineAudioContext=m,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(e()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Fr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var yy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Bp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},yy),u),p=e(l,h),m=o(l),f=m?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,m,p.detune,153600,-153600),this._frequency=t(this,m,p.frequency,g,-g),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&h.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=h.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeOscillatorNode.onended=u;let l=this._nativeOscillatorNode.onended;this._onended=l!==null&&l===u?c:l}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){Ge(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),ae(this)&&ir(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var Gp=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(l,h)=>Q(null,null,function*(){let p=e(l),m=pt(p,h);if(!m){let f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:s===null?void 0:s,type:p.type};p=t(h,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return o.set(h,p),m?(yield n(h,l.detune,p.detune),yield n(h,l.frequency,p.frequency)):(yield r(h,l.detune,p.detune),yield r(h,l.frequency,p.frequency)),yield i(l,h,p),p});return{set periodicWave(l){s=l},set start(l){a=l},set stop(l){c=l},render(l,h){let p=o.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var xy={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},Vp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},xy),u),p=e(l,h),m=o(l),f=m?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,m,p.orientationX,Dt,Lt),this._orientationY=t(this,m,p.orientationY,Dt,Lt),this._orientationZ=t(this,m,p.orientationZ,Dt,Lt),this._positionX=t(this,m,p.positionX,Dt,Lt),this._positionY=t(this,m,p.positionY,Dt,Lt),this._positionZ=t(this,m,p.positionZ,Dt,Lt),s(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}};var qp=(n,t,e,r,i,o,s,a,c,u)=>()=>{let l=new WeakMap,h=null,p=(m,f)=>Q(null,null,function*(){let g=null,y=o(m),b={channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation},I=Z(M({},b),{coneInnerAngle:y.coneInnerAngle,coneOuterAngle:y.coneOuterAngle,coneOuterGain:y.coneOuterGain,distanceModel:y.distanceModel,maxDistance:y.maxDistance,panningModel:y.panningModel,refDistance:y.refDistance,rolloffFactor:y.rolloffFactor}),S=pt(y,f);if("bufferSize"in y)g=r(f,Z(M({},b),{gain:1}));else if(!S){let w=Z(M({},I),{orientationX:y.orientationX.value,orientationY:y.orientationY.value,orientationZ:y.orientationZ.value,positionX:y.positionX.value,positionY:y.positionY.value,positionZ:y.positionZ.value});y=i(f,w)}if(l.set(f,g===null?y:g),g!==null){if(h===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let R=new s(6,m.context.length,f.sampleRate),D=t(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});D.connect(R.destination),h=Q(null,null,function*(){let U=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((k,P)=>Q(null,null,function*(){let F=e(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P===0?1:0});return yield a(R,k,F.offset),F})));for(let k=0;k<6;k+=1)U[k].connect(D,0,k),U[k].start(0);return u(R)})}let w=yield h,_=r(f,Z(M({},b),{gain:1}));yield c(m,f,_);let v=[];for(let R=0;R<w.numberOfChannels;R+=1)v.push(w.getChannelData(R));let C=[v[0][0],v[1][0],v[2][0]],x=[v[3][0],v[4][0],v[5][0]],N=r(f,Z(M({},b),{gain:1})),j=i(f,Z(M({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:x[0],positionY:x[1],positionZ:x[2]}));_.connect(N).connect(j.inputs[0]),j.connect(g);for(let R=128;R<w.length;R+=128){let D=[v[0][R],v[1][R],v[2][R]],U=[v[3][R],v[4][R],v[5][R]];if(D.some((k,P)=>k!==C[P])||U.some((k,P)=>k!==x[P])){C=D,x=U;let k=R/f.sampleRate;N.gain.setValueAtTime(0,k),N=r(f,Z(M({},b),{gain:0})),j=i(f,Z(M({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:x[0],positionY:x[1],positionZ:x[2]})),N.gain.setValueAtTime(1,k),_.connect(N).connect(j.inputs[0]),j.connect(g)}}return g}return S?(yield n(f,m.orientationX,y.orientationX),yield n(f,m.orientationY,y.orientationY),yield n(f,m.orientationZ,y.orientationZ),yield n(f,m.positionX,y.positionX),yield n(f,m.positionY,y.positionY),yield n(f,m.positionZ,y.positionZ)):(yield a(f,m.orientationX,y.orientationX),yield a(f,m.orientationY,y.orientationY),yield a(f,m.orientationZ,y.orientationZ),yield a(f,m.positionX,y.positionX),yield a(f,m.positionY,y.positionY),yield a(f,m.positionZ,y.positionZ)),Oe(y)?yield c(m,f,y.inputs[0]):yield c(m,f,y),y});return{render(m,f){let g=l.get(f);return g!==void 0?Promise.resolve(g):p(m,f)}}};var by={disableNormalization:!1},Wp=(n,t,e,r)=>class Up{constructor(o,s){let a=t(o),c=r(M(M({},by),s)),u=n(a,c);return e.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===Up.prototype||e.has(o)}};var zp=(n,t)=>(e,r,i)=>(n(r).replay(i),t(r,e,i));var Yp=(n,t,e)=>(r,i,o)=>Q(null,null,function*(){let s=n(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>Q(null,[h],function*([u,l]){let m=yield t(u).render(u,i),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&m.connect(o,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var Hp=(n,t,e)=>(r,i,o)=>Q(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>Q(null,[u],function*([a,c]){let h=yield n(a).render(a,i);e(a)||h.connect(o,c)})))});var Zp=(n,t,e,r)=>i=>n(qe,()=>qe(i))?Promise.resolve(n(r,r)).then(o=>{if(!o){let s=e(i,512,0,1);i.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>i.currentTime,s.connect(i.destination)}return i.startRendering()}):new Promise(o=>{let s=t(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var Xp=n=>(t,e)=>{n.set(t,e)};var Qp=n=>(t,e)=>n.set(t,e);var Kp=(n,t,e,r,i,o,s,a)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(l=>e(l).render(l,u)))).then(()=>i(u)).then(l=>(typeof l.copyFromChannel!="function"?(s(l),Li(l)):t(o,()=>o(l))||a(l),n.add(l),l));var Ay={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Jp=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=M(M({},Ay),c),h=e(u,l),p=o(u),m=p?r():null;super(a,!1,h,m),this._pan=t(this,p,h.pan)}get pan(){return this._pan}};var $p=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>Q(null,null,function*(){let u=e(a),l=pt(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,h)}return o.set(c,u),l?yield n(c,a.pan,u.pan):yield r(c,a.pan,u.pan),Oe(u)?yield i(a,c,u.inputs[0]):yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var td=n=>()=>{if(n===null)return!1;try{new n({length:1,sampleRate:44100})}catch(t){return!1}return!0};var ed=(n,t)=>()=>Q(null,null,function*(){if(n===null)return!0;if(t===null)return!1;let e=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(e),o=!1,s=!1;try{yield r.audioWorklet.addModule(i);let a=new n(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>o=!0,a.onprocessorerror=()=>s=!0,c.connect(a),c.start(0),yield r.startRendering(),yield new Promise(u=>setTimeout(u))}catch(a){}finally{URL.revokeObjectURL(i)}return o&&!s});var rd=(n,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{e.oncomplete=()=>{r.disconnect(),i(e.currentTime!==0)},e.startRendering()})};var Dc=()=>new DOMException("","UnknownError");var Cy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},id=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},Cy),u),p=e(l,h),f=o(l)?r():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,s(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var nd=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>Q(null,null,function*(){let a=t(o);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=n(s,u)}return r.set(s,a),Oe(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var od=()=>typeof window=="undefined"?null:window;var sd=(n,t)=>e=>{e.copyFromChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)r[h]=u[h+s]},e.copyToChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)u[h+s]=r[h]}};var ad=n=>t=>{t.copyFromChannel=(e=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var cd=n=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),n(t,"buffer",i=>()=>{let o=i.call(t);return o===r?null:o},i=>o=>i.call(t,o===null?r:o))};var ud=(n,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw n()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw n()}});let i=e.createBufferSource();t(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(r,0,c)},()=>i.disconnect(r))};var Ec=(n,t,e)=>n.copyFromChannel===void 0?n.getChannelData(e)[0]:(n.copyFromChannel(t,e),t[0]);var kc=n=>{if(n===null)return!1;let t=n.length;return t%2!==0?n[Math.floor(t/2)]!==0:n[t/2-1]+n[t/2]!==0};var Zi=(n,t,e,r)=>{let i=n;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:o,set:s}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(n,t,{get:e(o),set:r(s)})};var ld=n=>Z(M({},n),{outputChannelCount:n.outputChannelCount!==void 0?n.outputChannelCount:n.numberOfInputs===1&&n.numberOfOutputs===1?[n.channelCount]:Array.from({length:n.numberOfOutputs},()=>1)});var hd=n=>Z(M({},n),{channelCount:n.numberOfOutputs});var pd=n=>{let{imag:t,real:e}=n;return t===void 0?e===void 0?Z(M({},n),{imag:[0,0],real:[0,0]}):Z(M({},n),{imag:Array.from(e,()=>0),real:e}):e===void 0?Z(M({},n),{imag:t,real:Array.from(t,()=>0)}):Z(M({},n),{imag:t,real:e})};var jc=(n,t,e)=>{try{n.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;jc(n,t,e+1e-7)}};var dd=n=>{let t=n.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var md=n=>{let t=n.createBufferSource(),e=n.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var fd=n=>{let t=n.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var ms=n=>{let t=n.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Lc=n=>{let t=n.createBuffer(1,1,44100),e=n.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var fs=n=>{let t=n.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var gd=n=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(n)}finally{t.close(),e.close()}};var yd=n=>{n.start=(t=>(e=0,r=0,i)=>{let o=n.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/n.context.sampleRate?t.call(n,e,0,0):t.call(n,e,s,i)})(n.start)};var Pc=(n,t)=>{let e=t.createGain();n.connect(e);let r=(i=>()=>{i.call(n,e),n.removeEventListener("ended",r)})(n.disconnect);n.addEventListener("ended",r),Re(n,e),n.stop=(i=>{let o=!1;return(s=0)=>{if(o)try{i.call(n,s)}catch(a){e.gain.setValueAtTime(0,s)}else i.call(n,s),o=!0}})(n.stop)};var ui=(n,t)=>e=>{let r={value:n};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(n,e):t.handleEvent.call(n,e)};var _y=al(Ve),vy=yl(Ve),Iy=ph(Lr),bd=new WeakMap,Sy=Nh(bd),Me=Hl(new Map,new WeakMap),nr=od(),Ad=ip(Me,Ne),Fc=Th(Yt),Jt=Yp(Yt,Fc,br),wy=Cl(Ad,Ct,Jt),St=Mh(ki),Ar=Op(nr),_t=Yh(Ar),Cd=new WeakMap,_d=Ch(ui),Xi=ap(nr),Bc=qh(Xi),Gc=Wh(nr),vd=Uh(nr),Hn=up(nr),Pt=Fl(cl(rs),gl(_y,vy,Pi,Iy,Fi,Yt,Sy,rr,Ct,Ve,ae,br,Bi),Me,Ph(Wn,Fi,Yt,Ct,ai,ae),Ne,Wi,Kt,uh(Pi,Wn,Yt,Ct,ai,St,ae,_t),fh(Cd,Yt,Gt),_d,St,Bc,Gc,vd,_t,Hn),Ty=Al(Pt,wy,Ne,Ad,St,_t);var Vc=new WeakSet,xd=np(nr),Id=ih(new Uint32Array(1)),qc=sd(Id,Ne),Wc=ad(Id),Uc=_l(Vc,Me,Kt,xd,Ar,td(xd),qc,Wc);var gs=xl(ce),Sd=Hp(Fc,Pr,br),or=Jl(Sd),Qi=sp(gs,Me,dd,md,fd,ms,Lc,fs,yd,cd(Zi),Pc),sr=zp(Oh(Pr),Sd),Ny=Sl(or,Qi,Ct,sr,Jt),We=Bl(ul(is),Cd,qn,Gl,mc,fc,gc,yc,xc,Ri,Pn,Xi,jc),Oy=Il(Pt,Ny,We,wt,Qi,St,_t,ui);var Ry=El(Pt,kl,Ne,wt,cp(ce,Zi),St,_t,Jt),My=Yl(or,Rc,Ct,sr,Jt),li=Qp(bd),Dy=zl(Pt,We,My,Wi,Rc,St,_t,li),Gr=ep(Ve,Gc),Ey=ud(wt,Gr),Vr=gp(Xi,Ey),ky=Xl(Vr,Ct,Jt),jy=Zl(Pt,ky,Vr,St,_t),Ly=Kl(Yi,Ct,Jt),Py=Ql(Pt,Ly,Yi,St,_t,hd),Fy=bp(gs,Qi,ce,Gr),Ki=xp(gs,Me,Fy,ms,fs),By=rh(or,Ki,Ct,sr,Jt),Gy=eh(Pt,We,By,Ki,St,_t,ui),wd=Ap(Kt,Zi),Vy=oh(wd,Ct,Jt),qy=nh(Pt,Vy,wd,St,_t,li),Wy=hh(or,Mc,Ct,sr,Jt),Uy=lh(Pt,We,Wy,Mc,St,_t,li),Td=Cp(Kt),zy=xh(or,Td,Ct,sr,Jt),Yy=yh(Pt,We,zy,Td,Kt,St,_t,li),Hy=Sh(or,ce,Ct,sr,Jt),Zy=Ih(Pt,We,Hy,ce,St,_t),Xy=Ip(Wi,wt,Hi,Kt),ys=Zp(Me,ce,Hi,rd(ce,Ar)),Qy=Lh(Qi,Ct,Ar,Jt,ys),Ky=_p(Xy),Jy=jh(Pt,Ky,Qy,St,_t,li),$y=jl(We,Vr,Ki,Hi,Kt,Ec,_t,Zi),Nd=new WeakMap,zc=$h(Ry,$y,_d,_t,Nd,ui),Od=Rp(gs,Me,ms,Lc,fs,Pc),tx=Gp(or,Od,Ct,sr,Jt),ex=Bp(Pt,We,Od,tx,St,_t,ui),Rd=th(Qi),rx=Pp(Rd,wt,ce,kc,Gr),xs=Lp(Rd,wt,rx,kc,Gr,Xi,Zi),ix=Dp(Pi,wt,Vr,ce,Hi,xs,Kt,Fi,Ec,Gr),Md=Mp(ix),nx=qp(or,Vr,Ki,ce,Md,Ct,Ar,sr,Jt,ys),ox=Vp(Pt,We,Md,nx,St,_t,li),sx=Ep(Ne),ax=Wp(sx,St,new WeakSet,pd),cx=jp(Vr,Yi,ce,xs,Kt,Gr),Dd=kp(cx,Kt),ux=$p(or,Dd,Ct,sr,Jt),lx=Jp(Pt,We,Dd,ux,St,_t),hx=nd(xs,Ct,Jt),px=id(Pt,wt,xs,hx,St,_t,li),Ed=Hh(nr),Yc=_h(nr),kd=new WeakMap,dx=Dh(kd,Ar),mx=Ed?fl(Me,Kt,Ah(nr),Yc,vh(sl),St,dx,_t,Hn,new WeakMap,new WeakMap,ed(Hn,Ar),nr):void 0,fx=zh(Bc,_t),gx=ch(Vc,Me,ah,bh,new WeakSet,St,fx,ji,qe,qc,Wc),jd=Ul(mx,Ty,Uc,Oy,Dy,jy,Py,Gy,qy,gx,Uy,Yy,Zy,Jy,zc,ex,ox,ax,lx,px),yx=Zh(Pt,Sp,St,_t),xx=Xh(Pt,wp,St,_t),bx=Qh(Pt,Tp,St,_t),Ax=Np(wt,_t),Cx=Kh(Pt,Ax,St),Ld=Dl(jd,wt,Kt,Dc,yx,xx,bx,Cx,Xi);var Hc=Eh(Nd),_x=bl(Hc),Pd=$l(Ne),vx=dh(Hc),Fd=gh(Ne),Bd=new WeakMap,Ix=wh(Bd,Gt),Sx=fp(Pd,Ne,wt,Vr,Yi,Ki,ce,Hi,Kt,Fd,Yc,Ix,Gr),wx=hp(wt,Sx,ce,Kt,Gr),Tx=Wl(or,Pd,Qi,Vr,Yi,Ki,ce,vx,Fd,Yc,Ct,Hn,Ar,sr,Jt,ys),Nx=Rh(kd),Ox=Xp(Bd),Zc=Ed?Vl(_x,Pt,We,Tx,wx,Yt,Nx,St,_t,Hn,ld,Ox,gd,ui):void 0;var jq=Jh(wt,Kt,Dc,zc,Xi);var Gd=sh(Kt,Ar),Vd=Kp(Vc,Me,Fc,Hc,ys,ji,qc,Wc),Lq=tp(Me,wt,Gd,zc,Vd);var qd=Fp(jd,Me,wt,Gd,Vd);var Wd=Fh(ki,Bc),Ud=Bh(Ei,Gc),zd=Gh(qn,vd),Yd=Vh(ki,_t);function Ft(n){return n===void 0}function $(n){return n!==void 0}function Hd(n){return typeof n=="function"}function $t(n){return typeof n=="number"}function Ue(n){return Object.prototype.toString.call(n)==="[object Object]"&&n.constructor===Object}function Xc(n){return typeof n=="boolean"}function Ot(n){return Array.isArray(n)}function re(n){return typeof n=="string"}function Zn(n){return re(n)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(n)}function z(n,t){if(!n)throw new Error(t)}function Et(n,t,e=1/0){if(!(t<=n&&n<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${n}`)}function bs(n){!n.isOffline&&n.state!=="running"&&hi('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Xd=!1,Zd=!1;function Qc(n){Xd=n}function Qd(n){Ft(n)&&Xd&&!Zd&&(Zd=!0,hi("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var Kd=console;function Jd(...n){Kd.log(...n)}function hi(...n){Kd.warn(...n)}function $d(n){return new Ld(n)}function tm(n,t,e){return new qd(n,t,e)}var ie=typeof self=="object"?self:null,em=ie&&(ie.hasOwnProperty("AudioContext")||ie.hasOwnProperty("webkitAudioContext"));function rm(n,t,e){return z($(Zc),"AudioWorkletNode only works in a secure context (https or localhost)"),new(n instanceof(ie==null?void 0:ie.BaseAudioContext)?ie==null?void 0:ie.AudioWorkletNode:Zc)(n,t,e)}function ne(n,t,e,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(t,e,o):s(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o}function ht(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(h){s(h)}}function c(l){try{u(r.throw(l))}catch(h){s(h)}}function u(l){l.done?o(l.value):i(l.value).then(a,c)}u((r=r.apply(n,t||[])).next())})}var As=class{constructor(t,e,r,i){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let t=new Blob([`
|
|
1
|
+
/* WebMusicScore v4.0.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
|
+
"use strict";var WebMusicScore=(()=>{var Zo=Object.defineProperty,km=Object.defineProperties,jm=Object.getOwnPropertyDescriptor,Pm=Object.getOwnPropertyDescriptors,Lm=Object.getOwnPropertyNames,Ho=Object.getOwnPropertySymbols;var Ya=Object.prototype.hasOwnProperty,Tu=Object.prototype.propertyIsEnumerable;var Nu=Math.pow,za=(n,t,e)=>t in n?Zo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,M=(n,t)=>{for(var e in t||(t={}))Ya.call(t,e)&&za(n,e,t[e]);if(Ho)for(var e of Ho(t))Tu.call(t,e)&&za(n,e,t[e]);return n},X=(n,t)=>km(n,Pm(t));var Mr=(n,t)=>{var e={};for(var r in n)Ya.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&Ho)for(var r of Ho(n))t.indexOf(r)<0&&Tu.call(n,r)&&(e[r]=n[r]);return e};var Ni=(n,t)=>{for(var e in t)Zo(n,e,{get:t[e],enumerable:!0})},Fm=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lm(t))!Ya.call(n,i)&&i!==e&&Zo(n,i,{get:()=>t[i],enumerable:!(r=jm(t,i))||r.enumerable});return n};var Bm=n=>Fm(Zo({},"__esModule",{value:!0}),n);var d=(n,t,e)=>za(n,typeof t!="symbol"?t+"":t,e);var K=(n,t,e)=>new Promise((r,i)=>{var o=c=>{try{a(e.next(c))}catch(u){i(u)}},s=c=>{try{a(e.throw(c))}catch(u){i(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((e=e.apply(n,t)).next())});var Pb={};Ni(Pb,{Audio:()=>uo,Core:()=>Ja,Pieces:()=>wu,Score:()=>Su,Theory:()=>uc});var uo={};Ni(uo,{getCurrentInstrument:()=>ob,getInstrumentList:()=>nb,playNote:()=>Ys,registerInstrument:()=>sb,setInstrument:()=>_m,stop:()=>du});var uc={};Ni(uc,{AccidentalType:()=>tc,Chord:()=>ec,DefaultGuitarNoteLabel:()=>yg,DefaultHandedness:()=>Wg,DefaultPitchNotation:()=>fg,DefaultTuningName:()=>zg,GuitarNoteLabel:()=>Qo,GuitarNoteLabelList:()=>xg,Handedness:()=>ic,Interval:()=>Pn,KeySignature:()=>Le,Mode:()=>$a,Note:()=>W,NoteLength:()=>Zt,NoteLengthProps:()=>Xt,PitchNotation:()=>Er,PitchNotationList:()=>mg,RhythmProps:()=>Qt,Scale:()=>jr,ScaleFactory:()=>zt,ScaleType:()=>ei,SymbolSet:()=>Dr,TimeSignature:()=>gr,TuningNameList:()=>Fn,Tuplet:()=>fr,alterTempoSpeed:()=>cc,getDefaultKeySignature:()=>Ko,getDefaultScale:()=>jg,getDefaultTempo:()=>rs,getDefaultTimeSignature:()=>es,getPitchNotationName:()=>gg,getScale:()=>dr,getScaleFactory:()=>tl,getScaleFactoryList:()=>Eg,getTempoString:()=>ac,getTuningStrings:()=>$o,validateGuitarNoteLabel:()=>bg,validateHandedness:()=>Ug,validateIntervalQuality:()=>Ng,validateNoteLength:()=>ii,validatePitchNotation:()=>zu,validateScaleType:()=>Ln,validateTuningName:()=>nc,validateTupletRatio:()=>ts});var Ru=Object.defineProperty,Gm=(n,t,e)=>t in n?Ru(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,pr=(n,t)=>{for(var e in t)Ru(n,e,{get:t[e],enumerable:!0})},tr=(n,t,e)=>Gm(n,typeof t!="symbol"?t+"":t,e),A={};pr(A,{Arr:()=>Mu,Dom:()=>ju,Enum:()=>Pu,Is:()=>Lu,Map:()=>Bu,Math:()=>Du,Obj:()=>Gu,Str:()=>Vu});var Mu={};pr(Mu,{arrayContains:()=>nf,chunckArray:()=>of,duplicate:()=>Km,fillArray:()=>tf,getRangeArray:()=>rf,getSequenceArray:()=>ef,isArray:()=>Za,mapRangeArray:()=>ku,mapSequenceArray:()=>Eu,removeDuplicates:()=>Jm,removeDuplicatesCmp:()=>$m,toArray:()=>Qm});var Du={};pr(Du,{calcNormal:()=>Zm,clamp:()=>Hm,interpolateCoord:()=>zm,interpolateY:()=>Ym,isInteger:()=>Se,linearToDecibels:()=>Vm,mod:()=>qm,romanize:()=>Wm,sum:()=>Xm,toOrdinalNumber:()=>Um});function Se(n){return typeof n=="number"&&isFinite(n)&&n===Math.trunc(n)}function Vm(n){if(isFinite(n))return n<=0?-1/0:20*Math.log10(n);throw new Error("linearToDecibel: Invalid linearVolume = "+n)}function qm(n,t){return(n%t+t)%t}function Wm(n){if(!Se(n)||n<0)throw new Error("romanize: Invalid n = "+n);for(var t=String(+n).split(""),e=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",i=3;i--;)r=(e[+t.pop()+i*10]||"")+r;return Array(+t.join("")+1).join("M")+r}function Um(n){if(!Se(n))throw new Error("toOrdinalNumber: Invalid n = "+n);let t=n.toString(),e=Number(t.charAt(t.length-1));return n===1||n>=20&&e===1?t+"st":n===2||n>=20&&e===2?t+"nd":n===3||n>=20&&e===3?t+"rd":t+"th"}function zm(n,t,e,r,i){return{x:n+(e-n)*i,y:t+(r-t)*i}}function Ym(n,t,e,r,i){let o=(i-n)/(e-n);return t+(r-t)*o}function Hm(n,t,e){return Math.min(Math.max(n,t),e)}function Zm(n,t,e,r){let i=e-n,s=-(r-t),a=i,c=Math.sqrt(s*s+a*a);return c>0?(s/=c,a/=c):(s=0,a=1),{nx:s,ny:a}}function Xm(n){return n.reduce((t,e)=>e+t,0)}function Za(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function Qm(n){return Za(n)?n:[n]}function Km(n){return n===void 0?n:n.slice()}function Jm(n){return n.filter((t,e,r)=>r.indexOf(t)===e)}function $m(n,t){return n.filter((e,r,i)=>r===i.findIndex(o=>t(e,o)))}function tf(n,t){if(!Se(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(n)}function Eu(n,t){if(!Se(n)||n<0)throw new Error("mapSequenceArray: Invalid len = "+n);let e=new Array(n);for(let r=0;r<n;r++)e[r]=t(r);return e}function ef(n){return Eu(n,t=>t)}function ku(n,t,e){if(!Se(n))throw new Error("mapRangeArray: Invalid start = "+t);if(!Se(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-n)+1,i=new Array(r);for(let o=0,s=n,a=Math.sign(t-n);o<r;s+=a,o++)i[o]=e(s);return i}function rf(n,t){return ku(n,t,e=>e)}function nf(n,t){return n.indexOf(t)>=0}function of(n,t){if(!Se(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}var ju={};pr(ju,{addClass:()=>sf,appendTo:()=>mf,getButton:()=>xf,getCanvas:()=>bf,getCanvasTextWidth:()=>vf,getDimension:()=>Cf,getHeight:()=>pf,getOffset:()=>uf,getPadding:()=>Af,getWidth:()=>lf,hasClass:()=>Xa,removeClass:()=>af,removeFromParent:()=>ff,setHeight:()=>df,setOffset:()=>cf,setRect:()=>yf,setVisibility:()=>gf,setWidth:()=>hf,styleLayoutChanged:()=>_f});var Pu={};pr(Pu,{getEnumValues:()=>Xo});function Xo(n){return Object.keys(n).filter(t=>Number.isNaN(Number(t))).map(t=>n[t])}var Ha;(n=>{let t=Error;function e(x){t=x!=null?x:Error}n.setErrorClass=e;function r(x,N){throw new t("Assertion Error: "+x+(N?" "+N:""))}function i(x){return typeof x=="number"&&isFinite(x)&&x===Math.trunc(x)}function o(x){return typeof x=="number"}function s(x,N){x||r(N!=null?N:"Assertion failed!")}n.assert=s;function a(x,N,k="value"){if(!Xo(N).some(R=>R===x))throw new TypeError(`Invalid ${k} enum value: ${x}`)}n.assertEnum=a;function c(x){r(x!=null?x:"Interrupted!")}n.interrupt=c;function u(x,N){return i(x)||r(`Expected ${x} to be integer.`,N),x}n.int=u;function l(x,N,k){return x!==N&&r(`Expected ${x} to equal ${N}.`,k),x}n.eq=l;function h(x,N,k){return i(x)&&o(N)&&x===N||r(`Expected ${x} to be integer equal to ${N}.`,k),x}n.int_eq=h;function p(x,N,k){return i(x)&&o(N)&&x<N||r(`Expected ${x} to be integer less than ${N}.`,k),x}n.int_lt=p;function m(x,N,k){return i(x)&&o(N)&&x<=N||r(`Expected ${x} to be integer less than or equal to ${N}.`,k),x}n.int_lte=m;function f(x,N,k){return i(x)&&o(N)&&x>N||r(`Expected ${x} to be integer greater than ${N}.`,k),x}n.int_gt=f;function g(x,N,k){return i(x)&&o(N)&&x>=N||r(`Expected ${x} to be integer greater than or equal to ${N}.`,k),x}n.int_gte=g;function y(x,N,k,R){return i(x)&&o(N)&&o(k)&&x>=N&&x<=k||r(`Expected ${x} to be integer between ${N} and ${k}.`,R),x}n.int_between=y;function b(x,N){return i(x)&&x%2===1||r(`Expected ${x} to be odd number.`,N),x}n.odd=b;function I(x,N){return i(x)&&x%2===0||r(`Expected ${x} to be even number.`,N),x}n.even=I;function S(x,N,k){if(!N.some(R=>R===x)){let R=N.map(D=>String(D)).join(", ");r(`Expected ${x} to be in group [${R}].`,k)}return x}n.in_group=S;function w(x,N){return o(x)&&isFinite(x)||r(`Expected ${x} to be finite number.`,N),x}n.finite=w;function _(x,N,k){return i(N)&&N>=0&&N<x.length||r(`Expected ${N} to be array index in bounds [0..${x.length-1}].`,k),N}n.array_id=_;function v(x,N,k){return x[_(x,N,k)]}n.array_elem=v;function C(x,N){if(x===void 0)r("Required value is undefined.",N);else return x}n.require=C})(Ha||(Ha={}));var kn;(n=>{function t(){let p=document.createElement("div");p.style.width="1in",document.body.appendChild(p);let m=p.offsetWidth;return p.remove(),m||96}function e(){try{let p=document.createElement("div");p.style.visibility="hidden",p.style.width="100px",document.body.appendChild(p);let m=p.offsetWidth;p.style.overflow="scroll";let f=document.createElement("div");f.style.width="100%",p.appendChild(f);let g=f.offsetWidth;return p.parentNode&&p.parentNode.removeChild(p),m-g}catch(p){return 0}}function r(){let p=document.createElement("div");p.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",p.appendChild(document.createTextNode("M")),document.body.appendChild(p);let m=p.offsetHeight;return document.body.removeChild(p),m}function i(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var p=" -webkit- -moz- -o- -ms- ".split(" "),m=function(g){return window.matchMedia(g).matches},f=["(",p.join("touch-enabled),("),"heartz",")"].join("");return m(f)}function o(){let p=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(p)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(p.substr(0,4))}function s(){return location.protocol+"//"+location.host}let a=/^(mm|cm|in|inch|px|em)$/,c=/^([0-9\\.]+)(.*)$/;n.DPI=t(),n.PxPerMm=n.DPI/25.4,n.ScrollbarWidth=e(),n.FontSize=r(),n.IsTouchDevice=i(),n.IsMobileDevice=o(),n.HostAddress=s();function u(p){return p/n.PxPerMm}n.pxToMm=u;function l(p){return p*n.PxPerMm}n.mmToPx=l;function h(p){if(typeof p=="number")return p;let m=NaN,f,g=p.toString().match(c);if(g&&g[1]){m=parseFloat(g[1]);let y=g[2]?g[2].toLowerCase():"undefined";f=a.test(y)?y:void 0,f||console.log("Unknown unit '"+y+"' => using 'px'.")}else m=parseFloat(p);switch(Ha.finite(m,"value in function toPx"),f){case"mm":return l(m);case"cm":return l(m)*10;case"in":case"inch":return l(m)*25.4;case"em":return n.FontSize*m;default:case"px":return m}}n.toPx=h})(kn||(kn={}));function vt(n){return n===void 0?void 0:kn.toPx(n)}function Xa(n,t){return t.length===0?!1:n.classList?n.classList.contains(t):!!n.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function sf(n,t){t.length!==0&&(n.classList?n.classList.add(t):Xa(n,t)||(n.className+=" "+t))}function af(n,t){if(t.length!==0){if(n.classList)n.classList.remove(t);else if(Xa(n,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");n.className=n.className.replace(e," ")}}}function cf(n,t,e,r="px"){n.style.left=t+r,n.style.top=e+r}function uf(n){let t=n.getBoundingClientRect(),e=document.documentElement;return{top:t.top+window.pageYOffset-e.clientTop,left:t.left+window.pageXOffset-e.clientLeft}}function lf(n){if(n instanceof Window)return n.innerWidth;{let t=parseFloat(getComputedStyle(n,null).width.replace("px",""));return isNaN(t)?0:t}}function hf(n,t){n.style.width=t+"px"}function pf(n){if(n instanceof Window)return n.innerHeight;{let t=parseFloat(getComputedStyle(n,null).height.replace("px",""));return isNaN(t)?0:t}}function df(n,t){n.style.height=t+"px"}function mf(n,t){t.appendChild(n)}function ff(n){n.remove()}function gf(n,t){n.style.display=t?"block":"none"}function yf(n,t,e,r,i,o="px"){n.style.left=t+o,n.style.top=e+o,n.style.width=r+o,n.style.height=i+o}function xf(n){let t=typeof n=="string"?document.getElementById(n):n;return t instanceof HTMLButtonElement?t:void 0}function bf(n){let t=typeof n=="string"?document.getElementById(n):n;return t instanceof HTMLCanvasElement?t:void 0}function Af(n){var s;if(!n)return{top:0,right:0,bottom:0,left:0};let t=vt(n.paddingTop),e=vt(n.paddingRight),r=vt(n.paddingBottom),i=vt(n.paddingLeft),o=((s=n.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(o.length){case 0:break;case 1:t!=null||(t=vt(o[0])),e!=null||(e=vt(o[0])),r!=null||(r=vt(o[0])),i!=null||(i=vt(o[0]));break;case 2:t!=null||(t=vt(o[0])),e!=null||(e=vt(o[1])),r!=null||(r=vt(o[0])),i!=null||(i=vt(o[1]));break;case 3:t!=null||(t=vt(o[0])),e!=null||(e=vt(o[1])),r!=null||(r=vt(o[2])),i!=null||(i=vt(o[1]));break;case 4:default:t!=null||(t=vt(o[0])),e!=null||(e=vt(o[1])),r!=null||(r=vt(o[2])),i!=null||(i=vt(o[3]));break}return t!=null||(t=0),e!=null||(e=0),r!=null||(r=0),i!=null||(i=0),{top:t,right:e,bottom:r,left:i}}function Cf(n){let t=vt(n==null?void 0:n.left),e=vt(n==null?void 0:n.right),r=vt(n==null?void 0:n.top),i=vt(n==null?void 0:n.bottom),o=vt(n==null?void 0:n.width),s=vt(n==null?void 0:n.height);return o===void 0&&t!==void 0&&e!==void 0&&(o=e-t),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:t,top:r,width:o,height:s}}function _f(n,t){return!n&&!t?!1:!n||!t?!0:n.left!==t.left||n.top!==t.top||n.right!==t.right||n.bottom!==t.bottom||n.width!==t.width||n.height!==t.height}var Dn;function vf(n,t){Dn!=null||(Dn=document.createElement("canvas"));let e=Dn.getContext("2d");return e?(e.font=t,e.measureText(n).width):0}var Lu={};pr(Lu,{isArray:()=>Jr,isArrayOrUndefined:()=>Nf,isBoolean:()=>Bf,isBooleanOrUndefined:()=>Gf,isEmptyArray:()=>Of,isEmptyArrayOrUndefined:()=>Mf,isEmptyString:()=>kf,isEmptyStringOrUndefined:()=>Lf,isEnumValue:()=>Wf,isEnumValueOrUndefined:()=>Uf,isFinite:()=>Qa,isFunction:()=>Vf,isFunctionOrUndefined:()=>qf,isInfinity:()=>eg,isInteger:()=>$r,isIntegerBetween:()=>$f,isIntegerEq:()=>Zf,isIntegerGt:()=>Xf,isIntegerGte:()=>Qf,isIntegerLt:()=>Kf,isIntegerLte:()=>Jf,isIntegerOrUndefined:()=>Hf,isNaNValue:()=>tg,isNegInfinity:()=>ig,isNonEmptyArray:()=>Rf,isNonEmptyArrayOrUndefined:()=>Df,isNonEmptyString:()=>jf,isNonEmptyStringOrUndefined:()=>Ff,isNull:()=>Sf,isNullish:()=>wf,isNumber:()=>zf,isNumberOrUndefined:()=>Yf,isObject:()=>Fu,isObjectOrUndefined:()=>Tf,isPosInfinity:()=>rg,isString:()=>Ef,isStringOrUndefined:()=>Pf,isUndefined:()=>If});function If(n){return n===void 0}function Sf(n){return n===null}function wf(n){return n==null}function Fu(n){return typeof n=="object"&&n!==null&&!Jr(n)}function Tf(n){return n===void 0||Fu(n)}function Jr(n){return!!n&&Object.prototype.toString.call(n)==="[object Array]"}function Nf(n){return n===void 0||Jr(n)}function Of(n){return Jr(n)&&n.length===0}function Rf(n){return Jr(n)&&n.length>0}function Mf(n){return Jr(n)&&n.length===0||n===void 0}function Df(n){return Jr(n)&&n.length>0||n===void 0}function Ef(n){return typeof n=="string"}function kf(n){return typeof n=="string"&&n.length===0}function jf(n){return typeof n=="string"&&n.length>0}function Pf(n){return n===void 0||typeof n=="string"}function Lf(n){return typeof n=="string"&&n.length===0||n===void 0}function Ff(n){return typeof n=="string"&&n.length>0||n===void 0}function Bf(n){return typeof n=="boolean"}function Gf(n){return n===void 0||typeof n=="boolean"}function Vf(n){return typeof n=="function"}function qf(n){return n===void 0||typeof n=="function"}function Wf(n,t,e="value"){return Xo(t).some(r=>r===n)}function Uf(n,t,e="value"){return n===void 0||Xo(t).some(r=>r===n)}function zf(n){return typeof n=="number"}function Yf(n){return typeof n=="number"||n===void 0}function Qa(n){return typeof n=="number"&&Number.isFinite(n)}function $r(n){return typeof n=="number"&&Qa(n)&&n===Math.trunc(n)}function Hf(n){return typeof n=="number"&&Qa(n)&&n===Math.trunc(n)||n===void 0}function Zf(n,t){return $r(n)&&n===t}function Xf(n,t){return $r(n)&&n>t}function Qf(n,t){return $r(n)&&n>=t}function Kf(n,t){return $r(n)&&n<t}function Jf(n,t){return $r(n)&&n<=t}function $f(n,t,e){return $r(n)&&n>=t&&n<=e}function tg(n){return typeof n=="number"&&Number.isNaN(n)}function eg(n){return typeof n=="number"&&Math.abs(n)===1/0}function rg(n){return typeof n=="number"&&n===1/0}function ig(n){return typeof n=="number"&&n===-1/0}var Bu={};pr(Bu,{getMapKeys:()=>ng});function ng(n){let t=[];return n.forEach((e,r)=>t.push(r)),t}var Gu={};pr(Gu,{isObject:()=>og});function og(n){return typeof n=="object"&&n!==null&&!Za(n)}var Vu={};pr(Vu,{charCount:()=>hg,chunkString:()=>cg,insertAt:()=>ug,makeSentenceFromPascal:()=>pg,removeAt:()=>lg,repeatString:()=>ag,replaceAt:()=>Ka,toCharArray:()=>sg});function sg(n){return n.split("")}function ag(n,t){if(!Se(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(n)}function cg(n,t){if(!Se(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<n.length;r+=t)e.push(n.slice(r,r+t));return e}function Ka(n,t,e,r){if(!Se(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!Se(t)||t<0||t+e>n.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+n.length);return n.substring(0,t)+r+n.substring(t+e)}function ug(n,t,e){return Ka(n,t,0,e)}function lg(n,t,e){return Ka(n,t,e,"")}function hg(n,t){if(t.length!==1||n.length===0)return 0;let e=0;for(let r=0;r<n.length;r++)n[r]===t&&e++;return e}function pg(n){if(n==="")return"";let t=n.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},i=o=>o.toUpperCase()!==o.toLowerCase()&&o===o.toUpperCase();for(let o=1;o<n.length;o++){let s=n.charAt(o);i(s)&&r(),t+=s.toLowerCase()}return r(),e}var Ou;(n=>{let t="ConsentCookie",e;(w=>{w.Accept="accept",w.Decline="decline"})(e||(e={}));let r,i,o=p(t);r=o==="accept"||o==="decline"?o:void 0;function s(w){i=new Date,i.setDate(i.getDate()+w)}n.setExpireDays=s;function a(){return r===void 0}n.isConsentPending=a;function c(){r="accept",h(t,r)}n.accept=c;function u(){r="decline",h(t,r)}n.decline=u;function l(){return document.cookie.split(";").map(_=>_.trim())}function h(w,_){let v=w+"="+_.toString()+";sameSite=Lax;";return i&&(v+="expires="+i.toUTCString()+";"),document.cookie=v,_}function p(w,_){let v=l().find(C=>C.startsWith(w+"="));return v===void 0?_:v.substring(w.length+1)}function m(w){document.cookie=w+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(w,_){return r==="accept"&&h(w,_),_}n.save=f;function g(w,_){return r==="accept"&&p(w,_)||_}n.read=g;function y(w,_){if(r==="accept"){let v=p(w);return v===void 0?_:parseInt(v)}else return _}n.readInt=y;function b(w,_){if(r==="accept"){let v=p(w);return v===void 0?_:/true|1/i.test(v)}else return _}n.readBool=b;function I(w){(r==="accept"||w===t)&&m(w)}n.erase=I;function S(){document.cookie.split(";").forEach(w=>I(w.trim().split("=")[0]))}n.eraseAll=S})(Ou||(Ou={}));var qu=class En{constructor(t,e){tr(this,"x"),tr(this,"y"),this.x=t!=null?t:0,this.y=e!=null?e:0}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}add(t){return new En(this.x+t.x,this.y+t.y)}sub(t){return new En(this.x-t.x,this.y-t.y)}mul(t){return new En(this.x*t,this.y*t)}div(t){return new En(this.x/t,this.y/t)}},Wu=class{constructor(n,t=1/0){tr(this,"cache"),tr(this,"next"),tr(this,"prev"),tr(this,"head"),tr(this,"tail"),tr(this,"capacity"),tr(this,"size"),tr(this,"maxKeyLength"),this.cache=Object.create(null),this.next=Object.create(null),this.prev=Object.create(null),this.head=null,this.tail=null,this.capacity=n,this.size=0,this.maxKeyLength=t}get(n){if(!(n.length>this.maxKeyLength)&&this.cache[n]!==void 0)return this.touch(n),this.cache[n]}set(n,t){if(!(n.length>this.maxKeyLength)){if(this.cache[n]!==void 0){this.cache[n]=t,this.touch(n);return}this.size>=this.capacity&&this.evict(),this.cache[n]=t,this.addToTail(n),this.size++}}touch(n){this.tail!==n&&(this.removeKey(n),this.addToTail(n))}evict(){if(this.head!==null){let n=this.head;this.removeKey(n),delete this.cache[n],this.size--}}removeKey(n){let t=this.prev[n],e=this.next[n];t!==void 0?this.next[t]=e:this.head=e!=null?e:null,e!==void 0?this.prev[e]=t:this.tail=t!=null?t:null,delete this.prev[n],delete this.next[n]}addToTail(n){this.tail!==null?(this.next[this.tail]=n,this.prev[n]=this.tail):this.head=n,this.tail=n}};var Ja={};Ni(Ja,{MusicError:()=>O,MusicErrorType:()=>pt,init:()=>ti});var pt=(a=>(a[a.Unknown=0]="Unknown",a[a.InvalidArg=1]="InvalidArg",a[a.Note=2]="Note",a[a.Scale=3]="Scale",a[a.KeySignature=4]="KeySignature",a[a.Timesignature=5]="Timesignature",a[a.Score=6]="Score",a))(pt||{});function dg(n){return n===void 0?"":`[${pt[n]}] `}var O=class extends Error{constructor(...e){let[r,i]=e.length===1?[0,e[0]]:e;super(dg(r)+i);d(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var Uu=!1;function ti(){Uu||(Uu=!0,console.log("%cWebMusicScore v4.0.1 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Dr=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(Dr||{}),Er=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(Er||{}),mg=A.Enum.getEnumValues(Er),fg=0;function zu(n){if(A.Is.isEnumValue(n,Er))return n;throw new O(1,`Invalid pitchNotation: ${n}`)}function gg(n){return Er[zu(n)]}var Qo=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Qo||{}),yg="Default",xg=A.Enum.getEnumValues(Qo);function bg(n){if(A.Is.isEnumValue(n,Qo))return n;throw new O(5,`Invalid guitarNoteLabel: ${n}`)}function Yu(n,t){return(n%t+t)%t}var Hu=12,Zu=7,Ag=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),Cg=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Xu=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),jn=["C","D","E","F","G","A","B"],Qu=[0,2,4,5,7,9,11],Ku=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,st=class st{constructor(t,e,r){d(this,"diatonicClass");d(this,"accidental");d(this,"octave");if(typeof t=="number"&&typeof e=="number"&&r===void 0)st.validateDiatonicId(t),this.diatonicClass=st.getDiatonicClass(t),this.accidental=st.validateAccidental(e),this.octave=st.getOctaveFromDiatonicId(t);else if(typeof t=="number"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=st.validateDiatonicClass(t),this.accidental=st.validateAccidental(e),this.octave=st.validateOctave(r);else if(typeof t=="string"&&typeof e=="number"&&typeof r=="number")this.diatonicClass=st.getDiatonicClass(t),this.accidental=st.validateAccidental(e),this.octave=st.validateOctave(r);else throw new O(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return st.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return st.getChromaticIdInOctave(Qu[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return st.getChromaticClass(Qu[this.diatonicClass]+this.accidental)}get noteLetter(){return jn[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:i}=this,o=st.getAccidentalSymbol(this.accidental,e);return t===1?i>=3?r.toLowerCase()+o+"\u2032".repeat(i-3):r.toUpperCase()+o+"\u0375".repeat(2-i):r+o+i}formatOmitOctave(t){let e=jn[this.diatonicClass],r=st.getAccidentalSymbol(this.accidental,t);return e+r}static getNote(t){let e=this.noteByNameCache.get(t);if(e===void 0){let r=st.parseNote(t);if(!r)throw new O(2,`Invalid noteName: ${t}`);if(r.octave===void 0)throw new O(2,"Octave is required for note.");e=new st(r.noteLetter,r.accidental,r.octave),this.noteByNameCache.set(t,e)}return e}static getChromaticNote(t){let e=this.chromaticNoteCache.get(t);if(e===void 0){let i=["C/B#","C#/Db","D","D#/Eb","E/Fb","F/E#","F#/Gb","G","G#/Ab","A","A#/Bb","B/Cb"][st.getChromaticClass(t)].split("/")[0]+st.getOctaveFromChromaticId(t),o=st.parseNote(i);if(!o)throw new O(2,`Invalid noteName: ${i}`);if(o.octave===void 0)throw new O(2,"Octave is required for note.");e=new st(o.noteLetter,o.accidental,o.octave),this.chromaticNoteCache.set(t,e)}return e}static getDiatonicClass(t){if(typeof t=="number")return Yu(t,7);if(typeof t=="string"&&t.length>0)return jn.indexOf(st.validateNoteLetter(t[0]));throw new O(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-Zu)/7)}static getDiatonicIdInOctave(t,e){return st.getDiatonicClass(t)+e*7+Zu}static getChromaticClass(t){return Yu(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-Hu)/12)}static getChromaticIdInOctave(t,e){return st.getChromaticClass(t)+e*12+Hu}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.diatonicId===e.diatonicId&&t.accidental===e.accidental}static replaceAccidentalSymbols(t,e){return e===1?t.replace("bb","\u{1D12B}").replace("b","\u266D").replace("#","\u266F").replace("x","\u{1D12A}"):t.replace("\u{1D12B}","bb").replace("\u266D","b").replace("\u266F","#").replace("\u{1D12A}","x")}static isValidNoteName(t){return Ku.test(t)}static parseNote(t){var c;let e=Ku.exec(t);if(!e)return;let r=st.validateNoteLetter(e[1]),i=e[2],o=st.validateAccidental((c=Xu.get(i))!=null?c:0),s=e[3],a=s?st.validateOctave(+s):void 0;return{noteLetter:r,accidental:o,octave:a}}static getScientificNoteName(t,e){let r=st.parseNote(t);if(!r)throw new O(2,`Invalid noteName: ${t}`);let{noteLetter:i,accidental:o,octave:s}=r;return i+st.getAccidentalSymbol(o,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?Cg.get(t):Ag.get(t)}static getAccidental(t){let e=Xu.get(t);if(e===void 0)throw new O(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return jn[st.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let i=st.getDiatonicClass(t),o=st.getDiatonicClass(e),s=r?i<=o?1:0:i<o?1:0;return st.getDiatonicIdInOctave(i,st.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(A.Is.isInteger(t))return t;throw new O(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(A.Is.isIntegerBetween(t,0,6))return t;throw new O(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(A.Is.isInteger(t))return t;throw new O(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(A.Is.isIntegerBetween(t,0,11))return t;throw new O(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(jn.some(e=>e===t))return t;throw new O(2,`Invalid note: ${t}`)}static validateOctave(t){if(A.Is.isInteger(t))return t;throw new O(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(A.Is.isIntegerBetween(t,-2,2))return t;throw new O(2,`Invalid accidental: ${t}`)}static sort(t){return t.slice().sort(st.compareFunc)}static removeDuplicates(t){let e=[];return t.forEach(r=>{e.find(i=>st.equals(r,i))===void 0&&e.push(r)}),e}static compareFunc(t,e){return t.diatonicId<e.diatonicId?-1:t.diatonicId>e.diatonicId?1:t.accidental<e.accidental?-1:t.accidental>e.accidental?1:0}};d(st,"noteByNameCache",new Map),d(st,"chromaticNoteCache",new Map);var W=st;function _g(n,t){let e=W.getChromaticClass(n)-new W(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return W.validateAccidental(e)}var vg=/^(bb?|b?|#?|x?)([0-9]*)$/;function Ig(n){var i,o;let t=vg.exec(""+n);if(!t)throw new O(4,`Invalid degree: ${n}`);let e=(o=W.getAccidental((i=t[1])!=null?i:""))!=null?o:0,r=+t[2];if(!A.Is.isInteger(e)||e<-2||e>2||!A.Is.isInteger(r)||r<1)throw new O(4,`Invalid degree: ${n}`);return{deg:r,acc:e}}var $a=(a=>(a[a.Ionian=1]="Ionian",a[a.Dorian=2]="Dorian",a[a.Phrygian=3]="Phrygian",a[a.Lydian=4]="Lydian",a[a.Mixolydian=5]="Mixolydian",a[a.Aeolian=6]="Aeolian",a[a.Locrian=7]="Locrian",a))($a||{}),tc=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(tc||{});function Ko(){return dr("C","Major")}var kr=class kr{constructor(t,e){this.tonic=t;this.mode=e;d(this,"naturalScaleNotes");d(this,"accidentalByDiatonicClass");d(this,"orderedAccidentedNotes");if(!A.Is.isEnumValue(e,$a))throw new O(4,`Invalid mode: ${e}`);let r=[2,2,1,2,2,2,1];for(let c=1;c<e;c++)r.push(r.shift());this.naturalScaleNotes=[],this.accidentalByDiatonicClass=[];let i=W.getDiatonicClass(t[0]),o=W.getNote(t+"0").chromaticId;for(let c=0;c<7;i++,o+=r[c],c++){let u=new W(W.getDiatonicClass(i),_g(o,i));if(Math.abs(u.accidental)>=2)throw new O(4,"Key signature contains double accidental.");this.naturalScaleNotes[c]=u,this.accidentalByDiatonicClass[u.diatonicClass]=u.accidental}let s=this.naturalScaleNotes.filter(c=>c.accidental>0).sort((c,u)=>{let l=kr.OrderOfSharps.indexOf(c.noteLetter),h=kr.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=kr.OrderOfFlats.indexOf(c.noteLetter),h=kr.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new O(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new O(4,"Key Signature has both sharps and flats.");this.orderedAccidentedNotes=a.length>0?a:s}getAccidentalType(){return this.orderedAccidentedNotes.length===0?0:this.orderedAccidentedNotes[0].accidental<0?1:2}getNaturalScaleNotes(){return this.naturalScaleNotes}getAccidental(t){var e;return(e=this.accidentalByDiatonicClass[W.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=Ig(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let i=this.naturalScaleNotes[(e-1)%7];return new W(i.diatonicId,i.accidental+r)}}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.tonic===e.tonic&&t.mode===e.mode}};d(kr,"OrderOfSharps","FCGDAEB"),d(kr,"OrderOfFlats","BEADGCF");var Le=kr;var Sg=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),wg={1:{0:"Perfect",1:"Augmented","-1":"diminished",2:"Doubly Augmented","-2":"doubly diminished"},2:{2:"Major",1:"minor",3:"Augmented",0:"diminished",4:"Doubly Augmented","-1":"doubly diminished"},3:{4:"Major",3:"minor",5:"Augmented",2:"diminished",6:"Doubly Augmented",1:"doubly diminished"},4:{5:"Perfect",6:"Augmented",4:"diminished",7:"Doubly Augmented",3:"doubly diminished"},5:{7:"Perfect",8:"Augmented",6:"diminished",9:"Doubly Augmented",5:"doubly diminished"},6:{9:"Major",8:"minor",10:"Augmented",7:"diminished",11:"Doubly Augmented",6:"doubly diminished"},7:{11:"Major",10:"minor",12:"Augmented",9:"diminished",13:"Doubly Augmented",8:"doubly diminished"},8:{12:"Perfect",13:"Augmented",11:"diminished",14:"Doubly Augmented",10:"doubly diminished"}};function Tg(n,t){for(;n<1;)n+=7,t+=12;for(;n>8;)n-=7,t-=12;let e=wg[n];if(e)return e[t]}function Ng(n){if(n==="Perfect"||n==="Major"||n==="minor"||n==="Augmented"||n==="diminished"||n==="Doubly Augmented"||n==="doubly diminished")return n;throw new O(1,`Invalid interval quality: ${n}`)}function Og(n){if(A.Is.isIntegerGte(n,1))return A.Math.toOrdinalNumber(n);throw new O(1,`Invalid interval quantity: ${n}`)}var Jo=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},Pn=class n{constructor(t,e){this.note1=t;this.note2=e;d(this,"direction");d(this,"semitones");d(this,"quantity");d(this,"quality");e.diatonicId>=t.diatonicId?(this.direction=e.diatonicId===t.diatonicId?"Unison":"Ascending",this.quantity=e.diatonicId-t.diatonicId+1,this.semitones=e.chromaticId-t.chromaticId):(this.direction="Descending",this.quantity=t.diatonicId-e.diatonicId+1,this.semitones=t.chromaticId-e.chromaticId);let r=Tg(this.quantity,this.semitones);if(r)this.quality=r;else throw new Jo("Unknown interval quality")}static get(t,e){try{return new n(t,e)}catch(r){if(r instanceof Jo)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":Og(this.quantity);return t+e+r}toAbbrString(){var i;let t=this.direction==="Descending"?"\u2193":"",e=(i=Sg.get(this.quality))!=null?i:"?",r=this.quantity;return t+e+r}};function Rg(n){let t=W.getDiatonicClass("CCDDEFFGGAAB"[W.getChromaticClass(n)]),e=W.getOctaveFromChromaticId(n);return W.getDiatonicIdInOctave(t,e)}var Mg=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],ei=(g=>(g.Major="Major",g.NaturalMinor="Natural Minor",g.HarmonicMinor="Harmonic Minor",g.Ionian="Ionian",g.Dorian="Dorian",g.Phrygian="Phrygian",g.Lydian="Lydian",g.Mixolydian="Mixolydian",g.Aeolian="Aeolian",g.Locrian="Locrian",g.MajorPentatonic="Major Pentatonic",g.MinorPentatonic="Minor Pentatonic",g.MajorHexatonicBlues="Major Hexatonic Blues",g.MinorHexatonicBlues="Minor Hexatonic Blues",g.HeptatonicBlues="Heptatonic Blues",g))(ei||{});function Dg(n){switch(n){case"Major":return 1;case"Natural Minor":return 6;case"Harmonic Minor":return 6;case"Ionian":return 1;case"Dorian":return 2;case"Phrygian":return 3;case"Lydian":return 4;case"Mixolydian":return 5;case"Aeolian":return 6;case"Locrian":return 7;case"Major Pentatonic":return 1;case"Minor Pentatonic":return 6;case"Major Hexatonic Blues":return 1;case"Minor Hexatonic Blues":return 6;case"Heptatonic Blues":return 1;default:throw new O(3,`Invalid scaleType: ${n}`)}}var jr=class extends Le{constructor(e,r){super(e,Dg(r));this.tonic=e;this.scaleType=r;d(this,"scaleDegrees");d(this,"scaleNotes");d(this,"chromaticClassDegree");d(this,"preferredChromaticNoteCache",new Map);switch(r){case"Harmonic Minor":this.scaleDegrees=[1,2,3,4,5,6,"#7"];break;case"Major Pentatonic":this.scaleDegrees=[1,2,3,5,6];break;case"Minor Pentatonic":this.scaleDegrees=[1,3,4,5,7];break;case"Major Hexatonic Blues":this.scaleDegrees=[1,2,"b3",3,5,6];break;case"Minor Hexatonic Blues":this.scaleDegrees=[1,3,4,"b5",5,7];break;case"Heptatonic Blues":this.scaleDegrees=[1,2,"b3",4,"b5",6,"b7"];break;default:this.scaleDegrees=[1,2,3,4,5,6,7];break}this.scaleNotes=this.scaleDegrees.map(i=>this.getNoteByDegree(i)),this.chromaticClassDegree=[0,1,2,3,4,5,6,7,8,9,10,11].map(i=>{let o=this.scaleNotes.findIndex(s=>s.chromaticClass===i);return o>=0?this.scaleDegrees[o]:void 0})}static equals(e,r){return e==null&&r==null?!0:e==null||r==null?!1:e===r||e.getScaleName()===r.getScaleName()}getScaleName(e){switch(e){case 1:return W.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!A.Is.isIntegerGte(r,1))throw new O(3,`Invalid numOctaves: ${r}`);let i=[];for(let s=1;s<=r;s++)i=[...i,...this.scaleNotes];i.push(this.scaleNotes[0]);let o=W.getNote(e).diatonicId;return i.map(s=>(o=W.findNextDiatonicIdAbove(s.diatonicId,o,!1),new W(o,s.accidental)))}getScaleOverview(){return this.getScaleNotes("C4",1).map(e=>e.formatOmitOctave(1)).join(" - ")}getScaleSteps(){let e=this.getScaleNotes("C4",1).map(i=>i.chromaticId),r=[];for(let i=0;i<e.length-1;i++)r.push(A.Math.mod(e[i+1]-e[i],12));return r}getScaleStringSteps(){return this.getScaleSteps().map(e=>e===1?"H":e===2?"W":e.toString()+"H")}isScaleNote(e){return this.chromaticClassDegree[e.chromaticClass]!==void 0}isScaleRootNote(e){return String(this.chromaticClassDegree[e.chromaticClass])==="1"}getIntervalFromRootNote(e){let r=this.getScaleNotes("C0",1)[0];for(;e.chromaticId>=r.chromaticId+12;)e=new W(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new O(3,"Note is below rootNote.");let i=Pn.get(r,e);if(i===void 0)throw new O(3,"Interval is undefined.");return i}getPreferredChromaticNote(e){W.validateChromaticId(e);let r=this.preferredChromaticNoteCache.get(e);if(r)return r;let i=W.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new W(h.diatonicClass,h.accidental,i+1):h.noteLetter==="B"&&h.accidental>0?new W(h.diatonicClass,h.accidental,i-1):new W(h.diatonicClass,h.accidental,i)).find(h=>W.getChromaticClass(e)===h.chromaticClass),r)return this.preferredChromaticNoteCache.set(e,r),r;let s=Rg(e),a=s-2,c=s+2,l=this.getAccidentalType()===1?[0,-1,1,-2,2]:[0,1,-1,2,-2];for(let h=0;h<l.length;h++){let p=l[h];for(let m=Math.max(0,a);m<=c;m++)if(r=new W(m,p),e===r.chromaticId)return this.preferredChromaticNoteCache.set(e,r),r}return r=W.getChromaticNote(e),this.preferredChromaticNoteCache.set(e,r),r}},zt=class{constructor(t){this.type=t;d(this,"tonicList",[]);d(this,"scaleMap",new Map);let e=[],r=[],i=[];if(Mg.forEach(s=>{try{let a=new jr(s,this.type);switch(a.getAccidentalType()){case 0:e.push(a);break;case 2:if(s.endsWith("b"))return;r.push(a);break;case 1:if(s.endsWith("#"))return;i.push(a);break}this.scaleMap.set(s,a)}catch(a){}}),e.length===0)throw new O(3,"Expected natural scale.");let o=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(o).map(s=>s.tonic),"- Sharps -",...r.sort(o).map(s=>s.tonic),"- Flats -",...i.sort(o).map(s=>s.tonic)]}getTonicList(){return this.tonicList}getDefaultTonic(){return this.tonicList[0]}getType(){return this.type}getScale(t){let e=this.scaleMap.get(t);if(e)return e;throw new O(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},Ju=[new zt("Major"),new zt("Natural Minor"),new zt("Harmonic Minor"),"- Modes -",new zt("Ionian"),new zt("Dorian"),new zt("Phrygian"),new zt("Lydian"),new zt("Mixolydian"),new zt("Aeolian"),new zt("Locrian"),"- Pentatonic -",new zt("Major Pentatonic"),new zt("Minor Pentatonic"),"- Blues -",new zt("Major Hexatonic Blues"),new zt("Minor Hexatonic Blues"),new zt("Heptatonic Blues")];function Eg(){return Ju}var $u=new Map;Ju.forEach(n=>{n instanceof zt&&$u.set(n.getType(),n)});function tl(n){let t=$u.get(n);if(t)return t;throw new O(3,`Invalid scaleType: ${n}`)}function Ln(n){if(A.Is.isEnumValue(n,ei))return n;throw new O(3,`Invalid scaleType: "${n}"`)}function dr(n,t){let e,r;return t!==void 0?(e=n,r=Ln(t)):(e=n.split(" ")[0],r=Ln(n.substring(e.length+1))),tl(r).getScale(e)}var kg=dr("C","Major");function jg(){return kg}var mr=(n,t)=>n.chromaticClass===t.chromaticClass,Pg=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(n=>W.getNote(n+"0")),el=new Map;function Lg(n){let t=n.chromaticClass,e=el.get(t);if(!e){if(e=Pg.find(r=>mr(r,n)),!e)throw new O(1,`Invalid chord root note: ${n.formatOmitOctave(1)}`);el.set(t,e)}return e}function Fg(n,t){let e=n.formatOmitOctave(0);return dr(e,"Major").getNoteByDegree(t)}function Bg(n){return A.Arr.removeDuplicatesCmp(n,mr)}var Gg=[{name:"5",degrees:[1,5]},{name:"",degrees:[1,3,5]},{name:"m",degrees:[1,"b3",5]},{name:"dim",degrees:[1,"b3","b5"]},{name:"aug",degrees:[1,3,"#5"]},{name:"sus2",degrees:[1,2,5]},{name:"sus4",degrees:[1,4,5]},{name:"6",degrees:[1,3,5,6]},{name:"m6",degrees:[1,"b3",5,6]},{name:"m(maj7)",degrees:[1,"b3",5,7]},{name:"7",degrees:[1,3,5,"b7"]},{name:"7\u266D5",degrees:[1,3,"b5","b7"]},{name:"7\u266F5",degrees:[1,3,"#5","b7"]},{name:"7sus2",degrees:[1,2,5,"b7"]},{name:"7sus4",degrees:[1,4,5,"b7"]},{name:"dim7",degrees:[1,"b3","b5","bb7"]},{name:"maj7",degrees:[1,3,5,7]},{name:"maj7\u266D5",degrees:[1,3,"b5",7]},{name:"maj7\u266F5",degrees:[1,3,"#5",7]},{name:"m7",degrees:[1,"b3",5,"b7"]},{name:"m7\u266D5",degrees:[1,"b3","b5","b7"]},{name:"m7\u266F5",degrees:[1,"b3","#5","b7"]},{name:"9",degrees:[1,3,5,"b7",9]},{name:"m9",degrees:[1,"b3",5,"b7",9]},{name:"7\u266F9",degrees:[1,3,5,"b7","#9"]},{name:"7\u266D9",degrees:[1,3,5,"b7","b9"]},{name:"11",degrees:[1,3,5,"b7",9,11]},{name:"m11",degrees:[1,"b3",5,"b7",9,11]},{name:"13",degrees:[1,3,5,"b7",9,11,13]},{name:"m13",degrees:[1,"b3",5,"b7",9,11,13]}];function Vg(n,t){return n.degrees.every(e=>e!==t)?!0:n.degrees.length>=4&&t===5||n.degrees.length>=6&&t===9||n.degrees.length>=7&&t===11}var Oi=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},ec=class n{constructor(t,e,r,i){this.chordInfo=t;this.rootNote=r;d(this,"name");d(this,"notes");d(this,"omitNotes");d(this,"slashBassNote");this.name=t.name;let o=e.slice();!o.some(a=>mr(a,i))&&o.push(i),this.notes=new Array(this.chordInfo.degrees.length),this.omitNotes=new Array(this.chordInfo.degrees.length);for(let a=0;a<t.degrees.length;a++){let c=t.degrees[a],u=this.notes[a]=Fg(this.rootNote,c),l=o.findIndex(h=>mr(h,u));if(l>=0)this.omitNotes[a]=!1,o.splice(l,1);else if(Vg(t,c))this.omitNotes[a]=!0;else throw new Oi("Missing chord note!");mr(i,u)&&(i=u)}if(o.length>0)if(o.every(a=>mr(a,i)))this.slashBassNote=i;else throw new Oi("Got some extra notes that are not bass note!");else this.slashBassNote=mr(i,this.rootNote)?void 0:i;if(t.name==="5"&&this.slashBassNote)throw new Oi("Power chord no bass note allowed!")}static getChords(t){let e=[],r=W.sort(t),i=r[0],o=Bg(r);for(let s=0;s<o.length;s++){let a=Lg(o[s]);Gg.forEach(c=>{try{let u=new n(c,o,a,i),l=e.findIndex(h=>h.replaceWith(u));l>=0?e[l]=u:e.push(u)}catch(u){if(!(u instanceof Oi))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!mr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!mr(t.notes[e],this.notes[e])||t.omitNotes[e]!==this.omitNotes[e])return!1;return!0}toString(){let t=1,e=this.rootNote.formatOmitOctave(t),r=this.slashBassNote?"/"+this.slashBassNote.formatOmitOctave(t):"";return e+this.name+r}getDegreeNotationString(){let t=1,e=this.slashBassNote?this.slashBassNote.formatOmitOctave(t)+" - ":"",r=this.omitNotes.map((i,o)=>this.getDegreeStr(o)+"("+(i?"-":this.getNoteStr(o))+")").join(" - ");return e+r}getOmittedDegreesString(){let t=this.omitNotes.map((e,r)=>e?this.getDegreeStr(r)+"("+this.getNoteStr(r)+")":void 0).filter(e=>e!==void 0);return t.length>0?"Omits "+t.join(", "):""}getDegreeStr(t){return W.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var rc={list:[{name:"Standard",strings:["E2","A2","D3","G3","B3","E4"]},{name:"B Standard",strings:["B1","E2","A2","D3","F#3","B3"]},{name:"C Standard",strings:["C2","F2","A#2","D#3","G3","C4"]},{name:"D Modal",strings:["D2","A2","D3","G3","A3","D4"]},{name:"D Standard",strings:["D2","G2","C3","F3","A3","D4"]},{name:"D# Standard",strings:["D#2","G#2","C#3","F#3","A#3","D#4"]},{name:"Double Drop D",strings:["D2","A2","D3","G3","B3","D4"]},{name:"Drop B",strings:["B1","F#2","B2","E3","G#3","C#4"]},{name:"Drop C",strings:["C2","G2","C3","F3","A3","D4"]},{name:"Drop D",strings:["D2","A2","D3","G3","B3","E4"]},{name:"Low C",strings:["C2","G2","D3","G3","A3","D4"]},{name:"New Standard",strings:["C2","G2","D3","A3","E4","G4"]},{name:"Open A",strings:["E2","A2","C#3","E3","A3","E4"]},{name:"Open A Minor",strings:["E2","A2","E3","A3","C4","E4"]},{name:"Open C",strings:["C2","G2","C3","G3","C4","E4"]},{name:"Open C Minor",strings:["C2","G2","C3","G3","C4","D#4"]},{name:"Open D",strings:["D2","A2","D3","F#3","A3","D4"]},{name:"Open D Minor",strings:["D2","A2","D3","F3","A3","D4"]},{name:"Open E",strings:["E2","B2","E3","G#3","B3","E4"]},{name:"Open E Minor",strings:["E2","B2","E3","G3","B3","E4"]},{name:"Open G",strings:["D2","G2","D3","G3","B3","D4"]},{name:"Open G Minor",strings:["D2","G2","D3","G3","A#3","D4"]}]};var ic=(e=>(e[e.RightHanded=0]="RightHanded",e[e.LeftHanded=1]="LeftHanded",e))(ic||{}),Wg=0;function Ug(n){if(A.Is.isEnumValue(n,ic))return n;throw new O(1,`Invalid handedness: ${n}`)}var Fn=rc.list.map(n=>n.name),zg=Fn[0];function nc(n){if(Fn.indexOf(n)<0)throw new O(1,`Invalid tuning name: ${n}`);return n}var rl=new Wu(100);function $o(n){let t=rl.get(n);if(!t){let e=rc.list.find(r=>r.name===n);if(!e)throw new O(1,`Invalid tuningName: ${n}`);if(t=e.strings.slice().reverse().map(r=>W.getNote(r)),!A.Is.isIntegerEq(t.length,6))throw new O(0,`Tuning has ${t.length} strings.`);rl.set(n,t)}return t}var nl=(n,t)=>n===t?0:n<t?-1:1,il=12,Yg=12*11*9*7*5,Zt=(F=>(F.Whole="1n",F.WholeTriplet="1t",F.WholeDot="1.",F.Whole2Dots="1..",F.Whole12Dots="1..",F.Whole3Dots="1...",F.Whole4Dots="1....",F.Whole5Dots="1.....",F.Whole6Dots="1......",F.Half="2n",F.HalfTriplet="2t",F.HalfDot="2.",F.Half2Dots="2..",F.Half3Dots="2...",F.Half4Dots="2....",F.Half5Dots="2.....",F.Quarter="4n",F.QuarterTriplet="4t",F.QuarterDot="4.",F.Quarter2Dots="4..",F.Quarter3Dots="4...",F.Quarter4Dots="4....",F.Eighth="8n",F.EighthTriplet="8t",F.EighthDot="8.",F.Eighth2Dots="8..",F.Eighth3Dots="8...",F.Sixteenth="16n",F.SixteenthTriplet="16t",F.SixteenthDot="16.",F.Sixteenth2Dots="16..",F.ThirtySecond="32n",F.ThirtySecondTriplet="32t",F.ThirtySecondDot="32.",F.SixtyFourth="64n",F.SixtyFourthTriplet="64t",F))(Zt||{});function ii(n){if(A.Is.isEnumValue(n,Zt))return n;throw new O(1,`Invalid noteLength: ${n}`)}var ee=class ee{constructor(t){d(this,"noteLength");d(this,"noteSize");d(this,"ticks");d(this,"flagCount");d(this,"dotCount");d(this,"maxDotCount");d(this,"isTriplet");d(this,"hasStem");d(this,"isSolid");if(this.noteLength=ii(t),this.noteSize=parseInt(t),this.isTriplet=t.endsWith("t"),this.maxDotCount=this.isTriplet?0:Math.floor(Math.log2(ee.ShortestNoteSize/this.noteSize)),this.dotCount=A.Str.charCount(t,"."),this.flagCount=this.noteSize>4?Math.floor(Math.log2(this.noteSize/4)):0,this.ticks=Yg*ee.ShortestNoteSize/this.noteSize,this.hasStem=this.noteSize>1,this.isSolid=this.noteSize>2,this.dotCount>this.maxDotCount)throw new O(2,`dotCount ${this.dotCount} > maxDotCount ${this.maxDotCount}, for noteLength "${this.noteLength}".`);if(this.isTriplet&&this.dotCount>0)throw new O(2,`noteLength "${this.noteLength}" is both triplet and dotted!`)}static get(t){let e=this.cache.get(t);return e||this.cache.set(t,e=new ee(t)),e}static create(t,e=0){let r=typeof t=="number"?t:this.get(t).noteSize;return this.get(r+(A.Is.isIntegerGte(e,1)?".".repeat(e):"n"))}static cmp(t,e){let r=t instanceof ee?t.noteSize:typeof t=="number"?t:ee.get(t).noteSize,i=e instanceof ee?e.noteSize:typeof e=="number"?e:ee.get(e).noteSize;return nl(i,r)}static equals(t,e){let r=t instanceof ee?t.noteSize:typeof t=="number"?t:ee.get(t).noteSize,i=e instanceof ee?e.noteSize:typeof e=="number"?e:ee.get(e).noteSize;return r===i}};d(ee,"LongestNoteSize",Math.min(...A.Enum.getEnumValues(Zt).map(t=>parseInt(t)))),d(ee,"ShortestNoteSize",Math.max(...A.Enum.getEnumValues(Zt).map(t=>parseInt(t)))),d(ee,"cache",new Map);var Xt=ee;function ts(n){if(A.Is.isObject(n)&&A.Is.isIntegerBetween(n.parts,2,il)&&A.Is.isIntegerBetween(n.inTimeOf,2,il))return n;throw new O(2,`Invalid tupletRatio ${JSON.stringify(n)}`)}var fr={Duplet:{parts:2,inTimeOf:3},Triplet:{parts:3,inTimeOf:2},Quadruplet:{parts:4,inTimeOf:3}},ri=class ri{constructor(t,e,r){d(this,"noteLength");d(this,"noteSize");d(this,"dotCount");d(this,"tupletRatio");d(this,"ticks");d(this,"flagCount");d(this,"hasStem");d(this,"isSolidNoteHead");this.noteLength=ii(t);let i=Xt.get(t);if(this.noteSize=i.noteSize,this.ticks=i.ticks,this.flagCount=i.flagCount,this.dotCount=e!=null?e:i.dotCount,this.hasStem=i.hasStem,this.isSolidNoteHead=i.isSolid,A.Is.isObject(r)?this.tupletRatio=ts(r):i.isTriplet?this.tupletRatio=fr.Triplet:this.tupletRatio=void 0,this.dotCount>0&&this.tupletRatio!==void 0)throw new O(2,"Note cannot be both dotted and tuplet!");if(this.dotCount>i.maxDotCount)throw new O(2,`Too big dot count ${this.dotCount} for note length ${this.noteLength}.`);for(let o=this.ticks/2,s=1;s<=this.dotCount;s++,o/=2)this.ticks+=o;this.tupletRatio&&(this.ticks*=this.tupletRatio.inTimeOf/this.tupletRatio.parts)}toString(){let t=ri.NoteSymbolMap.get(this.noteSize),e=".".repeat(this.dotCount);return t?t+e:""+this.noteSize+(e.length>0?e:"n")}static get(t,e,r){if(e!==void 0||r!==void 0)return new ri(t,e,r);{let i=this.cache.get(t);return i||this.cache.set(t,i=new ri(t)),i}}static cmp(t,e){return nl(t.ticks,e.ticks)}static equals(t,e){return t.ticks===e.ticks}};d(ri,"NoteSymbolMap",new Map([[1,"\u{1D15D}"],[2,"\u{1D15E}"],[4,"\u{1D15F}"],[8,"\u{1D160}"],[16,"\u{1D161}"],[32,"\u{1D162}"],[64,"\u{1D163}"],[128,"\u{1D164}"]])),d(ri,"cache",new Map);var Qt=ri;var gr=class{constructor(...t){d(this,"beatCount");d(this,"beatSize");d(this,"beatLength");d(this,"measureTicks");d(this,"beamGroupCount");d(this,"beamGroupLength");if(t.length===1&&typeof t[0]=="string"){let r=t[0].split("/");this.beatCount=+r[0],this.beatSize=+r[1]}else if(t.length===2&&typeof t[0]=="number"&&typeof t[1]=="number")this.beatCount=t[0],this.beatSize=t[1];else throw new O(5,`Invalid args: ${t}`);if(A.Is.isIntegerGte(this.beatCount,1)){if(!A.Is.isIntegerGte(this.beatSize,1))throw new O(5,`Invalid beatSize: ${this.beatSize}`)}else throw new O(5,`Invalid beatCount: ${this.beatCount}`);let e=Xt.create(this.beatSize);if(this.beatLength=e.noteLength,this.measureTicks=this.beatCount*e.ticks,this.is(2,4)||this.is(3,4)||this.is(4,4)?this.beamGroupCount=this.beatCount:this.is(6,8)||this.is(9,8)?this.beamGroupCount=this.beatCount/3:(console.warn("Not necessarily an error, but unsupported time signature: "+this.toString()),this.beamGroupCount=1),this.beamGroupLength=this.measureTicks/this.beamGroupCount,!A.Is.isIntegerGte(this.beamGroupLength,1))throw new O(5,`Invalid beamGroupLength: ${this.beamGroupLength}`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},oc;function es(){return oc||(oc=new gr(4,4)),oc}var sc;function rs(){return sc||(sc={beatsPerMinute:120,options:{beatLength:"4n",dotCount:0}}),sc}function ac(n){return Qt.get(n.options.beatLength,n.options.dotCount).toString()+"="+n.beatsPerMinute}function cc(n,t){return{beatsPerMinute:n.beatsPerMinute*t,options:{beatLength:n.options.beatLength,dotCount:n.options.dotCount}}}ti();var Bn="15.1.22";var lc=(n,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:n});var hc=(n,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:n});var Ri=(n,t)=>({startTime:t,type:"setValue",value:n});var Gn=(n,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:n});var is=(n,t,{startTime:e,target:r,timeConstant:i})=>r+(t-r)*Math.exp((e-n)/i);var yr=n=>n.type==="exponentialRampToValue";var ni=n=>n.type==="linearRampToValue";var Fe=n=>yr(n)||ni(n);var Mi=n=>n.type==="setValue";var we=n=>n.type==="setValueCurve";var Di=(n,t,e,r)=>{let i=n[t];return i===void 0?r:Fe(i)||Mi(i)?i.value:we(i)?i.values[i.values.length-1]:is(e,Di(n,t-1,i.startTime,r),i)};var pc=(n,t,e,r,i)=>e===void 0?[r.insertTime,i]:Fe(e)?[e.endTime,e.value]:Mi(e)?[e.startTime,e.value]:we(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,Di(n,t-1,e.startTime,i)];var Vn=n=>n.type==="cancelAndHold";var qn=n=>n.type==="cancelScheduledValues";var xr=n=>Vn(n)||qn(n)?n.cancelTime:yr(n)||ni(n)?n.endTime:n.startTime;var dc=(n,t,e,{endTime:r,value:i})=>e===i?i:0<e&&0<i||e<0&&i<0?e*Nu(i/e,(n-t)/(r-t)):0;var mc=(n,t,e,{endTime:r,value:i})=>e+(n-t)/(r-t)*(i-e);var ol=(n,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?n[e]:(1-(t-e))*n[e]+(1-(r-t))*n[r]};var sl=(n,{duration:t,startTime:e,values:r})=>{let i=(n-e)/t*(r.length-1);return ol(r,i)};var Wn=n=>n.type==="setTarget";var Un=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=xr(t);if(Vn(t)||qn(t)){let r=this._automationEvents.findIndex(o=>qn(t)&&we(o)?o.startTime+o.duration>=e:xr(o)>=e),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),Vn(t)){let o=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Fe(i)){if(o!==void 0&&Wn(o))throw new Error("The internal list is malformed.");let s=o===void 0?i.insertTime:we(o)?o.startTime+o.duration:xr(o),a=o===void 0?this._defaultValue:we(o)?o.values[o.values.length-1]:o.value,c=yr(i)?dc(e,s,a,i):mc(e,s,a,i),u=yr(i)?lc(c,e,this._currenTime):hc(c,e,this._currenTime);this._automationEvents.push(u)}if(o!==void 0&&Wn(o)&&this._automationEvents.push(Ri(this.getValue(e),e)),o!==void 0&&we(o)&&o.startTime+o.duration>e){let s=e-o.startTime,a=(o.values.length-1)/o.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,l=o.values.slice(0,c);if(u<1)for(let h=1;h<c;h+=1){let p=u*h%1;l[h]=o.values[h-1]*(1-p)+o.values[h]*p}this._automationEvents[this._automationEvents.length-1]=Gn(l,o.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>xr(s)>e),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&we(i)&&xr(i)+i.duration>e)return!1;let o=yr(t)?lc(t.value,t.endTime,this._currenTime):ni(t)?hc(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(o);else{if(we(t)&&e+t.duration>xr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,o)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>xr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),i=r[0];Wn(i)&&r.unshift(Ri(Di(this._automationEvents,e-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=r}}getValue(t){if(this._automationEvents.length===0)return this._defaultValue;let e=this._automationEvents.findIndex(s=>xr(s)>t),r=this._automationEvents[e],i=(e===-1?this._automationEvents.length:e)-1,o=this._automationEvents[i];if(o!==void 0&&Wn(o)&&(r===void 0||!Fe(r)||r.insertTime>t))return is(t,Di(this._automationEvents,i-1,o.startTime,this._defaultValue),o);if(o!==void 0&&Mi(o)&&(r===void 0||!Fe(r)))return o.value;if(o!==void 0&&we(o)&&(r===void 0||!Fe(r)||o.startTime+o.duration>t))return t<o.startTime+o.duration?sl(t,o):o.values[o.values.length-1];if(o!==void 0&&Fe(o)&&(r===void 0||!Fe(r)))return o.value;if(r!==void 0&&yr(r)){let[s,a]=pc(this._automationEvents,i,o,r,this._defaultValue);return dc(t,s,a,r)}if(r!==void 0&&ni(r)){let[s,a]=pc(this._automationEvents,i,o,r,this._defaultValue);return mc(t,s,a,r)}return this._defaultValue}};var fc=n=>({cancelTime:n,type:"cancelAndHold"});var gc=n=>({cancelTime:n,type:"cancelScheduledValues"});var yc=(n,t)=>({endTime:t,type:"exponentialRampToValue",value:n});var xc=(n,t)=>({endTime:t,type:"linearRampToValue",value:n});var bc=(n,t,e)=>({startTime:t,target:n,timeConstant:e,type:"setTarget"});var al=()=>new DOMException("","AbortError");var cl=n=>(t,e,[r,i,o],s)=>{n(t[i],[e,r,o],a=>a[0]===e&&a[1]===r,s)};var ul=n=>(t,e,r)=>{let i=[];for(let o=0;o<r.numberOfInputs;o+=1)i.push(new Set);n.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var ll=n=>(t,e)=>{n.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var er=new WeakSet,ns=new WeakMap,Ei=new WeakMap,os=new WeakMap,zn=new WeakMap,ki=new WeakMap,ss=new WeakMap,Yn=new WeakMap,Hn=new WeakMap,Zn=new WeakMap;var hl={construct(){return hl}},pl=n=>{try{let t=new Proxy(n,hl);new t}catch(t){return!1}return!0};var dl=/^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]*);?/,Ac=(n,t)=>{let e=[],r=n.replace(/^[\s]+/,""),i=r.match(dl);for(;i!==null;){let o=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(o,new URL(o,t).toString());e.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(dl)}return[e.join(";"),r]};var ml=n=>{if(n!==void 0&&!Array.isArray(n))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},fl=n=>{if(!pl(n))throw new TypeError("The given value for processorCtor should be a constructor.");if(n.prototype===null||typeof n.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},gl=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>{let m=0;return(f,g,y={credentials:"omit"})=>{let b=l.get(f);if(b!==void 0&&b.has(g))return Promise.resolve();let I=u.get(f);if(I!==void 0){let _=I.get(g);if(_!==void 0)return _}let S=o(f),w=S.audioWorklet===void 0?i(g).then(([_,v])=>{let[C,x]=Ac(_,v),N=`${C};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${x}
|
|
3
|
+
})})(window,'_AWGS')`;return e(N)}).then(()=>{let _=p._AWGS.pop();if(_===void 0)throw new SyntaxError;r(S.currentTime,S.sampleRate,()=>_(class{},void 0,(v,C)=>{if(v.trim()==="")throw t();let x=Hn.get(S);if(x!==void 0){if(x.has(v))throw t();fl(C),ml(C.parameterDescriptors),x.set(v,C)}else fl(C),ml(C.parameterDescriptors),Hn.set(S,new Map([[v,C]]))},S.sampleRate,void 0,void 0))}):Promise.all([i(g),Promise.resolve(n(h,h))]).then(([[_,v],C])=>{let x=m+1;m=x;let[N,k]=Ac(_,v),E=`${N};((AudioWorkletProcessor,registerProcessor)=>{${k}
|
|
4
|
+
})(${C?"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{${C?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${C?"":"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${x}',class extends AudioWorkletProcessor{process(){return !1}})`,P=new Blob([E],{type:"application/javascript; charset=utf-8"}),L=URL.createObjectURL(P);return S.audioWorklet.addModule(L,y).then(()=>{if(a(S))return S;let V=s(S);return V.audioWorklet.addModule(L,y).then(()=>V)}).then(V=>{if(c===null)throw new SyntaxError;try{new c(V,`__sac${x}`)}catch(Q){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(L))});return I===void 0?u.set(f,new Map([[g,w]])):I.set(g,w),w.then(()=>{let _=l.get(f);_===void 0?l.set(f,new Set([g])):_.add(g)}).finally(()=>{let _=u.get(f);_!==void 0&&_.delete(g)}),w}};var Gt=(n,t)=>{let e=n.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var Pr=(n,t)=>{let e=Array.from(n).filter(t);if(e.length>1)throw Error("More than one element was found.");if(e.length===0)throw Error("No element was found.");let[r]=e;return n.delete(r),r};var as=(n,t,e,r)=>{let i=Gt(n,t),o=Pr(i,s=>s[0]===e&&s[1]===r);return i.size===0&&n.delete(t),o};var rr=n=>Gt(ss,n);var Be=n=>{if(er.has(n))throw new Error("The AudioNode is already stored.");er.add(n),rr(n).forEach(t=>t(!0))};var cs=n=>"port"in n;var ir=n=>{if(!er.has(n))throw new Error("The AudioNode is not stored.");er.delete(n),rr(n).forEach(t=>t(!1))};var Xn=(n,t)=>{!cs(n)&&t.every(e=>e.size===0)&&ir(n)};var yl=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>{let m=new WeakMap;return(f,g,y,b,I)=>{let{activeInputs:S,passiveInputs:w}=o(g),{outputs:_}=o(f),v=a(f),C=x=>{let N=c(g),k=c(f);if(x){let R=as(w,f,y,b);n(S,f,R,!1),!I&&!h(f)&&e(k,N,y,b),p(g)&&Be(g)}else{let R=r(S,f,y,b);t(w,b,R,!1),!I&&!h(f)&&i(k,N,y,b);let D=s(g);if(D===0)l(g)&&Xn(g,S);else{let U=m.get(g);U!==void 0&&clearTimeout(U),m.set(g,setTimeout(()=>{l(g)&&Xn(g,S)},D*1e3))}}};return u(_,[g,y,b],x=>x[0]===g&&x[1]===y&&x[2]===b,!0)?(v.add(C),l(f)?n(S,f,[y,b,C],!0):t(w,b,[f,y,C],!0),!0):!1}};var xl=n=>(t,e,[r,i,o],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[i,e,o]])):n(a,[i,e,o],c=>c[0]===i&&c[1]===e,s)};var bl=n=>(t,e)=>{let r=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(r).connect(t.destination);let i=()=>{e.removeEventListener("ended",i),e.disconnect(r),r.disconnect()};e.addEventListener("ended",i)};var Al=n=>(t,e)=>{n(t).add(e)};var Hg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},Cl=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=M(M({},Hg),c),h=r(u,l),p=o(u)?t():null;super(a,!1,h,p),this._nativeAnalyserNode=h}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(a){this._nativeAnalyserNode.fftSize=a}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(a){let c=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=a,!(a>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=c,e()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(a){let c=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=a,!(this._nativeAnalyserNode.maxDecibels>a))throw this._nativeAnalyserNode.minDecibels=c,e()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(a){this._nativeAnalyserNode.smoothingTimeConstant=a}getByteFrequencyData(a){this._nativeAnalyserNode.getByteFrequencyData(a)}getByteTimeDomainData(a){this._nativeAnalyserNode.getByteTimeDomainData(a)}getFloatFrequencyData(a){this._nativeAnalyserNode.getFloatFrequencyData(a)}getFloatTimeDomainData(a){this._nativeAnalyserNode.getFloatTimeDomainData(a)}};var dt=(n,t)=>n.context===t;var _l=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!dt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,fftSize:a.fftSize,maxDecibels:a.maxDecibels,minDecibels:a.minDecibels,smoothingTimeConstant:a.smoothingTimeConstant};a=n(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var ji=n=>{try{n.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var Te=()=>new DOMException("","IndexSizeError");var Pi=n=>{n.getChannelData=(t=>e=>{try{return t.call(n,e)}catch(r){throw r.code===12?Te():r}})(n.getChannelData)};var Zg={numberOfChannels:1},vl=(n,t,e,r,i,o,s,a)=>{let c=null;return class Il{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:p,sampleRate:m}=M(M({},Zg),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&t(o,o)?new r({length:h,numberOfChannels:p,sampleRate:m}):c.createBuffer(p,h,m);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),Pi(f)):t(ji,()=>ji(f))||a(f),n.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===Il.prototype||n.has(l)}}};var Pt=-34028234663852886e22,Dt=-Pt;var ae=n=>er.has(n);var Xg={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},Sl=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=M(M({},Xg),l),m=i(h,p),f=s(h),g=f?t():null;super(u,!1,m,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=m,this._onended=null,this._playbackRate=e(this,f,m.playbackRate,Dt,Pt)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(u){if(this._nativeAudioBufferSourceNode.buffer=u,u!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(u){this._nativeAudioBufferSourceNode.loop=u}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(u){this._nativeAudioBufferSourceNode.loopEnd=u}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(u){this._nativeAudioBufferSourceNode.loopStart=u}get onended(){return this._onended}set onended(u){let l=typeof u=="function"?a(this,u):null;this._nativeAudioBufferSourceNode.onended=l;let h=this._nativeAudioBufferSourceNode.onended;this._onended=h!==null&&h===l?u:h}get playbackRate(){return this._playbackRate}start(u=0,l=0,h){if(this._nativeAudioBufferSourceNode.start(u,l,h),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=h===void 0?[u,l]:[u,l,h]),this.context.state!=="closed"){Be(this);let p=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",p),ae(this)&&ir(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var wl=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=e(u),p=dt(h,l);if(!p){let m={buffer:h.buffer,channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,loop:h.loop,loopEnd:h.loopEnd,loopStart:h.loopStart,playbackRate:h.playbackRate.value};h=t(l,m),s!==null&&h.start(...s),a!==null&&h.stop(a)}return o.set(l,h),p?yield n(l,u.playbackRate,h.playbackRate):yield r(l,u.playbackRate,h.playbackRate),yield i(u,l,h),h});return{set start(u){s=u},set stop(u){a=u},render(u,l){let h=o.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var Tl=n=>"playbackRate"in n;var Nl=n=>"frequency"in n&&"gain"in n;var Ol=n=>"offset"in n;var Rl=n=>!("frequency"in n)&&"gain"in n;var Ml=n=>"detune"in n&&"frequency"in n&&!("gain"in n);var Dl=n=>"pan"in n;var Yt=n=>Gt(ns,n);var Lr=n=>Gt(os,n);var us=(n,t)=>{let{activeInputs:e}=Yt(n);e.forEach(i=>i.forEach(([o])=>{t.includes(n)||us(o,[...t,n])}));let r=Tl(n)?[n.playbackRate]:cs(n)?Array.from(n.parameters.values()):Nl(n)?[n.Q,n.detune,n.frequency,n.gain]:Ol(n)?[n.offset]:Rl(n)?[n.gain]:Ml(n)?[n.detune,n.frequency]:Dl(n)?[n.pan]:[];for(let i of r){let o=Lr(i);o!==void 0&&o.activeInputs.forEach(([s])=>us(s,t))}ae(n)&&ir(n)};var Fr=n=>{us(n.destination,[])};var ls=n=>n===void 0||typeof n=="number"||typeof n=="string"&&(n==="balanced"||n==="interactive"||n==="playback");var El=(n,t,e,r,i,o,s,a,c)=>class extends n{constructor(l={}){if(c===null)throw new Error("Missing the native AudioContext constructor.");let h;try{h=new c(l)}catch(f){throw f.code===12&&f.message==="sampleRate is not in range"?e():f}if(h===null)throw r();if(!ls(l.latencyHint))throw new TypeError(`The provided value '${l.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(l.sampleRate!==void 0&&h.sampleRate!==l.sampleRate)throw e();super(h,2);let{latencyHint:p}=l,{sampleRate:m}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/m:p==="interactive"||p===void 0?256/m:p==="playback"?1024/m:Math.max(2,Math.min(128,Math.round(p*m/128)))*128/m,this._nativeAudioContext=h,c.name==="webkitAudioContext"?(this._nativeGainNode=h.createGain(),this._nativeOscillatorNode=h.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(h.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,h.state==="running"){this._state="suspended";let f=()=>{this._state==="suspended"&&(this._state=null),h.removeEventListener("statechange",f)};h.addEventListener("statechange",f)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.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()),Fr(this)}))}createMediaElementSource(l){return new i(this,{mediaElement:l})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(l){return new s(this,{mediaStream:l})}createMediaStreamTrackSource(l){return new a(this,{mediaStreamTrack:l})}resume(){return this._state==="suspended"?new Promise((l,h)=>{let p=()=>{this._nativeAudioContext.removeEventListener("statechange",p),this._nativeAudioContext.state==="running"?l():this.resume().then(l,h)};this._nativeAudioContext.addEventListener("statechange",p)}):this._nativeAudioContext.resume().catch(l=>{throw l===void 0||l.code===15?t():l})}suspend(){return this._nativeAudioContext.suspend().catch(l=>{throw l===void 0?t():l})}};var kl=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=s(h),m=i(h,l,p),f=p?t(a):null;super(u,!1,m,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=m}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(u>this._nativeAudioDestinationNode.maxChannelCount)throw e();this._nativeAudioDestinationNode.channelCount=u}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(u){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=u}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}};var jl=n=>{let t=new WeakMap,e=(r,i)=>K(null,null,function*(){let o=i.destination;return t.set(i,o),yield n(r,i,o),o});return{render(r,i){let o=t.get(i);return o!==void 0?Promise.resolve(o):e(r,i)}}};var Pl=(n,t,e,r,i,o,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let _=new Float32Array(1),v=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),C=s(u),x=!1,N=[0,0,-1,0,1,0],k=[0,0,0],R=()=>{if(x)return;x=!0;let P=r(u,256,9,0);P.onaudioprocess=({inputBuffer:L})=>{let V=[o(L,_,0),o(L,_,1),o(L,_,2),o(L,_,3),o(L,_,4),o(L,_,5)];V.some((Y,F)=>Y!==N[F])&&(l.setOrientation(...V),N=V);let Q=[o(L,_,6),o(L,_,7),o(L,_,8)];Q.some((Y,F)=>Y!==k[F])&&(l.setPosition(...Q),k=Q)},v.connect(P)},D=P=>L=>{L!==N[P]&&(N[P]=L,l.setOrientation(...N))},U=P=>L=>{L!==k[P]&&(k[P]=L,l.setPosition(...k))},E=(P,L,V)=>{let Q=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:L});Q.connect(v,0,P),Q.start(),Object.defineProperty(Q.offset,"defaultValue",{get(){return L}});let Y=n({context:c},C,Q.offset,Dt,Pt);return a(Y,"value",F=>()=>F.call(Y),F=>ct=>{try{F.call(Y,ct)}catch(xt){if(xt.code!==9)throw xt}R(),C&&V(ct)}),Y.cancelAndHoldAtTime=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.cancelAndHoldAtTime),Y.cancelScheduledValues=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.cancelScheduledValues),Y.exponentialRampToValueAtTime=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.exponentialRampToValueAtTime),Y.linearRampToValueAtTime=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.linearRampToValueAtTime),Y.setTargetAtTime=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.setTargetAtTime),Y.setValueAtTime=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.setValueAtTime),Y.setValueCurveAtTime=(F=>C?()=>{throw i()}:(...ct)=>{let xt=F.apply(Y,ct);return R(),xt})(Y.setValueCurveAtTime),Y};return{forwardX:E(0,0,D(0)),forwardY:E(1,0,D(1)),forwardZ:E(2,-1,D(2)),positionX:E(6,0,U(0)),positionY:E(7,0,U(1)),positionZ:E(8,0,U(2)),upX:E(3,0,D(3)),upY:E(4,1,D(4)),upZ:E(5,0,D(5))}},{forwardX:p,forwardY:m,forwardZ:f,positionX:g,positionY:y,positionZ:b,upX:I,upY:S,upZ:w}=l.forwardX===void 0?h():l;return{get forwardX(){return p},get forwardY(){return m},get forwardZ(){return f},get positionX(){return g},get positionY(){return y},get positionZ(){return b},get upX(){return I},get upY(){return S},get upZ(){return w}}};var oi=n=>"context"in n;var Br=n=>oi(n[0]);var Ge=(n,t,e,r)=>{for(let i of n)if(e(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return n.add(t),!0};var Cc=(n,t,[e,r],i)=>{Ge(n,[t,e,r],o=>o[0]===t&&o[1]===e,i)};var _c=(n,[t,e,r],i)=>{let o=n.get(t);o===void 0?n.set(t,new Set([[e,r]])):Ge(o,[e,r],s=>s[0]===e,i)};var Ne=n=>"inputs"in n;var Li=(n,t,e,r)=>{if(Ne(t)){let i=t.inputs[r];return n.connect(i,e,0),[i,e,0]}return n.connect(t,e,r),[t,e,r]};var vc=(n,t,e)=>{for(let r of n)if(r[0]===t&&r[1]===e)return n.delete(r),r;return null};var Ll=(n,t,e)=>Pr(n,r=>r[0]===t&&r[1]===e);var Ic=(n,t)=>{if(!rr(n).delete(t))throw new Error("Missing the expected event listener.")};var Sc=(n,t,e)=>{let r=Gt(n,t),i=Pr(r,o=>o[0]===e);return r.size===0&&n.delete(t),i};var Fi=(n,t,e,r)=>{Ne(t)?n.disconnect(t.inputs[r],e,0):n.disconnect(t,e,r)};var Ct=n=>Gt(Ei,n);var si=n=>Gt(zn,n);var br=n=>Yn.has(n);var Bi=n=>!er.has(n);var wc=(n,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=n.createScriptProcessor(256,1,1),i=n.createGain(),o=n.createBuffer(1,2,44100),s=o.getChannelData(0);s[0]=1,s[1]=1;let a=n.createBufferSource();a.buffer=o,a.loop=!0,a.connect(r).connect(n.destination),a.connect(i),a.disconnect(i),r.onaudioprocess=c=>{let u=c.inputBuffer.getChannelData(0);Array.prototype.some.call(u,l=>l===1)?e(!0):e(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(n.destination)},a.start()}});var hs=(n,t)=>{let e=new Map;for(let r of n)for(let i of r){let o=e.get(i);e.set(i,o===void 0?1:o+1)}e.forEach((r,i)=>t(i,r))};var ai=n=>"context"in n;var Fl=n=>{let t=new Map;n.connect=(e=>(r,i=0,o=0)=>{let s=ai(r)?e(r,i,o):e(r,i),a=t.get(r);return a===void 0?t.set(r,[{input:o,output:i}]):a.every(c=>c.input!==o||c.output!==i)&&a.push({input:o,output:i}),s})(n.connect.bind(n)),n.disconnect=(e=>(r,i,o)=>{if(e.apply(n),r===void 0)t.clear();else if(typeof r=="number")for(let[s,a]of t){let c=a.filter(u=>u.output!==r);c.length===0?t.delete(s):t.set(s,c)}else if(t.has(r))if(i===void 0)t.delete(r);else{let s=t.get(r);if(s!==void 0){let a=s.filter(c=>c.output!==i&&(c.input!==o||o===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{ai(s)?n.connect(s,c.output,c.input):n.connect(s,c.output)})})(n.disconnect)};var Qg=(n,t,e,r)=>{let{activeInputs:i,passiveInputs:o}=Lr(t),{outputs:s}=Yt(n),a=rr(n),c=u=>{let l=Ct(n),h=si(t);if(u){let p=Sc(o,n,e);Cc(i,n,p,!1),!r&&!br(n)&&l.connect(h,e)}else{let p=Ll(i,n,e);_c(o,p,!1),!r&&!br(n)&&l.disconnect(h,e)}};return Ge(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),ae(n)?Cc(i,n,[e,c],!0):_c(o,[n,e,c],!0),!0):!1},Kg=(n,t,e,r)=>{let{activeInputs:i,passiveInputs:o}=Yt(t),s=vc(i[r],n,e);return s===null?[as(o,n,e,r)[2],!1]:[s[2],!0]},Jg=(n,t,e)=>{let{activeInputs:r,passiveInputs:i}=Lr(t),o=vc(r,n,e);return o===null?[Sc(i,n,e)[1],!1]:[o[2],!0]},Tc=(n,t,e,r,i)=>{let[o,s]=Kg(n,e,r,i);if(o!==null&&(Ic(n,o),s&&!t&&!br(n)&&Fi(Ct(n),Ct(e),r,i)),ae(e)){let{activeInputs:a}=Yt(e);Xn(e,a)}},Nc=(n,t,e,r)=>{let[i,o]=Jg(n,e,r);i!==null&&(Ic(n,i),o&&!t&&!br(n)&&Ct(n).disconnect(si(e),r))},$g=(n,t)=>{let e=Yt(n),r=[];for(let i of e.outputs)Br(i)?Tc(n,t,...i):Nc(n,t,...i),r.push(i[0]);return e.outputs.clear(),r},ty=(n,t,e)=>{let r=Yt(n),i=[];for(let o of r.outputs)o[1]===e&&(Br(o)?Tc(n,t,...o):Nc(n,t,...o),i.push(o[0]),r.outputs.delete(o));return i},ey=(n,t,e,r,i)=>{let o=Yt(n);return Array.from(o.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Br(s)?Tc(n,t,...s):Nc(n,t,...s),o.outputs.delete(s),s[0]))},Bl=(n,t,e,r,i,o,s,a,c,u,l,h,p,m,f,g)=>class extends u{constructor(b,I,S,w){super(S),this._context=b,this._nativeAudioNode=S;let _=l(b);h(_)&&e(wc,()=>wc(_,g))!==!0&&Fl(S),Ei.set(this,S),ss.set(this,new Set),b.state!=="closed"&&I&&Be(this),n(this,w,S)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(b){this._nativeAudioNode.channelCount=b}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(b){this._nativeAudioNode.channelCountMode=b}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(b){this._nativeAudioNode.channelInterpretation=b}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(b,I=0,S=0){if(I<0||I>=this._nativeAudioNode.numberOfOutputs)throw i();let w=l(this._context),_=f(w);if(p(b)||m(b))throw o();if(oi(b)){let x=Ct(b);try{let k=Li(this._nativeAudioNode,x,I,S),R=Bi(this);(_||R)&&this._nativeAudioNode.disconnect(...k),this.context.state!=="closed"&&!R&&Bi(b)&&Be(b)}catch(k){throw k.code===12?o():k}if(t(this,b,I,S,_)){let k=c([this],b);hs(k,r(_))}return b}let v=si(b);if(v.name==="playbackRate"&&v.maxValue===1024)throw s();try{this._nativeAudioNode.connect(v,I),(_||Bi(this))&&this._nativeAudioNode.disconnect(v,I)}catch(x){throw x.code===12?o():x}if(Qg(this,b,I,_)){let x=c([this],b);hs(x,r(_))}}disconnect(b,I,S){let w,_=l(this._context),v=f(_);if(b===void 0)w=$g(this,v);else if(typeof b=="number"){if(b<0||b>=this.numberOfOutputs)throw i();w=ty(this,v,b)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||oi(b)&&S!==void 0&&(S<0||S>=b.numberOfInputs))throw i();if(w=ey(this,v,b,I,S),w.length===0)throw o()}for(let C of w){let x=c([this],C);hs(x,a)}}};var Gl=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>(m,f,g,y=null,b=null)=>{let I=g.value,S=new Un(I),w=f?r(S):null,_={get defaultValue(){return I},get maxValue(){return y===null?g.maxValue:y},get minValue(){return b===null?g.minValue:b},get value(){return g.value},set value(v){g.value=v,_.setValueAtTime(v,m.context.currentTime)},cancelAndHoldAtTime(v){if(typeof g.cancelAndHoldAtTime=="function")w===null&&S.flush(m.context.currentTime),S.add(i(v)),g.cancelAndHoldAtTime(v);else{let C=Array.from(S).pop();w===null&&S.flush(m.context.currentTime),S.add(i(v));let x=Array.from(S).pop();g.cancelScheduledValues(v),C!==x&&x!==void 0&&(x.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(x.value,x.endTime):x.type==="linearRampToValue"?g.linearRampToValueAtTime(x.value,x.endTime):x.type==="setValue"?g.setValueAtTime(x.value,x.startTime):x.type==="setValueCurve"&&g.setValueCurveAtTime(x.values,x.startTime,x.duration))}return _},cancelScheduledValues(v){return w===null&&S.flush(m.context.currentTime),S.add(o(v)),g.cancelScheduledValues(v),_},exponentialRampToValueAtTime(v,C){if(v===0)throw new RangeError;if(!Number.isFinite(C)||C<0)throw new RangeError;let x=m.context.currentTime;return w===null&&S.flush(x),Array.from(S).length===0&&(S.add(u(I,x)),g.setValueAtTime(I,x)),S.add(s(v,C)),g.exponentialRampToValueAtTime(v,C),_},linearRampToValueAtTime(v,C){let x=m.context.currentTime;return w===null&&S.flush(x),Array.from(S).length===0&&(S.add(u(I,x)),g.setValueAtTime(I,x)),S.add(a(v,C)),g.linearRampToValueAtTime(v,C),_},setTargetAtTime(v,C,x){return w===null&&S.flush(m.context.currentTime),S.add(c(v,C,x)),g.setTargetAtTime(v,C,x),_},setValueAtTime(v,C){return w===null&&S.flush(m.context.currentTime),S.add(u(v,C)),g.setValueAtTime(v,C),_},setValueCurveAtTime(v,C,x){let N=v instanceof Float32Array?v:new Float32Array(v);if(h!==null&&h.name==="webkitAudioContext"){let k=C+x,R=m.context.sampleRate,D=Math.ceil(C*R),U=Math.floor(k*R),E=U-D,P=new Float32Array(E);for(let V=0;V<E;V+=1){let Q=(N.length-1)/x*((D+V)/R-C),Y=Math.floor(Q),F=Math.ceil(Q);P[V]=Y===F?N[Y]:(1-(Q-Y))*N[Y]+(1-(F-Q))*N[F]}w===null&&S.flush(m.context.currentTime),S.add(l(P,C,x)),g.setValueCurveAtTime(P,C,x);let L=U/R;L<k&&p(_,P[P.length-1],L),p(_,N[N.length-1],k)}else w===null&&S.flush(m.context.currentTime),S.add(l(N,C,x)),g.setValueCurveAtTime(N,C,x);return _}};return e.set(_,g),t.set(_,m),n(_,w),_};var Vl=n=>({replay(t){for(let e of n)if(e.type==="exponentialRampToValue"){let{endTime:r,value:i}=e;t.exponentialRampToValueAtTime(i,r)}else if(e.type==="linearRampToValue"){let{endTime:r,value:i}=e;t.linearRampToValueAtTime(i,r)}else if(e.type==="setTarget"){let{startTime:r,target:i,timeConstant:o}=e;t.setTargetAtTime(i,r,o)}else if(e.type==="setValue"){let{startTime:r,value:i}=e;t.setValueAtTime(i,r)}else if(e.type==="setValueCurve"){let{duration:r,startTime:i,values:o}=e;t.setValueCurveAtTime(o,i,r)}else throw new Error("Can't apply an unknown automation.")}});var Gi=class{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((r,i)=>t.call(e,r,i,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}};var ry={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},ql=(n,t,e,r,i,o,s,a,c,u,l,h,p,m)=>class extends t{constructor(g,y,b){var I;let S=a(g),w=c(S),_=l(M(M({},ry),b));p(_);let v=Hn.get(S),C=v==null?void 0:v.get(y),x=w||S.state!=="closed"?S:(I=s(S))!==null&&I!==void 0?I:S,N=i(x,w?null:g.baseLatency,u,y,C,_),k=w?r(y,_,C):null;super(g,!0,N,k);let R=[];N.parameters.forEach((U,E)=>{let P=e(this,w,U);R.push([E,P])}),this._nativeAudioWorkletNode=N,this._onprocessorerror=null,this._parameters=new Gi(R),w&&n(S,this);let{activeInputs:D}=o(this);h(N,D)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let y=typeof g=="function"?m(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=y;let b=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=b!==null&&b===y?g:b}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Vi(n,t,e,r,i){if(typeof n.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),n.copyFromChannel(t[e],r,i);else{let o=n.getChannelData(r);if(t[e].byteLength===0)t[e]=o.slice(i,i+128);else{let s=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var ps=(n,t,e,r,i)=>{typeof n.copyToChannel=="function"?t[e].byteLength!==0&&n.copyToChannel(t[e],r,i):t[e].byteLength!==0&&n.getChannelData(r).set(t[e],i)};var qi=(n,t)=>{let e=[];for(let r=0;r<n;r+=1){let i=[],o=typeof t=="number"?t:t[r];for(let s=0;s<o;s+=1)i.push(new Float32Array(128));e.push(i)}return e};var Wl=(n,t)=>{let e=Gt(Zn,n),r=Ct(t);return Gt(e,r)};var iy=(n,t,e,r,i,o,s)=>K(null,null,function*(){let a=t===null?Math.ceil(n.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((y,b)=>y+b,0),l=u===0?null:e.createBuffer(u,a,e.sampleRate);if(o===void 0)throw new Error("Missing the processor constructor.");let h=Yt(n),p=yield Wl(e,n),m=qi(r.numberOfInputs,r.channelCount),f=qi(r.numberOfOutputs,i),g=Array.from(n.parameters.keys()).reduce((y,b)=>X(M({},y),{[b]:new Float32Array(128)}),{});for(let y=0;y<a;y+=128){if(r.numberOfInputs>0&&t!==null)for(let b=0;b<r.numberOfInputs;b+=1)for(let I=0;I<r.channelCount;I+=1)Vi(t,m[b],I,I,y);o.parameterDescriptors!==void 0&&t!==null&&o.parameterDescriptors.forEach(({name:b},I)=>{Vi(t,g,b,c+I,y)});for(let b=0;b<r.numberOfInputs;b+=1)for(let I=0;I<i[b];I+=1)f[b][I].byteLength===0&&(f[b][I]=new Float32Array(128));try{let b=m.map((S,w)=>h.activeInputs[w].size===0?[]:S),I=s(y/e.sampleRate,e.sampleRate,()=>p.process(b,f,g));if(l!==null)for(let S=0,w=0;S<r.numberOfOutputs;S+=1){for(let _=0;_<i[S];_+=1)ps(l,f[S],_,w+_,y);w+=i[S]}if(!I)break}catch(b){n.dispatchEvent(new ErrorEvent("processorerror",{colno:b.colno,filename:b.filename,lineno:b.lineno,message:b.message}));break}}return l}),Ul=(n,t,e,r,i,o,s,a,c,u,l,h,p,m,f,g)=>(y,b,I)=>{let S=new WeakMap,w=null,_=(v,C)=>K(null,null,function*(){let x=l(v),N=null,k=dt(x,C),R=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(h===null){let D=R.reduce((L,V)=>L+V,0),U=i(C,{channelCount:Math.max(1,D),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,D)}),E=[];for(let L=0;L<v.numberOfOutputs;L+=1)E.push(r(C,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:R[L]}));let P=s(C,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1});P.connect=t.bind(null,E),P.disconnect=c.bind(null,E),N=[U,E,P]}else k||(x=new h(C,y));if(S.set(C,N===null?x:N[2]),N!==null){if(w===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let V=v.channelCount*v.numberOfInputs,Q=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,Y=V+Q;w=iy(v,Y===0?null:yield K(null,null,function*(){let ct=new p(Y,Math.ceil(v.context.length/128)*128,C.sampleRate),xt=[],jt=[];for(let At=0;At<b.numberOfInputs;At+=1)xt.push(s(ct,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),jt.push(i(ct,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let xe=yield Promise.all(Array.from(v.parameters.values()).map(At=>K(null,null,function*(){let nt=o(ct,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:At.value});return yield m(ct,At,nt.offset),nt}))),be=r(ct,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,V+Q)});for(let At=0;At<b.numberOfInputs;At+=1){xt[At].connect(jt[At]);for(let nt=0;nt<b.channelCount;nt+=1)jt[At].connect(be,nt,At*b.channelCount+nt)}for(let[At,nt]of xe.entries())nt.connect(be,0,V+At),nt.start(0);return be.connect(ct.destination),yield Promise.all(xt.map(At=>f(v,ct,At))),g(ct)}),C,b,R,I,u)}let D=yield w,U=e(C,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[E,P,L]=N;D!==null&&(U.buffer=D,U.start(0)),U.connect(E);for(let V=0,Q=0;V<v.numberOfOutputs;V+=1){let Y=P[V];for(let F=0;F<R[V];F+=1)E.connect(Y,Q+F,F);Q+=R[V]}return L}if(k)for(let[D,U]of v.parameters.entries())yield n(C,U,x.parameters.get(D));else for(let[D,U]of v.parameters.entries())yield m(C,U,x.parameters.get(D));return yield f(v,C,x),x});return{render(v,C){a(C,v);let x=S.get(C);return x!==void 0?Promise.resolve(x):_(v,C)}}};var zl=(n,t,e,r,i,o,s,a,c,u,l,h,p,m,f,g,y,b,I,S)=>class extends f{constructor(_,v){super(_,v),this._nativeContext=_,this._audioWorklet=n===void 0?void 0:{addModule:(C,x)=>n(this,C,x)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(_,v,C){return new e({length:v,numberOfChannels:_,sampleRate:C})}createBufferSource(){return new r(this)}createChannelMerger(_=6){return new o(this,{numberOfInputs:_})}createChannelSplitter(_=6){return new s(this,{numberOfOutputs:_})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(_=1){return new l(this,{maxDelayTime:_})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(_,v){return new m(this,{feedback:v,feedforward:_})}createOscillator(){return new g(this)}createPanner(){return new y(this)}createPeriodicWave(_,v,C={disableNormalization:!1}){return new b(this,X(M({},C),{imag:v,real:_}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new S(this)}decodeAudioData(_,v,C){return u(this._nativeContext,_).then(x=>(typeof v=="function"&&v(x),x),x=>{throw typeof C=="function"&&C(x),x})}};var ny={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Yl=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=M(M({},ny),l),m=i(h,p),f=s(h),g=f?e():null;super(u,!1,m,g),this._Q=t(this,f,m.Q,Dt,Pt),this._detune=t(this,f,m.detune,1200*Math.log2(Dt),-1200*Math.log2(Dt)),this._frequency=t(this,f,m.frequency,u.sampleRate/2,0),this._gain=t(this,f,m.gain,40*Math.log10(Dt),Pt),this._nativeBiquadFilterNode=m,a(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(u){this._nativeBiquadFilterNode.type=u}getFrequencyResponse(u,l,h){try{this._nativeBiquadFilterNode.getFrequencyResponse(u,l,h)}catch(p){throw p.code===11?r():p}if(u.length!==l.length||l.length!==h.length)throw r()}};var Hl=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=dt(u,c);if(!l){let h={Q:u.Q.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,detune:u.detune.value,frequency:u.frequency.value,gain:u.gain.value,type:u.type};u=t(c,h)}return o.set(c,u),l?(yield n(c,a.Q,u.Q),yield n(c,a.detune,u.detune),yield n(c,a.frequency,u.frequency),yield n(c,a.gain,u.gain)):(yield r(c,a.Q,u.Q),yield r(c,a.detune,u.detune),yield r(c,a.frequency,u.frequency),yield r(c,a.gain,u.gain)),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Zl=(n,t)=>(e,r)=>{let i=t.get(e);if(i!==void 0)return i;let o=n.get(e);if(o!==void 0)return o;try{let s=r();return s instanceof Promise?(n.set(e,s),s.catch(()=>!1).then(a=>(n.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var oy={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Xl=(n,t,e,r,i)=>class extends n{constructor(s,a){let c=r(s),u=M(M({},oy),a),l=e(c,u),h=i(c)?t():null;super(s,!1,l,h)}};var Ql=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!dt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=n(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var sy={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Kl=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=o(M(M({},sy),c)),h=e(u,l),p=i(u)?t():null;super(a,!1,h,p)}};var Jl=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!dt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=n(s,u)}return r.set(s,a),yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var $l=n=>(t,e,r)=>n(e,t,r);var th=n=>(t,e,r=0,i=0)=>{let o=t[r];if(o===void 0)throw n();return ai(e)?o.connect(e,0,i):o.connect(e,0)};var eh=n=>(t,e)=>{let r=n(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),i=t.createBuffer(1,2,44100);return r.buffer=i,r.loop=!0,r.connect(e),r.start(),()=>{r.stop(),r.disconnect(e)}};var ay={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},rh=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},ay),u),p=r(l,h),m=o(l),f=m?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,m,p.offset,Dt,Pt),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeConstantSourceNode.onended=u;let l=this._nativeConstantSourceNode.onended;this._onended=l!==null&&l===u?c:l}start(c=0){if(this._nativeConstantSourceNode.start(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.start=c),this.context.state!=="closed"){Be(this);let u=()=>{this._nativeConstantSourceNode.removeEventListener("ended",u),ae(this)&&ir(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var ih=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=(u,l)=>K(null,null,function*(){let h=e(u),p=dt(h,l);if(!p){let m={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,m),s!==null&&h.start(s),a!==null&&h.stop(a)}return o.set(l,h),p?yield n(l,u.offset,h.offset):yield r(l,u.offset,h.offset),yield i(u,l,h),h});return{set start(u){s=u},set stop(u){a=u},render(u,l){let h=o.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var nh=n=>t=>(n[0]=t,n[0]);var cy={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},oh=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=M(M({},cy),c),h=e(u,l),m=i(u)?t():null;super(a,!1,h,m),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&o(this,l.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(a){if(this._nativeConvolverNode.buffer=a,a===null&&this._nativeConvolverNode.buffer!==null){let c=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=c.createBuffer(1,1,c.sampleRate),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var sh=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!dt(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=n(s,u)}return r.set(s,a),Ne(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var ah=(n,t)=>(e,r,i)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,i)}catch(o){throw o.name==="SyntaxError"?n():o}};var ch=()=>new DOMException("","DataCloneError");var Oc=n=>{let{port1:t,port2:e}=new MessageChannel;return new Promise(r=>{let i=()=>{e.onmessage=null,t.close(),e.close(),r()};e.onmessage=()=>i();try{t.postMessage(n,[n])}catch(o){}finally{i()}})};var uh=(n,t,e,r,i,o,s,a,c,u,l)=>(h,p)=>{let m=s(h)?h:o(h);if(i.has(p)){let f=e();return Promise.reject(f)}try{i.add(p)}catch(f){}return t(c,()=>c(m))?m.decodeAudioData(p).then(f=>(Oc(p).catch(()=>{}),t(a,()=>a(f))||l(f),n.add(f),f)):new Promise((f,g)=>{let y=()=>K(null,null,function*(){try{yield Oc(p)}catch(I){}}),b=I=>{g(I),y()};try{m.decodeAudioData(p,I=>{typeof I.copyFromChannel!="function"&&(u(I),Pi(I)),n.add(I),y().then(()=>f(I))},I=>{b(I===null?r():I)})}catch(I){b(I)}})};var lh=(n,t,e,r,i,o,s,a)=>(c,u)=>{let l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=o(c.context),p=a(h);if(l===u){if(t.delete(c),!p&&s(c)){let m=r(c),{outputs:f}=e(c);for(let g of f)if(Br(g)){let y=r(g[0]);n(m,y,g[1],g[2])}else{let y=i(g[0]);m.connect(y,g[1])}}}else t.set(c,l-u)};var uy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},hh=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},uy),u),p=r(l,h),m=o(l),f=m?e(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,m,p.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var ph=(n,t,e,r,i)=>o=>{let s=new WeakMap,a=(c,u)=>K(null,null,function*(){let l=e(c),h=dt(l,u);if(!h){let p={channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,delayTime:l.delayTime.value,maxDelayTime:o};l=t(u,p)}return s.set(u,l),h?yield n(u,c.delayTime,l.delayTime):yield r(u,c.delayTime,l.delayTime),yield i(c,u,l),l});return{render(c,u){let l=s.get(u);return l!==void 0?Promise.resolve(l):a(c,u)}}};var dh=n=>(t,e,r,i)=>n(t[i],o=>o[0]===e&&o[1]===r);var mh=n=>(t,e)=>{n(t).delete(e)};var fh=n=>"delayTime"in n;var gh=(n,t,e)=>function r(i,o){let s=oi(o)?o:e(n,o);if(fh(s))return[];if(i[0]===s)return[i];if(i.includes(s))return[];let{outputs:a}=t(s);return Array.from(a).map(c=>r([...i,s],c[0])).reduce((c,u)=>c.concat(u),[])};var ds=(n,t,e)=>{let r=t[e];if(r===void 0)throw n();return r},yh=n=>(t,e=void 0,r=void 0,i=0)=>e===void 0?t.forEach(o=>o.disconnect()):typeof e=="number"?ds(n,t,e).disconnect():ai(e)?r===void 0?t.forEach(o=>o.disconnect(e)):i===void 0?ds(n,t,r).disconnect(e,0):ds(n,t,r).disconnect(e,0,i):r===void 0?t.forEach(o=>o.disconnect(e)):ds(n,t,r).disconnect(e,0);var ly={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},xh=(n,t,e,r,i,o,s,a)=>class extends n{constructor(u,l){let h=o(u),p=M(M({},ly),l),m=r(h,p),f=s(h),g=f?e():null;super(u,!1,m,g),this._attack=t(this,f,m.attack),this._knee=t(this,f,m.knee),this._nativeDynamicsCompressorNode=m,this._ratio=t(this,f,m.ratio),this._release=t(this,f,m.release),this._threshold=t(this,f,m.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(u){let l=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=u,u>2)throw this._nativeDynamicsCompressorNode.channelCount=l,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(u){let l=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=u,u==="max")throw this._nativeDynamicsCompressorNode.channelCountMode=l,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}};var bh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=dt(u,c);if(!l){let h={attack:u.attack.value,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,knee:u.knee.value,ratio:u.ratio.value,release:u.release.value,threshold:u.threshold.value};u=t(c,h)}return o.set(c,u),l?(yield n(c,a.attack,u.attack),yield n(c,a.knee,u.knee),yield n(c,a.ratio,u.ratio),yield n(c,a.release,u.release),yield n(c,a.threshold,u.threshold)):(yield r(c,a.attack,u.attack),yield r(c,a.knee,u.knee),yield r(c,a.ratio,u.ratio),yield r(c,a.release,u.release),yield r(c,a.threshold,u.threshold)),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Ah=()=>new DOMException("","EncodingError");var Ch=n=>t=>new Promise((e,r)=>{if(n===null){r(new SyntaxError);return}let i=n.document.head;if(i===null)r(new SyntaxError);else{let o=n.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=n.onerror,u=()=>{n.onerror=c,URL.revokeObjectURL(a)};n.onerror=(l,h,p,m,f)=>{if(h===a||h===n.location.href&&p===1&&m===1)return u(),r(f),!1;if(c!==null)return c(l,h,p,m,f)},o.onerror=()=>{u(),r(new SyntaxError)},o.onload=()=>{u(),e()},o.src=a,o.type="module",i.appendChild(o)}});var _h=n=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,i){if(r!==null){let o=this._listeners.get(r);o===void 0&&(o=n(this,r),typeof r=="function"&&this._listeners.set(r,o)),this._nativeEventTarget.addEventListener(e,o,i)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,i){let o=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,o===void 0?null:o,i)}};var vh=n=>(t,e,r)=>{Object.defineProperties(n,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{n!==null&&(delete n.currentFrame,delete n.currentTime)}};var Ih=n=>t=>K(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw n()});var hy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Sh=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=M(M({},hy),c),h=r(u,l),p=o(u),m=p?e():null;super(a,!1,h,m),this._gain=t(this,p,h.gain,Dt,Pt)}get gain(){return this._gain}};var wh=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=dt(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,gain:u.gain.value};u=t(c,h)}return o.set(c,u),l?yield n(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Th=(n,t)=>e=>t(n,e);var Nh=n=>t=>{let e=n(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var Oh=n=>t=>{var e;return(e=n.get(t))!==null&&e!==void 0?e:0};var Rh=n=>t=>{let e=n(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var Mh=n=>t=>n.get(t);var wt=()=>new DOMException("","InvalidStateError");var Dh=n=>t=>{let e=n.get(t);if(e===void 0)throw wt();return e};var Eh=(n,t)=>e=>{let r=n.get(e);if(r!==void 0)return r;if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new t(1,1,44100),n.set(e,r),r};var kh=n=>t=>{let e=n.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var Wi=()=>new DOMException("","InvalidAccessError");var jh=n=>{n.getFrequencyResponse=(t=>(e,r,i)=>{if(e.length!==r.length||r.length!==i.length)throw Wi();return t.call(n,e,r,i)})(n.getFrequencyResponse)};var py={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Ph=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=r(a),l=i(u),h=M(M({},py),c),p=t(u,l?null:a.baseLatency,h),m=l?e(h.feedback,h.feedforward):null;super(a,!1,p,m),jh(p),this._nativeIIRFilterNode=p,o(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var ms=(n,t,e,r,i,o,s,a,c,u,l)=>{let h=u.length,p=a;for(let m=0;m<h;m+=1){let f=e[0]*u[m];for(let g=1;g<i;g+=1){let y=p-g&c-1;f+=e[g]*o[y],f-=n[g]*s[y]}for(let g=i;g<r;g+=1)f+=e[g]*o[p-g&c-1];for(let g=i;g<t;g+=1)f-=n[g]*s[p-g&c-1];o[p]=u[m],s[p]=f,p=p+1&c-1,l[m]=f}return p};var dy=(n,t,e,r)=>{let i=e instanceof Float64Array?e:new Float64Array(e),o=r instanceof Float64Array?r:new Float64Array(r),s=i.length,a=o.length,c=Math.min(s,a);if(i[0]!==1){for(let f=0;f<s;f+=1)o[f]/=i[0];for(let f=1;f<a;f+=1)i[f]/=i[0]}let u=32,l=new Float32Array(u),h=new Float32Array(u),p=t.createBuffer(n.numberOfChannels,n.length,n.sampleRate),m=n.numberOfChannels;for(let f=0;f<m;f+=1){let g=n.getChannelData(f),y=p.getChannelData(f);l.fill(0),h.fill(0),ms(i,s,o,a,c,l,h,0,u,g,y)}return p},Lh=(n,t,e,r,i)=>(o,s)=>{let a=new WeakMap,c=null,u=(l,h)=>K(null,null,function*(){let p=null,m=t(l),f=dt(m,h);if(h.createIIRFilter===void 0?p=n(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(m=h.createIIRFilter(s,o)),a.set(h,p===null?m:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let y=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=K(null,null,function*(){yield r(l,y,y.destination);let b=yield i(y);return dy(b,h,o,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(l,h,m),m});return{render(l,h){let p=a.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Fh=(n,t,e,r,i,o)=>s=>(a,c)=>{let u=n.get(a);if(u===void 0){if(!s&&o(a)){let l=r(a),{outputs:h}=e(a);for(let p of h)if(Br(p)){let m=r(p[0]);t(l,m,p[1],p[2])}else{let m=i(p[0]);l.disconnect(m,p[1])}}n.set(a,c)}else n.set(a,u+c)};var Bh=(n,t)=>e=>{let r=n.get(e);return t(r)||t(e)};var Gh=(n,t)=>e=>n.has(e)||t(e);var Vh=(n,t)=>e=>n.has(e)||t(e);var qh=(n,t)=>e=>{let r=n.get(e);return t(r)||t(e)};var Wh=n=>t=>n!==null&&t instanceof n;var Uh=n=>t=>n!==null&&typeof n.AudioNode=="function"&&t instanceof n.AudioNode;var zh=n=>t=>n!==null&&typeof n.AudioParam=="function"&&t instanceof n.AudioParam;var Yh=(n,t)=>e=>n(e)||t(e);var Hh=n=>t=>n!==null&&t instanceof n;var Zh=n=>n!==null&&n.isSecureContext;var Xh=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw TypeError();super(o,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var my={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Qh=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o);if(r(a))throw new TypeError;let c=M(M({},my),s),u=t(a,c);super(o,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Kh=(n,t,e,r)=>class extends n{constructor(o,s){let a=e(o),c=t(a,s);if(r(a))throw new TypeError;super(o,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var Jh=(n,t,e)=>class extends n{constructor(i,o){let s=e(i),a=t(s,o);super(i,!0,a,null)}};var $h=(n,t,e,r,i)=>class extends r{constructor(s={}){if(i===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new i(s)}catch(l){throw l.code===12&&l.message==="sampleRate is not in range"?t():l}if(a===null)throw e();if(!ls(s.latencyHint))throw new TypeError(`The provided value '${s.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(s.sampleRate!==void 0&&a.sampleRate!==s.sampleRate)throw t();super(a,2);let{latencyHint:c}=s,{sampleRate:u}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:c==="balanced"?512/u:c==="interactive"||c===void 0?256/u:c==="playback"?1024/u:Math.max(2,Math.min(128,Math.round(c*u/128)))*128/u,this._nativeAudioContext=a,i.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";let l=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",l)};a.addEventListener("statechange",l)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw n()}):(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()),Fr(this)}))}resume(){return this._state==="suspended"?new Promise((s,a)=>{let c=()=>{this._nativeAudioContext.removeEventListener("statechange",c),this._nativeAudioContext.state==="running"?s():this.resume().then(s,a)};this._nativeAudioContext.addEventListener("statechange",c)}):this._nativeAudioContext.resume().catch(s=>{throw s===void 0||s.code===15?n():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?n():s})}};var tp=(n,t,e,r,i,o)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,ki.set(this,a),r(a)&&i.set(a,new Set),this._destination=new n(this,c),this._listener=t(this,a),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(a){let c=typeof a=="function"?o(this,a):null;this._nativeContext.onstatechange=c;let u=this._nativeContext.onstatechange;this._onstatechange=u!==null&&u===c?a:u}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}};var Ve=n=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=n.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var fy={numberOfChannels:1},ep=(n,t,e,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=M(M({},fy),s),l=e(c,a,u);n(Ve,()=>Ve(l))||l.addEventListener("statechange",(()=>{let h=0,p=m=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",p),m.stopImmediatePropagation(),this._waitForThePromiseToSettle(m)):h+=1)};return p})()),super(l,c),this._length=a,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(t()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Fr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var rp=(n,t)=>(e,r,i)=>{let o=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let l=o.size===0;if(t(a))return s.call(e,a,c,u),n(o,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(e,a,c),n(o,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let l=o.size>0;if(a===void 0)s.apply(e),o.clear();else if(typeof a=="number"){s.call(e,a);for(let p of o)p[1]===a&&o.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of o)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&o.delete(p)}let h=o.size===0;l&&h&&i()})(e.disconnect),e};var mt=(n,t,e)=>{let r=t[e];r!==void 0&&r!==n[e]&&(n[e]=r)};var ut=(n,t)=>{mt(n,t,"channelCount"),mt(n,t,"channelCountMode"),mt(n,t,"channelInterpretation")};var Rc=n=>typeof n.getFloatTimeDomainData=="function";var ip=n=>{n.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);n.getByteTimeDomainData(e);let r=Math.max(e.length,n.fftSize);for(let i=0;i<r;i+=1)t[i]=(e[i]-128)*.0078125;return t}};var np=(n,t)=>(e,r)=>{let i=e.createAnalyser();if(ut(i,r),!(r.maxDecibels>r.minDecibels))throw t();return mt(i,r,"fftSize"),mt(i,r,"maxDecibels"),mt(i,r,"minDecibels"),mt(i,r,"smoothingTimeConstant"),n(Rc,()=>Rc(i))||ip(i),i};var op=n=>n===null?null:n.hasOwnProperty("AudioBuffer")?n.AudioBuffer:null;var yt=(n,t,e)=>{let r=t[e];r!==void 0&&r!==n[e].value&&(n[e].value=r)};var sp=n=>{n.start=(t=>{let e=!1;return(r=0,i=0,o)=>{if(e)throw wt();t.call(n,r,i,o),e=!0}})(n.start)};var Ui=n=>{n.start=(t=>(e=0,r=0,i)=>{if(typeof i=="number"&&i<0||r<0||e<0)throw new RangeError("The parameters can't be negative.");t.call(n,e,r,i)})(n.start)};var zi=n=>{n.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(n,e)})(n.stop)};var ap=(n,t,e,r,i,o,s,a,c,u,l)=>(h,p)=>{let m=h.createBufferSource();return ut(m,p),yt(m,p,"playbackRate"),mt(m,p,"buffer"),mt(m,p,"loop"),mt(m,p,"loopEnd"),mt(m,p,"loopStart"),t(e,()=>e(h))||sp(m),t(r,()=>r(h))||c(m),t(i,()=>i(h))||u(m,h),t(o,()=>o(h))||Ui(m),t(s,()=>s(h))||l(m,h),t(a,()=>a(h))||zi(m),n(h,m),m};var cp=n=>n===null?null:n.hasOwnProperty("AudioContext")?n.AudioContext:n.hasOwnProperty("webkitAudioContext")?n.webkitAudioContext:null;var up=(n,t)=>(e,r,i)=>{let o=e.destination;if(o.channelCount!==r)try{o.channelCount=r}catch(a){}i&&o.channelCountMode!=="explicit"&&(o.channelCountMode="explicit"),o.maxChannelCount===0&&Object.defineProperty(o,"maxChannelCount",{value:r});let s=n(e,{channelCount:r,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{o.channelCount=c}catch(u){if(c>o.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),o.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>o.maxChannelCount}),s.connect(o),s};var lp=n=>n===null?null:n.hasOwnProperty("AudioWorkletNode")?n.AudioWorkletNode:null;var hp=n=>{let{port1:t}=new MessageChannel;try{t.postMessage(n)}finally{t.close()}};var pp=(n,t,e,r,i)=>(o,s,a,c,u,l)=>{if(a!==null)try{let h=new a(o,c,l),p=new Map,m=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw n()}},channelCountMode:{get:()=>"explicit",set:()=>{throw n()}},onprocessorerror:{get:()=>m,set:f=>{typeof m=="function"&&h.removeEventListener("processorerror",m),m=typeof f=="function"?f:null,typeof m=="function"&&h.addEventListener("processorerror",m)}}}),h.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let y=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(y!==null){let b=p.get(g[1]);b!==void 0?g[1]=b:(g[1]=I=>{I.type==="error"?(Object.defineProperties(I,{type:{value:"processorerror"}}),y(I)):y(new ErrorEvent(g[0],M({},I)))},p.set(y,g[1]))}}return f.call(h,"error",g[1],g[2]),f.call(h,...g)})(h.addEventListener),h.removeEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let y=p.get(g[1]);y!==void 0&&(p.delete(g[1]),g[1]=y)}return f.call(h,"error",g[1],g[2]),f.call(h,g[0],g[1],g[2])})(h.removeEventListener),l.numberOfOutputs!==0){let f=e(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(o.destination),i(h,()=>f.disconnect(),()=>f.connect(o.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return hp(l),t(o,s,u,l)};var fs=(n,t)=>n===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(n*t)))));var dp=n=>new Promise((t,e)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:o})=>{r.close(),i.close(),t(o)},r.onmessageerror=({data:o})=>{r.close(),i.close(),e(o)},i.postMessage(n)});var mp=(n,t)=>K(null,null,function*(){let e=yield dp(t);return new n(e)});var fp=(n,t,e,r)=>{let i=Zn.get(n);i===void 0&&(i=new WeakMap,Zn.set(n,i));let o=mp(e,r);return i.set(t,o),o};var gp=(n,t,e,r,i,o,s,a,c,u,l,h,p)=>(m,f,g,y)=>{if(y.numberOfInputs===0&&y.numberOfOutputs===0)throw c();let b=Array.isArray(y.outputChannelCount)?y.outputChannelCount:Array.from(y.outputChannelCount);if(b.some(H=>H<1))throw c();if(b.length!==y.numberOfOutputs)throw t();if(y.channelCountMode!=="explicit")throw c();let I=y.channelCount*y.numberOfInputs,S=b.reduce((H,rt)=>H+rt,0),w=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+w>6||S>6)throw c();let _=new MessageChannel,v=[],C=[];for(let H=0;H<y.numberOfInputs;H+=1)v.push(s(m,{channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation,gain:1})),C.push(i(m,{channelCount:y.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:y.channelCount}));let x=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:H,maxValue:rt,minValue:Ut,name:Nt}of g.parameterDescriptors){let gt=o(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:y.parameterData[Nt]!==void 0?y.parameterData[Nt]:H===void 0?0:H});Object.defineProperties(gt.offset,{defaultValue:{get:()=>H===void 0?0:H},maxValue:{get:()=>rt===void 0?Dt:rt},minValue:{get:()=>Ut===void 0?Pt:Ut}}),x.push(gt)}let N=r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+w)}),k=fs(f,m.sampleRate),R=a(m,k,I+w,Math.max(1,S)),D=i(m,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),U=[];for(let H=0;H<y.numberOfOutputs;H+=1)U.push(r(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:b[H]}));for(let H=0;H<y.numberOfInputs;H+=1){v[H].connect(C[H]);for(let rt=0;rt<y.channelCount;rt+=1)C[H].connect(N,rt,H*y.channelCount+rt)}let E=new Gi(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:H},rt)=>{let Ut=x[rt];return Ut.connect(N,0,I+rt),Ut.start(0),[H,Ut.offset]}));N.connect(R);let P=y.channelInterpretation,L=null,V=y.numberOfOutputs===0?[R]:U,Q={get bufferSize(){return k},get channelCount(){return y.channelCount},set channelCount(H){throw e()},get channelCountMode(){return y.channelCountMode},set channelCountMode(H){throw e()},get channelInterpretation(){return P},set channelInterpretation(H){for(let rt of v)rt.channelInterpretation=H;P=H},get context(){return R.context},get inputs(){return v},get numberOfInputs(){return y.numberOfInputs},get numberOfOutputs(){return y.numberOfOutputs},get onprocessorerror(){return L},set onprocessorerror(H){typeof L=="function"&&Q.removeEventListener("processorerror",L),L=typeof H=="function"?H:null,typeof L=="function"&&Q.addEventListener("processorerror",L)},get parameters(){return E},get port(){return _.port2},addEventListener(...H){return R.addEventListener(H[0],H[1],H[2])},connect:n.bind(null,V),disconnect:u.bind(null,V),dispatchEvent(...H){return R.dispatchEvent(H[0])},removeEventListener(...H){return R.removeEventListener(H[0],H[1],H[2])}},Y=new Map;_.port1.addEventListener=(H=>(...rt)=>{if(rt[0]==="message"){let Ut=typeof rt[1]=="function"?rt[1]:typeof rt[1]=="object"&&rt[1]!==null&&typeof rt[1].handleEvent=="function"?rt[1].handleEvent:null;if(Ut!==null){let Nt=Y.get(rt[1]);Nt!==void 0?rt[1]=Nt:(rt[1]=gt=>{l(m.currentTime,m.sampleRate,()=>Ut(gt))},Y.set(Ut,rt[1]))}}return H.call(_.port1,rt[0],rt[1],rt[2])})(_.port1.addEventListener),_.port1.removeEventListener=(H=>(...rt)=>{if(rt[0]==="message"){let Ut=Y.get(rt[1]);Ut!==void 0&&(Y.delete(rt[1]),rt[1]=Ut)}return H.call(_.port1,rt[0],rt[1],rt[2])})(_.port1.removeEventListener);let F=null;Object.defineProperty(_.port1,"onmessage",{get:()=>F,set:H=>{typeof F=="function"&&_.port1.removeEventListener("message",F),F=typeof H=="function"?H:null,typeof F=="function"&&(_.port1.addEventListener("message",F),_.port1.start())}}),g.prototype.port=_.port1;let ct=null;fp(m,Q,g,y).then(H=>ct=H);let jt=qi(y.numberOfInputs,y.channelCount),xe=qi(y.numberOfOutputs,b),be=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((H,{name:rt})=>X(M({},H),{[rt]:new Float32Array(128)}),{}),At=!0,nt=()=>{y.numberOfOutputs>0&&R.disconnect(D);for(let H=0,rt=0;H<y.numberOfOutputs;H+=1){let Ut=U[H];for(let Nt=0;Nt<b[H];Nt+=1)D.disconnect(Ut,rt+Nt,Nt);rt+=b[H]}},Si=new Map;R.onaudioprocess=({inputBuffer:H,outputBuffer:rt})=>{if(ct!==null){let Ut=h(Q);for(let Nt=0;Nt<k;Nt+=128){for(let gt=0;gt<y.numberOfInputs;gt+=1)for(let Mt=0;Mt<y.channelCount;Mt+=1)Vi(H,jt[gt],Mt,Mt,Nt);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:gt},Mt)=>{Vi(H,be,gt,I+Mt,Nt)});for(let gt=0;gt<y.numberOfInputs;gt+=1)for(let Mt=0;Mt<b[gt];Mt+=1)xe[gt][Mt].byteLength===0&&(xe[gt][Mt]=new Float32Array(128));try{let gt=jt.map((Ie,Rr)=>{if(Ut[Rr].size>0)return Si.set(Rr,k/128),Ie;let Ua=Si.get(Rr);return Ua===void 0?[]:(Ie.every(Dm=>Dm.every(Em=>Em===0))&&(Ua===1?Si.delete(Rr):Si.set(Rr,Ua-1)),Ie)});At=l(m.currentTime+Nt/m.sampleRate,m.sampleRate,()=>ct.process(gt,xe,be));for(let Ie=0,Rr=0;Ie<y.numberOfOutputs;Ie+=1){for(let Mn=0;Mn<b[Ie];Mn+=1)ps(rt,xe[Ie],Mn,Rr+Mn,Nt);Rr+=b[Ie]}}catch(gt){At=!1,Q.dispatchEvent(new ErrorEvent("processorerror",{colno:gt.colno,filename:gt.filename,lineno:gt.lineno,message:gt.message}))}if(!At){for(let gt=0;gt<y.numberOfInputs;gt+=1){v[gt].disconnect(C[gt]);for(let Mt=0;Mt<y.channelCount;Mt+=1)C[Nt].disconnect(N,Mt,gt*y.channelCount+Mt)}if(g.parameterDescriptors!==void 0){let gt=g.parameterDescriptors.length;for(let Mt=0;Mt<gt;Mt+=1){let Ie=x[Mt];Ie.disconnect(N,0,I+Mt),Ie.stop()}}N.disconnect(R),R.onaudioprocess=null,Nn?nt():Ti();break}}}};let Nn=!1,J=s(m,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),wi=()=>R.connect(J).connect(m.destination),Ti=()=>{R.disconnect(J),J.disconnect()},On=()=>{if(At){Ti(),y.numberOfOutputs>0&&R.connect(D);for(let H=0,rt=0;H<y.numberOfOutputs;H+=1){let Ut=U[H];for(let Nt=0;Nt<b[H];Nt+=1)D.connect(Ut,rt+Nt,Nt);rt+=b[H]}}Nn=!0},Rn=()=>{At&&(wi(),nt()),Nn=!1};return wi(),p(Q,On,Rn)};var Mc=(n,t)=>{let e=n.createBiquadFilter();return ut(e,t),yt(e,t,"Q"),yt(e,t,"detune"),yt(e,t,"frequency"),yt(e,t,"gain"),mt(e,t,"type"),e};var yp=(n,t)=>(e,r)=>{let i=e.createChannelMerger(r.numberOfInputs);return n!==null&&n.name==="webkitAudioContext"&&t(e,i),ut(i,r),i};var xp=n=>{let t=n.numberOfOutputs;Object.defineProperty(n,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw wt()}}),Object.defineProperty(n,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw wt()}}),Object.defineProperty(n,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw wt()}})};var Yi=(n,t)=>{let e=n.createChannelSplitter(t.numberOfOutputs);return ut(e,t),xp(e),e};var bp=(n,t,e,r,i)=>(o,s)=>{if(o.createConstantSource===void 0)return e(o,s);let a=o.createConstantSource();return ut(a,s),yt(a,s,"offset"),t(r,()=>r(o))||Ui(a),t(i,()=>i(o))||zi(a),n(o,a),a};var Oe=(n,t)=>(n.connect=t.connect.bind(t),n.disconnect=t.disconnect.bind(t),n);var Ap=(n,t,e,r)=>(i,a)=>{var c=a,{offset:o}=c,s=Mr(c,["offset"]);let u=i.createBuffer(1,2,44100),l=t(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=e(i,X(M({},s),{gain:o})),p=u.getChannelData(0);p[0]=1,p[1]=1,l.buffer=u,l.loop=!0;let m={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(y){h.channelCount=y},get channelCountMode(){return h.channelCountMode},set channelCountMode(y){h.channelCountMode=y},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(y){h.channelInterpretation=y},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return l.onended},set onended(y){l.onended=y},addEventListener(...y){return l.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return l.dispatchEvent(y[0])},removeEventListener(...y){return l.removeEventListener(y[0],y[1],y[2])},start(y=0){l.start.call(l,y)},stop(y=0){l.stop.call(l,y)}},f=()=>l.connect(h),g=()=>l.disconnect(h);return n(i,l),r(Oe(m,h),f,g)};var Cp=(n,t)=>(e,r)=>{let i=e.createConvolver();if(ut(i,r),r.disableNormalization===i.normalize&&(i.normalize=!r.disableNormalization),mt(i,r,"buffer"),r.channelCount>2||(t(i,"channelCount",o=>()=>o.call(i),o=>s=>{if(s>2)throw n();return o.call(i,s)}),r.channelCountMode==="max"))throw n();return t(i,"channelCountMode",o=>()=>o.call(i),o=>s=>{if(s==="max")throw n();return o.call(i,s)}),i};var Dc=(n,t)=>{let e=n.createDelay(t.maxDelayTime);return ut(e,t),yt(e,t,"delayTime"),e};var _p=n=>(t,e)=>{let r=t.createDynamicsCompressor();if(ut(r,e),e.channelCount>2||e.channelCountMode==="max")throw n();return yt(r,e,"attack"),yt(r,e,"knee"),yt(r,e,"ratio"),yt(r,e,"release"),yt(r,e,"threshold"),r};var ce=(n,t)=>{let e=n.createGain();return ut(e,t),yt(e,t,"gain"),e};var vp=n=>(t,e,r)=>{if(t.createIIRFilter===void 0)return n(t,e,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return ut(i,r),i};function gy(n,t){let e=t[0]*t[0]+t[1]*t[1];return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]}function yy(n,t){return[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]]}function Ip(n,t){let e=[0,0];for(let r=n.length-1;r>=0;r-=1)e=yy(e,t),e[0]+=n[r];return e}var Sp=(n,t,e,r)=>(i,o,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=fs(o,i.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),m=l instanceof Float64Array?l:new Float64Array(l),f=p.length,g=m.length,y=Math.min(f,g);if(f===0||f>20)throw r();if(p[0]===0)throw t();if(g===0||g>20)throw r();if(m[0]===0)throw t();if(p[0]!==1){for(let x=0;x<g;x+=1)m[x]/=p[0];for(let x=1;x<f;x+=1)p[x]/=p[0]}let b=e(i,h,s,s);b.channelCount=s,b.channelCountMode=a,b.channelInterpretation=c;let I=32,S=[],w=[],_=[];for(let x=0;x<s;x+=1){S.push(0);let N=new Float32Array(I),k=new Float32Array(I);N.fill(0),k.fill(0),w.push(N),_.push(k)}b.onaudioprocess=x=>{let N=x.inputBuffer,k=x.outputBuffer,R=N.numberOfChannels;for(let D=0;D<R;D+=1){let U=N.getChannelData(D),E=k.getChannelData(D);S[D]=ms(p,f,m,g,y,w[D],_[D],S[D],I,U,E)}};let v=i.sampleRate/2;return Oe({get bufferSize(){return h},get channelCount(){return b.channelCount},set channelCount(x){b.channelCount=x},get channelCountMode(){return b.channelCountMode},set channelCountMode(x){b.channelCountMode=x},get channelInterpretation(){return b.channelInterpretation},set channelInterpretation(x){b.channelInterpretation=x},get context(){return b.context},get inputs(){return[b]},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},addEventListener(...x){return b.addEventListener(x[0],x[1],x[2])},dispatchEvent(...x){return b.dispatchEvent(x[0])},getFrequencyResponse(x,N,k){if(x.length!==N.length||N.length!==k.length)throw n();let R=x.length;for(let D=0;D<R;D+=1){let U=-Math.PI*(x[D]/v),E=[Math.cos(U),Math.sin(U)],P=Ip(m,E),L=Ip(p,E),V=gy(P,L);N[D]=Math.sqrt(V[0]*V[0]+V[1]*V[1]),k[D]=Math.atan2(V[1],V[0])}},removeEventListener(...x){return b.removeEventListener(x[0],x[1],x[2])}},b)};var wp=(n,t)=>n.createMediaElementSource(t.mediaElement);var Tp=(n,t)=>{let e=n.createMediaStreamDestination();return ut(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var Np=(n,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((o,s)=>o.id<s.id?-1:o.id>s.id?1:0);let r=e.slice(0,1),i=n.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i};var Op=(n,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let i=new MediaStream([r]),o=e.createMediaStreamSource(i);if(r.kind!=="audio")throw n();if(t(e))throw new TypeError;return o};var Rp=n=>n===null?null:n.hasOwnProperty("OfflineAudioContext")?n.OfflineAudioContext:n.hasOwnProperty("webkitOfflineAudioContext")?n.webkitOfflineAudioContext:null;var Mp=(n,t,e,r,i,o)=>(s,a)=>{let c=s.createOscillator();return ut(c,a),yt(c,a,"detune"),yt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):mt(c,a,"type"),t(e,()=>e(s))||Ui(c),t(r,()=>r(s))||o(c,s),t(i,()=>i(s))||zi(c),n(s,c),c};var Dp=n=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?n(t,e):(ut(r,e),yt(r,e,"orientationX"),yt(r,e,"orientationY"),yt(r,e,"orientationZ"),yt(r,e,"positionX"),yt(r,e,"positionY"),yt(r,e,"positionZ"),mt(r,e,"coneInnerAngle"),mt(r,e,"coneOuterAngle"),mt(r,e,"coneOuterGain"),mt(r,e,"distanceModel"),mt(r,e,"maxDistance"),mt(r,e,"panningModel"),mt(r,e,"refDistance"),mt(r,e,"rolloffFactor"),r)};var Ep=(n,t,e,r,i,o,s,a,c,u)=>(l,k)=>{var R=k,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:m,distanceModel:f,maxDistance:g,orientationX:y,orientationY:b,orientationZ:I,panningModel:S,positionX:w,positionY:_,positionZ:v,refDistance:C,rolloffFactor:x}=R,N=Mr(R,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let D=l.createPanner();if(N.channelCount>2||N.channelCountMode==="max")throw s();ut(D,N);let U={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},E=e(l,X(M({},U),{channelInterpretation:"speakers",numberOfInputs:6})),P=r(l,X(M({},N),{gain:1})),L=r(l,X(M({},U),{gain:1})),V=r(l,X(M({},U),{gain:0})),Q=r(l,X(M({},U),{gain:0})),Y=r(l,X(M({},U),{gain:0})),F=r(l,X(M({},U),{gain:0})),ct=r(l,X(M({},U),{gain:0})),xt=i(l,256,6,1),jt=o(l,X(M({},U),{curve:new Float32Array([1,1]),oversample:"none"})),xe=[y,b,I],be=[w,_,v],At=new Float32Array(1);xt.onaudioprocess=({inputBuffer:J})=>{let wi=[c(J,At,0),c(J,At,1),c(J,At,2)];wi.some((On,Rn)=>On!==xe[Rn])&&(D.setOrientation(...wi),xe=wi);let Ti=[c(J,At,3),c(J,At,4),c(J,At,5)];Ti.some((On,Rn)=>On!==be[Rn])&&(D.setPosition(...Ti),be=Ti)},Object.defineProperty(V.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Y.gain,"defaultValue",{get:()=>0}),Object.defineProperty(F.gain,"defaultValue",{get:()=>0}),Object.defineProperty(ct.gain,"defaultValue",{get:()=>0});let nt={get bufferSize(){},get channelCount(){return D.channelCount},set channelCount(J){if(J>2)throw s();P.channelCount=J,D.channelCount=J},get channelCountMode(){return D.channelCountMode},set channelCountMode(J){if(J==="max")throw s();P.channelCountMode=J,D.channelCountMode=J},get channelInterpretation(){return D.channelInterpretation},set channelInterpretation(J){P.channelInterpretation=J,D.channelInterpretation=J},get coneInnerAngle(){return D.coneInnerAngle},set coneInnerAngle(J){D.coneInnerAngle=J},get coneOuterAngle(){return D.coneOuterAngle},set coneOuterAngle(J){D.coneOuterAngle=J},get coneOuterGain(){return D.coneOuterGain},set coneOuterGain(J){if(J<0||J>1)throw t();D.coneOuterGain=J},get context(){return D.context},get distanceModel(){return D.distanceModel},set distanceModel(J){D.distanceModel=J},get inputs(){return[P]},get maxDistance(){return D.maxDistance},set maxDistance(J){if(J<0)throw new RangeError;D.maxDistance=J},get numberOfInputs(){return D.numberOfInputs},get numberOfOutputs(){return D.numberOfOutputs},get orientationX(){return L.gain},get orientationY(){return V.gain},get orientationZ(){return Q.gain},get panningModel(){return D.panningModel},set panningModel(J){D.panningModel=J},get positionX(){return Y.gain},get positionY(){return F.gain},get positionZ(){return ct.gain},get refDistance(){return D.refDistance},set refDistance(J){if(J<0)throw new RangeError;D.refDistance=J},get rolloffFactor(){return D.rolloffFactor},set rolloffFactor(J){if(J<0)throw new RangeError;D.rolloffFactor=J},addEventListener(...J){return P.addEventListener(J[0],J[1],J[2])},dispatchEvent(...J){return P.dispatchEvent(J[0])},removeEventListener(...J){return P.removeEventListener(J[0],J[1],J[2])}};h!==nt.coneInnerAngle&&(nt.coneInnerAngle=h),p!==nt.coneOuterAngle&&(nt.coneOuterAngle=p),m!==nt.coneOuterGain&&(nt.coneOuterGain=m),f!==nt.distanceModel&&(nt.distanceModel=f),g!==nt.maxDistance&&(nt.maxDistance=g),y!==nt.orientationX.value&&(nt.orientationX.value=y),b!==nt.orientationY.value&&(nt.orientationY.value=b),I!==nt.orientationZ.value&&(nt.orientationZ.value=I),S!==nt.panningModel&&(nt.panningModel=S),w!==nt.positionX.value&&(nt.positionX.value=w),_!==nt.positionY.value&&(nt.positionY.value=_),v!==nt.positionZ.value&&(nt.positionZ.value=v),C!==nt.refDistance&&(nt.refDistance=C),x!==nt.rolloffFactor&&(nt.rolloffFactor=x),(xe[0]!==1||xe[1]!==0||xe[2]!==0)&&D.setOrientation(...xe),(be[0]!==0||be[1]!==0||be[2]!==0)&&D.setPosition(...be);let Si=()=>{P.connect(D),n(P,jt,0,0),jt.connect(L).connect(E,0,0),jt.connect(V).connect(E,0,1),jt.connect(Q).connect(E,0,2),jt.connect(Y).connect(E,0,3),jt.connect(F).connect(E,0,4),jt.connect(ct).connect(E,0,5),E.connect(xt).connect(l.destination)},Nn=()=>{P.disconnect(D),a(P,jt,0,0),jt.disconnect(L),L.disconnect(E),jt.disconnect(V),V.disconnect(E),jt.disconnect(Q),Q.disconnect(E),jt.disconnect(Y),Y.disconnect(E),jt.disconnect(F),F.disconnect(E),jt.disconnect(ct),ct.disconnect(E),E.disconnect(xt),xt.disconnect(l.destination)};return u(Oe(nt,D),Si,Nn)};var kp=n=>(t,{disableNormalization:e,imag:r,real:i})=>{let o=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=t.createPeriodicWave(s,o,{disableNormalization:e});if(Array.from(r).length<2)throw n();return a};var Hi=(n,t,e,r)=>n.createScriptProcessor(t,e,r);var jp=(n,t)=>(e,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw t();if(e.createStereoPanner===void 0)return n(e,r);let o=e.createStereoPanner();return ut(o,r),yt(o,r,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw t()}}),o};var Pp=(n,t,e,r,i,o)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=X(M({},u),{oversample:"none"}),h=(f,g,y,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385);for(let N=0;N<16385;N+=1){let k=N/16384*c;I[N]=Math.cos(k),S[N]=Math.sin(k)}let w=e(f,X(M({},u),{gain:0})),_=r(f,X(M({},l),{curve:I})),v=r(f,X(M({},l),{curve:a})),C=e(f,X(M({},u),{gain:0})),x=r(f,X(M({},l),{curve:S}));return{connectGraph(){g.connect(w),g.connect(v.inputs===void 0?v:v.inputs[0]),g.connect(C),v.connect(y),y.connect(_.inputs===void 0?_:_.inputs[0]),y.connect(x.inputs===void 0?x:x.inputs[0]),_.connect(w.gain),x.connect(C.gain),w.connect(b,0,0),C.connect(b,0,1)},disconnectGraph(){g.disconnect(w),g.disconnect(v.inputs===void 0?v:v.inputs[0]),g.disconnect(C),v.disconnect(y),y.disconnect(_.inputs===void 0?_:_.inputs[0]),y.disconnect(x.inputs===void 0?x:x.inputs[0]),_.disconnect(w.gain),x.disconnect(C.gain),w.disconnect(b,0,0),C.disconnect(b,0,1)}}},p=(f,g,y,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385),w=new Float32Array(16385),_=new Float32Array(16385),v=Math.floor(16385/2);for(let V=0;V<16385;V+=1)if(V>v){let Q=(V-v)/(16384-v)*c;I[V]=Math.cos(Q),S[V]=Math.sin(Q),w[V]=0,_[V]=1}else{let Q=V/(16384-v)*c;I[V]=1,S[V]=0,w[V]=Math.cos(Q),_[V]=Math.sin(Q)}let C=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),x=e(f,X(M({},u),{gain:0})),N=r(f,X(M({},l),{curve:I})),k=e(f,X(M({},u),{gain:0})),R=r(f,X(M({},l),{curve:S})),D=r(f,X(M({},l),{curve:a})),U=e(f,X(M({},u),{gain:0})),E=r(f,X(M({},l),{curve:w})),P=e(f,X(M({},u),{gain:0})),L=r(f,X(M({},l),{curve:_}));return{connectGraph(){g.connect(C),g.connect(D.inputs===void 0?D:D.inputs[0]),C.connect(x,0),C.connect(k,0),C.connect(U,1),C.connect(P,1),D.connect(y),y.connect(N.inputs===void 0?N:N.inputs[0]),y.connect(R.inputs===void 0?R:R.inputs[0]),y.connect(E.inputs===void 0?E:E.inputs[0]),y.connect(L.inputs===void 0?L:L.inputs[0]),N.connect(x.gain),R.connect(k.gain),E.connect(U.gain),L.connect(P.gain),x.connect(b,0,0),U.connect(b,0,0),k.connect(b,0,1),P.connect(b,0,1)},disconnectGraph(){g.disconnect(C),g.disconnect(D.inputs===void 0?D:D.inputs[0]),C.disconnect(x,0),C.disconnect(k,0),C.disconnect(U,1),C.disconnect(P,1),D.disconnect(y),y.disconnect(N.inputs===void 0?N:N.inputs[0]),y.disconnect(R.inputs===void 0?R:R.inputs[0]),y.disconnect(E.inputs===void 0?E:E.inputs[0]),y.disconnect(L.inputs===void 0?L:L.inputs[0]),N.disconnect(x.gain),R.disconnect(k.gain),E.disconnect(U.gain),L.disconnect(P.gain),x.disconnect(b,0,0),U.disconnect(b,0,0),k.disconnect(b,0,1),P.disconnect(b,0,1)}}},m=(f,g,y,b,I)=>{if(g===1)return h(f,y,b,I);if(g===2)return p(f,y,b,I);throw i()};return(f,S)=>{var w=S,{channelCount:g,channelCountMode:y,pan:b}=w,I=Mr(w,["channelCount","channelCountMode","pan"]);if(y==="max")throw i();let _=n(f,X(M({},I),{channelCount:1,channelCountMode:y,numberOfInputs:2})),v=e(f,X(M({},I),{channelCount:g,channelCountMode:y,gain:1})),C=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:b}),{connectGraph:x,disconnectGraph:N}=m(f,g,v,C,_);Object.defineProperty(C.gain,"defaultValue",{get:()=>0}),Object.defineProperty(C.gain,"maxValue",{get:()=>1}),Object.defineProperty(C.gain,"minValue",{get:()=>-1});let k={get bufferSize(){},get channelCount(){return v.channelCount},set channelCount(E){v.channelCount!==E&&(R&&N(),{connectGraph:x,disconnectGraph:N}=m(f,E,v,C,_),R&&x()),v.channelCount=E},get channelCountMode(){return v.channelCountMode},set channelCountMode(E){if(E==="clamped-max"||E==="max")throw i();v.channelCountMode=E},get channelInterpretation(){return v.channelInterpretation},set channelInterpretation(E){v.channelInterpretation=E},get context(){return v.context},get inputs(){return[v]},get numberOfInputs(){return v.numberOfInputs},get numberOfOutputs(){return v.numberOfOutputs},get pan(){return C.gain},addEventListener(...E){return v.addEventListener(E[0],E[1],E[2])},dispatchEvent(...E){return v.dispatchEvent(E[0])},removeEventListener(...E){return v.removeEventListener(E[0],E[1],E[2])}},R=!1,D=()=>{x(),R=!0},U=()=>{N(),R=!1};return o(Oe(k,_),D,U)}};var Lp=(n,t,e,r,i,o,s)=>(a,c)=>{let u=a.createWaveShaper();if(o!==null&&o.name==="webkitAudioContext"&&a.createGain().gain.automationRate===void 0)return e(a,c);ut(u,c);let l=c.curve===null||c.curve instanceof Float32Array?c.curve:new Float32Array(c.curve);if(l!==null&&l.length<2)throw t();mt(u,{curve:l},"curve"),mt(u,c,"oversample");let h=null,p=!1;return s(u,"curve",g=>()=>g.call(u),g=>y=>(g.call(u,y),p&&(r(y)&&h===null?h=n(a,u):!r(y)&&h!==null&&(h(),h=null)),y)),i(u,()=>{p=!0,r(u.curve)&&(h=n(a,u))},()=>{p=!1,h!==null&&(h(),h=null)})};var Fp=(n,t,e,r,i)=>(o,u)=>{var l=u,{curve:s,oversample:a}=l,c=Mr(l,["curve","oversample"]);let h=o.createWaveShaper(),p=o.createWaveShaper();ut(h,c),ut(p,c);let m=e(o,X(M({},c),{gain:1})),f=e(o,X(M({},c),{gain:-1})),g=e(o,X(M({},c),{gain:1})),y=e(o,X(M({},c),{gain:-1})),b=null,I=!1,S=null,w={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(C){m.channelCount=C,f.channelCount=C,h.channelCount=C,g.channelCount=C,p.channelCount=C,y.channelCount=C},get channelCountMode(){return h.channelCountMode},set channelCountMode(C){m.channelCountMode=C,f.channelCountMode=C,h.channelCountMode=C,g.channelCountMode=C,p.channelCountMode=C,y.channelCountMode=C},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(C){m.channelInterpretation=C,f.channelInterpretation=C,h.channelInterpretation=C,g.channelInterpretation=C,p.channelInterpretation=C,y.channelInterpretation=C},get context(){return h.context},get curve(){return S},set curve(C){if(C!==null&&C.length<2)throw t();if(C===null)h.curve=C,p.curve=C;else{let x=C.length,N=new Float32Array(x+2-x%2),k=new Float32Array(x+2-x%2);N[0]=C[0],k[0]=-C[x-1];let R=Math.ceil((x+1)/2),D=(x+1)/2-1;for(let U=1;U<R;U+=1){let E=U/R*D,P=Math.floor(E),L=Math.ceil(E);N[U]=P===L?C[P]:(1-(E-P))*C[P]+(1-(L-E))*C[L],k[U]=P===L?-C[x-1-P]:-((1-(E-P))*C[x-1-P])-(1-(L-E))*C[x-1-L]}N[R]=x%2===1?C[R-1]:(C[R-2]+C[R-1])/2,h.curve=N,p.curve=k}S=C,I&&(r(S)&&b===null?b=n(o,m):b!==null&&(b(),b=null))},get inputs(){return[m]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(C){h.oversample=C,p.oversample=C},addEventListener(...C){return m.addEventListener(C[0],C[1],C[2])},dispatchEvent(...C){return m.dispatchEvent(C[0])},removeEventListener(...C){return m.removeEventListener(C[0],C[1],C[2])}};s!==null&&(w.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==w.oversample&&(w.oversample=a);let _=()=>{m.connect(h).connect(g),m.connect(f).connect(p).connect(y).connect(g),I=!0,r(S)&&(b=n(o,m))},v=()=>{m.disconnect(h),h.disconnect(g),m.disconnect(f),f.disconnect(p),p.disconnect(y),y.disconnect(g),I=!1,b!==null&&(b(),b=null)};return i(Oe(w,g),_,v)};var Kt=()=>new DOMException("","NotSupportedError");var xy={numberOfChannels:1},Bp=(n,t,e,r,i)=>class extends n{constructor(s,a,c){let u;if(typeof s=="number"&&a!==void 0&&c!==void 0)u={length:a,numberOfChannels:s,sampleRate:c};else if(typeof s=="object")u=s;else throw new Error("The given parameters are not valid.");let{length:l,numberOfChannels:h,sampleRate:p}=M(M({},xy),u),m=r(h,l,p);t(Ve,()=>Ve(m))||m.addEventListener("statechange",(()=>{let f=0,g=y=>{this._state==="running"&&(f>0?(m.removeEventListener("statechange",g),y.stopImmediatePropagation(),this._waitForThePromiseToSettle(y)):f+=1)};return g})()),super(m,h),this._length=l,this._nativeOfflineAudioContext=m,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(e()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,Fr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var by={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Gp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},by),u),p=e(l,h),m=o(l),f=m?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,m,p.detune,153600,-153600),this._frequency=t(this,m,p.frequency,g,-g),this._nativeOscillatorNode=p,this._onended=null,this._oscillatorNodeRenderer=f,this._oscillatorNodeRenderer!==null&&h.periodicWave!==void 0&&(this._oscillatorNodeRenderer.periodicWave=h.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(c){let u=typeof c=="function"?s(this,c):null;this._nativeOscillatorNode.onended=u;let l=this._nativeOscillatorNode.onended;this._onended=l!==null&&l===u?c:l}get type(){return this._nativeOscillatorNode.type}set type(c){this._nativeOscillatorNode.type=c,this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(c){this._nativeOscillatorNode.setPeriodicWave(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.periodicWave=c)}start(c=0){if(this._nativeOscillatorNode.start(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.start=c),this.context.state!=="closed"){Be(this);let u=()=>{this._nativeOscillatorNode.removeEventListener("ended",u),ae(this)&&ir(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var Vp=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=null,a=null,c=null,u=(l,h)=>K(null,null,function*(){let p=e(l),m=dt(p,h);if(!m){let f={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:s===null?void 0:s,type:p.type};p=t(h,f),a!==null&&p.start(a),c!==null&&p.stop(c)}return o.set(h,p),m?(yield n(h,l.detune,p.detune),yield n(h,l.frequency,p.frequency)):(yield r(h,l.detune,p.detune),yield r(h,l.frequency,p.frequency)),yield i(l,h,p),p});return{set periodicWave(l){s=l},set start(l){a=l},set stop(l){c=l},render(l,h){let p=o.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Ay={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},qp=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},Ay),u),p=e(l,h),m=o(l),f=m?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,m,p.orientationX,Dt,Pt),this._orientationY=t(this,m,p.orientationY,Dt,Pt),this._orientationZ=t(this,m,p.orientationZ,Dt,Pt),this._positionX=t(this,m,p.positionX,Dt,Pt),this._positionY=t(this,m,p.positionY,Dt,Pt),this._positionZ=t(this,m,p.positionZ,Dt,Pt),s(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(c){this._nativePannerNode.coneInnerAngle=c}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(c){this._nativePannerNode.coneOuterAngle=c}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(c){this._nativePannerNode.coneOuterGain=c}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(c){this._nativePannerNode.distanceModel=c}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(c){this._nativePannerNode.maxDistance=c}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(c){this._nativePannerNode.panningModel=c}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(c){this._nativePannerNode.refDistance=c}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(c){this._nativePannerNode.rolloffFactor=c}};var Wp=(n,t,e,r,i,o,s,a,c,u)=>()=>{let l=new WeakMap,h=null,p=(m,f)=>K(null,null,function*(){let g=null,y=o(m),b={channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation},I=X(M({},b),{coneInnerAngle:y.coneInnerAngle,coneOuterAngle:y.coneOuterAngle,coneOuterGain:y.coneOuterGain,distanceModel:y.distanceModel,maxDistance:y.maxDistance,panningModel:y.panningModel,refDistance:y.refDistance,rolloffFactor:y.rolloffFactor}),S=dt(y,f);if("bufferSize"in y)g=r(f,X(M({},b),{gain:1}));else if(!S){let w=X(M({},I),{orientationX:y.orientationX.value,orientationY:y.orientationY.value,orientationZ:y.orientationZ.value,positionX:y.positionX.value,positionY:y.positionY.value,positionZ:y.positionZ.value});y=i(f,w)}if(l.set(f,g===null?y:g),g!==null){if(h===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let R=new s(6,m.context.length,f.sampleRate),D=t(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});D.connect(R.destination),h=K(null,null,function*(){let U=yield Promise.all([m.orientationX,m.orientationY,m.orientationZ,m.positionX,m.positionY,m.positionZ].map((E,P)=>K(null,null,function*(){let L=e(R,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P===0?1:0});return yield a(R,E,L.offset),L})));for(let E=0;E<6;E+=1)U[E].connect(D,0,E),U[E].start(0);return u(R)})}let w=yield h,_=r(f,X(M({},b),{gain:1}));yield c(m,f,_);let v=[];for(let R=0;R<w.numberOfChannels;R+=1)v.push(w.getChannelData(R));let C=[v[0][0],v[1][0],v[2][0]],x=[v[3][0],v[4][0],v[5][0]],N=r(f,X(M({},b),{gain:1})),k=i(f,X(M({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:x[0],positionY:x[1],positionZ:x[2]}));_.connect(N).connect(k.inputs[0]),k.connect(g);for(let R=128;R<w.length;R+=128){let D=[v[0][R],v[1][R],v[2][R]],U=[v[3][R],v[4][R],v[5][R]];if(D.some((E,P)=>E!==C[P])||U.some((E,P)=>E!==x[P])){C=D,x=U;let E=R/f.sampleRate;N.gain.setValueAtTime(0,E),N=r(f,X(M({},b),{gain:0})),k=i(f,X(M({},I),{orientationX:C[0],orientationY:C[1],orientationZ:C[2],positionX:x[0],positionY:x[1],positionZ:x[2]})),N.gain.setValueAtTime(1,E),_.connect(N).connect(k.inputs[0]),k.connect(g)}}return g}return S?(yield n(f,m.orientationX,y.orientationX),yield n(f,m.orientationY,y.orientationY),yield n(f,m.orientationZ,y.orientationZ),yield n(f,m.positionX,y.positionX),yield n(f,m.positionY,y.positionY),yield n(f,m.positionZ,y.positionZ)):(yield a(f,m.orientationX,y.orientationX),yield a(f,m.orientationY,y.orientationY),yield a(f,m.orientationZ,y.orientationZ),yield a(f,m.positionX,y.positionX),yield a(f,m.positionY,y.positionY),yield a(f,m.positionZ,y.positionZ)),Ne(y)?yield c(m,f,y.inputs[0]):yield c(m,f,y),y});return{render(m,f){let g=l.get(f);return g!==void 0?Promise.resolve(g):p(m,f)}}};var Cy={disableNormalization:!1},Up=(n,t,e,r)=>class zp{constructor(o,s){let a=t(o),c=r(M(M({},Cy),s)),u=n(a,c);return e.add(u),u}static[Symbol.hasInstance](o){return o!==null&&typeof o=="object"&&Object.getPrototypeOf(o)===zp.prototype||e.has(o)}};var Yp=(n,t)=>(e,r,i)=>(n(r).replay(i),t(r,e,i));var Hp=(n,t,e)=>(r,i,o)=>K(null,null,function*(){let s=n(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>K(null,[h],function*([u,l]){let m=yield t(u).render(u,i),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&m.connect(o,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var Zp=(n,t,e)=>(r,i,o)=>K(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>K(null,[u],function*([a,c]){let h=yield n(a).render(a,i);e(a)||h.connect(o,c)})))});var Xp=(n,t,e,r)=>i=>n(Ve,()=>Ve(i))?Promise.resolve(n(r,r)).then(o=>{if(!o){let s=e(i,512,0,1);i.oncomplete=()=>{s.onaudioprocess=null,s.disconnect()},s.onaudioprocess=()=>i.currentTime,s.connect(i.destination)}return i.startRendering()}):new Promise(o=>{let s=t(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),o(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var Qp=n=>(t,e)=>{n.set(t,e)};var Kp=n=>(t,e)=>n.set(t,e);var Jp=(n,t,e,r,i,o,s,a)=>(c,u)=>e(c).render(c,u).then(()=>Promise.all(Array.from(r(u)).map(l=>e(l).render(l,u)))).then(()=>i(u)).then(l=>(typeof l.copyFromChannel!="function"?(s(l),Pi(l)):t(o,()=>o(l))||a(l),n.add(l),l));var _y={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},$p=(n,t,e,r,i,o)=>class extends n{constructor(a,c){let u=i(a),l=M(M({},_y),c),h=e(u,l),p=o(u),m=p?r():null;super(a,!1,h,m),this._pan=t(this,p,h.pan)}get pan(){return this._pan}};var td=(n,t,e,r,i)=>()=>{let o=new WeakMap,s=(a,c)=>K(null,null,function*(){let u=e(a),l=dt(u,c);if(!l){let h={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,pan:u.pan.value};u=t(c,h)}return o.set(c,u),l?yield n(c,a.pan,u.pan):yield r(c,a.pan,u.pan),Ne(u)?yield i(a,c,u.inputs[0]):yield i(a,c,u),u});return{render(a,c){let u=o.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var ed=n=>()=>{if(n===null)return!1;try{new n({length:1,sampleRate:44100})}catch(t){return!1}return!0};var rd=(n,t)=>()=>K(null,null,function*(){if(n===null)return!0;if(t===null)return!1;let e=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(e),o=!1,s=!1;try{yield r.audioWorklet.addModule(i);let a=new n(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>o=!0,a.onprocessorerror=()=>s=!0,c.connect(a),c.start(0),yield r.startRendering(),yield new Promise(u=>setTimeout(u))}catch(a){}finally{URL.revokeObjectURL(i)}return o&&!s});var id=(n,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{e.oncomplete=()=>{r.disconnect(),i(e.currentTime!==0)},e.startRendering()})};var Ec=()=>new DOMException("","UnknownError");var vy={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},nd=(n,t,e,r,i,o,s)=>class extends n{constructor(c,u){let l=i(c),h=M(M({},vy),u),p=e(l,h),f=o(l)?r():null;super(c,!0,p,f),this._isCurveNullified=!1,this._nativeWaveShaperNode=p,s(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(c){if(c===null)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(c.length<2)throw t();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=c}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(c){this._nativeWaveShaperNode.oversample=c}};var od=(n,t,e)=>()=>{let r=new WeakMap,i=(o,s)=>K(null,null,function*(){let a=t(o);if(!dt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=n(s,u)}return r.set(s,a),Ne(a)?yield e(o,s,a.inputs[0]):yield e(o,s,a),a});return{render(o,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(o,s)}}};var sd=()=>typeof window=="undefined"?null:window;var ad=(n,t)=>e=>{e.copyFromChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)r[h]=u[h+s]},e.copyToChannel=(r,i,o=0)=>{let s=n(o),a=n(i);if(a>=e.numberOfChannels)throw t();let c=e.length,u=e.getChannelData(a),l=r.length;for(let h=s<0?-s:0;h+s<c&&h<l;h+=1)u[h+s]=r[h]}};var cd=n=>t=>{t.copyFromChannel=(e=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,i,o=0)=>{let s=n(o),a=n(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var ud=n=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),n(t,"buffer",i=>()=>{let o=i.call(t);return o===r?null:o},i=>o=>i.call(t,o===null?r:o))};var ld=(n,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw n()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw n()}});let i=e.createBufferSource();t(r,()=>{let a=r.numberOfInputs;for(let c=0;c<a;c+=1)i.connect(r,0,c)},()=>i.disconnect(r))};var kc=(n,t,e)=>n.copyFromChannel===void 0?n.getChannelData(e)[0]:(n.copyFromChannel(t,e),t[0]);var jc=n=>{if(n===null)return!1;let t=n.length;return t%2!==0?n[Math.floor(t/2)]!==0:n[t/2-1]+n[t/2]!==0};var Zi=(n,t,e,r)=>{let i=n;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:o,set:s}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(n,t,{get:e(o),set:r(s)})};var hd=n=>X(M({},n),{outputChannelCount:n.outputChannelCount!==void 0?n.outputChannelCount:n.numberOfInputs===1&&n.numberOfOutputs===1?[n.channelCount]:Array.from({length:n.numberOfOutputs},()=>1)});var pd=n=>X(M({},n),{channelCount:n.numberOfOutputs});var dd=n=>{let{imag:t,real:e}=n;return t===void 0?e===void 0?X(M({},n),{imag:[0,0],real:[0,0]}):X(M({},n),{imag:Array.from(e,()=>0),real:e}):e===void 0?X(M({},n),{imag:t,real:Array.from(t,()=>0)}):X(M({},n),{imag:t,real:e})};var Pc=(n,t,e)=>{try{n.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;Pc(n,t,e+1e-7)}};var md=n=>{let t=n.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var fd=n=>{let t=n.createBufferSource(),e=n.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var gd=n=>{let t=n.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var gs=n=>{let t=n.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Lc=n=>{let t=n.createBuffer(1,1,44100),e=n.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var ys=n=>{let t=n.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var yd=n=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(n)}finally{t.close(),e.close()}};var xd=n=>{n.start=(t=>(e=0,r=0,i)=>{let o=n.buffer,s=o===null?r:Math.min(o.duration,r);o!==null&&s>o.duration-.5/n.context.sampleRate?t.call(n,e,0,0):t.call(n,e,s,i)})(n.start)};var Fc=(n,t)=>{let e=t.createGain();n.connect(e);let r=(i=>()=>{i.call(n,e),n.removeEventListener("ended",r)})(n.disconnect);n.addEventListener("ended",r),Oe(n,e),n.stop=(i=>{let o=!1;return(s=0)=>{if(o)try{i.call(n,s)}catch(a){e.gain.setValueAtTime(0,s)}else i.call(n,s),o=!0}})(n.stop)};var ci=(n,t)=>e=>{let r={value:n};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(n,e):t.handleEvent.call(n,e)};var Iy=cl(Ge),Sy=xl(Ge),wy=dh(Pr),Ad=new WeakMap,Ty=Oh(Ad),Re=Zl(new Map,new WeakMap),nr=sd(),Cd=np(Re,Te),Bc=Nh(Yt),Jt=Hp(Yt,Bc,br),Ny=_l(Cd,Ct,Jt),It=Dh(ki),Ar=Rp(nr),_t=Hh(Ar),_d=new WeakMap,vd=_h(ci),Xi=cp(nr),Gc=Wh(Xi),Vc=Uh(nr),Id=zh(nr),Qn=lp(nr),Lt=Bl(ul(ns),yl(Iy,Sy,Li,wy,Fi,Yt,Ty,rr,Ct,Ge,ae,br,Bi),Re,Fh(Yn,Fi,Yt,Ct,si,ae),Te,Wi,Kt,lh(Li,Yn,Yt,Ct,si,It,ae,_t),gh(_d,Yt,Gt),vd,It,Gc,Vc,Id,_t,Qn),Oy=Cl(Lt,Ny,Te,Cd,It,_t);var qc=new WeakSet,bd=op(nr),Sd=nh(new Uint32Array(1)),Wc=ad(Sd,Te),Uc=cd(Sd),zc=vl(qc,Re,Kt,bd,Ar,ed(bd),Wc,Uc);var xs=bl(ce),wd=Zp(Bc,Lr,br),or=$l(wd),Qi=ap(xs,Re,md,fd,gd,gs,Lc,ys,xd,ud(Zi),Fc),sr=Yp(Rh(Lr),wd),Ry=wl(or,Qi,Ct,sr,Jt),qe=Gl(ll(os),_d,zn,Vl,fc,gc,yc,xc,bc,Ri,Gn,Xi,Pc),My=Sl(Lt,Ry,qe,wt,Qi,It,_t,ci);var Dy=kl(Lt,jl,Te,wt,up(ce,Zi),It,_t,Jt),Ey=Hl(or,Mc,Ct,sr,Jt),ui=Kp(Ad),ky=Yl(Lt,qe,Ey,Wi,Mc,It,_t,ui),Gr=rp(Ge,Vc),jy=ld(wt,Gr),Vr=yp(Xi,jy),Py=Ql(Vr,Ct,Jt),Ly=Xl(Lt,Py,Vr,It,_t),Fy=Jl(Yi,Ct,Jt),By=Kl(Lt,Fy,Yi,It,_t,pd),Gy=Ap(xs,Qi,ce,Gr),Ki=bp(xs,Re,Gy,gs,ys),Vy=ih(or,Ki,Ct,sr,Jt),qy=rh(Lt,qe,Vy,Ki,It,_t,ci),Td=Cp(Kt,Zi),Wy=sh(Td,Ct,Jt),Uy=oh(Lt,Wy,Td,It,_t,ui),zy=ph(or,Dc,Ct,sr,Jt),Yy=hh(Lt,qe,zy,Dc,It,_t,ui),Nd=_p(Kt),Hy=bh(or,Nd,Ct,sr,Jt),Zy=xh(Lt,qe,Hy,Nd,Kt,It,_t,ui),Xy=wh(or,ce,Ct,sr,Jt),Qy=Sh(Lt,qe,Xy,ce,It,_t),Ky=Sp(Wi,wt,Hi,Kt),bs=Xp(Re,ce,Hi,id(ce,Ar)),Jy=Lh(Qi,Ct,Ar,Jt,bs),$y=vp(Ky),tx=Ph(Lt,$y,Jy,It,_t,ui),ex=Pl(qe,Vr,Ki,Hi,Kt,kc,_t,Zi),Od=new WeakMap,Yc=tp(Dy,ex,vd,_t,Od,ci),Rd=Mp(xs,Re,gs,Lc,ys,Fc),rx=Vp(or,Rd,Ct,sr,Jt),ix=Gp(Lt,qe,Rd,rx,It,_t,ci),Md=eh(Qi),nx=Fp(Md,wt,ce,jc,Gr),As=Lp(Md,wt,nx,jc,Gr,Xi,Zi),ox=Ep(Li,wt,Vr,ce,Hi,As,Kt,Fi,kc,Gr),Dd=Dp(ox),sx=Wp(or,Vr,Ki,ce,Dd,Ct,Ar,sr,Jt,bs),ax=qp(Lt,qe,Dd,sx,It,_t,ui),cx=kp(Te),ux=Up(cx,It,new WeakSet,dd),lx=Pp(Vr,Yi,ce,As,Kt,Gr),Ed=jp(lx,Kt),hx=td(or,Ed,Ct,sr,Jt),px=$p(Lt,qe,Ed,hx,It,_t),dx=od(As,Ct,Jt),mx=nd(Lt,wt,As,dx,It,_t,ui),kd=Zh(nr),Hc=vh(nr),jd=new WeakMap,fx=Eh(jd,Ar),gx=kd?gl(Re,Kt,Ch(nr),Hc,Ih(al),It,fx,_t,Qn,new WeakMap,new WeakMap,rd(Qn,Ar),nr):void 0,yx=Yh(Gc,_t),xx=uh(qc,Re,ch,Ah,new WeakSet,It,yx,ji,Ve,Wc,Uc),Pd=zl(gx,Oy,zc,My,ky,Ly,By,qy,Uy,xx,Yy,Zy,Qy,tx,Yc,ix,ax,ux,px,mx),bx=Xh(Lt,wp,It,_t),Ax=Qh(Lt,Tp,It,_t),Cx=Kh(Lt,Np,It,_t),_x=Op(wt,_t),vx=Jh(Lt,_x,It),Ld=El(Pd,wt,Kt,Ec,bx,Ax,Cx,vx,Xi);var Zc=kh(Od),Ix=Al(Zc),Fd=th(Te),Sx=mh(Zc),Bd=yh(Te),Gd=new WeakMap,wx=Th(Gd,Gt),Tx=gp(Fd,Te,wt,Vr,Yi,Ki,ce,Hi,Kt,Bd,Hc,wx,Gr),Nx=pp(wt,Tx,ce,Kt,Gr),Ox=Ul(or,Fd,Qi,Vr,Yi,Ki,ce,Sx,Bd,Hc,Ct,Qn,Ar,sr,Jt,bs),Rx=Mh(jd),Mx=Qp(Gd),Xc=kd?ql(Ix,Lt,qe,Ox,Nx,Yt,Rx,It,_t,Qn,hd,Mx,yd,ci):void 0;var Pq=$h(wt,Kt,Ec,Yc,Xi);var Vd=ah(Kt,Ar),qd=Jp(qc,Re,Bc,Zc,bs,ji,Wc,Uc),Lq=ep(Re,wt,Vd,Yc,qd);var Wd=Bp(Pd,Re,wt,Vd,qd);var Ud=Bh(ki,Gc),zd=Gh(Ei,Vc),Yd=Vh(zn,Id),Hd=qh(ki,_t);function Ft(n){return n===void 0}function tt(n){return n!==void 0}function Zd(n){return typeof n=="function"}function $t(n){return typeof n=="number"}function We(n){return Object.prototype.toString.call(n)==="[object Object]"&&n.constructor===Object}function Qc(n){return typeof n=="boolean"}function Ot(n){return Array.isArray(n)}function re(n){return typeof n=="string"}function Kn(n){return re(n)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(n)}function z(n,t){if(!n)throw new Error(t)}function Et(n,t,e=1/0){if(!(t<=n&&n<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${n}`)}function Cs(n){!n.isOffline&&n.state!=="running"&&li('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Qd=!1,Xd=!1;function Kc(n){Qd=n}function Kd(n){Ft(n)&&Qd&&!Xd&&(Xd=!0,li("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var Jd=console;function $d(...n){Jd.log(...n)}function li(...n){Jd.warn(...n)}function tm(n){return new Ld(n)}function em(n,t,e){return new Wd(n,t,e)}var ie=typeof self=="object"?self:null,rm=ie&&(ie.hasOwnProperty("AudioContext")||ie.hasOwnProperty("webkitAudioContext"));function im(n,t,e){return z(tt(Xc),"AudioWorkletNode only works in a secure context (https or localhost)"),new(n instanceof(ie==null?void 0:ie.BaseAudioContext)?ie==null?void 0:ie.AudioWorkletNode:Xc)(n,t,e)}function ne(n,t,e,r){var i=arguments.length,o=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,t,e,r);else for(var a=n.length-1;a>=0;a--)(s=n[a])&&(o=(i<3?s(o):i>3?s(t,e,o):s(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o}function ht(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(h){s(h)}}function c(l){try{u(r.throw(l))}catch(h){s(h)}}function u(l){l.done?o(l.value):i(l.value).then(a,c)}u((r=r.apply(n,t||[])).next())})}var _s=class{constructor(t,e,r,i){this._callback=t,this._type=e,this._minimumUpdateInterval=Math.max(128/(i||44100),.001),this.updateInterval=r,this._createClock()}_createWorker(){let t=new Blob([`
|
|
5
5
|
// the initial timeout time
|
|
6
6
|
let timeoutTime = ${(this._updateInterval*1e3).toFixed(1)};
|
|
7
7
|
// onmessage callback
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
// call tick initially
|
|
18
18
|
tick();
|
|
19
|
-
`],{type:"text/javascript"}),e=URL.createObjectURL(t),r=new Worker(e);r.onmessage=this._callback.bind(this),this._worker=r}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch(t){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(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}};function ze(n){return zd(n)}function ar(n){return Ud(n)}function Ji(n){return Yd(n)}function qr(n){return Wd(n)}function im(n){return n instanceof Uc}function Dx(n,t){return n==="value"||ze(t)||ar(t)||im(t)}function De(n,...t){if(!t.length)return n;let e=t.shift();if(Ue(n)&&Ue(e))for(let r in e)Dx(r,e[r])?n[r]=e[r]:Ue(e[r])?(n[r]||Object.assign(n,{[r]:{}}),De(n[r],e[r])):Object.assign(n,{[r]:e[r]});return De(n,...t)}function nm(n,t){return n.length===t.length&&n.every((e,r)=>t[r]===e)}function T(n,t,e=[],r){let i={},o=Array.from(t);if(Ue(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(n,a))||(De(i,{[r]:o[0]}),e.splice(e.indexOf(r),1),o.shift())),o.length===1&&Ue(o[0]))De(i,o[0]);else for(let s=0;s<e.length;s++)$(o[s])&&(i[e[s]]=o[s]);return De(n,i)}function om(n){return n.constructor.getDefaults()}function Ce(n,t){return Ft(n)?t:n}function Ye(n,t){return t.forEach(e=>{Reflect.has(n,e)&&delete n[e]}),n}var Ht=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ie&&this.toString()===ie.TONE_DEBUG_CLASS)&&Jd(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Ht.version=Ln;function Cr(n,t){return n>t+1e-6}function Xn(n,t){return Cr(n,t)||ue(n,t)}function pi(n,t){return n+1e-6<t}function ue(n,t){return Math.abs(n-t)<1e-6}function Kc(n,t,e){return Math.max(Math.min(n,e),t)}var Vt=class n extends Ht{constructor(){super(),this.name="Timeline",this._timeline=[];let t=T(n.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(z(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){let e=this._timeline[this.length-1];z(Xn(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{let e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){let e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){let r=this._search(t,e);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){let r=this._search(t,e);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(t){let e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];let r=this._search(t);return r-1>=0?this._timeline[r-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(ue(this._timeline[e].time,t)){for(let r=e;r>=0&&ue(this._timeline[r].time,t);r--)e=r;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&Xn(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){let e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){let e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let r=0,i=this._timeline.length,o=i;if(i>0&&this._timeline[i-1][e]<=t)return i-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ue(a[e],t)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ue(l[e],t))s=u;else break}return s}else{if(pi(a[e],t)&&Cr(c[e],t))return s;Cr(a[e],t)?o=s:r=s+1}}return-1}_iterate(t,e=0,r=this._timeline.length-1){this._timeline.slice(e,r+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){let r=this._search(t);return r!==-1&&this._iterate(e,0,r),this}forEachAfter(t,e){let r=this._search(t);return this._iterate(e,r+1),this}forEachBetween(t,e,r){let i=this._search(t),o=this._search(e);return i!==-1&&o!==-1?(this._timeline[i].time!==t&&(i+=1),this._timeline[o].time===e&&(o-=1),this._iterate(r,i,o)):i===-1&&this._iterate(r,0,o),this}forEachFrom(t,e){let r=this._search(t);for(;r>=0&&this._timeline[r].time>=t;)r--;return this._iterate(e,r+1),this}forEachAtTime(t,e){let r=this._search(t);if(r!==-1&&ue(this._timeline[r].time,t)){let i=r;for(let o=r;o>=0&&ue(this._timeline[o].time,t);o--)i=o;this._iterate(o=>{e(o)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var sm=[];function Wr(n){sm.push(n)}function am(n){sm.forEach(t=>t(n))}var cm=[];function Ur(n){cm.push(n)}function um(n){cm.forEach(t=>t(n))}var zr=class n extends Ht{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(i=>{Ft(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(e)}),this}once(t,e){let r=(...i)=>{e(...i),this.off(t,r)};return this.on(t,r),this}off(t,e){return t.split(/\W+/).forEach(i=>{if(Ft(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Ft(e))this._events[i]=[];else{let o=this._events[i];for(let s=o.length-1;s>=0;s--)o[s]===e&&o.splice(s,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){let r=this._events[t].slice(0);for(let i=0,o=r.length;i<o;i++)r[i].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(n.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var $i=class extends zr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var di=class n extends $i{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Vt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=T(n.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=$d({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new As(this.emit.bind(this,"tick"),r.clockSource,r.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(am(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,r){return this._context.createBuffer(t,e,r)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,r){return this._context.createPeriodicWave(t,e,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return z(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return z(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return z(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){z(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){z(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){z(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){z(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return rm(this.rawContext,t,e)}addAudioWorkletModule(t){return ht(this,void 0,void 0,function*(){z($(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return ht(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return qr(this._context)?this._context.resume():Promise.resolve()}close(){return ht(this,void 0,void 0,function*(){qr(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&um(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{let e=this._context.createBuffer(1,128,this._context.sampleRate),r=e.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=t;let i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=e,i.loop=!0,i.start(0),this._constants.set(t,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){let t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:r+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){let r=++this._timeoutIds,i=()=>{let o=this.now();this._timeouts.add({callback:()=>{t(),i()},id:r,time:o+e})};return i(),r}};var Cs=class extends $i{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,r){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return ht(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};function q(n,t){Ot(t)?t.forEach(e=>q(n,e)):Object.defineProperty(n,t,{enumerable:!0,writable:!1})}function mi(n,t){Ot(t)?t.forEach(e=>mi(n,e)):Object.defineProperty(n,t,{writable:!0})}var et=()=>{};var kt=class n extends Ht{constructor(){super(),this.name="ToneAudioBuffer",this.onload=et;let t=T(n.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,re(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:et,onload:et,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Bt().sampleRate}set(t){return t instanceof n?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 ht(this,void 0,void 0,function*(){let e=n.load(t).then(r=>{this.set(r),this.onload(this)});n.downloads.push(e);try{yield e}finally{let r=n.downloads.indexOf(e);n.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Ot(t)&&t[0].length>0,r=e?t.length:1,i=e?t[0].length:t.length,o=Bt(),s=o.createBuffer(r,i,o.sampleRate),a=!e&&r===1?[t]:t;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(t){if($t(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let i=0;i<r;i++){let o=this.toArray(i);for(let s=0;s<o.length;s++)e[s]+=o[s]}e=e.map(i=>i/r),this.fromArray(e)}return this}toArray(t){if($t(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let r=0;r<this.numberOfChannels;r++)e[r]=this.getChannelData(r);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){z(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),i=Math.floor(e*this.sampleRate);z(r<i,"The start time must be less than the end time");let o=i-r,s=Bt().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,i),a);return new n(s)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new n().fromArray(t)}static fromUrl(t){return ht(this,void 0,void 0,function*(){return yield new n().load(t)})}static load(t){return ht(this,void 0,void 0,function*(){let e=n.baseUrl===""||n.baseUrl.endsWith("/")?n.baseUrl:n.baseUrl+"/",r=yield fetch(e+t);if(!r.ok)throw new Error(`could not load url: ${t}`);let i=yield r.arrayBuffer();return yield Bt().decodeAudioData(i)})}static supportsType(t){let e=t.split("."),r=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return ht(this,void 0,void 0,function*(){for(yield Promise.resolve();n.downloads.length;)yield n.downloads[0]})}};kt.baseUrl="";kt.downloads=[];var He=class extends di{constructor(){super({clockSource:"offline",context:Ji(arguments[0])?arguments[0]:tm(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Ji(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Ji(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return ht(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;let r=Math.floor(this.sampleRate/128);t&&e%r===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return ht(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);let e=yield this._context.startRendering();return new kt(e)})}close(){return Promise.resolve()}};var lm=new Cs,tn=lm;function Bt(){return tn===lm&&em&&Jc(new di),tn}function Jc(n,t=!1){t&&tn.dispose(),qr(n)?tn=new di(n):Ji(n)?tn=new He(n):tn=n}if(ie&&!ie.TONE_SILENCE_LOGGING){let n="v";Ln==="dev"&&(n="");let t=` * Tone.js ${n}${Ln} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function en(n){return Math.pow(10,n/20)}function rn(n){return 20*(Math.log(n)/Math.LN10)}function fi(n){return Math.pow(2,n/12)}var _s=440;function hm(){return _s}function pm(n){_s=n}function Ze(n){return Math.round($c(n))}function $c(n){return 69+12*Math.log2(n/_s)}function Qn(n){return _s*Math.pow(2,(n-69)/12)}var vs=class n extends Ht{constructor(t,e,r){super(),this.defaultUnits="s",this._val=e,this._units=r,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{let r=parseInt(t,10),i=e==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/r)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{let e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,r)=>{let i=0;return t&&t!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(i+=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(i+=this._beatsToUnits(parseFloat(r)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof n&&this.fromType(this._val),Ft(this._val))return this._noArg();if(re(this._val)&&Ft(this._units)){for(let t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(Ue(this._val)){let t=0;for(let e in this._val)if($(this._val[e])){let r=this._val[e],i=new this.constructor(this.context,e).valueOf()*r;t+=i}return t}if($(this._units)){let t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return re(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var _e=class n extends vs{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let e=new n(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){let r=new this.constructor(this.context,t).valueOf(),i=this.valueOf(),a=Math.round(i/r)*r-i;return i+a*e}toNotation(){let t=this.toSeconds(),e=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],i=new n(this.context,e[0]).toSeconds();return e.forEach(o=>{let s=new n(this.context,o).toSeconds();Math.abs(s-t)<Math.abs(i-t)&&(r=o,i=s)}),r}toBarsBeatsSixteenths(){let t=this._beatsToUnits(1),e=this.valueOf()/t;e=parseFloat(e.toFixed(4));let r=Math.floor(e/this._getTimeSignature()),i=e%1*4;e=Math.floor(e)%this._getTimeSignature();let o=i.toString();return o.length>3&&(i=parseFloat(parseFloat(o).toFixed(3))),[r,e,i].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Ze(this.toFrequency())}_now(){return this.context.now()}};var le=class n extends _e{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return hm()}static set A4(t){pm(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:n.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let i=Ex[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?i:n.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,r){let i=1;return t&&t!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(i*=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(i*=this._beatsToUnits(parseFloat(r)/4)),i}}})}transpose(t){return new n(this.context,this.valueOf()*fi(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return Ze(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/n.A4),r=Math.round(12*e)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),kx[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return Qn(t)}static ftom(t){return Ze(t)}},Ex={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},kx=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var Ee=class extends _e{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var qt=class n extends Ht{constructor(){super();let t=T(n.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Bt()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return Qd(t),new _e(this.context,t).toSeconds()}toFrequency(t){return new le(this.context,t).toFrequency()}toTicks(t){return new Ee(this.context,t).toTicks()}_getPartialProperties(t){let e=this.get();return Object.keys(e).forEach(r=>{Ft(t[r])&&delete e[r]}),e}get(){let t=om(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){let r=this[e];$(r)&&$(r.value)&&$(r.setValueAtTime)?t[e]=r.value:r instanceof n?t[e]=r._getPartialProperties(t[e]):Ot(r)||$t(r)||re(r)||Xc(r)?t[e]=r:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&$(this[e])&&(this[e]&&$(this[e].value)&&$(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof n?this[e].set(t[e]):this[e]=t[e])}),this}};var cr=class extends Vt{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){let e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,r){return Et(e,0),this.add(Object.assign({},r,{state:t,time:e})),this}getLastState(t,e){let r=this._search(e);for(let i=r;i>=0;i--){let o=this._timeline[i];if(o.state===t)return o}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let o=this._timeline[i];if(o.state===t)return o}}};var ot=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,z($(t.param)&&(ze(t.param)||t.param instanceof n),"param must be an AudioParam");!ze(t.param);)t.param=t.param._param;this._swappable=$(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 Vt(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,$(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(qt.getDefaults(),{convert:!0,units:"number"})}get value(){let t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return $(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 $(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return $(this.maxValue)&&$(this.minValue)&&Et(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?en(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?rn(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),i=this._fromType(t);return z(isFinite(i)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",t,r),this._events.add({time:r,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,r),this}getValueAtTime(t){let e=Math.max(this.toSeconds(t),0),r=this._events.getAfter(e),i=this._events.get(e),o=this._initialValue;if(i===null)o=this._initialValue;else if(i.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(i.time),a;s===null?a=this._initialValue:a=s.value,i.type==="setTargetAtTime"&&(o=this._exponentialApproach(i.time,a,i.value,i.constant,e))}else if(r===null)o=i.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=i.value;if(i.type==="setTargetAtTime"){let a=this._events.getBefore(i.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(i.time,s,r.time,r.value,e):o=this._exponentialInterpolate(i.time,s,r.time,r.value,e)}else o=i.value;return this._toType(o)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){let r=this._fromType(t),i=this.toSeconds(e);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this._events.add({time:i,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",t,i),this._param.linearRampToValueAtTime(r,i),this}exponentialRampToValueAtTime(t,e){let r=this._fromType(t);r=ue(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(e);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",t,i),this._param.exponentialRampToValueAtTime(r,i),this}exponentialRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(t,r+this.toSeconds(e)),this}linearRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(t,r+this.toSeconds(e)),this}targetRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(t,r,e),this}exponentialApproachValueAtTime(t,e,r){e=this.toSeconds(e),r=this.toSeconds(r);let i=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(t,e,i),this.cancelAndHoldAtTime(e+r*.9),this.linearRampToValueAtTime(t,e+r),this}setTargetAtTime(t,e,r){let i=this._fromType(t);z(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(e);return this._assertRange(i),z(isFinite(i)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",t,o,r),this._param.setTargetAtTime(i,o,r),this}setValueCurveAtTime(t,e,r,i=1){r=this.toSeconds(r),e=this.toSeconds(e);let o=this._fromType(t[0])*i;this.setValueAtTime(this._toType(o),e);let s=r/(t.length-1);for(let a=1;a<t.length;a++){let c=this._fromType(t[a])*i;this.linearRampToValueAtTime(this._toType(c),e+a*s)}return this}cancelScheduledValues(t){let e=this.toSeconds(t);return z(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){let e=this.toSeconds(t),r=this._fromType(this.getValueAtTime(e));z(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let i=this._events.get(e),o=this._events.getAfter(e);return i&&ue(i.time,e)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),e)),this._events.add({time:e,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,e),this}rampTo(t,e=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,r):this.linearRampTo(t,e,r),this}apply(t){let e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);let r=this._events.get(e);if(r&&r.type==="setTargetAtTime"){let i=this._events.getAfter(r.time),o=i?i.time:e+2,s=(o-e)/10;for(let a=e;a<o;a+=s)t.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?t.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?t.setTargetAtTime(i.value,i.time,i.constant):t[i.type](i.value,i.time)}),this}setParam(t){z(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,r,i,o){return r+(e-r)*Math.exp(-(o-t)/i)}_linearInterpolate(t,e,r,i,o){return e+(i-e)*((o-t)/(r-t))}_exponentialInterpolate(t,e,r,i,o){return e*Math.pow(i/e,(o-t)/(r-t))}};var L=class n extends qt{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return $(this.input)?ze(this.input)||this.input instanceof ot?1:this.input.numberOfInputs:0}get numberOfOutputs(){return $(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return $(t)&&(t instanceof n||ar(t))}_getInternalNodes(){let t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(r=>{r.channelCount=t.channelCount,r.channelCountMode=t.channelCountMode,r.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){let t=this._getInternalNodes();z(t.length>0,"ToneAudioNode does not have any internal nodes");let e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,r=0){return te(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return hi("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return dm(this,t,e,r),this}chain(...t){return ke(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),$(this.input)&&(this.input instanceof n?this.input.dispose():ar(this.input)&&this.input.disconnect()),$(this.output)&&(this.output instanceof n?this.output.dispose():ar(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function ke(...n){let t=n.shift();n.reduce((e,r)=>(e instanceof L?e.connect(r):ar(e)&&te(e,r),r),t)}function te(n,t,e=0,r=0){for(z($(n),"Cannot connect from undefined node"),z($(t),"Cannot connect to undefined node"),(t instanceof L||ar(t))&&z(t.numberOfInputs>0,"Cannot connect to node with no inputs"),z(n.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof L||t instanceof ot;)$(t.input)&&(t=t.input);for(;n instanceof L;)$(n.output)&&(n=n.output);ze(t)?n.connect(t,e):n.connect(t,e,r)}function dm(n,t,e=0,r=0){if($(t))for(;t instanceof L;)t=t.input;for(;!ar(n);)$(n.output)&&(n=n.output);ze(t)?n.disconnect(t,e):ar(t)?n.disconnect(t,e,r):n.disconnect()}var H=class n extends L{constructor(){let t=T(n.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 ot({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),q(this,"gain")}static getDefaults(){return Object.assign(L.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}};var Xe=class extends L{constructor(t){super(t),this.onended=et,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new H({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let r=this.toSeconds(e);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(L.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:et})}_startGain(t,e=1){z(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=t+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+r):this._gainNode.gain.exponentialApproachValueAtTime(e,t,r)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){z(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==et&&(this.onended(this),this.onended=et,!this.context.isOffline)){let t=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(t):setTimeout(t,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=et,this}};var Kn=class n extends Xe{constructor(){let t=T(n.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),te(this._source,this._gainNode),this.offset=new ot({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(Xe.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var J=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new Kn({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(L.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,r=0){return nn(this,t,e,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,r){return this._param.exponentialRampTo(t,e,r),this}linearRampTo(t,e,r){return this._param.linearRampTo(t,e,r),this}targetRampTo(t,e,r){return this._param.targetRampTo(t,e,r),this}exponentialApproachValueAtTime(t,e,r){return this._param.exponentialApproachValueAtTime(t,e,r),this}setTargetAtTime(t,e,r){return this._param.setTargetAtTime(t,e,r),this}setValueCurveAtTime(t,e,r,i){return this._param.setValueCurveAtTime(t,e,r,i),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,r){return this._param.rampTo(t,e,r),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}};function nn(n,t,e,r){(t instanceof ot||ze(t)||t instanceof J&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof J&&(t.overridden=!0)),te(n,t,e,r)}var Is=class n extends ot{constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Vt(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(ot.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let i=this._fromType(t),o=this._events.get(e),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+e,u=this._exponentialApproach(o.time,o.value,i,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){let r=this.toSeconds(e);super.setValueAtTime(t,e);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}linearRampToValueAtTime(t,e){let r=this.toSeconds(e);super.linearRampToValueAtTime(t,e);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);let r=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max((e-i.time)*10,1)),s=(e-i.time)/o;for(let a=0;a<=o;a++){let c=s*a+i.time,u=this._exponentialInterpolate(i.time,i.value,e,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Ft(t.ticks)){let s=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(s,t.time)}let r=this._fromType(this.getValueAtTime(t.time)),i=this._fromType(this.getValueAtTime(e)),o=this._events.get(e);return o&&o.time===e&&o.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(r+i)+t.ticks}getTicksAtTime(t){let e=this.toSeconds(t),r=this._events.get(e);return Math.max(this._getTicksUntilEvent(r,e),0)}getDurationOfTicks(t,e){let r=this.toSeconds(e),i=this.getTicksAtTime(e);return this.getTimeOfTick(i+t)-r}getTimeOfTick(t){let e=this._events.get(t,"ticks"),r=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&r&&r.type==="linearRampToValueAtTime"&&e.value!==r.value){let i=this._fromType(this.getValueAtTime(e.time)),s=(this._fromType(this.getValueAtTime(r.time))-i)/(r.time-e.time),a=Math.sqrt(Math.pow(i,2)-2*s*(e.ticks-t)),c=(-i+a)/s,u=(-i-a)/s;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){let r=this.toSeconds(e),i=this.toSeconds(t),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-o}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){let e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}};var Ss=class n extends J{constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new Is({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(J.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}};var ws=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new cr,this._tickOffset=new Vt,this._ticksAtTime=new Vt,this._secondsAtTime=new Vt,this.frequency=new Ss({context:this.context,units:t.units,value:t.frequency}),q(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},qt.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){let r=this.toSeconds(t);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),$(e)&&this.setTicksAtTime(e,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(t){let e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){let r=this._state.get(e);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){let e=this.toSeconds(t),r=this._state.getLastState("stopped",e),i=this._ticksAtTime.get(e),o={state:"paused",time:e};this._state.add(o);let s=i||r,a=i?i.ticks:0,c=null;return this._state.forEachBetween(s.time,e+this.sampleTime,u=>{let l=s.time,h=this._tickOffset.get(u.time);h&&h.time>=s.time&&(a=h.ticks,l=h.time),s.state==="started"&&u.state!=="started"&&(a+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(l),u.time!==o.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(o),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){let e=this.now(),r=this.frequency.timeToTicks(t,e);this.setTicksAtTime(r,e)}getSecondsAtTime(t){t=this.toSeconds(t);let e=this._state.getLastState("stopped",t),r={state:"paused",time:t};this._state.add(r);let i=this._secondsAtTime.get(t),o=i||e,s=i?i.seconds:0,a=null;return this._state.forEachBetween(o.time,t+this.sampleTime,c=>{let u=o.time,l=this._tickOffset.get(c.time);l&&l.time>=o.time&&(s=l.seconds,u=l.time),o.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),o=c}),this._state.remove(r),a&&this._secondsAtTime.add(a),s}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){let r=this._tickOffset.get(e),i=this._state.get(e),o=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(o)+t-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,r){let i=this._state.get(t);this._state.forEachBetween(t,e,s=>{i&&i.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(i.time,t),s.time-this.sampleTime,r),i=s});let o=null;if(i&&i.state==="started"){let s=Math.max(i.time,t),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(i.time),u=a-c,l=Math.ceil(u)-u;l=ue(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<e;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(p){o=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(o)throw o;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var on=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=et,this._lastUpdate=0,this._state=new cr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new ws({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,q(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(qt.getDefaults(),{callback:et,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){bs(this.context);let r=this.toSeconds(t);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,e),r<this._lastUpdate&&this.emit("start",r,e)),this}stop(t){let e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){let r=this.toSeconds(e),i=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(i+t,r)}_loop(){let t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,r=>{switch(r.state){case"started":let i=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,i);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(t,e,(r,i)=>{this.callback(r,i)}))}getStateAtTime(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};zr.mixin(on);var je=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new H({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,q(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var tu=class n extends L{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="Destination",this.input=new je({context:this.context}),this.output=new H({context:this.context}),this.volume=this.input.volume,ke(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(L.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),ke(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Wr(n=>{n.destination=new tu({context:n})});Ur(n=>{n.destination.dispose()});var eu=class extends L{constructor(){super(...arguments),this.name="Listener",this.positionX=new ot({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ot({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ot({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ot({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ot({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ot({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ot({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ot({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ot({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(L.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}};Wr(n=>{n.listener=new eu({context:n})});Ur(n=>{n.listener.dispose()});var sn=class n extends Ht{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=T(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let r=t.urls[e];this.add(e,r,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:et,onload:et,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return z(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,r=et,i=et){return re(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new kt(this.baseUrl+e,r,i))):this._buffers.set(t.toString(),new kt(e,r,i)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var Jn=class n extends le{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return Ze(super._frequencyToUnits(t))}_ticksToUnits(t){return Ze(super._ticksToUnits(t))}_beatsToUnits(t){return Ze(super._beatsToUnits(t))}_secondsToUnits(t){return Ze(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return Qn(this.toMidi())}transpose(t){return new n(this.context,this.toMidi()+t)}};var ve=class extends Ee{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var ru=class extends qt{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Vt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){let t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};Wr(n=>{n.draw=new ru({context:n})});Ur(n=>{n.draw.dispose()});var Ts=class extends Ht{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){z($(t.time),"Events must have a time property"),z($(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new iu(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){let e=[];this._root.search(t.time,e);for(let r of e)if(r.event===t){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{let e=t.getBalance(),r,i=null;if(e>0)if(t.left.right===null)r=t.left,r.right=t.right,i=r;else{for(r=t.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,i=r.parent,r.left=t.left,r.right=t.right)}else if(t.right.left===null)r=t.right,r.left=t.left,i=r;else{for(r=t.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,i=r.parent,r.left=t.left,r.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=r:t.parent.right=r:this._setRoot(r),i&&this._rebalance(i)}t.dispose()}_rotateLeft(t){let e=t.parent,r=t.isLeftChild(),i=t.right;i&&(t.right=i.left,i.left=t),e!==null?r?e.left=i:e.right=i:this._setRoot(i)}_rotateRight(t){let e=t.parent,r=t.isLeftChild(),i=t.left;i&&(t.left=i.right,i.right=t),e!==null?r?e.left=i:e.right=i:this._setRoot(i)}_rebalance(t){let e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){let e=[];if(this._root.search(t,e),e.length>0){let r=e[0];for(let i=1;i<e.length;i++)e[i].low>r.low&&(r=e[i]);return r.event}}return null}forEach(t){if(this._root!==null){let e=[];this._root.traverse(r=>e.push(r)),e.forEach(r=>{r.event&&t(r.event)})}return this}forEachAtTime(t,e){if(this._root!==null){let r=[];this._root.search(t,r),r.forEach(i=>{i.event&&e(i.event)})}return this}forEachFrom(t,e){if(this._root!==null){let r=[];this._root.searchAfter(t,r),r.forEach(i=>{i.event&&e(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}},iu=class{constructor(t,e,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}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 t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var Ns=class extends Ht{constructor(t){super(),this.name="TimelineValue",this._timeline=new Vt({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){let e=this._timeline.get(t);return e?e.value:this._initialValue}};var oe=class n extends L{constructor(){super(T(n.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return nn(this,t,e,r),this}};var de=class n extends oe{constructor(){let t=T(n.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Ot(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Hd(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(J.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let i=0,o=e;i<o;i++){let s=i/(o-1)*2-1;r[i]=t(s,i)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){let e=["none","2x","4x"].some(r=>r.includes(t));z(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var an=class n extends oe{constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new de({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(oe.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var _r=class n{constructor(t,e){this.id=n._eventId++,this._remainderTime=0;let r=Object.assign(n.getDefaults(),e);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:et,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){let e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};_r._eventId=0;var Os=class n extends _r{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(n.getDefaults(),e);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({},_r.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return pi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new ve(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){pi(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 ve(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let e=this.transport.getTicksAtTime(t);Cr(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}};var Rs=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Ns(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Vt,this._repeatedEvents=new Ts,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new on({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),q(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(qt.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){let r=e%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(r*Math.PI)*this._swingAmount;t+=new ve(this.context,this._swingTicks*2/3).toSeconds()*i}Qc(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),Qc(!1)}schedule(t,e){let r=new _r(this,{callback:t,time:new Ee(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,i=1/0){let o=new Os(this,{callback:t,duration:new _e(this.context,i).toTicks(),interval:new _e(this.context,e).toTicks(),time:new Ee(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(t,e){let r=new _r(this,{callback:t,once:!0,time:new Ee(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){let e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){let e=this.toTicks(t);return this._timeline.forEachFrom(e,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(e,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new ve(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let r;return $(e)&&(r=this.toTicks(e)),this._clock.start(t,r),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Ot(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new _e(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new _e(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new ve(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){let t=this.now(),e=this._clock.getTicksAtTime(t);return new ve(this.context,e).toBarsBeatsSixteenths()}set position(t){let e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){let e=this.now(),r=this._clock.frequency.timeToTicks(t,e);this.ticks=r}get progress(){if(this.loop){let t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){let e=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(e),i=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,e),o=e+i;this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{let e=this.now(),r=this.getTicksAtTime(e),i=t-r%t;return this._clock.nextTickTime(i,e)}}syncSignal(t,e){let r=this.now(),i=this.bpm,o=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/o,u=new H(c),l=new an(-1),h=new H(c);i.chain(u,l,h),i=h,o=1/o,s=[u,l,h]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/o:e=0);let a=new H(e);return i.connect(a),a.connect(t._param),s.push(a),this._syncedSignals.push({initial:t.value,nodes:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){let r=this._syncedSignals[e];r.signal===t&&(r.nodes.forEach(i=>i.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),mi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};zr.mixin(Rs);Wr(n=>{n.transport=new Rs({context:n})});Ur(n=>{n.transport.dispose()});var mt=class extends L{constructor(t){super(t),this.input=void 0,this._state=new cr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=et,this._syncedStop=et,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new je({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,q(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,onstop:et,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(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,r){let i=Ft(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")z(Cr(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,e,r);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){let o=this._state.get(i);o&&(o.offset=this.toSeconds(Ce(e,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,e,r)},i);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else bs(this.context),this._start(i,e,r);return this}stop(t){let e=Ft(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||$(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{let r=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(r)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,r){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(Cr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let i=e-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-i),this._start(t,this.toSeconds(r.offset)+i,o)}}},this._syncedStop=t=>{let e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=et,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var ur=class n extends Xe{constructor(){let t=T(n.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,te(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ot({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 kt(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Xe.getDefaults(),{url:new kt,loop:!1,loopEnd:0,loopStart:0,onload:et,onerror:et,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,r,i=1){z(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(t);this._startGain(o,i),this.loop?e=Ce(e,this.loopStart):e=Ce(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;Xn(s,a)&&(s=(s-c)%u+c),ue(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,pi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),$(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var gi=class n extends mt{constructor(){let t=T(n.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(mt.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(z(t in mm,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,this.state==="started")){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){let e=mm[this._type];this._source=new ur({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},cn=44100*5,nu=2,vr={brown:null,pink:null,white:null},mm={get brown(){if(!vr.brown){let n=[];for(let t=0;t<nu;t++){let e=new Float32Array(cn);n[t]=e;let r=0;for(let i=0;i<cn;i++){let o=Math.random()*2-1;e[i]=(r+.02*o)/1.02,r=e[i],e[i]*=3.5}}vr.brown=new kt().fromArray(n)}return vr.brown},get pink(){if(!vr.pink){let n=[];for(let t=0;t<nu;t++){let e=new Float32Array(cn);n[t]=e;let r,i,o,s,a,c,u;r=i=o=s=a=c=u=0;for(let l=0;l<cn;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,i=.99332*i+h*.0750759,o=.969*o+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,e[l]=r+i+o+s+a+c+u+h*.5362,e[l]*=.11,u=h*.115926}}vr.pink=new kt().fromArray(n)}return vr.pink},get white(){if(!vr.white){let n=[];for(let t=0;t<nu;t++){let e=new Float32Array(cn);n[t]=e;for(let r=0;r<cn;r++)e[r]=Math.random()*2-1}vr.white=new kt().fromArray(n)}return vr.white}};function me(n,t){return ht(this,void 0,void 0,function*(){let e=t/n.context.sampleRate,r=new He(1,e,n.context.sampleRate);return new n.constructor(Object.assign(n.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var $n=class n extends Xe{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],te(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new ot({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new ot({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),q(this,["frequency","detune"])}static getDefaults(){return Object.assign(Xe.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Rt=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new J({context:this.context,units:"frequency",value:t.frequency}),q(this,"frequency"),this.detune=new J({context:this.context,units:"cents",value:t.detune}),q(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(mt.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){let e=this.toSeconds(t),r=new $n({context:this.context,onended:()=>this.onstop(this)});this._oscillator=r,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){let e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){let e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return n._periodicWaveCache.find(e=>e.phase===this._phase&&nm(e.partials,this._partials));{let t=n._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 e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let r=this._getCachedPeriodicWave();if($(r)){let{partials:i,wave:o}=r;this._wave=o,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[i,o]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(i,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),n._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),n._periodicWaveCache.length>100&&n._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){Et(t,0);let e=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(e=r[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{let i=new Float32Array(t);this._partials.forEach((o,s)=>i[s]=o),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(t,e){let i=2048,o=new Float32Array(i),s=new Float32Array(i),a=1;if(t==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){let u=2/(c*Math.PI),l;switch(t){case"sine":l=c<=a?1:0,this._partials[c-1]=l;break;case"square":l=c&1?2*u:0,this._partials[c-1]=l;break;case"sawtooth":l=u*(c&1?1:-1),this._partials[c-1]=l;break;case"triangle":c&1?l=2*(u*u)*(c-1>>1&1?-1:1):l=0,this._partials[c-1]=l;break;case"custom":l=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}l!==0?(o[c]=-l*Math.sin(e*c),s[c]=l*Math.cos(e*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(t,e,r){let i=0,o=t.length;for(let s=0;s<o;s++)i+=t[s]*Math.cos(s*r)+e[s]*Math.sin(s*r);return i}getInitialValue(){let[t,e]=this._getRealImaginary(this._type,0),r=0,i=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(t,e,s/o*i),r);return Kc(-this._inverseFFT(t,e,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Rt._periodicWaveCache=[];var un=class extends oe{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new de({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var Wt=class n extends J{constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new H({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(J.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var to=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new un({context:this.context}),this._modulationNode=new H({context:this.context}),this._carrier=new Rt({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 Rt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Wt({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),q(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Rt.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}};var ln=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new H({context:this.context,gain:0}),this._carrier=new Rt({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 J({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Rt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Wt({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Wt({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),q(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Rt.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var yi=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new H({context:this.context,gain:0}),this._thresh=new de({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new J({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Rt({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),q(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(mt.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var eo=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new J({context:this.context,units:"frequency",value:t.frequency}),this.detune=new J({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,q(this,["frequency","detune"])}static getDefaults(){return Object.assign(Rt.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){let e=-t/2,r=t/(this._oscillators.length-1);this._forEach((i,o)=>i.detune.value=e+r*o)}}get count(){return this._oscillators.length}set count(t){if(Et(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Rt({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):et});this.type==="custom"&&(r.partials=this._partials),this.frequency.connect(r.frequency),this.detune.connect(r.detune),r.detune.overridden=!1,r.connect(this.output),this._oscillators[e]=r}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,r)=>e.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var ro=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Wt({context:this.context,value:2}),this._pulse=new yi({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Rt({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),q(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(mt.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var fm={am:to,fat:eo,fm:ln,oscillator:Rt,pulse:yi,pwm:ro},xi=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new J({context:this.context,units:"frequency",value:t.frequency}),this.detune=new J({context:this.context,units:"cents",value:t.detune}),q(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Rt.getDefaults(),ln.getDefaults(),to.getDefaults(),eo.getDefaults(),yi.getDefaults(),ro.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;let e=fm[t],r=this.now();if(this._oscillator){let i=this._oscillator;i.stop(r),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(r)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof fm[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}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(t){this._getOscType(this._oscillator,"fat")&&$t(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&$t(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&re(t)&&(this._oscillator.modulationType=t)}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 ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function Ds(n,t=1/0){let e=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Et(o,n,t),e.set(this,o)}})}}function fe(n,t=1/0){let e=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Et(this.toSeconds(o),n,t),e.set(this,o)}})}}var io=class n extends mt{constructor(){let t=T(n.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new kt({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(mt.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:et,onerror:et,playbackRate:1,reverse:!1})}load(t){return ht(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=et){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,r){return super.start(t,e,r),this}_start(t,e,r){this._loop?e=Ce(e,this._loopStart):e=Ce(e,0);let i=this.toSeconds(e),o=r;r=Ce(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new ur({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Ft(o)?a.start(t,i):a.start(t,i,s-this.toSeconds(this.fadeOut))}_stop(t){let e=this.toSeconds(t);this._activeSources.forEach(r=>r.stop(e))}restart(t,e,r){return super.restart(t,e,r),this}_restart(t,e,r){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(t),this._start(t,e,r)}seek(t,e){let r=this.toSeconds(e);if(this._state.getValueAtTime(r)==="started"){let i=this.toSeconds(t);this._stop(r),this._start(r,i)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Et(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&Et(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){let e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;let e=this.now(),r=this._state.getNextState("stopped",e);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};ne([fe(0)],io.prototype,"fadeIn",void 0);ne([fe(0)],io.prototype,"fadeOut",void 0);var Es=class extends oe{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new de({context:this.context,mapping:t=>Math.abs(t)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var he=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new J({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(L.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(re(t))return t;{let r;for(r in ks)if(ks[r][e]===t)return r;return t}}_setCurve(t,e,r){if(re(r)&&Reflect.has(ks,r)){let i=ks[r];Ue(i)?t!=="_decayCurve"&&(this[t]=i[e]):this[t]=i}else if(Ot(r)&&t!=="_decayCurve")this[t]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let i=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(t);if(s>0){let a=1/i;i=(1-s)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,i,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,i,t);else{this._sig.cancelAndHoldAtTime(t);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=s&&s<=a[c]){a=this._attackCurve.slice(c),a[0]=s;break}this._sig.setValueCurveAtTime(a,t,i,e)}if(o&&this.sustain<1){let a=e*this.sustain,c=t+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);let e=this.getValueAtTime(t);if(e>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,t):(z(Ot(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,r,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,r=1){return e=this.toSeconds(e),this.triggerAttack(e,r),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,r=0){return nn(this,t,e,r),this}asArray(){return ht(this,arguments,void 0,function*(t=1024){let e=t/this.context.sampleRate,r=new He(1,e,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=i+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(e*(i+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};ne([fe(0)],he.prototype,"attack",void 0);ne([fe(0)],he.prototype,"decay",void 0);ne([Ds(0,1)],he.prototype,"sustain",void 0);ne([fe(0)],he.prototype,"release",void 0);var ks=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let i=[],o=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*o-Math.PI/2)+1;i[t]=p/10+e*.83}i[127]=1;let s=[],a=5;for(t=0;t<128;t++)s[t]=Math.ceil(t/127*a)/a;let c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));let u=[];for(t=0;t<128;t++){e=t/127;let p=Math.pow(e,3)*4+.2,m=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(m*(1-e))}function l(p){let m=new Array(p.length);for(let f=0;f<p.length;f++)m[f]=1-p[f];return m}function h(p){return p.slice(0).reverse()}return{bounce:{In:l(u),Out:u},cosine:{In:r,Out:h(r)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:l(i)},sine:{In:c,Out:l(c)},step:{In:s,Out:l(s)}}})();var Ie=class n extends L{constructor(){let t=T(n.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 je({context:this.context,volume:t.volume}),this.volume=this._volume.volume,q(this,"volume")}static getDefaults(){return Object.assign(L.getDefaults(),{volume:0})}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",0),this.context.transport.on("stop",this._syncedRelease),this.context.transport.on("pause",this._syncedRelease),this.context.transport.on("loopEnd",this._syncedRelease)),this}_syncState(){let t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){let r=this["_original_"+t]=this[t];this[t]=(...i)=>{let o=i[e],s=this.context.transport.schedule(a=>{i[e]=a,r.apply(this,i)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,r,i){let o=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,o,i),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var ge=class n extends Ie{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Ie.getDefaults(),{detune:0,onsilence:et,portamento:0})}triggerAttack(t,e,r=1){this.log("triggerAttack",t,e,r);let i=this.toSeconds(e);return this._triggerEnvelopeAttack(i,r),this.setNote(t,i),this}triggerRelease(t){this.log("triggerRelease",t);let e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){let r=this.toSeconds(e),i=t instanceof le?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,o,r)}else this.frequency.setValueAtTime(i,r);return this}};ne([fe(0)],ge.prototype,"portamento",void 0);var hn=class n extends he{constructor(){super(T(n.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new H({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}};var lr=class n extends ge{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new xi(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 hn(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),q(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ge.getDefaults(),{envelope:Object.assign(Ye(he.getDefaults(),Object.keys(L.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ye(xi.getDefaults(),[...Object.keys(mt.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+r+i)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var no=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ot({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new ot({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new ot({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new ot({context:this.context,units:"decibels",convert:!1,value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(L.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){let e=new Float32Array(t);for(let s=0;s<t;s++){let c=Math.pow(s/t,2)*19980+20;e[s]=c}let r=new Float32Array(t),i=new Float32Array(t),o=this.context.createBiquadFilter();return o.type=this.type,o.Q.value=this.Q.value,o.frequency.value=this.frequency.value,o.gain.value=this.gain.value,o.getFrequencyResponse(e,r,i),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var Ir=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new H({context:this.context}),this.output=new H({context:this.context}),this._filters=[],this._filters=[],this.Q=new J({context:this.context,units:"positive",value:t.Q}),this.frequency=new J({context:this.context,units:"frequency",value:t.frequency}),this.detune=new J({context:this.context,units:"cents",value:t.detune}),this.gain=new J({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,q(this,["detune","frequency","gain","Q"])}static getDefaults(){return Object.assign(L.getDefaults(),{Q:1,detune:0,frequency:350,gain:0,rolloff:-12,type:"lowpass"})}get type(){return this._type}set type(t){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._type=t,this._filters.forEach(r=>r.type=t)}get rolloff(){return this._rolloff}set rolloff(t){let e=$t(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],i=r.indexOf(e);z(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(i);for(let o=0;o<i;o++){let s=new no({context:this.context});s.type=this._type,this.frequency.connect(s.frequency),this.detune.connect(s.detune),this.Q.connect(s.Q),this.gain.connect(s.gain),this._filters[o]=s}this._internalChannels=this._filters,ke(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new no({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),r=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((o,s)=>r[s]*=o)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),mi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var js=class n extends lr{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,q(this,["oscillator","envelope"])}static getDefaults(){return De(ge.getDefaults(),lr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){let r=this.toSeconds(e),i=this.toFrequency(t instanceof le?t.toFrequency():t),o=i*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(i,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};ne([Ds(0)],js.prototype,"octaves",void 0);ne([fe(0)],js.prototype,"pitchDecay",void 0);var gm=new Set;function dn(n){gm.add(n)}function Ls(n,t){let e=`registerProcessor("${n}", ${t})`;gm.add(e)}var Px=`
|
|
19
|
+
`],{type:"text/javascript"}),e=URL.createObjectURL(t),r=new Worker(e);r.onmessage=this._callback.bind(this),this._worker=r}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},this._updateInterval*1e3)}_createClock(){if(this._type==="worker")try{this._createWorker()}catch(t){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(t){var e;this._updateInterval=Math.max(t,this._minimumUpdateInterval),this._type==="worker"&&((e=this._worker)===null||e===void 0||e.postMessage(this._updateInterval*1e3))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}};function Ue(n){return Yd(n)}function ar(n){return zd(n)}function Ji(n){return Hd(n)}function qr(n){return Ud(n)}function nm(n){return n instanceof zc}function kx(n,t){return n==="value"||Ue(t)||ar(t)||nm(t)}function Me(n,...t){if(!t.length)return n;let e=t.shift();if(We(n)&&We(e))for(let r in e)kx(r,e[r])?n[r]=e[r]:We(e[r])?(n[r]||Object.assign(n,{[r]:{}}),Me(n[r],e[r])):Object.assign(n,{[r]:e[r]});return Me(n,...t)}function om(n,t){return n.length===t.length&&n.every((e,r)=>t[r]===e)}function T(n,t,e=[],r){let i={},o=Array.from(t);if(We(o[0])&&r&&!Reflect.has(o[0],r)&&(Object.keys(o[0]).some(a=>Reflect.has(n,a))||(Me(i,{[r]:o[0]}),e.splice(e.indexOf(r),1),o.shift())),o.length===1&&We(o[0]))Me(i,o[0]);else for(let s=0;s<e.length;s++)tt(o[s])&&(i[e[s]]=o[s]);return Me(n,i)}function sm(n){return n.constructor.getDefaults()}function Ae(n,t){return Ft(n)?t:n}function ze(n,t){return t.forEach(e=>{Reflect.has(n,e)&&delete n[e]}),n}var Ht=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ie&&this.toString()===ie.TONE_DEBUG_CLASS)&&$d(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Ht.version=Bn;function Cr(n,t){return n>t+1e-6}function Jn(n,t){return Cr(n,t)||ue(n,t)}function hi(n,t){return n+1e-6<t}function ue(n,t){return Math.abs(n-t)<1e-6}function Jc(n,t,e){return Math.max(Math.min(n,e),t)}var Vt=class n extends Ht{constructor(){super(),this.name="Timeline",this._timeline=[];let t=T(n.getDefaults(),arguments,["memory"]);this.memory=t.memory,this.increasing=t.increasing}static getDefaults(){return{memory:1/0,increasing:!1}}get length(){return this._timeline.length}add(t){if(z(Reflect.has(t,"time"),"Timeline: events must have a time attribute"),t.time=t.time.valueOf(),this.increasing&&this.length){let e=this._timeline[this.length-1];z(Jn(t.time,e.time),"The time must be greater than or equal to the last scheduled time"),this._timeline.push(t)}else{let e=this._search(t.time);this._timeline.splice(e+1,0,t)}if(this.length>this.memory){let e=this.length-this.memory;this._timeline.splice(0,e)}return this}remove(t){let e=this._timeline.indexOf(t);return e!==-1&&this._timeline.splice(e,1),this}get(t,e="time"){let r=this._search(t,e);return r!==-1?this._timeline[r]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){let r=this._search(t,e);return r+1<this._timeline.length?this._timeline[r+1]:null}getBefore(t){let e=this._timeline.length;if(e>0&&this._timeline[e-1].time<t)return this._timeline[e-1];let r=this._search(t);return r-1>=0?this._timeline[r-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(ue(this._timeline[e].time,t)){for(let r=e;r>=0&&ue(this._timeline[r].time,t);r--)e=r;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else this._timeline.length===1&&Jn(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){let e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){let e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(this._timeline.length===0)return-1;let r=0,i=this._timeline.length,o=i;if(i>0&&this._timeline[i-1][e]<=t)return i-1;for(;r<o;){let s=Math.floor(r+(o-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ue(a[e],t)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ue(l[e],t))s=u;else break}return s}else{if(hi(a[e],t)&&Cr(c[e],t))return s;Cr(a[e],t)?o=s:r=s+1}}return-1}_iterate(t,e=0,r=this._timeline.length-1){this._timeline.slice(e,r+1).forEach(t)}forEach(t){return this._iterate(t),this}forEachBefore(t,e){let r=this._search(t);return r!==-1&&this._iterate(e,0,r),this}forEachAfter(t,e){let r=this._search(t);return this._iterate(e,r+1),this}forEachBetween(t,e,r){let i=this._search(t),o=this._search(e);return i!==-1&&o!==-1?(this._timeline[i].time!==t&&(i+=1),this._timeline[o].time===e&&(o-=1),this._iterate(r,i,o)):i===-1&&this._iterate(r,0,o),this}forEachFrom(t,e){let r=this._search(t);for(;r>=0&&this._timeline[r].time>=t;)r--;return this._iterate(e,r+1),this}forEachAtTime(t,e){let r=this._search(t);if(r!==-1&&ue(this._timeline[r].time,t)){let i=r;for(let o=r;o>=0&&ue(this._timeline[o].time,t);o--)i=o;this._iterate(o=>{e(o)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var am=[];function Wr(n){am.push(n)}function cm(n){am.forEach(t=>t(n))}var um=[];function Ur(n){um.push(n)}function lm(n){um.forEach(t=>t(n))}var zr=class n extends Ht{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(i=>{Ft(this._events)&&(this._events={}),this._events.hasOwnProperty(i)||(this._events[i]=[]),this._events[i].push(e)}),this}once(t,e){let r=(...i)=>{e(...i),this.off(t,r)};return this.on(t,r),this}off(t,e){return t.split(/\W+/).forEach(i=>{if(Ft(this._events)&&(this._events={}),this._events.hasOwnProperty(i))if(Ft(e))this._events[i]=[];else{let o=this._events[i];for(let s=o.length-1;s>=0;s--)o[s]===e&&o.splice(s,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){let r=this._events[t].slice(0);for(let i=0,o=r.length;i<o;i++)r[i].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(n.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var $i=class extends zr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var pi=class n extends $i{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new Vt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=T(n.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=tm({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new _s(this.emit.bind(this,"tick"),r.clockSource,r.updateInterval,this._context.sampleRate),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this[!((e=arguments[0])===null||e===void 0)&&e.hasOwnProperty("updateInterval")?"_lookAhead":"lookAhead"]=r.lookAhead}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){return this._initialized||(cm(this),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,r){return this._context.createBuffer(t,e,r)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,r){return this._context.createPeriodicWave(t,e,r)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createMediaStreamSource(t){return z(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return z(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return z(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){z(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){z(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){z(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){z(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return im(this.rawContext,t,e)}addAudioWorkletModule(t){return ht(this,void 0,void 0,function*(){z(tt(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletPromise||(this._workletPromise=this.rawContext.audioWorklet.addModule(t)),yield this._workletPromise})}workletsAreReady(){return ht(this,void 0,void 0,function*(){(yield this._workletPromise)?this._workletPromise:Promise.resolve()})}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get lookAhead(){return this._lookAhead}set lookAhead(t){this._lookAhead=t,this.updateInterval=t?t/2:.01}get latencyHint(){return this._latencyHint}get rawContext(){return this._context}now(){return this._context.currentTime+this._lookAhead}immediate(){return this._context.currentTime}resume(){return qr(this._context)?this._context.resume():Promise.resolve()}close(){return ht(this,void 0,void 0,function*(){qr(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&lm(this)})}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{let e=this._context.createBuffer(1,128,this._context.sampleRate),r=e.getChannelData(0);for(let o=0;o<r.length;o++)r[o]=t;let i=this._context.createBufferSource();return i.channelCount=1,i.channelCountMode="explicit",i.buffer=e,i.loop=!0,i.start(0),this._constants.set(t,i),i}}dispose(){return super.dispose(),this._ticker.dispose(),this._timeouts.dispose(),Object.keys(this._constants).map(t=>this._constants[t].disconnect()),this.close(),this}_timeoutLoop(){let t=this.now();this._timeouts.forEachBefore(t,e=>{e.callback(),this._timeouts.remove(e)})}setTimeout(t,e){this._timeoutIds++;let r=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:r+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){let r=++this._timeoutIds,i=()=>{let o=this.now();this._timeouts.add({callback:()=>{t(),i()},id:r,time:o+e})};return i(),r}};var vs=class extends $i{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,r){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,r){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t){return ht(this,void 0,void 0,function*(){return Promise.resolve()})}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};function q(n,t){Ot(t)?t.forEach(e=>q(n,e)):Object.defineProperty(n,t,{enumerable:!0,writable:!1})}function di(n,t){Ot(t)?t.forEach(e=>di(n,e)):Object.defineProperty(n,t,{writable:!0})}var et=()=>{};var kt=class n extends Ht{constructor(){super(),this.name="ToneAudioBuffer",this.onload=et;let t=T(n.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,re(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:et,onload:et,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Bt().sampleRate}set(t){return t instanceof n?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 ht(this,void 0,void 0,function*(){let e=n.load(t).then(r=>{this.set(r),this.onload(this)});n.downloads.push(e);try{yield e}finally{let r=n.downloads.indexOf(e);n.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Ot(t)&&t[0].length>0,r=e?t.length:1,i=e?t[0].length:t.length,o=Bt(),s=o.createBuffer(r,i,o.sampleRate),a=!e&&r===1?[t]:t;for(let c=0;c<r;c++)s.copyToChannel(a[c],c);return this._buffer=s,this}toMono(t){if($t(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let i=0;i<r;i++){let o=this.toArray(i);for(let s=0;s<o.length;s++)e[s]+=o[s]}e=e.map(i=>i/r),this.fromArray(e)}return this}toArray(t){if($t(t))return this.getChannelData(t);if(this.numberOfChannels===1)return this.toArray(0);{let e=[];for(let r=0;r<this.numberOfChannels;r++)e[r]=this.getChannelData(r);return e}}getChannelData(t){return this._buffer?this._buffer.getChannelData(t):new Float32Array(0)}slice(t,e=this.duration){z(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),i=Math.floor(e*this.sampleRate);z(r<i,"The start time must be less than the end time");let o=i-r,s=Bt().createBuffer(this.numberOfChannels,o,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,i),a);return new n(s)}_reverse(){if(this.loaded)for(let t=0;t<this.numberOfChannels;t++)this.getChannelData(t).reverse();return this}get loaded(){return this.length>0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return new n().fromArray(t)}static fromUrl(t){return ht(this,void 0,void 0,function*(){return yield new n().load(t)})}static load(t){return ht(this,void 0,void 0,function*(){let e=n.baseUrl===""||n.baseUrl.endsWith("/")?n.baseUrl:n.baseUrl+"/",r=yield fetch(e+t);if(!r.ok)throw new Error(`could not load url: ${t}`);let i=yield r.arrayBuffer();return yield Bt().decodeAudioData(i)})}static supportsType(t){let e=t.split("."),r=e[e.length-1];return document.createElement("audio").canPlayType("audio/"+r)!==""}static loaded(){return ht(this,void 0,void 0,function*(){for(yield Promise.resolve();n.downloads.length;)yield n.downloads[0]})}};kt.baseUrl="";kt.downloads=[];var Ye=class extends pi{constructor(){super({clockSource:"offline",context:Ji(arguments[0])?arguments[0]:em(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Ji(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Ji(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return ht(this,void 0,void 0,function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;let r=Math.floor(this.sampleRate/128);t&&e%r===0&&(yield new Promise(i=>setTimeout(i,1)))}})}render(){return ht(this,arguments,void 0,function*(t=!0){yield this.workletsAreReady(),yield this._renderClock(t);let e=yield this._context.startRendering();return new kt(e)})}close(){return Promise.resolve()}};var hm=new vs,tn=hm;function Bt(){return tn===hm&&rm&&$c(new pi),tn}function $c(n,t=!1){t&&tn.dispose(),qr(n)?tn=new pi(n):Ji(n)?tn=new Ye(n):tn=n}if(ie&&!ie.TONE_SILENCE_LOGGING){let n="v";Bn==="dev"&&(n="");let t=` * Tone.js ${n}${Bn} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function en(n){return Math.pow(10,n/20)}function rn(n){return 20*(Math.log(n)/Math.LN10)}function mi(n){return Math.pow(2,n/12)}var Is=440;function pm(){return Is}function dm(n){Is=n}function He(n){return Math.round(tu(n))}function tu(n){return 69+12*Math.log2(n/Is)}function $n(n){return Is*Math.pow(2,(n-69)/12)}var Ss=class n extends Ht{constructor(t,e,r){super(),this.defaultUnits="s",this._val=e,this._units=r,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{let r=parseInt(t,10),i=e==="."?1.5:1;return r===1?this._beatsToUnits(this._getTimeSignature())*i:this._beatsToUnits(4/r)*i},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{let e=parseInt(t,10);return this._beatsToUnits(8/(Math.floor(e)*3))},regexp:/^(\d+)t$/i},tr:{method:(t,e,r)=>{let i=0;return t&&t!=="0"&&(i+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(i+=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(i+=this._beatsToUnits(parseFloat(r)/4)),i},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof n&&this.fromType(this._val),Ft(this._val))return this._noArg();if(re(this._val)&&Ft(this._units)){for(let t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(We(this._val)){let t=0;for(let e in this._val)if(tt(this._val[e])){let r=this._val[e],i=new this.constructor(this.context,e).valueOf()*r;t+=i}return t}if(tt(this._units)){let t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}else return re(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi();break}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return this.toSeconds()*1e3}};var Ce=class n extends Ss{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{let e=new n(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){let r=new this.constructor(this.context,t).valueOf(),i=this.valueOf(),a=Math.round(i/r)*r-i;return i+a*e}toNotation(){let t=this.toSeconds(),e=["1m"];for(let o=1;o<9;o++){let s=Math.pow(2,o);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],i=new n(this.context,e[0]).toSeconds();return e.forEach(o=>{let s=new n(this.context,o).toSeconds();Math.abs(s-t)<Math.abs(i-t)&&(r=o,i=s)}),r}toBarsBeatsSixteenths(){let t=this._beatsToUnits(1),e=this.valueOf()/t;e=parseFloat(e.toFixed(4));let r=Math.floor(e/this._getTimeSignature()),i=e%1*4;e=Math.floor(e)%this._getTimeSignature();let o=i.toString();return o.length>3&&(i=parseFloat(parseFloat(o).toFixed(3))),[r,e,i].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return He(this.toFrequency())}_now(){return this.context.now()}};var le=class n extends Ce{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return pm()}static set A4(t){dm(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:n.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let i=jx[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?i:n.mtof(i)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,r){let i=1;return t&&t!=="0"&&(i*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&e!=="0"&&(i*=this._beatsToUnits(parseFloat(e))),r&&r!=="0"&&(i*=this._beatsToUnits(parseFloat(r)/4)),i}}})}transpose(t){return new n(this.context,this.valueOf()*mi(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return He(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/n.A4),r=Math.round(12*e)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),Px[r%12]+i.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){let t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(t*60/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return $n(t)}static ftom(t){return He(t)}},jx={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},Px=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var De=class extends Ce{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var qt=class n extends Ht{constructor(){super();let t=T(n.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Bt()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return Kd(t),new Ce(this.context,t).toSeconds()}toFrequency(t){return new le(this.context,t).toFrequency()}toTicks(t){return new De(this.context,t).toTicks()}_getPartialProperties(t){let e=this.get();return Object.keys(e).forEach(r=>{Ft(t[r])&&delete e[r]}),e}get(){let t=sm(this);return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){let r=this[e];tt(r)&&tt(r.value)&&tt(r.setValueAtTime)?t[e]=r.value:r instanceof n?t[e]=r._getPartialProperties(t[e]):Ot(r)||$t(r)||re(r)||Qc(r)?t[e]=r:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&tt(this[e])&&(this[e]&&tt(this[e].value)&&tt(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof n?this[e].set(t[e]):this[e]=t[e])}),this}};var cr=class extends Vt{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){let e=this.get(t);return e!==null?e.state:this._initial}setStateAtTime(t,e,r){return Et(e,0),this.add(Object.assign({},r,{state:t,time:e})),this}getLastState(t,e){let r=this._search(e);for(let i=r;i>=0;i--){let o=this._timeline[i];if(o.state===t)return o}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let o=this._timeline[i];if(o.state===t)return o}}};var ot=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,z(tt(t.param)&&(Ue(t.param)||t.param instanceof n),"param must be an AudioParam");!Ue(t.param);)t.param=t.param._param;this._swappable=tt(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 Vt(1e3),this._initialValue=this._param.defaultValue,this.units=t.units,this.convert=t.convert,this._minValue=t.minValue,this._maxValue=t.maxValue,tt(t.value)&&t.value!==this._toType(this._initialValue)&&this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(qt.getDefaults(),{convert:!0,units:"number"})}get value(){let t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return tt(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 tt(this._maxValue)?this._maxValue:this.units==="normalRange"||this.units==="audioRange"?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return tt(this.maxValue)&&tt(this.minValue)&&Et(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?en(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?rn(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),i=this._fromType(t);return z(isFinite(i)&&isFinite(r),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(i),this.log(this.units,"setValueAtTime",t,r),this._events.add({time:r,type:"setValueAtTime",value:i}),this._param.setValueAtTime(i,r),this}getValueAtTime(t){let e=Math.max(this.toSeconds(t),0),r=this._events.getAfter(e),i=this._events.get(e),o=this._initialValue;if(i===null)o=this._initialValue;else if(i.type==="setTargetAtTime"&&(r===null||r.type==="setValueAtTime")){let s=this._events.getBefore(i.time),a;s===null?a=this._initialValue:a=s.value,i.type==="setTargetAtTime"&&(o=this._exponentialApproach(i.time,a,i.value,i.constant,e))}else if(r===null)o=i.value;else if(r.type==="linearRampToValueAtTime"||r.type==="exponentialRampToValueAtTime"){let s=i.value;if(i.type==="setTargetAtTime"){let a=this._events.getBefore(i.time);a===null?s=this._initialValue:s=a.value}r.type==="linearRampToValueAtTime"?o=this._linearInterpolate(i.time,s,r.time,r.value,e):o=this._exponentialInterpolate(i.time,s,r.time,r.value,e)}else o=i.value;return this._toType(o)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),this._fromType(e)===0&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){let r=this._fromType(t),i=this.toSeconds(e);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(r),this._events.add({time:i,type:"linearRampToValueAtTime",value:r}),this.log(this.units,"linearRampToValueAtTime",t,i),this._param.linearRampToValueAtTime(r,i),this}exponentialRampToValueAtTime(t,e){let r=this._fromType(t);r=ue(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(e);return z(isFinite(r)&&isFinite(i),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:i,type:"exponentialRampToValueAtTime",value:r}),this.log(this.units,"exponentialRampToValueAtTime",t,i),this._param.exponentialRampToValueAtTime(r,i),this}exponentialRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialRampToValueAtTime(t,r+this.toSeconds(e)),this}linearRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.linearRampToValueAtTime(t,r+this.toSeconds(e)),this}targetRampTo(t,e,r){return r=this.toSeconds(r),this.setRampPoint(r),this.exponentialApproachValueAtTime(t,r,e),this}exponentialApproachValueAtTime(t,e,r){e=this.toSeconds(e),r=this.toSeconds(r);let i=Math.log(r+1)/Math.log(200);return this.setTargetAtTime(t,e,i),this.cancelAndHoldAtTime(e+r*.9),this.linearRampToValueAtTime(t,e+r),this}setTargetAtTime(t,e,r){let i=this._fromType(t);z(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let o=this.toSeconds(e);return this._assertRange(i),z(isFinite(i)&&isFinite(o),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:o,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",t,o,r),this._param.setTargetAtTime(i,o,r),this}setValueCurveAtTime(t,e,r,i=1){r=this.toSeconds(r),e=this.toSeconds(e);let o=this._fromType(t[0])*i;this.setValueAtTime(this._toType(o),e);let s=r/(t.length-1);for(let a=1;a<t.length;a++){let c=this._fromType(t[a])*i;this.linearRampToValueAtTime(this._toType(c),e+a*s)}return this}cancelScheduledValues(t){let e=this.toSeconds(t);return z(isFinite(e),`Invalid argument to cancelScheduledValues: ${JSON.stringify(t)}`),this._events.cancel(e),this._param.cancelScheduledValues(e),this.log(this.units,"cancelScheduledValues",e),this}cancelAndHoldAtTime(t){let e=this.toSeconds(t),r=this._fromType(this.getValueAtTime(e));z(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let i=this._events.get(e),o=this._events.getAfter(e);return i&&ue(i.time,e)?o?(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):o&&(this._param.cancelScheduledValues(o.time),this._events.cancel(o.time),o.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):o.type==="exponentialRampToValueAtTime"&&this.exponentialRampToValueAtTime(this._toType(r),e)),this._events.add({time:e,type:"setValueAtTime",value:r}),this._param.setValueAtTime(r,e),this}rampTo(t,e=.1,r){return this.units==="frequency"||this.units==="bpm"||this.units==="decibels"?this.exponentialRampTo(t,e,r):this.linearRampTo(t,e,r),this}apply(t){let e=this.context.currentTime;t.setValueAtTime(this.getValueAtTime(e),e);let r=this._events.get(e);if(r&&r.type==="setTargetAtTime"){let i=this._events.getAfter(r.time),o=i?i.time:e+2,s=(o-e)/10;for(let a=e;a<o;a+=s)t.linearRampToValueAtTime(this.getValueAtTime(a),a)}return this._events.forEachAfter(this.context.currentTime,i=>{i.type==="cancelScheduledValues"?t.cancelScheduledValues(i.time):i.type==="setTargetAtTime"?t.setTargetAtTime(i.value,i.time,i.constant):t[i.type](i.value,i.time)}),this}setParam(t){z(this._swappable,"The Param must be assigned as 'swappable' in the constructor");let e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,r,i,o){return r+(e-r)*Math.exp(-(o-t)/i)}_linearInterpolate(t,e,r,i,o){return e+(i-e)*((o-t)/(r-t))}_exponentialInterpolate(t,e,r,i,o){return e*Math.pow(i/e,(o-t)/(r-t))}};var j=class n extends qt{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return tt(this.input)?Ue(this.input)||this.input instanceof ot?1:this.input.numberOfInputs:0}get numberOfOutputs(){return tt(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return tt(t)&&(t instanceof n||ar(t))}_getInternalNodes(){let t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(r=>{r.channelCount=t.channelCount,r.channelCountMode=t.channelCountMode,r.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){let t=this._getInternalNodes();z(t.length>0,"ToneAudioNode does not have any internal nodes");let e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){let e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,r=0){return te(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return li("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return mm(this,t,e,r),this}chain(...t){return Ee(this,...t),this}fan(...t){return t.forEach(e=>this.connect(e)),this}dispose(){return super.dispose(),tt(this.input)&&(this.input instanceof n?this.input.dispose():ar(this.input)&&this.input.disconnect()),tt(this.output)&&(this.output instanceof n?this.output.dispose():ar(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function Ee(...n){let t=n.shift();n.reduce((e,r)=>(e instanceof j?e.connect(r):ar(e)&&te(e,r),r),t)}function te(n,t,e=0,r=0){for(z(tt(n),"Cannot connect from undefined node"),z(tt(t),"Cannot connect to undefined node"),(t instanceof j||ar(t))&&z(t.numberOfInputs>0,"Cannot connect to node with no inputs"),z(n.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof j||t instanceof ot;)tt(t.input)&&(t=t.input);for(;n instanceof j;)tt(n.output)&&(n=n.output);Ue(t)?n.connect(t,e):n.connect(t,e,r)}function mm(n,t,e=0,r=0){if(tt(t))for(;t instanceof j;)t=t.input;for(;!ar(n);)tt(n.output)&&(n=n.output);Ue(t)?n.disconnect(t,e):ar(t)?n.disconnect(t,e,r):n.disconnect()}var Z=class n extends j{constructor(){let t=T(n.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 ot({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),q(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}};var Ze=class extends j{constructor(t){super(t),this.onended=et,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Z({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let r=this.toSeconds(e);return this._startTime!==-1&&r>=this._startTime&&(this._stopTime===-1||r<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(j.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:et})}_startGain(t,e=1){z(this._startTime===-1,"Source cannot be started more than once");let r=this.toSeconds(this._fadeIn);return this._startTime=t+r,this._startTime=Math.max(this._startTime,this.context.currentTime),r>0?(this._gainNode.gain.setValueAtTime(0,t),this._curve==="linear"?this._gainNode.gain.linearRampToValueAtTime(e,t+r):this._gainNode.gain.exponentialApproachValueAtTime(e,t,r)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){z(this._startTime!==-1,"'start' must be called before 'stop'"),this.cancelStop();let e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.now()),e>0?this._curve==="linear"?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{let r=this._curve==="exponential"?e*2:0;this._stopSource(this.now()+r),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==et&&(this.onended(this),this.onended=et,!this.context.isOffline)){let t=()=>this.dispose();typeof requestIdleCallback!="undefined"?requestIdleCallback(t):setTimeout(t,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=et,this}};var to=class n extends Ze{constructor(){let t=T(n.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),te(this._source,this._gainNode),this.offset=new ot({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(Ze.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){this._source.stop(t)}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._source.disconnect(),this.offset.dispose(),this}};var $=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new to({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(t,e=0,r=0){return nn(this,t,e,r),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,r){return this._param.exponentialRampTo(t,e,r),this}linearRampTo(t,e,r){return this._param.linearRampTo(t,e,r),this}targetRampTo(t,e,r){return this._param.targetRampTo(t,e,r),this}exponentialApproachValueAtTime(t,e,r){return this._param.exponentialApproachValueAtTime(t,e,r),this}setTargetAtTime(t,e,r){return this._param.setTargetAtTime(t,e,r),this}setValueCurveAtTime(t,e,r,i){return this._param.setValueCurveAtTime(t,e,r,i),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,r){return this._param.rampTo(t,e,r),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}};function nn(n,t,e,r){(t instanceof ot||Ue(t)||t instanceof $&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof $&&(t.overridden=!0)),te(n,t,e,r)}var ws=class n extends ot{constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new Vt(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(ot.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let i=this._fromType(t),o=this._events.get(e),s=Math.round(Math.max(1/r,1));for(let a=0;a<=s;a++){let c=r*a+e,u=this._exponentialApproach(o.time,o.value,i,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}setValueAtTime(t,e){let r=this.toSeconds(e);super.setValueAtTime(t,e);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}linearRampToValueAtTime(t,e){let r=this.toSeconds(e);super.linearRampToValueAtTime(t,e);let i=this._events.get(r),o=this._events.previousEvent(i),s=this._getTicksUntilEvent(o,r);return i.ticks=Math.max(s,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);let r=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max((e-i.time)*10,1)),s=(e-i.time)/o;for(let a=0;a<=o;a++){let c=s*a+i.time,u=this._exponentialInterpolate(i.time,i.value,e,r,c);this.linearRampToValueAtTime(this._toType(u),c)}return this}_getTicksUntilEvent(t,e){if(t===null)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(Ft(t.ticks)){let s=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(s,t.time)}let r=this._fromType(this.getValueAtTime(t.time)),i=this._fromType(this.getValueAtTime(e)),o=this._events.get(e);return o&&o.time===e&&o.type==="setValueAtTime"&&(i=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(r+i)+t.ticks}getTicksAtTime(t){let e=this.toSeconds(t),r=this._events.get(e);return Math.max(this._getTicksUntilEvent(r,e),0)}getDurationOfTicks(t,e){let r=this.toSeconds(e),i=this.getTicksAtTime(e);return this.getTimeOfTick(i+t)-r}getTimeOfTick(t){let e=this._events.get(t,"ticks"),r=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&r&&r.type==="linearRampToValueAtTime"&&e.value!==r.value){let i=this._fromType(this.getValueAtTime(e.time)),s=(this._fromType(this.getValueAtTime(r.time))-i)/(r.time-e.time),a=Math.sqrt(Math.pow(i,2)-2*s*(e.ticks-t)),c=(-i+a)/s,u=(-i-a)/s;return(c>0?c:u)+e.time}else return e?e.value===0?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){let r=this.toSeconds(e),i=this.toSeconds(t),o=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-o}_fromType(t){return this.units==="bpm"&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return this.units==="bpm"&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){let e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}};var Ts=class n extends ${constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new ws({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign($.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}};var Ns=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new cr,this._tickOffset=new Vt,this._ticksAtTime=new Vt,this._secondsAtTime=new Vt,this.frequency=new Ts({context:this.context,units:t.units,value:t.frequency}),q(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},qt.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){let r=this.toSeconds(t);return this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),tt(e)&&this.setTicksAtTime(e,r),this._ticksAtTime.cancel(r),this._secondsAtTime.cancel(r)),this}stop(t){let e=this.toSeconds(t);if(this._state.getValueAtTime(e)==="stopped"){let r=this._state.get(e);r&&r.time>0&&(this._tickOffset.cancel(r.time),this._state.cancel(r.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e)),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this._ticksAtTime.cancel(t),this._secondsAtTime.cancel(t),this}getTicksAtTime(t){let e=this.toSeconds(t),r=this._state.getLastState("stopped",e),i=this._ticksAtTime.get(e),o={state:"paused",time:e};this._state.add(o);let s=i||r,a=i?i.ticks:0,c=null;return this._state.forEachBetween(s.time,e+this.sampleTime,u=>{let l=s.time,h=this._tickOffset.get(u.time);h&&h.time>=s.time&&(a=h.ticks,l=h.time),s.state==="started"&&u.state!=="started"&&(a+=this.frequency.getTicksAtTime(u.time)-this.frequency.getTicksAtTime(l),u.time!==o.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(o),c&&this._ticksAtTime.add(c),a}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){let e=this.now(),r=this.frequency.timeToTicks(t,e);this.setTicksAtTime(r,e)}getSecondsAtTime(t){t=this.toSeconds(t);let e=this._state.getLastState("stopped",t),r={state:"paused",time:t};this._state.add(r);let i=this._secondsAtTime.get(t),o=i||e,s=i?i.seconds:0,a=null;return this._state.forEachBetween(o.time,t+this.sampleTime,c=>{let u=o.time,l=this._tickOffset.get(c.time);l&&l.time>=o.time&&(s=l.seconds,u=l.time),o.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),o=c}),this._state.remove(r),a&&this._secondsAtTime.add(a),s}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this._ticksAtTime.cancel(e),this._secondsAtTime.cancel(e),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){let r=this._tickOffset.get(e),i=this._state.get(e),o=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(o)+t-r.ticks;return this.frequency.getTimeOfTick(s)}forEachTickBetween(t,e,r){let i=this._state.get(t);this._state.forEachBetween(t,e,s=>{i&&i.state==="started"&&s.state!=="started"&&this.forEachTickBetween(Math.max(i.time,t),s.time-this.sampleTime,r),i=s});let o=null;if(i&&i.state==="started"){let s=Math.max(i.time,t),a=this.frequency.getTicksAtTime(s),c=this.frequency.getTicksAtTime(i.time),u=a-c,l=Math.ceil(u)-u;l=ue(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<e;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(p){o=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(o)throw o;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var on=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=et,this._lastUpdate=0,this._state=new cr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new Ns({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,q(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(qt.getDefaults(),{callback:et,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){Cs(this.context);let r=this.toSeconds(t);return this.log("start",r),this._state.getValueAtTime(r)!=="started"&&(this._state.setStateAtTime("started",r),this._tickSource.start(r,e),r<this._lastUpdate&&this.emit("start",r,e)),this}stop(t){let e=this.toSeconds(t);return this.log("stop",e),this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._tickSource.stop(e),e<this._lastUpdate&&this.emit("stop",e),this}pause(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)==="started"&&(this._state.setStateAtTime("paused",e),this._tickSource.pause(e),e<this._lastUpdate&&this.emit("pause",e)),this}get ticks(){return Math.ceil(this.getTicksAtTime(this.now()))}set ticks(t){this._tickSource.ticks=t}get seconds(){return this._tickSource.seconds}set seconds(t){this._tickSource.seconds=t}getSecondsAtTime(t){return this._tickSource.getSecondsAtTime(t)}setTicksAtTime(t,e){return this._tickSource.setTicksAtTime(t,e),this}getTimeOfTick(t,e=this.now()){return this._tickSource.getTimeOfTick(t,e)}getTicksAtTime(t){return this._tickSource.getTicksAtTime(t)}nextTickTime(t,e){let r=this.toSeconds(e),i=this.getTicksAtTime(r);return this._tickSource.getTimeOfTick(i+t,r)}_loop(){let t=this._lastUpdate,e=this.now();this._lastUpdate=e,this.log("loop",t,e),t!==e&&(this._state.forEachBetween(t,e,r=>{switch(r.state){case"started":let i=this._tickSource.getTicksAtTime(r.time);this.emit("start",r.time,i);break;case"stopped":r.time!==0&&this.emit("stop",r.time);break;case"paused":this.emit("pause",r.time);break}}),this._tickSource.forEachTickBetween(t,e,(r,i)=>{this.callback(r,i)}))}getStateAtTime(t){let e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}};zr.mixin(on);var ke=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new Z({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,q(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(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}};var eu=class n extends j{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="Destination",this.input=new ke({context:this.context}),this.output=new Z({context:this.context}),this.volume=this.input.volume,Ee(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(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),Ee(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Wr(n=>{n.destination=new eu({context:n})});Ur(n=>{n.destination.dispose()});var ru=class extends j{constructor(){super(...arguments),this.name="Listener",this.positionX=new ot({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new ot({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new ot({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new ot({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new ot({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new ot({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new ot({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new ot({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new ot({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}};Wr(n=>{n.listener=new ru({context:n})});Ur(n=>{n.listener.dispose()});var sn=class n extends Ht{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=T(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;let r=t.urls[e];this.add(e,r,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:et,onload:et,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return z(this.has(t),`ToneAudioBuffers has no buffer named: ${t}`),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,this._loadingCount===0&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,r=et,i=et){return re(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new kt(this.baseUrl+e,r,i))):this._buffers.set(t.toString(),new kt(e,r,i)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var eo=class n extends le{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return He(super._frequencyToUnits(t))}_ticksToUnits(t){return He(super._ticksToUnits(t))}_beatsToUnits(t){return He(super._beatsToUnits(t))}_secondsToUnits(t){return He(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return $n(this.toMidi())}transpose(t){return new n(this.context,this.toMidi()+t)}};var _e=class extends De{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}};var iu=class extends qt{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Vt,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),this._events.length===1&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){let t=this.context.currentTime;this._events.forEachBefore(t+this.anticipation,e=>{t-e.time<=this.expiration&&e.callback(),this._events.remove(e)}),this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}};Wr(n=>{n.draw=new iu({context:n})});Ur(n=>{n.draw.dispose()});var Os=class extends Ht{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){z(tt(t.time),"Events must have a time property"),z(tt(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new nu(t.time,t.time+t.duration,t);for(this._root===null?this._root=e:this._root.insert(e),this._length++;e!==null;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(this._root!==null){let e=[];this._root.search(t.time,e);for(let r of e)if(r.event===t){this._removeNode(r),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,e=>this.remove(e)),this}_setRoot(t){this._root=t,this._root!==null&&(this._root.parent=null)}_replaceNodeInParent(t,e){t.parent!==null?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(t.left===null&&t.right===null)this._replaceNodeInParent(t,null);else if(t.right===null)this._replaceNodeInParent(t,t.left);else if(t.left===null)this._replaceNodeInParent(t,t.right);else{let e=t.getBalance(),r,i=null;if(e>0)if(t.left.right===null)r=t.left,r.right=t.right,i=r;else{for(r=t.left.right;r.right!==null;)r=r.right;r.parent&&(r.parent.right=r.left,i=r.parent,r.left=t.left,r.right=t.right)}else if(t.right.left===null)r=t.right,r.left=t.left,i=r;else{for(r=t.right.left;r.left!==null;)r=r.left;r.parent&&(r.parent.left=r.right,i=r.parent,r.left=t.left,r.right=t.right)}t.parent!==null?t.isLeftChild()?t.parent.left=r:t.parent.right=r:this._setRoot(r),i&&this._rebalance(i)}t.dispose()}_rotateLeft(t){let e=t.parent,r=t.isLeftChild(),i=t.right;i&&(t.right=i.left,i.left=t),e!==null?r?e.left=i:e.right=i:this._setRoot(i)}_rotateRight(t){let e=t.parent,r=t.isLeftChild(),i=t.left;i&&(t.left=i.right,i.right=t),e!==null?r?e.left=i:e.right=i:this._setRoot(i)}_rebalance(t){let e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(this._root!==null){let e=[];if(this._root.search(t,e),e.length>0){let r=e[0];for(let i=1;i<e.length;i++)e[i].low>r.low&&(r=e[i]);return r.event}}return null}forEach(t){if(this._root!==null){let e=[];this._root.traverse(r=>e.push(r)),e.forEach(r=>{r.event&&t(r.event)})}return this}forEachAtTime(t,e){if(this._root!==null){let r=[];this._root.search(t,r),r.forEach(i=>{i.event&&e(i.event)})}return this}forEachFrom(t,e){if(this._root!==null){let r=[];this._root.searchAfter(t,r),r.forEach(i=>{i.event&&e(i.event)})}return this}dispose(){return super.dispose(),this._root!==null&&this._root.traverse(t=>t.dispose()),this._root=null,this}},nu=class{constructor(t,e,r){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=r,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?this.left===null?this.left=t:this.left.insert(t):this.right===null?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(this.left!==null&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),!(this.low>t)&&this.right!==null&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),this.left!==null&&this.left.searchAfter(t,e)),this.right!==null&&this.right.searchAfter(t,e)}traverse(t){t(this),this.left!==null&&this.left.traverse(t),this.right!==null&&this.right.traverse(t)}updateHeight(){this.left!==null&&this.right!==null?this.height=Math.max(this.left.height,this.right.height)+1:this.right!==null?this.height=this.right.height+1:this.left!==null?this.height=this.left.height+1:this.height=0}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 t=0;return this.left!==null&&this.right!==null?t=this.left.height-this.right.height:this.left!==null?t=this.left.height+1:this.right!==null&&(t=-(this.right.height+1)),t}isLeftChild(){return this.parent!==null&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,t!==null&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}};var Rs=class extends Ht{constructor(t){super(),this.name="TimelineValue",this._timeline=new Vt({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){let e=this._timeline.get(t);return e?e.value:this._initialValue}};var oe=class n extends j{constructor(){super(T(n.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return nn(this,t,e,r),this}};var de=class n extends oe{constructor(){let t=T(n.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Ot(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Zd(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign($.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let i=0,o=e;i<o;i++){let s=i/(o-1)*2-1;r[i]=t(s,i)}return this.curve=r,this}get curve(){return this._shaper.curve}set curve(t){this._shaper.curve=t}get oversample(){return this._shaper.oversample}set oversample(t){let e=["none","2x","4x"].some(r=>r.includes(t));z(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var an=class n extends oe{constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new de({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(oe.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}};var _r=class n{constructor(t,e){this.id=n._eventId++,this._remainderTime=0;let r=Object.assign(n.getDefaults(),e);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:et,once:!1,time:0}}get floatTime(){return this.time+this._remainderTime}invoke(t){if(this.callback){let e=this.transport.bpm.getDurationOfTicks(1,t);this.callback(t+this._remainderTime*e),this._once&&this.transport.clear(this.id)}}dispose(){return this.callback=void 0,this}};_r._eventId=0;var Ms=class n extends _r{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);let r=Object.assign(n.getDefaults(),e);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({},_r.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return hi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new _e(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){hi(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 _e(this.context,this._nextTick).toSeconds()))}_restart(t){this.transport.clear(this._currentId),this.transport.clear(this._nextId),this._nextTick=this.floatTime;let e=this.transport.getTicksAtTime(t);Cr(e,this.time)&&(this._nextTick=this.floatTime+Math.ceil((e-this.floatTime)/this._interval)*this._interval),this._currentId=this._createEvent(),this._nextTick+=this._interval,this._nextId=this._createEvent()}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this.transport.off("ticks",this._boundRestart),this}};var Ds=class n extends qt{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new Rs(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Vt,this._repeatedEvents=new Os,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new on({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),q(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(qt.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!==0&&e%(this._swingTicks*2)!==0){let r=e%(this._swingTicks*2)/(this._swingTicks*2),i=Math.sin(r*Math.PI)*this._swingAmount;t+=new _e(this.context,this._swingTicks*2/3).toSeconds()*i}Kc(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),Kc(!1)}schedule(t,e){let r=new _r(this,{callback:t,time:new De(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,i=1/0){let o=new Ms(this,{callback:t,duration:new Ce(this.context,i).toTicks(),interval:new Ce(this.context,e).toTicks(),time:new De(this.context,r).toTicks()});return this._addEvent(o,this._repeatedEvents)}scheduleOnce(t,e){let r=new _r(this,{callback:t,once:!0,time:new De(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){let e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){let e=this.toTicks(t);return this._timeline.forEachFrom(e,r=>this.clear(r.id)),this._repeatedEvents.forEachFrom(e,r=>this.clear(r.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new _e(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){this.context.resume();let r;return tt(e)&&(r=this.toTicks(e)),this._clock.start(t,r),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),this._clock.getStateAtTime(t)!=="started"?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){Ot(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Ce(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Ce(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new _e(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){let t=this.now(),e=this._clock.getTicksAtTime(t);return new _e(this.context,e).toBarsBeatsSixteenths()}set position(t){let e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){let e=this.now(),r=this._clock.frequency.timeToTicks(t,e);this.ticks=r}get progress(){if(this.loop){let t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}else return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){let e=this.now();if(this.state==="started"){let r=this._clock.getTicksAtTime(e),i=this._clock.frequency.getDurationOfTicks(Math.ceil(r)-r,e),o=e+i;this.emit("stop",o),this._clock.setTicksAtTime(t,o),this.emit("start",o,this._clock.getSecondsAtTime(o))}else this.emit("ticks",e),this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return this._clock.getTicksAtTime(t)}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),this.state!=="started")return 0;{let e=this.now(),r=this.getTicksAtTime(e),i=t-r%t;return this._clock.nextTickTime(i,e)}}syncSignal(t,e){let r=this.now(),i=this.bpm,o=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/o,u=new Z(c),l=new an(-1),h=new Z(c);i.chain(u,l,h),i=h,o=1/o,s=[u,l,h]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/o:e=0);let a=new Z(e);return i.connect(a),a.connect(t._param),s.push(a),this._syncedSignals.push({initial:t.value,nodes:s,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){let r=this._syncedSignals[e];r.signal===t&&(r.nodes.forEach(i=>i.dispose()),r.signal.value=r.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),di(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};zr.mixin(Ds);Wr(n=>{n.transport=new Ds({context:n})});Ur(n=>{n.transport.dispose()});var ft=class extends j{constructor(t){super(t),this.input=void 0,this._state=new cr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=et,this._syncedStop=et,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new ke({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,q(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,onstop:et,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(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,r){let i=Ft(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(i=this._clampToCurrentTime(i),!this._synced&&this._state.getValueAtTime(i)==="started")z(Cr(i,this._state.get(i).time),"Start time must be strictly greater than previous start time"),this._state.cancel(i),this._state.setStateAtTime("started",i),this.log("restart",i),this.restart(i,e,r);else if(this.log("start",i),this._state.setStateAtTime("started",i),this._synced){let o=this._state.get(i);o&&(o.offset=this.toSeconds(Ae(e,0)),o.duration=r?this.toSeconds(r):void 0);let s=this.context.transport.schedule(a=>{this._start(a,e,r)},i);this._scheduled.push(s),this.context.transport.state==="started"&&this.context.transport.getSecondsAtTime(this.immediate())>i&&this._syncedStart(this.now(),this.context.transport.seconds)}else Cs(this.context),this._start(i,e,r);return this}stop(t){let e=Ft(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),this._state.getValueAtTime(e)==="started"||tt(this._state.getNextState("started",e))){if(this.log("stop",e),!this._synced)this._stop(e);else{let r=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(r)}this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,r){return t=this.toSeconds(t),this._state.getValueAtTime(t)==="started"&&(this._state.cancel(t),this._restart(t,e,r)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(Cr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let i=e-this.toSeconds(r.time),o;r.duration&&(o=this.toSeconds(r.duration)-i),this._start(t,this.toSeconds(r.offset)+i,o)}}},this._syncedStop=t=>{let e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));this._state.getValueAtTime(e)==="started"&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=et,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var ur=class n extends Ze{constructor(){let t=T(n.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,te(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new ot({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 kt(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Ze.getDefaults(),{url:new kt,loop:!1,loopEnd:0,loopStart:0,onload:et,onerror:et,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,r,i=1){z(this.buffer.loaded,"buffer is either not set or not loaded");let o=this.toSeconds(t);this._startGain(o,i),this.loop?e=Ae(e,this.loopStart):e=Ae(e,0);let s=Math.max(this.toSeconds(e),0);if(this.loop){let a=this.toSeconds(this.loopEnd)||this.buffer.duration,c=this.toSeconds(this.loopStart),u=a-c;Jn(s,a)&&(s=(s-c)%u+c),ue(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,hi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(o,s)),tt(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(o+a)}return this}_stopSource(t){!this._sourceStopped&&this._sourceStarted&&(this._sourceStopped=!0,this._source.stop(this.toSeconds(t)),this._onended())}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}};var fi=class n extends ft{constructor(){let t=T(n.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(ft.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(z(t in fm,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,this.state==="started")){let e=this.now();this._stop(e),this._start(e)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){let e=fm[this._type];this._source=new ur({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},cn=44100*5,ou=2,vr={brown:null,pink:null,white:null},fm={get brown(){if(!vr.brown){let n=[];for(let t=0;t<ou;t++){let e=new Float32Array(cn);n[t]=e;let r=0;for(let i=0;i<cn;i++){let o=Math.random()*2-1;e[i]=(r+.02*o)/1.02,r=e[i],e[i]*=3.5}}vr.brown=new kt().fromArray(n)}return vr.brown},get pink(){if(!vr.pink){let n=[];for(let t=0;t<ou;t++){let e=new Float32Array(cn);n[t]=e;let r,i,o,s,a,c,u;r=i=o=s=a=c=u=0;for(let l=0;l<cn;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,i=.99332*i+h*.0750759,o=.969*o+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,e[l]=r+i+o+s+a+c+u+h*.5362,e[l]*=.11,u=h*.115926}}vr.pink=new kt().fromArray(n)}return vr.pink},get white(){if(!vr.white){let n=[];for(let t=0;t<ou;t++){let e=new Float32Array(cn);n[t]=e;for(let r=0;r<cn;r++)e[r]=Math.random()*2-1}vr.white=new kt().fromArray(n)}return vr.white}};function me(n,t){return ht(this,void 0,void 0,function*(){let e=t/n.context.sampleRate,r=new Ye(1,e,n.context.sampleRate);return new n.constructor(Object.assign(n.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var ro=class n extends Ze{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],te(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new ot({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new ot({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),q(this,["frequency","detune"])}static getDefaults(){return Object.assign(Ze.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){let e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){this._oscillator.stop(t)}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),this.state==="started"&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}};var Rt=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),q(this,"frequency"),this.detune=new $({context:this.context,units:"cents",value:t.detune}),q(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(ft.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){let e=this.toSeconds(t),r=new ro({context:this.context,onended:()=>this.onstop(this)});this._oscillator=r,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){let e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){let e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if(this._type==="custom")return n._periodicWaveCache.find(e=>e.phase===this._phase&&om(e.partials,this._partials));{let t=n._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 e=["sine","square","sawtooth","triangle"].indexOf(t)!==-1;if(this._phase===0&&e)this._wave=void 0,this._partialCount=0,this._oscillator!==null&&(this._oscillator.type=t);else{let r=this._getCachedPeriodicWave();if(tt(r)){let{partials:i,wave:o}=r;this._wave=o,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[i,o]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(i,o);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),n._periodicWaveCache.push({imag:o,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),n._periodicWaveCache.length>100&&n._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&this._type!=="custom"&&t!=="custom"?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){Et(t,0);let e=this._type,r=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(r&&(e=r[1]),this._type!=="custom")t===0?this.type=e:this.type=e+t.toString();else{let i=new Float32Array(t);this._partials.forEach((o,s)=>i[s]=o),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(t,e){let i=2048,o=new Float32Array(i),s=new Float32Array(i),a=1;if(t==="custom"){if(a=this._partials.length+1,this._partialCount=this._partials.length,i=a,this._partials.length===0)return[o,s]}else{let c=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);c?(a=parseInt(c[2],10)+1,this._partialCount=parseInt(c[2],10),t=c[1],a=Math.max(a,2),i=a):this._partialCount=0,this._partials=[]}for(let c=1;c<i;++c){let u=2/(c*Math.PI),l;switch(t){case"sine":l=c<=a?1:0,this._partials[c-1]=l;break;case"square":l=c&1?2*u:0,this._partials[c-1]=l;break;case"sawtooth":l=u*(c&1?1:-1),this._partials[c-1]=l;break;case"triangle":c&1?l=2*(u*u)*(c-1>>1&1?-1:1):l=0,this._partials[c-1]=l;break;case"custom":l=this._partials[c-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}l!==0?(o[c]=-l*Math.sin(e*c),s[c]=l*Math.cos(e*c)):(o[c]=0,s[c]=0)}return[o,s]}_inverseFFT(t,e,r){let i=0,o=t.length;for(let s=0;s<o;s++)i+=t[s]*Math.cos(s*r)+e[s]*Math.sin(s*r);return i}getInitialValue(){let[t,e]=this._getRealImaginary(this._type,0),r=0,i=Math.PI*2,o=32;for(let s=0;s<o;s++)r=Math.max(this._inverseFFT(t,e,s/o*i),r);return Jc(-this._inverseFFT(t,e,this._phase)/r,-1,1)}get partials(){return this._partials.slice(0,this.partialCount)}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this.type="custom")}get phase(){return this._phase*(180/Math.PI)}set phase(t){this._phase=t*Math.PI/180,this.type=this._type}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Rt._periodicWaveCache=[];var un=class extends oe{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new de({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var Wt=class n extends ${constructor(){let t=T(n.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Z({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($.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var io=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new un({context:this.context}),this._modulationNode=new Z({context:this.context}),this._carrier=new Rt({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 Rt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Wt({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),q(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Rt.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}};var ln=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new Z({context:this.context,gain:0}),this._carrier=new Rt({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 $({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Rt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Wt({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Wt({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),q(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Rt.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}};var gi=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new Z({context:this.context,gain:0}),this._thresh=new de({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new $({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Rt({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),q(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(ft.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var no=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this.detune=new $({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,q(this,["frequency","detune"])}static getDefaults(){return Object.assign(Rt.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;e<this._oscillators.length;e++)t(this._oscillators[e],e)}get type(){return this._type}set type(t){this._type=t,this._forEach(e=>e.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){let e=-t/2,r=t/(this._oscillators.length-1);this._forEach((i,o)=>i.detune.value=e+r*o)}}get count(){return this._oscillators.length}set count(t){if(Et(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Rt({context:this.context,volume:-6-t*1.1,type:this._type,phase:this._phase+e/t*360,partialCount:this._partialCount,onstop:e===0?()=>this.onstop(this):et});this.type==="custom"&&(r.partials=this._partials),this.frequency.connect(r.frequency),this.detune.connect(r.detune),r.detune.overridden=!1,r.connect(this.output),this._oscillators[e]=r}this.spread=this._spread,this.state==="started"&&this._forEach(e=>e.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((e,r)=>e.phase=this._phase+r/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var oo=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Wt({context:this.context,value:2}),this._pulse=new gi({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Rt({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),q(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(ft.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(){return ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var gm={am:io,fat:no,fm:ln,oscillator:Rt,pulse:gi,pwm:oo},yi=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this.detune=new $({context:this.context,units:"cents",value:t.detune}),q(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Rt.getDefaults(),ln.getDefaults(),io.getDefaults(),no.getDefaults(),gi.getDefaults(),oo.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(e=>this._sourceType===e)&&(t=this._sourceType),t+this._oscillator.type}set type(t){t.substr(0,2)==="fm"?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,2)==="am"?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):t.substr(0,3)==="fat"?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):t==="pwm"?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):t==="pulse"?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;let e=gm[t],r=this.now();if(this._oscillator){let i=this._oscillator;i.stop(r),this.context.setTimeout(()=>i.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),this.state==="started"&&this._oscillator.start(r)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";this._oscillator.type!=="pwm"&&this._oscillator.type!=="pulse"&&(e=this._oscillator.type),t==="fm"?this.type="fm"+e:t==="am"?this.type="am"+e:t==="fat"?this.type="fat"+e:t==="oscillator"?this.type=e:t==="pulse"?this.type="pulse":t==="pwm"&&(this.type="pwm")}_getOscType(t,e){return t instanceof gm[e]}get baseType(){return this._oscillator.baseType}set baseType(t){!this._getOscType(this._oscillator,"pulse")&&!this._getOscType(this._oscillator,"pwm")&&t!=="pulse"&&t!=="pwm"&&(this._oscillator.baseType=t)}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(t){this._getOscType(this._oscillator,"fat")&&$t(t)&&(this._oscillator.count=t)}get spread(){if(this._getOscType(this._oscillator,"fat"))return this._oscillator.spread}set spread(t){this._getOscType(this._oscillator,"fat")&&$t(t)&&(this._oscillator.spread=t)}get modulationType(){if(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))return this._oscillator.modulationType}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&re(t)&&(this._oscillator.modulationType=t)}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 ht(this,arguments,void 0,function*(t=1024){return me(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function ks(n,t=1/0){let e=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Et(o,n,t),e.set(this,o)}})}}function fe(n,t=1/0){let e=new WeakMap;return function(r,i){Reflect.defineProperty(r,i,{configurable:!0,enumerable:!0,get:function(){return e.get(this)},set:function(o){Et(this.toSeconds(o),n,t),e.set(this,o)}})}}var so=class n extends ft{constructor(){let t=T(n.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new kt({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(ft.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:et,onerror:et,playbackRate:1,reverse:!1})}load(t){return ht(this,void 0,void 0,function*(){return yield this._buffer.load(t),this._onload(),this})}_onload(t=et){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),this._activeSources.size===0&&!this._synced&&this._state.getValueAtTime(this.now())==="started"&&(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,r){return super.start(t,e,r),this}_start(t,e,r){this._loop?e=Ae(e,this._loopStart):e=Ae(e,0);let i=this.toSeconds(e),o=r;r=Ae(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new ur({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Ft(o)?a.start(t,i):a.start(t,i,s-this.toSeconds(this.fadeOut))}_stop(t){let e=this.toSeconds(t);this._activeSources.forEach(r=>r.stop(e))}restart(t,e,r){return super.restart(t,e,r),this}_restart(t,e,r){var i;(i=[...this._activeSources].pop())===null||i===void 0||i.stop(t),this._start(t,e,r)}seek(t,e){let r=this.toSeconds(e);if(this._state.getValueAtTime(r)==="started"){let i=this.toSeconds(t);this._stop(r),this._start(r,i)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Et(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&Et(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){let e=this._state.getNextState("stopped",this.now());e&&this._state.cancel(e.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;let e=this.now(),r=this._state.getNextState("stopped",e);r&&r.implicitEnd&&(this._state.cancel(r.time),this._activeSources.forEach(i=>i.cancelStop())),this._activeSources.forEach(i=>{i.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}};ne([fe(0)],so.prototype,"fadeIn",void 0);ne([fe(0)],so.prototype,"fadeOut",void 0);var js=class extends oe{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new de({context:this.context,mapping:t=>Math.abs(t)*2-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}};var he=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new $({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(t,e){if(re(t))return t;{let r;for(r in Ps)if(Ps[r][e]===t)return r;return t}}_setCurve(t,e,r){if(re(r)&&Reflect.has(Ps,r)){let i=Ps[r];We(i)?t!=="_decayCurve"&&(this[t]=i[e]):this[t]=i}else if(Ot(r)&&t!=="_decayCurve")this[t]=r;else throw new Error("Envelope: invalid curve: "+r)}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._getCurve(this._decayCurve,"Out")}set decayCurve(t){this._setCurve("_decayCurve","Out",t)}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let i=this.toSeconds(this.attack),o=this.toSeconds(this.decay),s=this.getValueAtTime(t);if(s>0){let a=1/i;i=(1-s)/a}if(i<this.sampleTime)this._sig.cancelScheduledValues(t),this._sig.setValueAtTime(e,t);else if(this._attackCurve==="linear")this._sig.linearRampTo(e,i,t);else if(this._attackCurve==="exponential")this._sig.targetRampTo(e,i,t);else{this._sig.cancelAndHoldAtTime(t);let a=this._attackCurve;for(let c=1;c<a.length;c++)if(a[c-1]<=s&&s<=a[c]){a=this._attackCurve.slice(c),a[0]=s;break}this._sig.setValueCurveAtTime(a,t,i,e)}if(o&&this.sustain<1){let a=e*this.sustain,c=t+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,o+c):this._sig.exponentialApproachValueAtTime(a,c,o)}return this}triggerRelease(t){this.log("triggerRelease",t),t=this.toSeconds(t);let e=this.getValueAtTime(t);if(e>0){let r=this.toSeconds(this.release);r<this.sampleTime?this._sig.setValueAtTime(0,t):this._releaseCurve==="linear"?this._sig.linearRampTo(0,r,t):this._releaseCurve==="exponential"?this._sig.targetRampTo(0,r,t):(z(Ot(this._releaseCurve),"releaseCurve must be either 'linear', 'exponential' or an array"),this._sig.cancelAndHoldAtTime(t),this._sig.setValueCurveAtTime(this._releaseCurve,t,r,e))}return this}getValueAtTime(t){return this._sig.getValueAtTime(t)}triggerAttackRelease(t,e,r=1){return e=this.toSeconds(e),this.triggerAttack(e,r),this.triggerRelease(e+this.toSeconds(t)),this}cancel(t){return this._sig.cancelScheduledValues(this.toSeconds(t)),this}connect(t,e=0,r=0){return nn(this,t,e,r),this}asArray(){return ht(this,arguments,void 0,function*(t=1024){let e=t/this.context.sampleRate,r=new Ye(1,e,this.context.sampleRate),i=this.toSeconds(this.attack)+this.toSeconds(this.decay),o=i+this.toSeconds(this.release),s=o*.1,a=o+s,c=new this.constructor(Object.assign(this.get(),{attack:e*this.toSeconds(this.attack)/a,decay:e*this.toSeconds(this.decay)/a,release:e*this.toSeconds(this.release)/a,context:r}));return c._sig.toDestination(),c.triggerAttackRelease(e*(i+s)/a,0),(yield r.render()).getChannelData(0)})}dispose(){return super.dispose(),this._sig.dispose(),this}};ne([fe(0)],he.prototype,"attack",void 0);ne([fe(0)],he.prototype,"decay",void 0);ne([ks(0,1)],he.prototype,"sustain",void 0);ne([fe(0)],he.prototype,"release",void 0);var Ps=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let i=[],o=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*o-Math.PI/2)+1;i[t]=p/10+e*.83}i[127]=1;let s=[],a=5;for(t=0;t<128;t++)s[t]=Math.ceil(t/127*a)/a;let c=[];for(t=0;t<128;t++)e=t/127,c[t]=.5*(1-Math.cos(Math.PI*e));let u=[];for(t=0;t<128;t++){e=t/127;let p=Math.pow(e,3)*4+.2,m=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(m*(1-e))}function l(p){let m=new Array(p.length);for(let f=0;f<p.length;f++)m[f]=1-p[f];return m}function h(p){return p.slice(0).reverse()}return{bounce:{In:l(u),Out:u},cosine:{In:r,Out:h(r)},exponential:"exponential",linear:"linear",ripple:{In:i,Out:l(i)},sine:{In:c,Out:l(c)},step:{In:s,Out:l(s)}}})();var ve=class n extends j{constructor(){let t=T(n.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 ke({context:this.context,volume:t.volume}),this.volume=this._volume.volume,q(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 t=!1;return this._synced||(this._synced=!0,t=!0),t}_syncMethod(t,e){let r=this["_original_"+t]=this[t];this[t]=(...i)=>{let o=i[e],s=this.context.transport.schedule(a=>{i[e]=a,r.apply(this,i)},o);this._scheduledEvents.push(s)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease,this.context.transport.off("stop",this._syncedRelease),this.context.transport.off("pause",this._syncedRelease),this.context.transport.off("loopEnd",this._syncedRelease)),this}triggerAttackRelease(t,e,r,i){let o=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,o,i),this.triggerRelease(o+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var ge=class n extends ve{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(ve.getDefaults(),{detune:0,onsilence:et,portamento:0})}triggerAttack(t,e,r=1){this.log("triggerAttack",t,e,r);let i=this.toSeconds(e);return this._triggerEnvelopeAttack(i,r),this.setNote(t,i),this}triggerRelease(t){this.log("triggerRelease",t);let e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){let r=this.toSeconds(e),i=t instanceof le?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let o=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,o,r)}else this.frequency.setValueAtTime(i,r);return this}};ne([fe(0)],ge.prototype,"portamento",void 0);var hn=class n extends he{constructor(){super(T(n.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Z({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}};var lr=class n extends ge{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new yi(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 hn(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),q(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(ge.getDefaults(),{envelope:Object.assign(ze(he.getDefaults(),Object.keys(j.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(ze(yi.getDefaults(),[...Object.keys(ft.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),this.envelope.sustain===0){let r=this.toSeconds(this.envelope.attack),i=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+r+i)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}};var ao=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new ot({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new ot({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new ot({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new ot({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(t){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._filter.type=t}getFrequencyResponse(t=128){let e=new Float32Array(t);for(let s=0;s<t;s++){let c=Math.pow(s/t,2)*19980+20;e[s]=c}let r=new Float32Array(t),i=new Float32Array(t),o=this.context.createBiquadFilter();return o.type=this.type,o.Q.value=this.Q.value,o.frequency.value=this.frequency.value,o.gain.value=this.gain.value,o.getFrequencyResponse(e,r,i),r}dispose(){return super.dispose(),this._filter.disconnect(),this.Q.dispose(),this.frequency.dispose(),this.gain.dispose(),this.detune.dispose(),this}};var Ir=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new Z({context:this.context}),this.output=new Z({context:this.context}),this._filters=[],this._filters=[],this.Q=new $({context:this.context,units:"positive",value:t.Q}),this.frequency=new $({context:this.context,units:"frequency",value:t.frequency}),this.detune=new $({context:this.context,units:"cents",value:t.detune}),this.gain=new $({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,q(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(t){z(["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t)!==-1,`Invalid filter type: ${t}`),this._type=t,this._filters.forEach(r=>r.type=t)}get rolloff(){return this._rolloff}set rolloff(t){let e=$t(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],i=r.indexOf(e);z(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(o=>o.disconnect()),this._filters=new Array(i);for(let o=0;o<i;o++){let s=new ao({context:this.context});s.type=this._type,this.frequency.connect(s.frequency),this.detune.connect(s.detune),this.Q.connect(s.Q),this.gain.connect(s.gain),this._filters[o]=s}this._internalChannels=this._filters,Ee(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new ao({context:this.context,frequency:this.frequency.value,gain:this.gain.value,Q:this.Q.value,type:this._type,detune:this.detune.value}),r=new Float32Array(t).map(()=>1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((o,s)=>r[s]*=o)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),di(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var Ls=class n extends lr{constructor(){let t=T(n.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,q(this,["oscillator","envelope"])}static getDefaults(){return Me(ge.getDefaults(),lr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){let r=this.toSeconds(e),i=this.toFrequency(t instanceof le?t.toFrequency():t),o=i*this.octaves;return this.oscillator.frequency.setValueAtTime(o,r),this.oscillator.frequency.exponentialRampToValueAtTime(i,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};ne([ks(0)],Ls.prototype,"octaves",void 0);ne([fe(0)],Ls.prototype,"pitchDecay",void 0);var ym=new Set;function dn(n){ym.add(n)}function Fs(n,t){let e=`registerProcessor("${n}", ${t})`;ym.add(e)}var Bx=`
|
|
20
20
|
/**
|
|
21
21
|
* The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}.
|
|
22
22
|
*/
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
`;dn(
|
|
49
|
+
`;dn(Bx);var Gx=`
|
|
50
50
|
/**
|
|
51
51
|
* Abstract class for a single input/output processor.
|
|
52
52
|
* has a 'generate' function which processes one sample at a time
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
return !this.disposed;
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
`;dn(
|
|
116
|
+
`;dn(Gx);var Vx=`
|
|
117
117
|
/**
|
|
118
118
|
* A multichannel buffer for use within an AudioWorkletProcessor as a delay line
|
|
119
119
|
*/
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
return this.buffer[channel][readHead];
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
`;dn(
|
|
160
|
+
`;dn(Vx);var xm="feedback-comb-filter",qx=`
|
|
161
161
|
class FeedbackCombFilterWorklet extends SingleIOProcessor {
|
|
162
162
|
|
|
163
163
|
constructor(options) {
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
return delayedSample;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
`;
|
|
190
|
+
`;Fs(xm,qx);var Bs=class n extends ve{constructor(){let t=T(n.getDefaults(),arguments,["voice","options"]);super(t),this.name="PolySynth",this._availableVoices=[],this._activeVoices=[],this._voices=[],this._gcTimeout=-1,this._averageActiveVoices=0,this._syncedRelease=i=>this.releaseAll(i),z(!$t(t.voice),"DEPRECATED: The polyphony count is no longer the first argument.");let e=t.voice.getDefaults();this.options=Object.assign(e,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(ve.getDefaults(),{maxPolyphony:32,options:{},voice:lr})}get activeVoices(){return this._activeVoices.length}_makeVoiceAvailable(t){this._availableVoices.push(t);let e=this._activeVoices.findIndex(r=>r.voice===t);this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.length<this.maxPolyphony){let t=new this.voice(Object.assign(this.options,{context:this.context,onsilence:this._makeVoiceAvailable.bind(this)}));return z(t instanceof ge,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}else li("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 t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,r){t.forEach(i=>{let o=new eo(this.context,i).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(i,e,r),this._activeVoices.push({midi:o,voice:s,released:!1}),this.log("triggerAttack",i,e))})}_triggerRelease(t,e){t.forEach(r=>{let i=new eo(this.context,r).toMidi(),o=this._activeVoices.find(({midi:s,released:a})=>s===i&&!a);o&&(o.voice.triggerRelease(e),o.released=!0,this.log("triggerRelease",r,e))})}_scheduleEvent(t,e,r,i){z(!this.disposed,"Synth was already disposed"),r<=this.now()?t==="attack"?this._triggerAttack(e,r,i):this._triggerRelease(e,r):this.context.setTimeout(()=>{this.disposed||this._scheduleEvent(t,e,r,i)},r-this.now())}triggerAttack(t,e,r){Array.isArray(t)||(t=[t]);let i=this.toSeconds(e);return this._scheduleEvent("attack",t,i,r),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);let r=this.toSeconds(e);return this._scheduleEvent("release",t,r),this}triggerAttackRelease(t,e,r,i){let o=this.toSeconds(r);if(this.triggerAttack(t,o,i),Ot(e)){z(Ot(t),"If the duration is an array, the notes must also be an array"),t=t;for(let s=0;s<t.length;s++){let a=e[Math.min(s,e.length-1)],c=this.toSeconds(a);z(c>0,"The duration must be greater than 0"),this.triggerRelease(t[s],o+c)}}else{let s=this.toSeconds(e);z(s>0,"The duration must be greater than 0"),this.triggerRelease(t,o+s)}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(t){let e=ze(t,["onsilence","context"]);return this.options=Me(this.options,e),this._voices.forEach(r=>r.set(e)),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){let e=this.toSeconds(t);return this._activeVoices.forEach(({voice:r})=>{r.triggerRelease(e)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(t=>t.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}};var Gs=class n extends ve{constructor(){let t=T(n.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");super(t),this.name="Sampler",this._activeSources=new Map;let e={};Object.keys(t.urls).forEach(r=>{let i=parseInt(r,10);if(z(Kn(r)||$t(i)&&isFinite(i),`url key is neither a note or midi pitch: ${r}`),Kn(r)){let o=new le(this.context,r).toMidi();e[o]=t.urls[r]}else $t(i)&&isFinite(i)&&(e[i]=t.urls[i])}),this._buffers=new sn({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(ve.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:et,onerror:et,release:.1,urls:{}})}_findClosest(t){let r=0;for(;r<96;){if(this._buffers.has(t+r))return-r;if(this._buffers.has(t-r))return r;r++}throw new Error(`No available buffers for note: ${t}`)}triggerAttack(t,e,r=1){return this.log("triggerAttack",t,e,r),Array.isArray(t)||(t=[t]),t.forEach(i=>{let o=tu(new le(this.context,i).toFrequency()),s=Math.round(o),a=o-s,c=this._findClosest(s),u=s-c,l=this._buffers.get(u),h=mi(c+a),p=new ur({url:l,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:h}).connect(this.output);p.start(e,0,l.duration/h,r),Ot(this._activeSources.get(s))||this._activeSources.set(s,[]),this._activeSources.get(s).push(p),p.onended=()=>{if(this._activeSources&&this._activeSources.has(s)){let m=this._activeSources.get(s),f=m.indexOf(p);f!==-1&&m.splice(f,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(r=>{let i=new le(this.context,r).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){let o=this._activeSources.get(i);e=this.toSeconds(e),o.forEach(s=>{s.stop(e)}),this._activeSources.set(i,[])}}),this}releaseAll(t){let e=this.toSeconds(t);return this._activeSources.forEach(r=>{for(;r.length;)r.shift().stop(e)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,r,i=1){let o=this.toSeconds(r);return this.triggerAttack(t,o,i),Ot(e)?(z(Ot(t),"notes must be an array when duration is array"),t.forEach((s,a)=>{let c=e[Math.min(a,e.length-1)];this.triggerRelease(s,o+this.toSeconds(c))})):this.triggerRelease(t,o+this.toSeconds(e)),this}add(t,e,r){if(z(Kn(t)||isFinite(t),`note must be a pitch or midi: ${t}`),Kn(t)){let i=new le(this.context,t).toMidi();this._buffers.add(i,e,r)}else this._buffers.add(t,e,r);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(e=>e.dispose())}),this._activeSources.clear(),this}};ne([fe(0)],Gs.prototype,"attack",void 0);ne([fe(0)],Gs.prototype,"release",void 0);var mn=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new js({context:this.context}),this.a=new Z({context:this.context,gain:0}),this.b=new Z({context:this.context,gain:0}),this.output=new Z({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new $({context:this.context,units:"normalRange",value:t.fade}),q(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",te(this._split,this.a.gain,0),te(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}};var ye=class extends j{constructor(t){super(t),this.name="Effect",this._dryWet=new mn({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Z({context:this.context}),this.effectReturn=new Z({context:this.context}),this.input=new Z({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],q(this,"wet")}static getDefaults(){return Object.assign(j.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}};var co=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new ot({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",q(this,"pan")}static getDefaults(){return Object.assign(j.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var Am="bit-crusher",Xx=`
|
|
191
191
|
class BitCrusherWorklet extends SingleIOProcessor {
|
|
192
192
|
|
|
193
193
|
static get parameterDescriptors() {
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
return val;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
`;Ls(bm,Hx);var Yr=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["channels"]);super(t),this.name="Merge",this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(L.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}};var nJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var pJ=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var Vs=class n extends ye{constructor(){let t=T(n.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Et(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Et(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(ye.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Et(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Et(t,0),this._preDelay=t,this.generate()}generate(){return ht(this,void 0,void 0,function*(){let t=this.ready,e=new He(2,this._decay+this._preDelay,this.context.sampleRate),r=new gi({context:e}),i=new gi({context:e}),o=new Yr({context:e});r.connect(o,0,0),i.connect(o,0,1);let s=new H({context:e}).toDestination();o.connect(s),r.start(0),i.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=e.render();return this.ready=a.then(et),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var fn=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new H({context:this.context}),n._allSolos.has(this.context)||n._allSolos.set(this.context,new Set),n._allSolos.get(this.context).add(this),this.solo=t.solo}static getDefaults(){return Object.assign(L.getDefaults(),{solo:!1})}get solo(){return this._isSoloed()}set solo(t){t?this._addSolo():this._removeSolo(),n._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){n._soloed.has(this.context)||n._soloed.set(this.context,new Set),n._soloed.get(this.context).add(this)}_removeSolo(){n._soloed.has(this.context)&&n._soloed.get(this.context).delete(this)}_isSoloed(){return n._soloed.has(this.context)&&n._soloed.get(this.context).has(this)}_noSolos(){return!n._soloed.has(this.context)||n._soloed.has(this.context)&&n._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),n._allSolos.get(this.context).delete(this),this._removeSolo(),this}};fn._allSolos=new Map;fn._soloed=new Map;var qs=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new oo({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new je({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,q(this,["pan","volume"])}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var uu=class n extends L{constructor(){let t=T(n.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new fn({solo:t.solo,context:this.context}),this._panVol=this.output=new qs({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),q(this,["pan","volume"])}static getDefaults(){return Object.assign(L.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return n.buses.has(t)||n.buses.set(t,new H({context:this.context})),n.buses.get(t)}send(t,e=0){let r=this._getBus(t),i=new H({context:this.context,units:"decibels",gain:e});return this.connect(i),i.connect(r),i}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};uu.buses=new Map;var tit=Bt().transport;var eit=Bt().destination,rit=Bt().destination;var iit=Bt().listener;var nit=Bt().draw;var oit=Bt();var lu=class{constructor(){d(this,"audioSource");try{let t=new Vs({decay:3,wet:.4}).toDestination(),e=new Ir(800,"lowpass").connect(t);this.audioSource=new Ps(lr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(e)}catch(t){this.audioSource=void 0,console.error(t)}}getName(){return"Synthesizer"}playNote(t,e,r){try{this.audioSource&&(r!==void 0&&(this.audioSource.volume.value=A.Math.linearToDecibels(r)),this.audioSource.triggerAttackRelease(t,e!=null?e:"2n"))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},hu=new lu;ei();function eb(n){return typeof n=="string"?n:(typeof n=="number"&&(n=W.getChromaticNote(n)),n.format(0,0))}var Ws=[hu],gn=hu;function rb(){return Ws.map(n=>n.getName())}function ib(){return gn.getName()}function nb(n){Ws.some(t=>t.getName()===n.getName())||(Ws.push(n),Cm(n.getName()))}function Cm(n){if(n===gn.getName())return;gn.stop();let t=Ws.find(e=>e.getName()===n);t&&(gn=t)}function Us(n,t,e){gn.playNote(eb(n),t,e)}function pu(){gn.stop()}var Iu={};Ni(Iu,{Annotation:()=>xn,Arpeggio:()=>Hr,Clef:()=>Sr,Connective:()=>Zr,DivRect:()=>B,DocumentBuilder:()=>Or,Fermata:()=>co,Label:()=>uo,MAccidental:()=>ho,MArpeggio:()=>fo,MBarLineLeft:()=>Oo,MBarLineRight:()=>No,MBeamGroup:()=>bo,MConnective:()=>ko,MDocument:()=>Kr,MEnding:()=>Mo,MExtensionLine:()=>Eo,MFermata:()=>Do,MHeader:()=>Go,MImage:()=>lo,MMeasure:()=>Lo,MNoteGroup:()=>Co,MPlaybackButtons:()=>_u,MPlayer:()=>Uo,MRenderer:()=>Cu,MRest:()=>go,MRhythmColumn:()=>Io,MScoreRow:()=>Bo,MSignature:()=>mo,MSpecialText:()=>So,MStaff:()=>Po,MStaffBeamGroup:()=>Ao,MStaffNoteGroup:()=>_o,MStaffRest:()=>yo,MStaffTabBarLine:()=>Ro,MTab:()=>Fo,MTabNoteGroup:()=>vo,MText:()=>po,MusicInterface:()=>bt,Navigation:()=>Je,NoteAnchor:()=>Le,PlayState:()=>Ys,ScoreEvent:()=>Vo,ScoreObjectEvent:()=>Ai,ScoreStaffPosEvent:()=>bi,StaffPreset:()=>yn,Stem:()=>Qe,TieType:()=>Ke,VerticalPosition:()=>ao,getStringNumbers:()=>zs,getVoiceIds:()=>se});var B=class n{constructor(...t){d(this,"left");d(this,"centerX");d(this,"right");d(this,"top");d(this,"centerY");d(this,"bottom");if(t.length===6)this.left=t[0],this.centerX=t[1],this.right=t[2],this.top=t[3],this.centerY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.centerX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.centerY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.centerX=this.right=0,this.top=this.centerY=this.bottom=0;else throw new O(1,`Invalid DivRect args: ${t}`)}static create(t,e,r,i){return new n(t,t+r,e,e+i)}static createCentered(t,e,r,i){return new n(t-r/2,t+r/2,e-i/2,e+i/2)}static createSections(t,e,r,i){return new n(-t,0,e,-r,0,i)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.centerX-this.left}get rightw(){return this.right-this.centerX}get toph(){return this.centerY-this.top}get bottomh(){return this.bottom-this.centerY}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.centerX===e.centerX&&t.right===e.right&&t.top===e.top&&t.centerY===e.centerY&&t.bottom===e.bottom}static equalsFrame(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}copy(){return new n(this.left,this.centerX,this.right,this.top,this.centerY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.centerX+=t,this.right+=t,this.top+=e,this.centerY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.copy().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.copy().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.centerX=A.Math.clamp(this.centerX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.centerY=A.Math.clamp(this.centerY,this.top,this.bottom),this}clipCopy(t){return this.copy().clipInPlace(t)}scaleInPlace(t,e){return e=e!=null?e:t,this.left=this.centerX-this.leftw*t,this.right=this.centerX+this.rightw*t,this.top=this.centerY-this.toph*e,this.bottom=this.centerY+this.bottomh*e,this}scaleCopy(t,e){return this.copy().scaleInPlace(t,e)}getRect(){return this}};var yn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(yn||{}),Sr=(e=>(e.G="G",e.F="F",e))(Sr||{});function se(){return[0,1,2,3]}function zs(){return[1,2,3,4,5,6]}var Qe=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(Qe||{}),Hr=(e=>(e.Up="up",e.Down="down",e))(Hr||{}),Ke=(e=>(e.Stub="stub",e.ToMeasureEnd="toMeasureEnd",e))(Ke||{}),Le=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(Le||{}),Zr=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(Zr||{}),ao=(i=>(i.Auto="auto",i.Above="above",i.Below="below",i.Both="both",i))(ao||{}),co=(e=>(e.AtNote="atNote",e.AtMeasureEnd="atMeasureEnd",e))(co||{}),Je=(h=>(h.DC_al_Fine="D.C. al Fine",h.DC_al_Coda="D.C. al Coda",h.DS_al_Fine="D.S. al Fine",h.DS_al_Coda="D.S. al Coda",h.Coda="Coda",h.toCoda="toCoda",h.Segno="Segno",h.Fine="Fine",h.StartRepeat="startRepeat",h.EndRepeat="endRepeat",h.Ending="ending",h))(Je||{}),xn=(e=>(e.Dynamics="dynamics",e.Tempo="tempo",e))(xn||{}),uo=(e=>(e.Note="note",e.Chord="chord",e))(uo||{}),Ys=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(Ys||{});var Hs=class{constructor(t){d(this,"head");d(this,"tail");this.head=t,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(t){this.tail.push(t)}detachTail(t){let e=this.tail.indexOf(t);e>=0&&this.tail.splice(e,1)}},it=class{constructor(t){this.parent=t;d(this,"anchoredLayoutObjects",[]);d(this,"link");d(this,"rect",new B);d(this,"needRectUpdate",!0)}getParent(){return this.parent}requestRectUpdate(){this.needRectUpdate=!0}updateRect(){}getRect(){return this.needRectUpdate&&(this.updateRect(),this.needRectUpdate=!1),this.rect}getShapeRects(){return[this.rect]}addAnchoredLayoutObject(t){this.anchoredLayoutObjects.push(t)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(t){this.link=t}getLink(){return this.link}isLinked(){return this.link!==null}};var Zs={DrawDebugRects:!1,DisableBeams:!1},at={DocumentScale:1,DocumentMinWidth:75,PostMeasureBreakWidth:10,NoteDotSpace:.5,NoteAccSpace:.5,NoteHeadWidth:2,NoteHeadHeight:1.3,DiamondNoteHeadSize:1.8,DotSize:.8,StemHeight:7,FlagWidth:1.5,FlagHeight:4,FlagSeparation:2,BeamSeparation:1.25,BeamAngleFactor:.5,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var _m="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYAAACCe+v6AAADHXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZZRcu0mDIbfWUWXgCSExHIwmJnu4C6/Pxg7J2kyTdv7GJhjsJCF0CfZJ5y//hzhDzRK5iGpeS45R7RUUuGKicerHetKMa3ratL2Gr2Xh5L3AkMkU/O6LbzlJ+SY074vexO69W9D94QqZvq2UOuWH+/lxzbI/tHQ9kDo2jn2/cA2JLw9Std92x7l4vbuaH2fGYqXyN9+SYyzZrKEa+JolgvmzjEZ4tmno6NxWYb0CugjuO9vVYZPfApJxFUkXV7K/IlUjBlXrAYokhhuFMK5UFbgI1DCBXha9kY1PsF8jc1bjL5o3zlWxCbjnMov1J7xQ97k/HnePLOdBg81z3tB3mON+Rk/lZPehu4Fefbh1529PTu/k4vE9BqK8Ip7jO5jHRqnqCkjFnkf6j7KmkHvmFFcT2V0izkgax2T2Qu6xxobcqrHhko7MC/EoDsoUadKg841NmpwMfHJhpG5BZYldEAq3GQmQ5qdBpsU6eLImHblkPDjC61ty9qukcceYieoMsEY4ZH/3MN3FceYtUQU/YoT0gJ+8axOeBEJ+OcANTCgsYOqK8B3/9gm18lMV5gdB6zxCJeJQ+ktuWSBFigqxgsyWd8GECJsrXCGBARiJlHK8MiYjQiBdACqcJ0l8QECpModTnISyYCD6sDeeMZoqbLyJcZbVVJAsWYUrYNQBayUFPljyZFDVUWTqmY1dS1as+RZeTlbnq/namLJ1LIZ3tlWrLp4cvXs5u7Fa+EieH1rQZ0WL6XUik0rLFc8XaFQ68GHHOnQIx92+FHCURvSp6WmLTdr3kqrnbt0FHjP3br30utJJ1LpTKee+bTTz3LWgVQbMtLQkYeF4aOM+lCjXbYf+7+gRpsaL1JT0R5qkJrdJmi+TnQyAzFOBOAGaiCGxJ7MolNKPMlNZvgeoSqU4aROOJ0mMRBMJ7EOethtcoHr7+EWzBc3/r/kwkT3TXJ/5/YZtT6/Em0Ru8pwBjUKqg/rp1f2Oj+vX47hnxS+O/4Y+jH0Y+jrcYwROv51hb8AKbCqdGIdCl0AAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDQBzFX1O1UqoOdhBxyFCd7OAH0rFUsQgWSluhVQeTS7+gSUOS4uIouBYc/FisOrg46+rgKgiCHyCuLk6KLlLi/5JCi1gPjvvx7t7j7h0gNCpMNXuigKpZRioeE7O5VdH3ij74MYgpRCRm6on0YgZdx9c9PHy9C/Os7uf+HANK3mSARySOMt2wiDeI5zYtnfM+cZCVJIX4nHjSoAsSP3JddvmNc9FhgWcGjUxqnjhILBY7WO5gVjJU4lnikKJqlC9kXVY4b3FWKzXWuid/YSCvraS5TnMMcSwhgSREyKihjAoshGnVSDGRov1YF/+o40+SSyZXGYwcC6hCheT4wf/gd7dmYWbaTQrEgN4X2/4YB3y7QLNu29/Htt08AbzPwJXW9lcbQOST9HpbCx0BQ9vAxXVbk/eAyx1g5EmXDMmRvDSFQgF4P6NvygHDt4B/ze2ttY/TByBDXS3fAAeHwESRste7vLu/s7d/z7T6+wEMNXLkxtwRywAADzRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDA3ODVjMzYtNDAxZC00YTZlLTkxODctMDQ1NTI4MmM0ZGY2IgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjhiZTJkYzc1LTVlYjQtNDk0Yy1iNWRlLWQ2MzZkNzZhNjI2YiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmU3YWE0MWNhLTNiYjMtNGU5Yi05NDQxLTllNTNmZTJiZjM5ZiIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IldpbmRvd3MiCiAgIEdJTVA6VGltZVN0YW1wPSIxNjg2NDA4NjA5MzE2NDM4IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzQiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIgogICB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzOjA2OjEwVDE3OjUwOjA5KzAzOjAwIgogICB4bXA6TW9kaWZ5RGF0ZT0iMjAyMzowNjoxMFQxNzo1MDowOSswMzowMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjI3MzY2YmY0LWVkZDMtNDE5OC05NjJhLWU5ZTM5MTBlNThiZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOC0yMlQwMjo1NTozNiIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NjVlMTM3OS0wZDlmLTQ5ODItYWQ3MC05MzhjOWMzOWE0ZjMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjItMDktMTFUMTY6MzU6MDAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MTBmYmEwYTMtOTI5Yi00NTRlLThjNGMtOGVkOGM4YWJhZGRjIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEwVDE3OjUwOjA5Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Ppn4NIQAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgoOMgm5WlWBAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAACHtJREFUeNrtnXuQVmMcxz+77cauTWUpbGSVu2w3BpnUEBq3chkmBjGayG1GBuNWLtUgw5SJkBkjl4QKg1wyQyarK0lRSlstU20bWam9+OM8O3P6vc8553nOe97tnO18Z84f57zP7XvOc/ndnueFfQx5e6neUmAI0B3oDPwD/AJ8Dvzcml5we+Al4D+gyeOaB1S0BrLHAut9iLqvf4ERSSZbBmwwJOu+RieV8JwQZJuARjXWE4WBIck2X38AByaJ8MwsCTcBTyWFbCFQFwHhv4DiKBqUn2PCPYEin9+bgI3AUuBPn3TtgMuT8IWv8vlq7wLdRPrTgPke6d9JAuFbPBo/3UfKK1TCh8yzIQmEb/cYjx0C8pUDuzV5D477GN6mefY+UBuQby0wV/O8U9wJr9E8W2iY92vNs45xJ6zTfKoN827UPNsdd8K1SlJyo8Awb7XhEIkVYYAVmjXVBPtr1uyqJBBeLu5LDPMdppkPdiaRcHvDfKeJ+++SIFoCLBP3R1toWW58lhQFogiodwkPlYZf1y1w/AcclCQVcYWQtILwqiA8M2lGgDcFgSN90nbXiJUXRdWQ/BYiLMdxH5+0k8VavRb4JGmEl4j7vh7pRgDni2fj1RyQKBwiuqjui/Un015dBbQloXCbaTdrZuUajTp4IwnGbEHmKPX8QmCHhuwC9p4rKBI8IghdB0zCsT1Lsg0+4zwxuEiQqqcVmGWDlAETk+zSJE9Ublyjuqof2TrgxKQT7anMNSZfd1iSiZYCUwy+avP1dJLJXglsxdyV8hHQJolEDwBewc5v9J3Klzj0xYnTsCG7W4mdicMdwC7CeQaPTBLRAjUxZeMKvSwpZPcDPghBUGpE45JAthjH92NLdiUwSDz7NO5k24YkuwTHGZYvtKMtcSabD7wVguy37OkilU7v8rgSfjoE2c816+wkkebKOJK9NgTZ2Wpykxgu0k2IG9lTcMIBbchOx9tTWKHpBbFBoZpwbMi+iL9FtEC8wG1xIvyQJdlJhuVWinzd4kD2cJxYZlOyky3KfkHkvSoOhF+2IPu8Zdk3x82O1QV96JDumhJSu5KB4XsVEwzJziCcy2Z/8UK3K5G1PZnhDi2iBW02IDvPY501xY8BuvJ6JcY+AQzAPCDGGucZkF2GefiCxFk4AWoN2K0AG4HHiSBATWJqQMXr1Qxui3Jlv8o2nHiHIl4UFeF1+G/ACOMGuZVoYqfd12qgX7ZkuwZUMjyEoWBaxETd1y5gVDaEr/YpfGqIyW9ODsm6r7FhCY/z6T625tTpLUS2+bo3DOHZHoVdYFnOqBYmG3rbz1JNQbZ2p2MsZfAor604G8OMsUVTyEBLwjMsv4r7vkapl28AH+PEWNqu1++ZNjRPk3mFJdnjDBu4HBipVoUGsewVaGb6fjgRPSsMSQ8wNb/KjA9bEp5osIzcLUitEml6BNQxxGPoWVtROmoynmFJ+CefRvytxFaJt0W6GwwtqE8GkA56cZSSGVxiI74FhTUM9ch3f0irCerleNU3wbZL2xrJzwhp+hks0s6PaBitMsnsXk7WWlY8xKPi7fjvOZI94x/sHOQFPobGw+U4kHBvrrDVRrw2RE4L6C3V7Ln3sBg43qLeeuAxj996BxHeJCYxm2i4Gh8RMwjL/BpqgA/VpKgTgnwJuzdXtbWUWpZpntUCiwwlPDf6WBLeBSzWPO8URFjuHOthUWm1ptJFaizZErb9wvJjNaMkiLDck2CrYD8n7k13hUrCvUIYB3Vdui6I8FI1qzbjUstKXwe+EV3aBKtE40pwjsKwwQEeuoEv4d3ALNf9ycCpFpU24ngRVrvkYNN8y7Ps1rqlb3MQYXCc3m7YytOb1FCYa2lhzHbiqjAoU4s2GoG+D+Fg85VGijq/ssh7qEboqLGZB6QDvBLHdZpLnK6R0EzlgNs0hGfZVJ6v1lV3ARNzTLhYo0sfY5h3sYWy4ole7Blh16ismrnEStFok/ou05BdR8iA1QfJDN2/PoeEZZTQkwZL0RoN4bvCNiCPzONlGpVJNBe7Tu4TdX1h2bbmmLCCbMfWAvTew6iDQy/QzLReZJ/RtKk+pFiagXZqmdCdyzGG8J5Eic6aOuSe4yK8A+RGRfn2/SqqwdmbVBZBPX/gHbh2MfAbEbtbTAQEr7itehyX6DDCn6zyCZlhUHcoTc7Ltj2WHKNcLexBRvaFaqxdr0Q/k2OixmNudN9uo+BEMcsOAB4AzrXIU6vUxlrVU3YqJaMEOELZoUzW0PeBezz04JyjN07o0mZy7zD7EjiTmKAQOAfHJlyJ/xmWtsHlo1UPCI28FnoBJym9urtaYspwdrOUKkmprerC/6pl7lel/HdxlTORBB/7aIJnLSQuK40orlisUWRaNXpoxnHX1ky4DZlhTkNbc5duwAlNjLRb58f8Ky/e1wgv2dcmrr6aiSur3agFOWxsL6XM91a6crUSCWfi+H9NoDtEsIKY7YI52sNQ4D5uZpBFeTKMamScyJqeFL4L8yOjfhB5x8Rp0ppoaPEoBF4j86A/HerEfUlcCB8GXGGRvqPSZYPQIeAF7DXC/bE3fJsY2eWsvCEuhMtC9oouAROgPPxveVwIN4TM53f08tnifgfmh/nmnPC6kPk2+fx2k7ifpWb4WKAT9mG+foFvMqqvkRj+pYntFp0HPMrZj8wg1VieEd8Tc6NdFXr3TCFOgLc77TZifE7AaAOyv+MY9iS64pxBK7vyJXHWcLy8eu4T0dybo9vhBMBMJvMwwEbgzqSodnfhvxOtDieQzOv3ncRkE7UNytV4tJ295+LsnUgsugKPAt/jvQm7DmcX2+Bcj7eWRjFwAo4rtYOa1avUMrSTFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIgL8D6ed2EKeJMaTAAAAAElFTkSuQmCC";var vm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABGCAYAAACQRffVAAADInpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7VdbktwgDPznFDkCkgCJ4/AwVblBjp8GY+/OZFPZPD7yMVADWIiWUEt2jTu+fR3uCxplTi5EtZRT8mghh8wFC/Nnq2skH9a4mrS9R49yF9LeYIhkap6Pmbf8gBxr2s95G6FL/wK6FlSwim8bpWx5fZTXDcj2DLQ3hE7Lvu8DG0h4exTO57Y9Stn04Wp93xmKp8jefkGUU0ykAWNgr5oy1sY+KOLZp6PcznP31S7B9XypMnziQ0g8RpFweinzJ1IwJ4wk4qA4hUXiGlmWGTiUEG4Fbj6BR/F3MN/H5i1GP2mfuZaHkXFM5XdXu+envOn147y5VzsN3JU3lvaGPNLq0z1/KKd4AV0bctvh95at3ZYf5ENWdt3Nvad7jG5jXRq3KCEhFmlf6rrKWkGvziiuUwldfXLANSxmz+jmi2/Iqe4bKq1inYnB/aBAnQoNOtbcqMHFwAcrZubmWJbQQFLmhlQgCbPTYJUsXQwp0c4cEr59oWU2L3ONzHfnO0GVCWCEI3/c3WcVx5i1ROTtjBM8g188qxNeeAL9c4IaGKGxgxpXgK/+3CavAgbjCrPhgsVXd0LUSG/JJYvoSW/EfFY9ad8ACBFMRzhDAgZ8IomU4JEyKxECaSCowHWWwBUMUIzc4SQHkQRyUB2wjTNKS5Ujn2K8VSU4FGsSBTdZCsgKISJ/NBhyqESJIcaYokaLOZYkaVZeSprm67moaNCoSVXNadZiYsGiJVMzy1YyZ8HrO2bUabaccykwWoBccLpAoZTKVWqosaaq1Wp2tTSkTwstttS0WcutdO7SUeA9de3Wcy8HHUilIxzxSIceduSjDKTakBFGHGmoGzbyKDdrtMv2uf8Ga7RZ48XUVNSbNUhVLwiar5M4OQNjHAiEK1gDY0jsyZk3CoEnc5MzfI9QFZHhZJzkdJqMgcFwEMdBN3ebOcfl3/Dm1BZv/LfMuUndJ5n7kbePWOvzK9EWY2cZzqB6QfVh/7DCVubn9aez+5XCZ+cX0AvoBfQCegG9gP57oIEPJ/4Bue+bLIaQwqExNwAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNAHMVfU7UiFQeLijhkqE4WREUcSxWLYKG0FVp1MLn0Q2jSkKS4OAquBQc/FqsOLs66OrgKguAHiKuLk6KLlPi/pNAixoPjfry797h7Bwj1MlPNjiigapaRisfEbG5FDLyiC0EMYgIDEjP1RHohA8/xdQ8fX+8iPMv73J+jV8mbDPCJxFGmGxbxOvHMpqVz3icOsZKkEJ8Tjxt0QeJHrssuv3EuOizwzJCRSc0Rh4jFYhvLbcxKhko8TRxWVI3yhazLCuctzmq5ypr35C8M5rXlNNdpjiCORSSQhAgZVWygDAsRWjVSTKRoP+bhH3b8SXLJ5NoAI8c8KlAhOX7wP/jdrVmYmnSTgjGg88W2P0aBwC7QqNn297FtN04A/zNwpbX8lTow+0l6raWFj4C+beDiuqXJe8DlDjD0pEuG5Eh+mkKhALyf0TflgP5boGfV7a25j9MHIENdLd0AB4fAWJGy1zze3d3e279nmv39ANCccsygwwDVAAAQE2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDo0MDc4NWMzNi00MDFkLTRhNmUtOTE4Ny0wNDU1MjgyYzRkZjYiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Nzg3YjYxN2YtMjg1MS00YzhlLTg2MTYtZWM3NGMwYzYwMWVlIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZTdhYTQxY2EtM2JiMy00ZTliLTk0NDEtOWU1M2ZlMmJmMzlmIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iV2luZG93cyIKICAgR0lNUDpUaW1lU3RhbXA9IjE2ODY2MTM5NDcxOTU2ODAiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zNCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiCiAgIHhtcDpNZXRhZGF0YURhdGU9IjIwMjM6MDY6MTNUMDI6NTI6MjUrMDM6MDAiCiAgIHhtcDpNb2RpZnlEYXRlPSIyMDIzOjA2OjEzVDAyOjUyOjI1KzAzOjAwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MjczNjZiZjQtZWRkMy00MTk4LTk2MmEtZTllMzkxMGU1OGJlIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIyLTA4LTIyVDAyOjU1OjM2Ii8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjk2NWUxMzc5LTBkOWYtNDk4Mi1hZDcwLTkzOGM5YzM5YTRmMyIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOS0xMVQxNjozNTowMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMGZiYTBhMy05MjliLTQ1NGUtOGM0Yy04ZWQ4YzhhYmFkZGMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMDYtMTBUMTc6NTA6MDkiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDBmYjM4YTMtZjZiMi00NjQ1LTliMTYtMjlhNWE0ODZlMjhhIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEzVDAyOjUyOjI3Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/PsIRrtIAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgwXNBsqJURsAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAABF9JREFUeNrtmluIF1Ucxz9/E8P1VnnJ9dJWC4Frmq2JJmqolGEILoQvK2gZeXlRCSm1Fx9UEsJQERWsXhRftECs0Gq70EK9ZHlbFyHbds3VVXFX91+7664P81tYhpnfmft//st84TzMzDm/8/vOnPO7nYEMGTJkyJAhQ4YMGSJBLkJZw4FyYAIwDHgU+A9oAxqBv4C7xfyySoBlwKfAFaAb6DG0euAzoAoYXCxEnwH2A60eCGrtFrALGJNWokNEwY6QRO2tFXgPGJAmss8DlyImam/fASPTQHaeGJueBFod8FQhrfSLwM+ynDX8L1/oV+BP4LZY58eBUUAlMB94ycPSvQTMERmJ4jGgwYPh2Qg84VFmGbAP6DTI/aoQS/lzg1JfA2MDyn4ZuGaQvyZJspUGv3oKGBhyjmeBJmWOmxLMJIITiiIXIgwaZgFdylxbDeNHANXAZmAVUBpEiScNe2xRxC/3Y2WuRmUlLRHD1rd/HljvV4F3FAVqYlhNo4B7Pl/wdPEMbmOq/ShwRBH0Vkxb6LAy536fW64HuOpn8vOKoLKYCC9Q5rzs0L/JQxDjyYPkgHYXAW0xGslByrLuFuPUFw0eCI92mmiAQ4LgZoEbYyTcAZxVPsJk271ag7x6cWueCLvhfsyu8LzybKLtersUF9ywxe2BnXBnAZOUJuXZeNv1OSki3LLdzwPrgONuguw+7g7wAHjEoW+vEagAXgeelr1yUSZoCUn4hvJsqMO9byRaWyLGtFkiwOtBJnYzBKcVg/ZuSMIrlHl3RrWMnFK1OqX/q8oXOAisDqFLVxL7xonw9yHk7Q5RoxpuyLdjI3wmhLzBwMqAY0ck4SGcCNeKIQqKOTF84RtxEu4BPgohc2QM467HSRjgqBL5mBDUPU1Rnl1JwqBNUuJqrW0M+OLdYuk8Cdas38Rf4b3FR0HP/nLdZNYaioKbxSVuA6ZGQfoNvNWlO6VvEKxW5O5yGbNc4ml7ZrUtCtLjgGMSdjop9Q+wMIT8GoXwKw79ZxrKUG9r+a8flMoyr5AA4ybwo1QgggYHpZJ6Ou3Ta5IpddvufwEsVWQ2xFisCI1Nypf6RMmsIql4JI0S8bFuSs9UvmCgikeh8b6i8C/KuKOYD+VShzGSwLsprRnByYYYoSqNhE8qCv/kYfxrYjT7jmuPIC+PBWsVsl1YRzBeE45qqWGtwjo1SR0WoZ8a7KAfYa5h7/2OVaPuF1gqtS83srclpi565IAP0c+b7wOz+wPZckOc3Jt0LC52oiXABx7y6VasGnfRYgiwwRAu9raGqPLXQmAGcADvvyN+m9bgXnP4i4E9wN8+KiJ5WQG5QilumnioJP9lwHPANKw/fF7A+fxJw2ms/y9SFdiPBf4Vn9hJNL8T/iFxbyoxgej+m6zBOtnLpXlvhiXcDOyVJV8UCEL4KnBI/OnAtBP0q+ADMTq/SfshrdUFr4TzwJdY9d57WIdYzRIk1GMdeXSQIUOGDBmSwUMtd8u2ArdcUAAAAABJRU5ErkJggg==";var ob="#55cc55",sb="#55cc55",ab="#44aa44",du=new Map([[0,{src:_m}],[1,{src:vm}]]);function cb(n,t){return!n&&!t?!0:!n||!t?!1:n.scoreRow===t.scoreRow&&n.diatonicId===t.diatonicId}function ub(n,t){return!n&&!t?!0:!n||!t?!1:n.length===t.length&&n.every((e,r)=>e===t[r])}var Xs=class{constructor(t){this.mi=t;d(this,"devicePixelRatio");d(this,"fontSize");d(this,"unitSize");d(this,"lineWidth");d(this,"beamThickness");d(this,"scoreEventListener");d(this,"canvas");d(this,"ctx");d(this,"mdoc");d(this,"cursorRect");d(this,"mousePos");d(this,"curStaffPos");d(this,"curObjects");d(this,"hilightedStaffPos");d(this,"hilightedObj");d(this,"usingTouch",!1);d(this,"onClickFn");d(this,"onMouseMoveFn");d(this,"onMouseLeaveFn");d(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=Mn.FontSize*at.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this.lineWidth=this.unitSize*.2,this.beamThickness=this.unitSize*.8,du.forEach(e=>{if(e.finished!==!0){let r=new Image;r.src=e.src,r.onload=()=>{e.img=r,this.finishImageAsset(e)},r.onerror=()=>{throw this.finishImageAsset(e),new O(6,"Failed to load image: "+e.src)}}}),this.onClickFn=this.onClick.bind(this),this.onMouseMoveFn=this.onMouseMove.bind(this),this.onMouseLeaveFn=this.onMouseLeave.bind(this),this.onTouchEndFn=this.onTouchEnd.bind(this)}getMusicInterface(){return this.mi}get doc(){var t;return(t=this.mdoc)==null?void 0:t.getMusicObject()}finishImageAsset(t){t.finished=!0,Array.from(du).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(t){var e;return(e=du.get(t))==null?void 0:e.img}setDocument(t){if(this.mdoc===t)return;this.updateCursorRect(void 0);let e=this.mdoc;this.mdoc=t,e&&e.getMusicObject().setRenderer(void 0),t&&t.getMusicObject().setRenderer(this)}setCanvas(t){var e,r;this.canvas!==t&&(this.canvas&&(this.canvas.removeEventListener("click",this.onClickFn),this.canvas.removeEventListener("mousemove",this.onMouseMoveFn),this.canvas.removeEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.removeEventListener("touchend",this.onTouchEndFn)),this.canvas=t,this.canvas.addEventListener("click",this.onClickFn),this.canvas.addEventListener("mousemove",this.onMouseMoveFn),this.canvas.addEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.addEventListener("touchend",this.onTouchEndFn),this.canvas.style.position="relative"),this.ctx=(r=(e=this.canvas)==null?void 0:e.getContext("2d"))!=null?r:void 0}setScoreEventListener(t){this.scoreEventListener=t}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(t){return new Vu(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!cb(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new bi("leave",this.getMusicInterface(),i.getMusicInterface(),o))}if(r&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=t;this.scoreEventListener(new bi("enter",this.getMusicInterface(),i.getMusicInterface(),o))}if(e&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=t;this.scoreEventListener(new bi("click",this.getMusicInterface(),i.getMusicInterface(),o))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!ub(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ai("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ai("enter",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new Ai("click",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),this.curObjects=t,r}onClick(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),this.scoreEventListener)){let r=e.pick(this.mousePos.x,this.mousePos.y),i=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),!this.usingTouch)){let r=e.pick(this.mousePos.x,this.mousePos.y),i=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(t){if(!this.needMouseInput())return;this.mousePos=void 0;let e=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(e||r)&&this.draw()}onTouchEnd(t){this.usingTouch=!0}onLoad(){this.doc&&(this.doc.requestFullLayout(),this.draw())}hilightObject(t){this.hilightedObj=t}hilightStaffPos(t){this.hilightedStaffPos=t}updateCursorRect(t){this.cursorRect=t,this.draw()}updateCanvasSize(){let{canvas:t,doc:e}=this;if(t&&e){let r=e.getRect(),i=r.width+1,o=r.height+1;t.width=i,t.height=o,t.style.width=i/this.devicePixelRatio+"px",t.style.height=o/this.devicePixelRatio+"px"}}draw(){let{ctx:t,doc:e}=this;!t||!e||(e.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),e.drawContent())}drawHilightStaffPosRect(){let t=this.getCanvasContext(),{mousePos:e,hilightedStaffPos:r,unitSize:i}=this;if(!t||!r)return;let{scoreRow:o,diatonicId:s}=r,a=o.getStaff(s);a&&(t.fillStyle=ob,t.fillRect(0,a.getDiatonicIdY(s)-i,t.canvas.width,2*i),e!==void 0&&this.drawLedgerLines(a,s,e.x))}drawHilightObjectRect(){let t=this.getCanvasContext(),{hilightedObj:e}=this;if(!t||!e)return;let r=e.getRect();t.strokeStyle=sb,t.strokeRect(r.left,r.top,r.width,r.height)}drawPlayCursor(){let{cursorRect:t,lineWidth:e}=this;t&&this.drawLine(t.centerX,t.top,t.centerX,t.bottom,ab,e*2)}txFromScreenCoord(t){return t.mul(this.devicePixelRatio)}txToScreenCoord(t){return t.div(this.devicePixelRatio)}getCanvasContext(){return this.ctx}clearCanvas(){let t=this.getCanvasContext();t&&t.clearRect(0,0,t.canvas.width,t.canvas.height)}getTextWidth(t,e){let r=this.getCanvasContext();if(r){let i=r.font;r.font=e;let o=r.measureText(t);return r.font=i,o.width}else return A.Dom.getCanvasTextWidth(t,e)}drawDebugRect(t){if(!Zs.DrawDebugRects)return;let e=this.getCanvasContext();e&&(e.lineWidth=1,e.strokeStyle="red",e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.stroke())}fillCircle(t,e,r,i){let o=this.getCanvasContext();o&&(i!==void 0&&(o.fillStyle=i),o.beginPath(),o.arc(t,e,r,0,2*Math.PI),o.fill())}drawLine(t,e,r,i,o,s){let a=this.getCanvasContext();a&&(a.strokeStyle=o!=null?o:"black",a.lineWidth=s!=null?s:this.lineWidth,a.beginPath(),a.moveTo(t,e),a.lineTo(r,i),a.stroke())}drawPartialLine(t,e,r,i,o,s,a,c){let u=this.getCanvasContext();if(u){let l=t+(r-t)*o,h=e+(i-e)*o,p=t+(r-t)*s,m=e+(i-e)*s;u.strokeStyle=a!=null?a:"black",u.lineWidth=c!=null?c:this.lineWidth,u.beginPath(),u.moveTo(l,h),u.lineTo(p,m),u.stroke()}}drawLedgerLines(t,e,r){let{unitSize:i}=this,o=i*at.LedgerLineWidth;if(e>=t.topLineDiatonicId+2){for(let s=t.topLineDiatonicId+2;s<=e;s+=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}else if(e<=t.bottomLineDiatonicId-2){for(let s=t.bottomLineDiatonicId-2;s>=e;s-=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}}};var Qs=class{constructor(t){this.measure=t;d(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===W.getDiatonicClass(t));return r?r.accidental:void 0}setAccidental(t){this.accidentalByDiatonicId[t.diatonicId]=t.accidental}needAccidental(t){var r,i;let e=(i=(r=this.accidentalByDiatonicId[t.diatonicId])!=null?r:this.getAccidentalFromKeySignature(t.diatonicId))!=null?i:0;return t.accidental!==e}};var Ks=class extends it{constructor(e,r,i,o,s){super(e);this.image=r;this.anchorX=i;this.anchorY=o;this.imageScale=s;d(this,"mi");this.mi=new lo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:i,image:o,imageScale:s}=this,{unitSize:a}=e;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=B.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new B}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let i=this.rect;e.drawDebugRect(i);try{r.drawImage(this.image,i.centerX-i.leftw,i.centerY-i.toph,i.width,i.height)}catch(o){}}};var Ci=class extends it{constructor(e,r,i,o="black"){super(e);this.diatonicId=r;this.accidental=i;this.color=o;d(this,"mi");this.mi=new ho(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;switch(this.accidental){case-2:this.rect=B.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=B.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=B.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=B.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=B.createSections(r*1,r*1,r*1,r*1);break;default:throw new O(6,"Invalid accidental value: "+this.accidental)}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;e.drawDebugRect(this.rect);let{unitSize:i,lineWidth:o}=e,{accidental:s}=this,a=this.rect.centerX,c=this.rect.centerY;r.strokeStyle=r.fillStyle=this.color;function u(l,h){r&&(r.lineWidth=o,r.beginPath(),r.moveTo(l-i*.75,h-i*4),r.lineTo(l-i*.75,h+i*1.1),r.bezierCurveTo(l+i*.75,h-i*0,l+i*.75,h-i*2.2,l-i*.75,h-i*.5),r.stroke())}s===-2?(u(a-i*.5,c),u(a+i*.5,c)):s===-1&&u(a,c),s===0?(r.beginPath(),r.lineWidth=o,r.moveTo(a-i*.5,c-i*2.2),r.lineTo(a-i*.5,c+i*1),r.moveTo(a+i*.5,c+i*2.2),r.lineTo(a+i*.5,c-i*1),r.stroke(),r.beginPath(),r.lineWidth=o*2,r.moveTo(a-i*.5,c+i*1),r.lineTo(a+i*.5,c+i*.6),r.moveTo(a+i*.5,c-i*1),r.lineTo(a-i*.5,c-i*.6),r.stroke()):s===1?(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.3,c-i*1.6),r.lineTo(a-i*.3,c+i*2),r.moveTo(a+i*.3,c-i*2),r.lineTo(a+i*.3,c+i*1.6),r.stroke(),r.lineWidth=o*2,r.beginPath(),r.moveTo(a-i*.75,c-i*.5),r.lineTo(a+i*.75,c-i*.9),r.moveTo(a-i*.75,c+i*.9),r.lineTo(a+i*.75,c+i*.5),r.stroke()):s===2&&(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.75,c-i*.75),r.lineTo(a+i*.75,c+i*.75),r.moveTo(a-i*.75,c+i*.75),r.lineTo(a+i*.75,c-i*.75),r.stroke(),r.fillRect(a-i*1,c-i*1,i*.7,i*.7),r.fillRect(a+i*.3,c-i*1,i*.7,i*.7),r.fillRect(a-i*1,c+i*.3,i*.7,i*.7),r.fillRect(a+i*.3,c+i*.3,i*.7,i*.7))}};var lb=.5,lt=class extends it{constructor(e,r,i,o){var a,c,u,l,h,p;super(e);this.anchorX=i;this.anchorY=o;d(this,"text");d(this,"scale");d(this,"color");d(this,"bold");d(this,"italic");d(this,"boxed");d(this,"padding");d(this,"bgcolor");d(this,"font","");d(this,"textLines");d(this,"lineWidths",[]);d(this,"lineHeight",0);d(this,"mi");let s=typeof r=="string"?{text:r}:r;this.text=s.text,this.scale=(a=s.scale)!=null?a:1,this.color=(c=s.color)!=null?c:"black",this.bold=(u=s.bold)!=null?u:!1,this.italic=(l=s.italic)!=null?l:!1,this.boxed=(h=s.boxed)!=null?h:!1,this.padding=(p=s.padding)!=null?p:this.boxed?lb:0,this.bgcolor=s.bgcolor,(!isFinite(this.padding)||this.padding<0)&&(this.padding=0),this.textLines=this.text.split(`
|
|
210
|
-
`),this.textLines.length===0&&(this.textLines=[""]),this.rect=new B,this.mi=new po(this)}getMusicInterface(){return this.mi}getText(){return this.text}updateAnchorX(e){this.anchorX=e;let{width:r}=this.rect;this.rect.left=this.rect.centerX-r*e,this.rect.right=this.rect.centerX+r*(1-e)}updateAnchorY(e){this.anchorY=e;let{height:r}=this.rect;this.rect.top=this.rect.centerY-r*e,this.rect.bottom=this.rect.centerY+r*(1-e)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{scale:r,anchorX:i,anchorY:o,bold:s,italic:a}=this,c=e.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(p=>e.getTextWidth(p,this.font)),this.lineHeight=c;let u=this.padding*e.unitSize,l=u+Math.max(...this.lineWidths)+u,h=u+this.lineHeight*this.textLines.length+u;(this.boxed==="square"||this.boxed==="circle")&&(h=l=Math.max(h,l)),this.rect=B.createSections(l*i,l*(1-i),h*o,h*(1-o))}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;e.drawDebugRect(this.rect),r.lineWidth=e.lineWidth,r.strokeStyle=r.fillStyle=this.color,r.font=this.font;let{rect:i,padding:o,lineHeight:s,lineWidths:a,anchorX:c,anchorY:u,italic:l}=this;this.bgcolor!==void 0&&(r.save(),r.fillStyle=this.bgcolor,r.beginPath(),r.fillRect(i.left,i.top,i.width,i.height),r.fill(),r.restore());let p=this.textLines.length*s,m=-s*(l?.25:.175),f=o*e.unitSize,g=(i.left+f)*(1-c)+(i.right-f)*c,y=(i.top+f)*(1-u)+(i.bottom-f)*u;switch(this.textLines.forEach((b,I)=>{let S=g-a[I]*c,w=y-p*u+s*(I+1)+m;r.fillText(b,S,w)}),this.boxed){case"square":case"rectangle":r.strokeRect(i.left,i.top,i.width,i.height);break;case"circle":case"ellipse":let b=(i.left+i.right)/2,I=(i.top+i.bottom)/2,S=(i.right-i.left)/2,w=(i.bottom-i.top)/2;r.beginPath(),r.ellipse(b,I,S,w,0,0,2*Math.PI),r.stroke();break}}};var Js=class extends it{constructor(e,r){super(e);this.measure=e;this.staff=r;d(this,"clefImage");d(this,"eightBelowClef");d(this,"measureNumber");d(this,"ksNeutralizeAccidentals",[]);d(this,"ksNewAccidentals",[]);d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new mo(this)}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let i=e.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new Ks(this,i,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new lt(this,"8",.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(e){if(e){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new lt(this,r,0,1)}else this.measureNumber=void 0}updateKeySignature(e){if(e){let{measure:r}=this,i=r.getPrevMeasure(),o=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],o&&!Fe.equals(s,o)&&o.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new Ci(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new Ci(this,this.getAccidentalDiatonicId(a),a.accidental))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new lt(this,{text:i,scale:1.4},0,.5);let o=r.beatSize.toString();this.beatSizeText=new lt(this,{text:o,scale:1.4},0,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=sc(this.measure.getTempo());this.tempoText=new lt(this,r,.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(e){let{clef:r}=this.staff.staffConfig,i;if(r==="G"?e.accidental>0?i=this.staff.bottomLineDiatonicId+3:e.accidental<0&&(i=this.staff.bottomLineDiatonicId+1):r==="F"&&(e.accidental>0?i=this.staff.bottomLineDiatonicId+1:e.accidental<0&&(i=this.staff.bottomLineDiatonicId-1)),i!==void 0)return W.findNextDiatonicIdAbove(e.diatonicId,i,!1);throw new O(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.eightBelowClef){let i=this.eightBelowClef.pick(e,r);if(i.length>0)return[this,...i]}if(this.clefImage){let i=this.clefImage.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.ksNeutralizeAccidentals.length;i++){let o=this.ksNeutralizeAccidentals[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.ksNewAccidentals.length;i++){let o=this.ksNewAccidentals[i].pick(e,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let i=this.beatCountText.pick(e,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(e,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(e,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(e,r);if(i.length>0)return[this,...i]}return[this]}layout(e){let{unitSize:r}=e,{staff:i}=this,o=r,s=0;if(this.rect=new B,this.clefImage&&(s+=o,this.clefImage.layout(e),this.clefImage.offset(s,i.getDiatonicIdY(i.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let c=this.clefImage.getRect();this.eightBelowClef.layout(e),this.eightBelowClef.offset(c.left+c.width/2,Math.max(c.centerY+c.height*.3,i.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}if(this.measureNumber){this.measureNumber.layout(e);let c=this.clefImage?this.clefImage.getRect().top:i.getTopLineY();this.measureNumber.offset(0,c),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)}this.ksNeutralizeAccidentals.length>0&&(s+=o,this.ksNeutralizeAccidentals.forEach(c=>{c.layout(e),c.offset(s+c.getRect().leftw,i.getDiatonicIdY(c.diatonicId)),this.rect.expandInPlace(c.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(c=>{c.layout(e),c.offset(s+c.getRect().leftw,i.getDiatonicIdY(c.diatonicId)),this.rect.expandInPlace(c.getRect()),s=this.rect.right}));let a=s;this.beatCountText&&(this.beatCountText.layout(e),this.beatCountText.offset(s+o,i.getDiatonicIdY(i.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.layout(e),this.beatSizeText.offset(s+o,i.getDiatonicIdY(i.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText&&(this.tempoText.layout(e),this.tempoText.offset(s,Math.min(this.rect.top,i.getTopLineY())),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){this.clefImage&&this.clefImage.offset(e,r),this.eightBelowClef&&this.eightBelowClef.offset(e,r),this.measureNumber&&this.measureNumber.offset(e,r),this.ksNeutralizeAccidentals.forEach(i=>i.offset(e,r)),this.ksNewAccidentals.forEach(i=>i.offset(e,r)),this.beatCountText&&this.beatCountText.offset(e,r),this.beatSizeText&&this.beatSizeText.offset(e,r),this.tempoText&&this.tempoText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.clefImage&&this.clefImage.draw(e),this.eightBelowClef&&this.eightBelowClef.draw(e),this.measureNumber&&this.measureNumber.draw(e),this.ksNeutralizeAccidentals.forEach(r=>r.draw(e)),this.ksNewAccidentals.forEach(r=>r.draw(e)),this.beatCountText&&this.beatCountText.draw(e),this.beatSizeText&&this.beatSizeText.draw(e),this.tempoText&&this.tempoText.draw(e)}};var $s=class extends it{constructor(e,r,i){super(e);this.col=e;this.line=r;this.arpeggioDir=i;d(this,"topArrowHeight",0);d(this,"bottomArrowHeight",0);d(this,"cycleHeight",0);d(this,"numCycles",0);d(this,"color","black");d(this,"mi");this.mi=new fo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let i=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-i)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new B(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i}=e,{rect:o,topArrowHeight:s,bottomArrowHeight:a}=this;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i*2,r.beginPath();for(let c=0,u=o.top+s;c<this.numCycles;c++,u+=this.cycleHeight)r.moveTo(o.centerX,u),r.quadraticCurveTo(o.left,u+this.cycleHeight/4,o.centerX,u+this.cycleHeight/2),r.quadraticCurveTo(o.right,u+this.cycleHeight*3/4,o.centerX,u+this.cycleHeight);r.stroke(),s>0&&(r.beginPath(),r.moveTo(o.centerX,o.top),r.lineTo(o.right,o.top+s),r.lineTo(o.left,o.top+s),r.fill()),a>0&&(r.beginPath(),r.moveTo(o.centerX,o.bottom),r.lineTo(o.left,o.bottom-a),r.lineTo(o.right,o.bottom-a),r.fill())}};function hb(n){return typeof n=="number"?W.getChromaticNote(n).diatonicId:typeof n=="string"?W.getNote(n).diatonicId:n instanceof W?n.diatonicId:void 0}var ta=class extends it{constructor(e,r){super(e);this.staff=e;this.rest=r;d(this,"restRect",new B);d(this,"dotRects",[]);d(this,"mi");e.addObject(this),this.mi=new yo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){this.restRect.offsetInPlace(e,r),this.dotRects.forEach(i=>i.offsetInPlace(e,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRects.forEach(e=>this.rect.expandInPlace(e))}},wr=class extends it{constructor(e,r,i,o,s){var l,h;super(e);this.col=e;this.voiceId=r;d(this,"ownStemDir");d(this,"ownDiatonicId");d(this,"color");d(this,"hide");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"mi");let a=hb(o==null?void 0:o.staffPos);if(a!==void 0){let p=this.row.hasStaff,m=this.row.getStaff(a);if(p&&!m)throw new O(6,"Rest staffPos is out of staff boundaries!")}this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,a),this.ownStemDir=this.measure.updateOwnStemDir(this);let c=this.row.getStaff(this.ownDiatonicId);c&&c.isSpace(this.ownDiatonicId)&&(this.ownDiatonicId+=this.ownDiatonicId>=c.middleLineDiatonicId?1:-1),this.color=(l=o==null?void 0:o.color)!=null?l:"black",this.hide=(h=o==null?void 0:o.hide)!=null?h:!1,this.oldStyleTriplet=s===void 0&&((o==null?void 0:o.triplet)===!0||Xt.get(i).isTriplet);let u=typeof(o==null?void 0:o.dotted)=="number"?o.dotted>0?o.dotted:void 0:(o==null?void 0:o.dotted)===!0?1:void 0;this.rhythmProps=Qt.get(i,u,(s!=null?s:this.oldStyleTriplet)?fr.Triplet:void 0),this.mi=new go(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get noteLength(){return this.rhythmProps.noteLength}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}getStaticObjects(e){let r=[];return this.staffObjects.forEach(i=>{i.staff===e&&r.push(i)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{let r=e.staff,i=e.getRect().centerX,o=this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ta&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case"1n":return 1;case"2n":return-1;case"4n":return-1;case"8n":return-1;case"16n":return-1;case"32n":return-3;case"64n":return-3;default:throw new O(6,"Cannot get rest dot vertical displacement because note length is invalid.")}}updateAccidentalState(e){}layout(e,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:i}=e,{ownDiatonicId:o}=this,{noteLength:s,dotCount:a,flagCount:c}=this.rhythmProps,u=0,l=0,h=0,p=0;if(s==="1n")u=i,l=i,h=0,p=i;else if(s==="2n")u=i,l=i,h=i,p=0;else if(s==="4n")u=i*1,l=i*1,h=i*3.2,p=i*3;else{let m=1-c%2;u=i*(1+c*.25),l=i*(1+c*.125),h=i*(.5+c-m),p=i*(1+c+m)}this.row.getStaves().forEach(m=>{if(!m.containsDiatonicId(o)||!m.containsVoiceId(this.voiceId))return;let f=new ta(m,this);f.restRect=new B(-u,0,l,-h,0,p);for(let g=0;g<a;g++){let y=at.DotSize*i,b=l+(at.RestDotSpace+at.DotSize*i)+g*at.DotSize*i*1.5,I=this.getRestDotVerticalDisplacement(s)*i;f.dotRects.push(B.createCentered(b,I,y,y))}f.offset(0,m.getDiatonicIdY(o)),this.staffObjects.push(f)})}updateRect(){if(this.staffObjects.length===0)this.rect=new B;else if(this.rect=this.staffObjects[0].getRect().copy(),this.staffObjects.length>1)for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let r=e.getCanvasContext();if(!r||this.staffObjects.length===0)return;e.drawDebugRect(this.getRect());let{unitSize:i,lineWidth:o}=e,{color:s}=this,{noteLength:a,flagCount:c}=this.rhythmProps;r.strokeStyle=r.fillStyle=s,r.lineWidth=o,this.staffObjects.forEach(u=>{let{dotRects:l,restRect:h}=u,p=h.centerX,m=h.centerY;if(a==="1n")r.fillRect(p-i,m,i*2,i);else if(a==="2n")r.fillRect(p-i,m-i,i*2,i);else if(a==="4n")r.beginPath(),r.moveTo(p-i*.6,m-i*3.2),r.lineTo(p+i*.7,m-i*1.5),r.quadraticCurveTo(p-i*.8,m-i*.5,p+i*1,m+i*1.5),r.lineTo(p-i*1,m-i*.75),r.quadraticCurveTo(p+i*.2,m-i*1.5,p-i*.6,m-i*3.2),r.moveTo(p+i*1,m+i*1.5),r.quadraticCurveTo(p-i*.8,m+i*1,p-i*.2,m+i*2.8),r.bezierCurveTo(p-i*1.8,m+i*1.5,p-i*.6,m-i*.2,p+i*.9,m+i*1.5),r.fill(),r.stroke();else if(c>0){let f=1-c%2,g=b=>p+(-b*.25+.5)*i,y=b=>m+(b+f)*i;r.beginPath(),r.moveTo(g(1+c),y(1+c)),r.lineTo(g(-.5-c),y(-.5-c)),r.stroke();for(let b=0;b<c;b++){let I=c-b*2;r.beginPath(),r.moveTo(g(I-2.5),y(I-2.5)),r.quadraticCurveTo(g(I-.5)+i*.25,y(I-1.5),g(I-1.5)-i*1.5,y(I-1.5)),r.stroke(),r.beginPath(),r.arc(g(I-2)-i*1.5,y(I-2),i*.5,0,Math.PI*2),r.fill()}}l.forEach(f=>{e.fillCircle(f.centerX,f.centerY,f.width/2)})})}};var pb=(n,t)=>{let e=at.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=n/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),n/r*e}},xo=class{constructor(t,e,r,i,o){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=i;this.y=o;d(this,"topBeamsHeight",0);d(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new B(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},mu=class extends it{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;d(this,"tupletNumber");d(this,"tupletNumberOffsetY",0);d(this,"points",[]);d(this,"mi");e.addObject(this),this.mi=new Ao(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.points.forEach(o=>o.offset(e,0)),(i=this.tupletNumber)==null||i.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().copy():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().copy()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Xr=class n extends it{constructor(e,r){super(e[0].measure);this.symbols=e;this.tupletRatio=r;d(this,"mi");d(this,"type");d(this,"staffObjects",[]);this.mi=new bo(this);let i=r?"Tuplet":"BeamGroup";if(e.every(o=>o.measure===e[0].measure)){if(e.length<2)throw new O(6,`${i} needs minimum 2 symbols, but ${e.length} given.`)}else throw new O(6,`All ${i} symbols are not in same measure.`);if(r!==void 0){let o=e.length<3||e.some(s=>!(s instanceof vt))||e.some(s=>s.rhythmProps.flagCount!==e[0].rhythmProps.flagCount);e.length>=3&&e[0]instanceof vt&&e[e.length-1]instanceof vt&&e[0].rhythmProps.flagCount===e[e.length-1].rhythmProps.flagCount&&(o=!1),e.some(s=>Xt.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,vt.setTupletBeamCounts(this)}else this.type=0;if(e.every(o=>o.getBeamGroup()===void 0))e.forEach(o=>o.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new O(6,`Cannot add ${i} because some symbol already has one.`)}get showTupletRatio(){var e;return((e=this.tupletRatio)==null?void 0:e.showRatio)===!0}static createBeam(e){e.length>1&&new n(e,void 0)}static createOldStyleTriplet(e){let r=e.slice(0,2),i=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(i[0]*2===i[1]||i[1]*2===i[0]))return new n(r,fr.Triplet),2;let o=e.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);return o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0])?(new n(o,fr.Triplet),3):0}static createTuplet(e,r){new n(e,r)}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(e=>e.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get stemDir(){return this.symbols[0].ownStemDir}layout(e){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let i=r[0].voiceId;if(r.some(c=>c.voiceId!==i))return;let{unitSize:o}=e,{stemDir:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var U,k;if(!c)return;let l=a.map(P=>{var F;return(F=P[u])==null?void 0:F.x}),h=a.map(P=>{var F;return(F=P[u])==null?void 0:F.y}),p=a.map(P=>{var F;return(F=P[u])==null?void 0:F.staff}),m=a.map(P=>{var F;return(F=P[u])==null?void 0:F.stemHeight}),f=r[0],g=l[0],y=h[0],b=p[0],I=r[r.length-1],S=l[l.length-1],w=h[h.length-1],_=p[h.length-1];if(g===void 0||y===void 0||b===void 0||S===void 0||w===void 0||_===void 0)return;let v=(U=m[0])!=null?U:0,C=(k=m[m.length-1])!=null?k:0;if(this.type!==2){let P=v<C?Math.sqrt(C-v):0,F=C<v?Math.sqrt(v-C):0;s==="up"&&(P*=-1,F*=-1),P!==0&&(y+=P,h[0]+=P),F!==0&&(w+=F,h[h.length-1]+=F)}let x=o*2*(s==="up"?-1:1),N=(w+y)/2,j=pb(S-g,w-y)/2;y=N-j,w=N+j;let R=0;h.forEach((P,F)=>{let V=l[F];if(V!==void 0&&P!==void 0){let X=A.Math.interpolateY(g,y,S,w,V),E=P-X;s==="up"&&E<0?R=Math.min(R,E):s==="down"&&E>0&&(R=Math.max(R,E))}}),y+=R,w+=R,h=h.map(P=>P===void 0?void 0:P+R);let D=new mu(c,this);if(this.type===2){let P=o/(S-g),F=A.Math.interpolateCoord(g,y+x,S,w+x,-P),V=A.Math.interpolateCoord(g,y+x,S,w+x,1+P);D.points.push(new xo(b,this,f,F.x,F.y)),D.points.push(new xo(_,this,I,V.x,V.y)),D.tupletNumberOffsetY=0}else if(this.type===0||this.type===1){R*=.5;let{beamThickness:P}=e,F=V=>{let X=r[V];if(X instanceof vt){let E=X instanceof vt?Math.max(X.getLeftBeamCount(),X.getRightBeamCount()):0;return at.BeamSeparation*o*(this.stemDir==="up"?E-1:0)}else return 0};r.forEach((V,X)=>{let E=p[X],tt=l[X],ct=h[X];if(E&&tt!==void 0&&ct!==void 0){let xt=new xo(E,this,V,tt,ct);xt.topBeamsHeight=P/2+(s==="down"?F(X):0),xt.bottomBeamsHeight=P/2+(s==="up"?F(X):0),D.points.push(xt)}}),D.tupletNumberOffsetY=x}if(this.isTuplet()&&this.tupletRatio){let P=this.showTupletRatio?String(this.tupletRatio.parts)+":"+String(this.tupletRatio.inTimeOf):String(this.tupletRatio.parts);D.tupletNumber=new lt(this,P,.5,.5),D.tupletNumber.layout(e),D.tupletNumber.offset((g+S)/2,(y+w)/2+D.tupletNumberOffsetY)}D.points.length>=2&&this.staffObjects.push(D)})}updateRect(){if(this.staffObjects.length===0)this.rect=new B;else{this.staffObjects.forEach(e=>e.updateRect()),this.rect=this.staffObjects[0].getRect().copy();for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}}updateStemTips(){this.staffObjects.forEach(e=>{let r=e.points[0],i=e.points[e.points.length-1];if(this.type!==2&&e.points.forEach(o=>{o.symbol instanceof vt&&(o!==r&&o!==i&&(o.y=A.Math.interpolateY(r.x,r.y,i.x,i.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),e.tupletNumber){let o=(r.y+i.y)/2+e.tupletNumberOffsetY;e.tupletNumber.offset(0,-e.tupletNumber.getRect().centerY+o)}})}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r,beamThickness:i,lineWidth:o}=e,s="black";this.staffObjects.forEach(a=>{if(this.type===2){let c=a.points[0],u=a.points[a.points.length-1];if(c&&u){let l=a.tupletNumber?a.tupletNumber.getRect().width/(u.x-c.x)*1.2:0,h=A.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5-l/2),p=A.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5+l/2),m=this.stemDir==="up"?r:-r;e.drawLine(c.x,c.y,h.x,h.y,s,o),e.drawLine(p.x,p.y,u.x,u.y,s,o),e.drawLine(c.x,c.y,c.x,c.y+m,s,o),e.drawLine(u.x,u.y,u.x,u.y+m,s,o)}}else if(this.type===0||this.type===1){let c=at.BeamSeparation*r*(this.stemDir==="up"?1:-1),u=a.points.filter(l=>l.symbol instanceof vt);for(let l=0;l<u.length-1;l++){let h=u[l],p=u[l+1];if(!(h.symbol instanceof vt&&p.symbol instanceof vt))continue;let m=h.symbol.getRightBeamCount(),f=p.symbol.getLeftBeamCount(),g=h.x,y=h.y,b=p.x,I=p.y;for(let S=0;S<Math.max(m,f);S++)S<m&&S<f?e.drawLine(g,y,b,I,s,i):m>f?e.drawPartialLine(g,y,b,I,0,.25,s,i):f>m&&e.drawPartialLine(g,y,b,I,.75,1,s,i),y+=c,I+=c}}a.tupletNumber&&a.tupletNumber.draw(e)})}};function db(n){return A.Is.isEnumValue(n,Qe)?n:void 0}function mb(n){return A.Is.isEnumValue(n,Hr)?n:n===!0?"up":void 0}function fb(n,t){let e=A.Arr.isArray(t)?t:t!==void 0?[t]:[],r=n.map((i,o)=>({note:i,string:e[o]}));return r=A.Arr.removeDuplicatesCmp(r,(i,o)=>W.equals(i.note,o.note)).sort((i,o)=>W.compareFunc(i.note,o.note)),{notes:r.map(i=>i.note),strings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}var ea=class extends it{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;d(this,"noteHeadRects",[]);d(this,"dotRects",[]);d(this,"accidentals",[]);d(this,"stemTip");d(this,"stemBase");d(this,"flagRects",[]);d(this,"prevTopNoteY",0);d(this,"prevBottomNoteY",0);d(this,"mi");this.mi=new _o(this)}getMusicInterface(){return this.mi}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.accidentals.length;i++){let o=this.accidentals[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].copy(),this.noteHeadRects.forEach(e=>this.rect.expandInPlace(e)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(e=>this.rect.expandInPlace(e)),this.flagRects.forEach(e=>this.rect.expandInPlace(e)),this.accidentals.forEach(e=>this.rect.expandInPlace(e.getRect()))}getRect(){let e=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.centerY||this.prevBottomNoteY!==e.centerY)&&(this.prevTopNoteY=r.centerY,this.prevBottomNoteY=e.centerY,this.requestRectUpdate()),super.getRect()}offset(e,r){var i,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(e,r)),this.dotRects.forEach(s=>s.offsetInPlace(e,r)),this.accidentals.forEach(s=>s.offset(e,r)),(i=this.stemTip)==null||i.offsetInPlace(e,r),(o=this.stemBase)==null||o.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},fu=class extends it{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;d(this,"fretNumbers",[]);d(this,"mi");e.addObject(this),this.mi=new vo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().copy(),this.fretNumbers.forEach(e=>this.rect.expandInPlace(e.getRect()))}offset(e,r){this.fretNumbers.forEach(i=>i.offset(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},vt=class n extends it{constructor(e,r,i,o,s,a){var l,h,p;super(e);this.col=e;this.voiceId=r;this.notes=i;d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"ownDiatonicId");d(this,"ownStemDir");d(this,"ownString");d(this,"color");d(this,"staccato");d(this,"diamond");d(this,"arpeggio");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"startConnnectives",[]);d(this,"runningConnectives",[]);d(this,"leftBeamCount",0);d(this,"rightBeamCount",0);d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"tabObjects",[]);d(this,"mi");if(!A.Is.isIntegerGte(i.length,1))throw new O(6,"Cannot create note group object because notes array is empty.");let c=fb(i,s==null?void 0:s.string);this.notes=c.notes,this.minDiatonicId=this.notes[0].diatonicId,this.maxDiatonicId=this.notes[this.notes.length-1].diatonicId,this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,Math.round((this.minDiatonicId+this.maxDiatonicId)/2)),this.ownStemDir=this.measure.updateOwnStemDir(this,db(s==null?void 0:s.stem)),this.ownString=this.measure.updateOwnString(this,c.strings),this.color=(l=s==null?void 0:s.color)!=null?l:"black",this.staccato=(h=s==null?void 0:s.staccato)!=null?h:!1,this.diamond=(p=s==null?void 0:s.diamond)!=null?p:!1,this.arpeggio=mb(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&((s==null?void 0:s.triplet)===!0||Xt.get(o).isTriplet);let u=typeof(s==null?void 0:s.dotted)=="number"?s.dotted>0?s.dotted:void 0:(s==null?void 0:s.dotted)===!0?1:void 0;this.rhythmProps=Qt.get(o,u,(a!=null?a:this.oldStyleTriplet)?fr.Triplet:void 0),this.mi=new Co(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof Pe||e.containsDiatonicId(this.ownDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective==="tie")throw new O(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective==="slur")throw new O(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(e),this.doc.addConnectiveProps(e)}getStaticObjects(e){let r=[];return this.staffObjects.forEach(i=>{i.staff===e&&r.push(i)}),this.tabObjects.forEach(i=>{i.tab===e&&r.push(i)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabObjects.length;i++){let o=this.tabObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,i,o,s){if(r instanceof Tt){let a=r;if(i<0||i>=this.notes.length)throw new O(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(_=>_.staff===a);if(!c||i<0||i>=c.noteHeadRects.length){let _=this.getRect();return{x:_.centerX,y:_.bottom}}let u=c.noteHeadRects[i],l=c.stemTip,h=this.stemDir,p=l!==void 0,m=p?h==="up"?"right":"left":void 0,f=u.height/2,g=u.centerX,y=u.centerY,b=u.left-f,I=u.right+f,S=u.top-f,w=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!p&&(o=h==="up"?"above":"below"),o){case"center":return s==="left"?{x:I,y}:{x:b,y};case"above":return!p||h==="down"?{x:g,y:S}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?b:g,y:S};case"below":return!p||h==="up"?{x:g,y:w}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?b:g,y:w};case"stemTip":return{x:g,y:l.centerY+(h==="up"?-f:f)};default:throw new O(6,"Invalid noteAnchor: "+o)}}else{let a=r,c=this.tabObjects.find(f=>f.tab===a),u=c==null?void 0:c.fretNumbers[i];if(!c||!u)return{x:0,y:0};let l=u.getRect(),h=s==="right"?l.left:l.right,p,m=.9;if(e.connective==="slide"){let f=e.noteGroups[0].getFretNumber(c,0),g=e.noteGroups[1].getFretNumber(c,0),y=f===void 0||g===void 0||f<=g;s==="left"?p=y?l.centerY+l.bottomh*m:l.centerY-l.toph*m:p=y?l.centerY-l.toph*m:l.centerY+l.bottomh*m}else p=l.centerY+l.bottomh*m;return{x:h,y:p}}}getFretNumberString(e){return this.ownString[e]}getFretNumber(e,r){let i=e.fretNumbers[r];return i===void 0?void 0:+i.getText()}getNextNoteGroup(){let e=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof n),r=e.indexOf(this);if(r<0)return;if(r<e.length-1)return e[r+1];let i=this.measure.getNextMeasure();for(;i;){let o=i.getVoiceSymbols(this.voiceId).filter(s=>s instanceof n);if(o.length>0)return o[0];i=i.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(e=>{this.runningConnectives.push(e);let r=this.getNextNoteGroup();for(;r&&e.addNoteGroup(r);)r.runningConnectives.push(e),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let e=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return e.indexOf("first")>=0?"first":e.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{var a,c,u,l;let r=e.staff,i=(c=(a=e.stemTip)==null?void 0:a.centerX)!=null?c:e.noteHeadRects[0].centerX,o=(l=(u=e.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=this.stemDir==="up"?Math.abs(e.noteHeadRects[0].centerY-o):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{flagCount:i,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?at.BeamSeparation:at.FlagSeparation;return(at.StemHeight+Math.max(0,i-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ea&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(i=>i.connective==="tie").map(i=>{let o=i.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(i.span==="stub"||i.span==="toMeasureEnd")return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=o[s-1];return a&&a.notes.some(c=>W.equals(c,e))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!W.equals(u,e))),s>=0&&(o=o.slice(0,s)),A.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(e){this.notes.forEach(r=>{e.needAccidental(r)&&e.setAccidental(r)})}layout(e,r){this.requestRectUpdate();let{unitSize:i}=e,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,l=at.DotSize*i,h=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadWidth)*i,p=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadHeight)*i;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.ownDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new ea(m,this),g=m,y=m;this.notes.forEach((C,x)=>{var F;let N=x===0,j=x===this.notes.length-1,R=(F=m.getActualStaff(C.diatonicId))!=null?F:m,D=this.col.getNoteHeadDisplacement(this,C)*h,U=R.getDiatonicIdY(C.diatonicId),k=R.isLine(C.diatonicId);N&&s==="up"&&(g=R),j&&s==="up"&&(y=R),N&&s==="down"&&(y=R),j&&s==="down"&&(g=R);let P=f.noteHeadRects[x]=B.createCentered(D,U,h,p);if(R.addObject(P),r.needAccidental(C)){let V=f.accidentals[x]=new Ci(this,C.diatonicId,C.accidental,this.color);V&&(V.layout(e),V.offset(-P.leftw-i*at.NoteAccSpace-V.getRect().rightw,U)),R.addObject(V)}for(let V=0;V<a;V++){let X=P.right+at.NoteDotSpace*i+l/2+V*l*1.5,E=U+this.getDotVerticalDisplacement(m,C.diatonicId,s)*i,tt=B.createCentered(X,E,l,l);f.dotRects.push(tt),R.addObject(tt)}if(this.staccato){if(s==="up"&&N){let V=D,X=U+i*(k?3:2),E=B.createCentered(V,X,l,l);f.dotRects.push(E),g.addObject(E)}else if(s==="down"&&j){let V=D,X=U-i*(k?3:2),E=B.createCentered(V,X,l,l);f.dotRects.push(E),g.addObject(E)}}});let b=f.noteHeadRects[0].centerY,I=f.noteHeadRects[f.noteHeadRects.length-1].centerY,S=s==="up"?h/2:-h/2,w=this.getStemHeight(e),_=s==="up"?I-w:b+w,v=s==="up"?b:I;if(u&&(f.stemTip=new B(S,S,_,_),f.stemBase=new B(S,S,v,v),y.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let C=c===0?0:at.FlagWidth*i,x=c===0?0:at.FlagHeight*i;for(let N=0;N<c;N++){let j=N*i*at.FlagSeparation,R=f.flagRects[N]=s==="up"?new B(S,S+C,_+j,_+x+j):new B(S,S+C,_-x-j,_-j);y.addObject(R)}}this.staffObjects.push(f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new fu(m,this);this.notes.forEach((g,y)=>{if(this.ownString[y]!==void 0){let b=this.ownString[y]-1,I=g.chromaticId-m.getTuningStrings()[b].chromaticId,S=I<0?"red":"black",w=new lt(this,{text:String(I),color:S,bgcolor:"white"},.5,.5);f.fretNumbers.push(w),w.layout(e);let _=this.col.getRect().centerX,v=m.getStringY(b);w.offset(_,v)}}),f.fretNumbers.length>0&&this.tabObjects.push(f)})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].copy();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().copy();else{this.rect=new B;return}this.staffObjects.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tabObjects.forEach(e=>this.rect.expandInPlace(e.getRect()))}setStemTipY(e,r){let i=this.staffObjects.find(o=>o.staff===e);!(i!=null&&i.stemTip)||r===i.stemTip.centerY||(i.stemTip.top=i.stemTip.centerY=i.stemTip.bottom=r,this.requestRectUpdate())}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.tabObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let r=e.getCanvasContext();if(!r)return;e.drawDebugRect(this.getRect());let{lineWidth:i}=e,{color:o,stemDir:s}=this,{isSolidNoteHead:a}=this.rhythmProps;this.staffObjects.forEach(c=>{c.accidentals.forEach(u=>u.draw(e)),r.strokeStyle=r.fillStyle=o,r.lineWidth=i,c.noteHeadRects.forEach(u=>{this.diamond?a?(r.beginPath(),r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.lineTo(u.left,u.centerY),r.lineTo(u.centerX,u.top),r.fill()):(r.beginPath(),r.lineWidth=i*2.5,r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.moveTo(u.left,u.centerY),r.lineTo(u.centerX,u.bottom),r.stroke(),r.beginPath(),r.lineWidth=i,r.moveTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.moveTo(u.centerX,u.top),r.lineTo(u.left,u.centerY),r.stroke()):(r.beginPath(),r.ellipse(u.centerX,u.centerY,u.leftw,u.toph,-.3,0,Math.PI*2),a?r.fill():r.stroke())}),c.dotRects.forEach(u=>e.fillCircle(u.centerX,u.centerY,u.width/2)),c.stemTip&&c.stemBase&&(r.beginPath(),r.moveTo(c.stemBase.centerX,c.stemBase.centerY),r.lineTo(c.stemTip.centerX,c.stemTip.centerY),r.stroke()),c.flagRects.forEach(u=>{let l=u.left,p=u.right-l,m=s==="up"?u.top:u.bottom,f=s==="up"?u.bottom:u.top;r.beginPath(),r.moveTo(l,m),r.bezierCurveTo(l,m*.75+f*.25,l+p*1.5,m*.5+f*.5,l+p*.5,f),r.stroke()})}),this.tabObjects.forEach(c=>c.fretNumbers.forEach(u=>u.draw(e)))}static setBeamCounts(e){let r=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:l,noteSize:h,dotCount:p}=s.rhythmProps;return a>0&&l>0&&u>0&&p===0&&c*Math.pow(2,u)===h};for(let o=0;o<e.length;o++){let s=e[o],a=e[o-1],c=e[o+1];s&&(s.leftBeamCount=0,s.rightBeamCount=0,a&&(a.rhythmProps.flagCount===s.rhythmProps.flagCount||r(a,s)||r(s,a)?s.leftBeamCount=s.rhythmProps.flagCount:s.leftBeamCount=Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount)),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||r(c,s)||r(s,c)?s.rightBeamCount=s.rhythmProps.flagCount:s.rightBeamCount=Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount)))}let i;do{i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=e[o-1],c=e[o+1];s&&s.leftBeamCount!==s.rhythmProps.flagCount&&s.rightBeamCount!==s.rhythmProps.flagCount&&(s.leftBeamCount=s.rightBeamCount=0,a&&a.rightBeamCount>0&&(a.rightBeamCount=0,i=!0),c&&c.leftBeamCount>0&&(c.leftBeamCount=0,i=!0))}}while(i)}static setTupletBeamCounts(e){let r=e.getType(),i=e.getSymbols();r===1?i.forEach((o,s)=>{o instanceof n&&(o.leftBeamCount=s===0?0:o.rhythmProps.flagCount,o.rightBeamCount=s===i.length-1?0:o.rhythmProps.flagCount)}):r===2&&i.forEach(o=>{o instanceof n&&(o.leftBeamCount=o.rightBeamCount=0)})}getDotVerticalDisplacement(e,r,i){return e.isLine(r)?i==="up"?-1:1:0}static hasSameNotes(e,r){if(e.notes.length!==r.notes.length)return!1;for(let i=0;i<e.notes.length;i++){let o=e.notes[i],s=r.notes[i];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var gb=(n,t)=>{let e=W.compareFunc(n.note,t.note);return e===0&&(e=n.noteGroup.stemDir===t.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1),e},Tr=class extends it{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;d(this,"voiceSymbol",[]);d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"staffMinDiatonicId",new Map);d(this,"staffMaxDiatonicId",new Map);d(this,"arpeggioDir");d(this,"arpeggios",[]);d(this,"noteHeadDisplacements",[]);d(this,"playerProps");d(this,"needLayout",!0);d(this,"shapeRects",[]);d(this,"mi");this.playerProps=new bn(this),this.mi=new Io(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let e=this.measure.getColumns().indexOf(this);if(e>=0&&e<this.measure.getColumnCount())return this.measure.getColumn(e+1);throw new O(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let e=this.getNextColumnInMeasure();return e||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let e=this.getNextColumnInMeasure(),r=this.positionTicks,i=e?e.positionTicks:this.measure.getConsumedTicks();return Math.max(0,i-r)}getShapeRects(){return this.getRect(),this.shapeRects}getStaticObjects(e){let r=[];return this.voiceSymbol.forEach(i=>{i&&(i.getRect(),i.getStaticObjects(e).forEach(o=>r.push(o)))}),this.arpeggios.forEach(i=>{i.line===e&&(i.getRect(),r.push(i))}),r}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.voiceSymbol.length;i++)if(this.voiceSymbol[i]){let o=this.voiceSymbol[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.arpeggios.length;i++){let o=this.arpeggios[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:"up"}setVoiceSymbol(e,r){ra(e),this.voiceSymbol[e]=r,r instanceof wr&&!r.hide?(this.minDiatonicId=this.minDiatonicId===void 0?r.ownDiatonicId:Math.min(this.minDiatonicId,r.ownDiatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.ownDiatonicId:Math.max(this.maxDiatonicId,r.ownDiatonicId)):r instanceof vt&&(this.minDiatonicId=this.minDiatonicId===void 0?r.notes[0].diatonicId:Math.min(this.minDiatonicId,r.notes[0].diatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.notes[r.notes.length-1].diatonicId:Math.max(this.maxDiatonicId,r.notes[r.notes.length-1].diatonicId),r.arpeggio!==void 0&&(this.arpeggioDir=r.arpeggio),this.setupNoteHeadDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(e){return this.voiceSymbol[e]}getMinWidth(){let e=Math.max(...this.voiceSymbol.map(i=>i.rhythmProps.noteSize)),r=at.NoteHeadWidth;switch(e){case 1:return r*5;case 2:return r*3;case 4:return r*2;default:return r}}setupNoteHeadDisplacements(){if(this.noteHeadDisplacements=[],this.voiceSymbol.forEach(e=>{e instanceof vt&&e.notes.forEach(r=>{this.noteHeadDisplacements.push({noteGroup:e,note:r})})}),this.noteHeadDisplacements.sort(gb),!(this.noteHeadDisplacements.length<2)){for(let e=0;e<this.noteHeadDisplacements.length;e++){let r=this.noteHeadDisplacements[e],i=this.noteHeadDisplacements[e+1];i&&r.note.diatonicId===i.note.diatonicId&&(r.displacement=i.displacement=0)}for(let e=0;e<this.noteHeadDisplacements.length;e++){let r=this.noteHeadDisplacements[e-1],i=this.noteHeadDisplacements[e],o=this.noteHeadDisplacements[e+1];if(i.displacement!==void 0)continue;let s=i.noteGroup.stemDir==="down"?-1:1;r&&i.note.diatonicId-r.note.diatonicId<=1?i.displacement=r.displacement===0?s:0:o&&o.note.diatonicId-i.note.diatonicId<=1&&(i.displacement=o.displacement===0?s:0)}}}getNoteHeadDisplacement(e,r){let i=this.noteHeadDisplacements.find(o=>o.noteGroup===e&&W.equals(o.note,r));return(i==null?void 0:i.displacement)!==void 0?i.displacement:0}isEmpty(){for(let e=0;e<this.voiceSymbol.length;e++)if(this.voiceSymbol[e]!==void 0&&!this.voiceSymbol[e].isEmpty())return!1;return!0}getPlayerNotes(){let e=[];function r(i,o,s,a){if(o<=0)return;e.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||e.push({note:i,ticks:o,staccato:s,slur:a})}return se().forEach(i=>{let o=this.getVoiceSymbol(i);if(o instanceof vt){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),e.sort((i,o)=>W.compareFunc(i.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new B;let{row:i}=this,{unitSize:o}=e,s=this.getMinWidth()*o/2,a=s,c=s;if(this.voiceSymbol.forEach(l=>{l.layout(e,r);let h=l.getRect();a=Math.max(a,h.leftw),c=Math.max(c,h.rightw)}),this.arpeggioDir!==void 0){let l=0;this.arpeggios=i.getNotationLines().map(h=>{let p=new $s(this,h,this.getArpeggioDir());return p.layout(e),p.offset(-a-p.getRect().right,h.getRect().centerY-p.getRect().centerY),l=Math.max(l,p.getRect().width),h.addObject(p),p}),a+=l}else this.arpeggios=[];let u=this.getAnchoredLayoutObjects().filter(l=>l.layoutGroup.widensColumn);u.length>0&&u.forEach(l=>{a=Math.max(a,l.musicObj.getRect().leftw),c=Math.max(c,l.musicObj.getRect().rightw)}),this.voiceSymbol.forEach(l=>l.updateAccidentalState(r)),this.rect.left=-a,this.rect.centerX=0,this.rect.right=c,this.row.getStaves().forEach(l=>{let h,p;this.voiceSymbol.forEach(m=>{m.visibleInStaff(l)&&(m instanceof vt?(h=h===void 0?m.minDiatonicId:Math.min(h,m.minDiatonicId),p=p===void 0?m.maxDiatonicId:Math.max(p,m.maxDiatonicId)):m instanceof wr&&(h=h===void 0?m.ownDiatonicId:Math.min(h,m.ownDiatonicId),p=p===void 0?m.ownDiatonicId:Math.max(p,m.ownDiatonicId)))}),h!==void 0?this.staffMinDiatonicId.set(l,h):this.staffMinDiatonicId.delete(l),p!==void 0?this.staffMaxDiatonicId.set(l,p):this.staffMaxDiatonicId.delete(l)})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(e=>!!e).map(e=>e.getRect().copy()),...this.arpeggios.map(e=>e.getRect().copy())],this.rect.top=Math.min(...this.shapeRects.map(e=>e.top)),this.rect.bottom=Math.max(...this.shapeRects.map(e=>e.bottom)),this.rect.centerY=(this.rect.top+this.rect.bottom)/2}offset(e,r){this.voiceSymbol.forEach(i=>i==null?void 0:i.offset(e,0)),this.arpeggios.forEach(i=>i.offset(e,0)),this.shapeRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){this.row.getStaves().forEach(r=>{let i=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);i!==void 0&&e.drawLedgerLines(r,i,this.getRect().centerX),o!==void 0&&e.drawLedgerLines(r,o,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(e)}),this.arpeggios.forEach(r=>r.draw(e))}};var hr=class hr extends it{constructor(e,r){super(e);this.text=r;d(this,"components",[]);d(this,"mi");switch(this.text){case hr.Coda:this.components=[new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new lt(this," Coda",0,1)];break;case hr.toCoda:this.components=[new lt(this,"toCoda ",1,1),new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case hr.Segno:this.components=[new lt(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new So(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){switch(this.text){case hr.Coda:{let r=this.components[0],i=this.components[1];r.layout(e),i.layout(e),r.offset(0,(i.getRect().top+i.getRect().bottom)/2),i.offset(r.getRect().right,0),this.rect=new B(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case hr.toCoda:{let r=this.components[0],i=this.components[1];r.layout(e),i.layout(e),i.offset(0,(r.getRect().top+r.getRect().bottom)/2),r.offset(i.getRect().left,0),this.rect=new B(r.getRect().left,i.getRect().centerX,i.getRect().right,r.getRect().top,r.getRect().centerY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(e),this.rect=r.getRect().copy();break}}}offset(e,r){this.components.forEach(i=>i.offset(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(e))}};d(hr,"toCoda","\u{1D10C} toCoda"),d(hr,"Coda","Coda \u{1D10C}"),d(hr,"Segno","\u{1D10B}");var $e=hr;function wo(n){switch(n){case"D.C. al Coda":return"D.C. al Coda";case"D.C. al Fine":return"D.C. al Fine";case"D.S. al Coda":return"D.S. al Coda";case"D.S. al Fine":return"D.S. al Fine";case"Fine":return"Fine";case"Segno":return $e.Segno;case"Coda":return $e.Coda;case"toCoda":return $e.toCoda;default:return n[0].toUpperCase()+n.substring(1)}}var ia=(p=>(p.cresc="cresc.",p.decresc="decresc.",p.dim="dim.",p.ppp="ppp",p.pp="pp",p.p="p",p.mp="mp",p.m="m",p.mf="mf",p.f="f",p.ff="ff",p.fff="fff",p))(ia||{}),na=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(na||{});function gu(n){return A.Is.isEnumValue(n,ia)}function To(n){if(/^(p+|f+|m|mp|mf)$/.test(n)){let t=.5-A.Str.charCount(n,"p")*.1+A.Str.charCount(n,"f")*.1;return A.Math.clamp(t,0,1)}else return}function yu(n){return A.Is.isEnumValue(n,na)}function Im(n){return A.Is.isEnumValue(n,ia)?"dynamics":A.Is.isEnumValue(n,na)?"tempo":void 0}function yb(n){switch(n){case"bottom":return .8;case"middle":return .5}}function xb(n){return gu(n)?2:yu(n)?1:0}var _i=class extends Hs{constructor(e,r,i,o,s,a){super(e);d(this,"length");d(this,"visible");d(this,"lineStyle");d(this,"linePos");d(this,"startColumn");d(this,"context");if(this.length=i,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=e instanceof lt?xb(e.getText()):0,e instanceof lt)e.updateAnchorY(yb(a));else throw new O(6,"Update anchor's y-coordinate is only implemented for text objects.")}isVisible(){return this.visible}getLineStyle(){return this.lineStyle}getLinePos(){return this.linePos}getSpanBreakText(e,r){if(e===e.measure.getColumn(0)){let i=e.measure.getPrevMeasure();if(i){if(i.hasEndSection()||i.hasEndSong())return"section-break";let o=["endRepeat","ending"];for(let s=0;s<o.length;s++)if(i.hasNavigation(o[s]))return"section-break"}}if(r===1){let i=e.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&yu(s))return s}}else if(r===2){let i=e.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&gu(s))return s}}}getExtensionRangeInfo(){let{startColumn:e,length:r,context:i}=this,o=[e];if(r<=0)return{startColumn:e,endColumn:e,columnRange:o,extensionBreakText:void 0};let s=r,a=e;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};a=c,o.push(a)}}};var bb=2,Ab=2,Cb=.5,_b=.5;function vb(n,t){let e=Qt.get(t.options.beatLength,t.options.dotCount).ticks,r=t.beatsPerMinute*e;return 60*n/r}function xu(){return To("m")}function Ib(n){return n*1.25}var Sb=.5,bn=class{constructor(t){this.col=t;d(this,"speed");d(this,"volume");this.speed=1,this.volume=xu()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=xu()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=A.Math.clamp(this.getSpeed(),.1,10);return ac(this.measure.getTempo(),t)}setVolume(t){this.volume=t}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:t}=this;if(t instanceof Nr)return this.measure.getMeasureTicks()/2;{let r=se().map(i=>t.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:A.Math.sum(r)/r.length}}},oa=class n{constructor(){d(this,"playTimer");d(this,"playPos");d(this,"playState",2);d(this,"doc");d(this,"cursorPositionChangeListener");d(this,"playStateChnageListener");d(this,"playerColumnSequence",[])}setDocument(t){this.doc=t,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(t){this.cursorPositionChangeListener=t}setPlayStateChnageListener(t){this.playStateChnageListener=t}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let t=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==t&&(this.playStateChnageListener&&this.playStateChnageListener(t),this.playState=t)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let t=[],e=this.doc.getFirstMeasure(),r=e,i,o=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=n.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation("startRepeat")&&(r=e),e.hasNavigation("Segno")&&(i=e),s&&e.hasNavigation("toCoda"))for(;e&&!e.hasNavigation("Coda");)e=e.getNextMeasure();else if(o&&e.hasNavigation("Fine"))e=void 0;else if(e.hasNavigation("D.C. al Coda"))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.C. al Fine"))o=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.S. al Coda"))s=!0,e=i;else if(e.hasNavigation("D.S. al Fine"))o=!0,e=i;else if(e.hasNavigation("endRepeat")){let u=e.getPassCount(),l=e.getEndRepeatPlayCount()-1,h=((a=e.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=l||h?e=r:e=e.getNextMeasure()}else e.hasEndSong()?e=void 0:e=e.getNextMeasure()}return t}collectPlayerColumnSequence(){let t=this.collectPlayerMeasureSequence(),e=[];for(let r=0;r<t.length;r++){let i=t[r];e=e.concat(i.getColumns()),i.hasFermata(i.getBarLineRight())&&e.push(i.getBarLineRight())}return e}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let t=1,e=xu(),r=new Map,i=new Map,o=(a,c)=>{var u;return r.set(a,[...(u=r.get(a))!=null?u:[],c])},s=(a,c)=>{var u;return i.set(a,[...(u=i.get(a))!=null?u:[],c])};this.playerColumnSequence.forEach(a=>{var l,h;if(!(a instanceof Tr))return;a.getAnchoredLayoutObjects().forEach(p=>{var g;let m=(g=p.getTextContent())!=null?g:"",f;if(m==="a tempo")t=1;else if((f=To(m))!==void 0)e=f;else if(p.musicObj.getLink()instanceof _i){let y=p.musicObj.getLink(),{columnRange:b,extensionBreakText:I}=y.getExtensionRangeInfo(),S=A.Math.sum(b.map(w=>w.getTicksToNextColumn()));switch(m){case"accel.":{let w=t,_=w*bb,v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,w+(_-w)*v/S)});break}case"rit.":{let w=t,_=w/Ab,v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,w+(_-w)*v/S)});break}case"cresc.":{let w=e,_=w+Cb;I&&(f=To(I))!==void 0&&f>w&&(_=f);let v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,w+(_-w)*v/S)});break}case"decresc.":case"dim.":{let w=e,_=w-_b;I&&(f=To(I))!==void 0&&f<w&&(_=f);let v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,w+(_-w)*v/S)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(t=A.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(e=A.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(t),a.getPlayerProps().setVolume(e)})}static getMeasureByEndingPassage(t,e){for(let r=t;;r=r.getNextMeasure()){let i=r==null?void 0:r.getEnding();if(i&&i.hasPassage(e))return r;let o=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!o||o.hasNavigation("startRepeat"))return}}playStep(){if(this.notifyCursorPositionChanged(),this.notifyPlayStateChanged(),this.playPos===void 0){this.stop();return}let t=this.playerColumnSequence[this.playPos],e=(s,a)=>{let c=vb(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),i=t.getPlayerProps().getFermataHoldTicks(),o;t instanceof Nr?o=e(i,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?Qt.get("32n").ticks*c:0,l=e(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(e(Qt.get("8n").ticks,r)/2,l/2));let h=Ib(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=Sb),u>0){let p=e(u,r);window.setTimeout(()=>Us(a.note,l,h),p*1e3)}else Us(a.note,l,h)}}),o=e(t.getTicksToNextColumn()+i,r)),this.playTimer=window.setTimeout(()=>this.playStep(),o*1e3),this.playPos=this.getNextPlayPosition(this.playPos),this.notifyPlayStateChanged()}play(){if(this.playState===0)this.stop();else if(this.playState===1){this.playStep();return}let{doc:t}=this;if(!t)return;t.getFirstMeasure()?(this.playPos=0,this.playStep()):this.playPos=void 0,this.notifyPlayStateChanged()}pause(){this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}stop(){this.playPos=void 0,this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}getNextPlayPosition(t){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let t=this.playerColumnSequence[this.playPos],e=t.measure,r=t.getRect().centerX,i=e.row.getRect().top,o=e.row.getRect().bottom;return new B(r,r,i,o)}};var bu=class extends it{constructor(e,r){super(r);this.barLine=e;this.line=r;d(this,"lineRects",[]);d(this,"dotRects",[]);d(this,"mi");r.addObject(this),this.mi=new Ro(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}setRect(e){this.rect=e}offset(e,r){this.lineRects.forEach(i=>i.offsetInPlace(e,r)),this.dotRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}},sa=class extends it{constructor(e){super(e);this.measure=e;d(this,"staffTabObjects",[]);d(this,"barLineType",0)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let o=this.staffTabObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}layout(e){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,lineWidth:i}=e,{measure:o,barLineType:s}=this,{row:a}=o,c=i,u=.7*r,l=.7*r,h=at.DotSize*r,p=h/2;a.getNotationLines().forEach(m=>{let f=new bu(this,m),g,y,b,I,S=(_,v)=>{f.lineRects.push(new B(_,_+v/2,_+v,b,0,I))},w=_=>{for(let v=-1;v<=1;v+=2){let C=g+v*y;f.dotRects.push(new B(_-p,_,_+p,C-p,C,C+p))}};switch(m instanceof Tt?(g=m.getMiddleLineY(),y=m.getDiatonicSpacing()):(g=(m.getBottomLineY()+m.getTopLineY())/2,y=(m.getBottomLineY()-m.getTopLineY())/6),b=m.getTopLineY(),I=m.getBottomLineY(),s){case 0:f.setRect(new B(0,0,0,b,0,I));break;case 1:f.setRect(new B(-c,0,0,b,0,I)),S(-c,c);break;case 2:f.setRect(new B(-c-l-c,0,0,b,0,I)),S(-c-l-c,c),S(-c,c);break;case 3:f.setRect(new B(-u-l-c,0,0,b,0,I)),S(-c-l-u,c),S(-u,u);break;case 4:f.setRect(new B(0,0,u+l+c+l+h,b,0,I)),S(0,u),S(u+l,c),w(u+l+c+l+p);break;case 5:f.setRect(new B(-u-l-c-l-h,0,0,b,0,I)),S(-c-l-u,c),S(-u,u),w(-c-l-u-l-p);break;case 6:f.setRect(new B(-h-l-c-l-u/2,0,u/2+l+c+l+h,b,0,I)),S(-u/2,u),S(-u/2-l-c,c),S(u/2+l,c),w(-u/2-l-c-l-p),w(u/2+l+c+l+p);break}this.staffTabObjects.push(f)})}updateRect(){if(this.staffTabObjects.length>0){this.rect=this.staffTabObjects[0].getRect().copy();for(let e=1;e<this.staffTabObjects.length;e++)this.rect.expandInPlace(this.staffTabObjects[e].getRect())}else this.rect=new B}offset(e,r){this.staffTabObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let r=e.getCanvasContext();!r||this.barLineType===0||(e.drawDebugRect(this.getRect()),r.strokeStyle=r.fillStyle="black",this.staffTabObjects.forEach(i=>{i.lineRects.forEach(o=>r.fillRect(o.left,o.top,o.width,o.height)),i.dotRects.forEach(o=>e.fillCircle(o.centerX,o.centerY,o.width/2))}))}},Qr=class extends sa{constructor(e){super(e);d(this,"mi");this.mi=new Oo(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation("startRepeat")?r&&r.row===e.row&&r.hasNavigation("endRepeat")?0:4:0}},Nr=class extends sa{constructor(e){super(e);d(this,"playerProps");d(this,"mi");this.playerProps=new bn(this),this.mi=new No(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation("endRepeat")?r&&r.row===e.row&&r.hasNavigation("startRepeat")?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var vi=class extends it{constructor(e,r){super(e);this.measure=e;this.passages=r;d(this,"endingText");d(this,"shapeRects",[]);d(this,"mi");if(this.mi=new Mo(this),A.Is.isIntegerGte(r.length,1)){if(!this.passages.every(o=>A.Is.isIntegerGte(o,1)))throw new O(6,"Invalid passages: "+this.passages)}else throw new O(6,"Passages is empty.");this.passages.sort((o,s)=>o-s);let i=this.passages.map(o=>o+".").join("");this.endingText=new lt(this,i,0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:e}=this,r=e.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||e.hasNavigation("endRepeat")||e.isLastMeasure()}hasPassage(e){return this.passages.some(r=>r===e)}getHighestPassage(){return Math.max(0,...this.passages)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new B,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:i}=this;this.endingText.layout(e);let o=this.endingText.getRect(),s=i.getColumnsContentRect(),a=o.height;this.rect=new B(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new B(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new B(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new B(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().copy()]}offset(e,r){this.endingText.offset(e,r),this.shapeRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i}=e,{rect:o}=this;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle="black",r.lineWidth=i,r.beginPath(),r.moveTo(o.left,o.bottom),r.lineTo(o.left,o.top),r.lineTo(o.right,o.top),this.isSingleMeasureEnding()&&r.lineTo(o.right,o.bottom),r.stroke(),this.endingText.draw(e)}};var An=class extends it{constructor(e,r){super(e);this.pos=r;d(this,"color","black");d(this,"mi");this.mi=new Do(this)}getMusicInterface(){return this.mi}static getFermataPositions(e){let{measure:r}=e,{row:i}=r;return i.getTopStaff()!==i.getBottomStaff()?[0,1]:[0]}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,i=r*4,o=r*3;this.rect=new B(-i/2,i/2,-o,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i,unitSize:o}=e,s=this.pos===1,a=(s?o:-o)*.7,c=this.rect.left,u=this.rect.right,l=(s?this.rect.bottom:this.rect.top)+a,h=(s?this.rect.top:this.rect.bottom)+a,p=h-l;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i,r.beginPath(),r.moveTo(c,h),r.bezierCurveTo(c,l,u,l,u,h),r.bezierCurveTo(u,l+p/5,c,l+p/5,c,h),r.stroke(),r.fill();let m=p/6;e.fillCircle((c+u)/2,h-m,Math.abs(m))}};var Cn=class extends it{constructor(e,r,i,o,s){super(e);this.measure=e;this.line=r;this.extension=i;this.leftObj=o;this.rightObj=s;d(this,"mi");i.addTail(this),this.mi=new Eo(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(){return this.leftObj instanceof Qr?this.leftObj.getRect().centerX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof Tr){let e=this.rightObj,r=e.getNextColumn();return r&&r.measure===e.measure?(e.getRect().right+r.getRect().left)/2:(e.getRect().right+e.measure.getBarLineRight().getRect().left)/2}else return this.rightObj.getRect().centerX}layoutFitToMeasure(e){let{unitSize:r}=e,i=this.getLineLeft(),o=this.getLineRight(),s=r;this.rect=new B(i,o,-s/2,s/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new B}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{rect:i}=this;this.extension.getLineStyle()==="dashed"&&r.setLineDash([7,3]),e.drawLine(i.left,i.centerY,i.right,i.centerY,"black",e.lineWidth),r.setLineDash([]);let o=this.extension.getTails();if(o.length>0&&this===o[o.length-1]){let s=i.centerY>this.line.getRect().centerY?-e.unitSize:e.unitSize;e.drawLine(i.right,i.centerY,i.right,i.centerY+s,"black",e.lineWidth)}}};var Ii=class extends it{constructor(e,r,i,o,s,...a){super(i);this.connectiveProps=e;this.line=r;this.measure=i;d(this,"lx",0);d(this,"ly",0);d(this,"rx",0);d(this,"ry",0);d(this,"cp1x",0);d(this,"cp1y",0);d(this,"cp2x",0);d(this,"cp2y",0);d(this,"arcHeight",0);d(this,"leftNoteGroup");d(this,"leftNoteId");d(this,"rightNoteGroup");d(this,"rightNoteId");d(this,"tieType");d(this,"mi");this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof vt&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):A.Is.isEnumValue(a[0],Ke)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new ko(this)}getMusicInterface(){return this.mi}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,{measure:i,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:p}=l,{row:m}=i,f=m.getPrevRow(),g=m.getNextRow(),y=m.getConnectivesContentRect(),b,I;b=s.getConnectiveAnchorPoint(l,o,a,h,"left"),c!==void 0&&u!==void 0?I=c.getConnectiveAnchorPoint(l,o,u,h,"right"):I=this.tieType==="toMeasureEnd"?{x:i.getColumnsContentRect().right,y:b.y}:{x:b.x+r*at.StubTieLength,y:b.y};let S,w,_,v;if(c===void 0)S=b.x,w=b.y,_=I.x,v=I.y;else if(s.row===m&&c.row===m)S=b.x,w=b.y,_=I.x,v=I.y;else if(s.row===f&&c.row===m){let D=f.getConnectivesContentRect().right-b.x,U=I.x-y.left;S=y.left,w=b.y+(I.y-b.y)*D/(D+U),_=I.x,v=I.y}else if(s.row===m&&c.row===g){let R=g.getConnectivesContentRect(),D=y.right-b.x,U=I.x-R.left;S=b.x,w=b.y,_=y.right,v=b.y+(I.y-b.y)*D/(D+U)}else throw new O(6,"Cannot layout connective object because no valid left and right note groups.");let x=(p==="up"?-1:1)*r*Math.log2(_-S)/3;this.lx=S,this.ly=w,this.rx=_,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:x;let{nx:N,ny:j}=A.Math.calcNormal(S,w,_,v);this.cp1x=S*.7+_*.3+N*this.arcHeight,this.cp1y=w*.7+v*.3+j*this.arcHeight,this.cp2x=S*.3+_*.7+N*this.arcHeight,this.cp2y=w*.3+v*.7+j*this.arcHeight,this.rect=new B(Math.min(this.lx,this.cp1x,this.cp2x,this.rx),Math.max(this.lx,this.cp1x,this.cp2x,this.rx),Math.min(this.ly,this.cp1y,this.cp2y,this.ry),Math.max(this.ly,this.cp1y,this.cp2y,this.ry)),this.line.addObject(this)}offset(e,r){this.lx+=e,this.ly+=r,this.rx+=e,this.ry+=r,this.cp1x+=e,this.cp1y+=r,this.cp2x+=e,this.cp2y+=r,this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;if(this.rightNoteGroup!==void 0){if(this.leftNoteGroup.measure!==this.rightNoteGroup.measure){if(this.leftNoteGroup.row.getNextRow()!==this.rightNoteGroup.row){if(this.measure!==this.rightNoteGroup.measure)return}}}let{rect:i}=this,{lineWidth:o}=e;e.drawDebugRect(i);let s=o*1.5,a=o*.25;r.strokeStyle=r.fillStyle="black",r.lineWidth=o,this.arcHeight===0?(r.beginPath(),r.moveTo(this.lx,this.ly),r.lineTo(this.rx,this.ry),r.stroke()):(r.beginPath(),r.moveTo(this.lx,this.ly-a),r.bezierCurveTo(this.cp1x,this.cp1y-s,this.cp2x,this.cp2y-s,this.rx,this.ry-a),r.lineTo(this.rx,this.ry+a),r.bezierCurveTo(this.cp2x,this.cp2y+s,this.cp1x,this.cp1y+s,this.lx,this.ly+a),r.fill())}};var _n=class{constructor(t,e,r,i){this.connective=t;this.span=e;this.noteAnchor=r;d(this,"noteGroups");d(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(){let{stemDir:t}=this.noteGroups[0],{hasStem:e}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=t==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=t==="up"||!e?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor="center":this.connective==="slide"?this.noteAnchor="center":this.arcDir==="up"?this.noteAnchor="above":this.noteAnchor="below";else if(this.noteAnchor==="center"){let{row:r}=this.noteGroups[0].measure,i=this.noteGroups[0].ownDiatonicId,o=r.getStaff(i);this.arcDir=!o||i<o.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(t=>{t.measure.removeConnectiveObjects(),t.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){this.getStartNoteGroup().collectConnectiveProps(),this.computeParams();let{connective:t,span:e}=this;if(t==="tie"){if(A.Is.isEnumValue(e,Ke)){let r=this.noteGroups[0];for(let i=0;i<r.notes.length;i++)this.createObjConnectiveWithTieType(r,i,e)}else if(this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];i.notes.forEach((s,a)=>{let c=o.notes.findIndex(u=>W.equals(u,s));c>=0&&this.createObjConnective(i,a,o,c)})}}else if(t==="slur"){if(typeof e=="number"&&e>=2&&this.noteGroups.length===e){let r=this.noteGroups[0],i=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,0,i,0)}}else if(t==="slide"&&this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];this.createObjConnective(i,0,o,0)}}createObjConnectiveWithTieType(t,e,r){t.row.getNotationLines().filter(i=>t.enableConnective(i)).forEach(i=>{i instanceof Tt?new Ii(this,i,t.measure,t,e,r):t.getFretNumberString(e)!==void 0&&new Ii(this,i,t.measure,t,e,r)})}createObjConnective(t,e,r,i){let o=(s,a,c,u,l)=>{s.row.getNotationLines().filter(h=>a.enableConnective(h)&&u.enableConnective(h)).forEach(h=>{if(h instanceof Tt)new Ii(this,h,s,a,c,u,l);else{let p=a.getFretNumberString(c),m=u.getFretNumberString(l);p!==void 0&&m!==void 0&&(p===m||this.connective==="slur")&&new Ii(this,h,s,a,c,u,l)}})};if(t.measure===r.measure)o(t.measure,t,e,r,i);else if(t.measure.getNextMeasure()===r.measure)o(t.measure,t,e,r,i),o(r.measure,t,e,r,i);else throw new O(6,"Cannot create connective because it is jumping measures.")}};function ra(n){if(se().indexOf(n)<0)throw new O(6,"Invalid voiceId: "+n);return n}function wb(n){if(typeof n=="string"&&(n=[n]),A.Is.isArray(n)){let t=0;for(let e=0;e<n.length;){let r=n[e],i=n[e+1];if(typeof r=="string"){e++;let o=Qt.get(r).ticks;typeof i=="number"&&(e++,o*=i),t+=o}else e++}return t}else return n}var jo=class jo extends it{constructor(e){super(e);this.row=e;d(this,"prevMeasure");d(this,"nextMeasure");d(this,"keySignature",Xo());d(this,"timeSignature",$o());d(this,"tempo",ts());d(this,"alterKeySignature");d(this,"alterTimeSignature");d(this,"alterTempo");d(this,"signatures",[]);d(this,"tabStringNotes",[]);d(this,"barLineLeft");d(this,"columns",[]);d(this,"barLineRight");d(this,"connectives",[]);d(this,"beamGroups",[]);d(this,"tabStringNotesWidth",0);d(this,"measureId");d(this,"needLayout",!0);d(this,"leftSolidAreaWidth",0);d(this,"minColumnsAreaWidth",0);d(this,"rightSolidAreaWidth",0);d(this,"useDiatonicId",[]);d(this,"useStemDir",[]);d(this,"useString",[]);d(this,"voiceSymbols",[]);d(this,"lastAddedRhythmColumn");d(this,"lastAddedRhythmSymbol");d(this,"addExtensionToMusicObjects",[]);d(this,"layoutObjects",[]);d(this,"postMeasureBreakWidth",0);d(this,"passCount",0);d(this,"needBeamsUpdate",!0);d(this,"navigationSet",new Set);d(this,"isEndSong",!1);d(this,"isEndSection",!1);d(this,"endRepeatPlayCount",2);d(this,"endRepeatPlayCountText");d(this,"staticObjectsCache",new Map);d(this,"mi");this.mi=new Lo(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new Qr(this),this.barLineRight=new Nr(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo()}getMusicInterface(){return this.mi}get doc(){return this.row.doc}isPartialMeasure(){return this.getConsumedTicks()<this.getMeasureTicks()}isUpBeat(){return this===this.doc.getFirstMeasure()}resetPassCount(){this.passCount=0}incPassCount(){this.passCount++}getPassCount(){return this.passCount}updateOwnDiatonicId(e,r){if(typeof r=="number")this.useDiatonicId[e]=r;else if(this.useDiatonicId[e]===void 0){let o=this.getPrevMeasure();o&&o.useDiatonicId[e]!==void 0&&(this.useDiatonicId[e]=o.useDiatonicId[e])}let i=this.useDiatonicId[e];return i===void 0&&(this.row.hasStaff?i=this.row.getTopStaff().middleLineDiatonicId:i=W.getNote("C4").diatonicId),this.useDiatonicId[e]=W.validateDiatonicId(i)}updateOwnStemDir(e,r){var s,a;let{voiceId:i}=e;r!==void 0?this.useStemDir[i]=r:this.useStemDir[i]===void 0&&(this.useStemDir[i]=(a=(s=this.getPrevMeasure())==null?void 0:s.useStemDir[i])!=null?a:"auto");let o=this.useStemDir[i];if(o==="auto"||o===void 0){let c=this.row.getStaff(e.ownDiatonicId);return c?e.ownDiatonicId>c.middleLineDiatonicId?"down":"up":"up"}else return o}updateOwnString(e,r){var o,s;let{voiceId:i}=e;return r!==void 0?this.useString[i]=r:this.useString[i]===void 0&&(this.useString[i]=(s=(o=this.getPrevMeasure())==null?void 0:o.useString[i])!=null?s:[]),this.useString[i]}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.signatures.length;i++){let o=this.signatures[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabStringNotes.length;i++){let o=this.tabStringNotes[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.columns.length;i++){let o=this.columns[i].pick(e,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let i=this.barLineLeft.pick(e,r);if(i.length>0)return[this,...i]}if(this.barLineRight){let i=this.barLineRight.pick(e,r);if(i.length>0)return[this,...i]}if(this.endRepeatPlayCountText){let i=this.endRepeatPlayCountText.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.connectives.length;i++){let o=this.connectives[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.beamGroups.length;i++){let o=this.beamGroups[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.layoutObjects.length;i++){let o=this.layoutObjects[i].musicObj.pick(e,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let e=this.doc.getFirstMeasure();return e&&e.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(e){return this.getColumns()[e]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...e){var r;if((r=this.getPrevMeasure())==null||r.endSection(),e[0]instanceof Fe)this.alterKeySignature=e[0];else if(e[0]instanceof jr)this.alterKeySignature=e[0];else if(A.Is.isNonEmptyString(e[0])){if(e.length===1)this.alterKeySignature=dr(e[0]);else if(e.length===2)try{let i=""+e[0],o=kn(""+e[1]);this.alterKeySignature=dr(i,o)}catch(i){throw new O(6,"Cannot set key signature because invalid args: "+e)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:Xo(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(e){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=e instanceof gr?e:new gr(e),this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:$o(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r,i){var o;if((o=this.getPrevMeasure())==null||o.endSection(),r===void 0)this.alterTempo={beatsPerMinute:e};else{let s=typeof i=="number"&&i>0?i:i===!0?1:Xt.get(r).dotCount,a={beatLength:ni(r),dotCount:s>0?s:void 0};this.alterTempo={beatsPerMinute:e,options:a}}this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:ts(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,o;this.alterTempo.options?(i=this.alterTempo.options.beatLength,o=(e=this.alterTempo.options.dotCount)!=null?e:0):this.alterTimeSignature?(i=this.alterTimeSignature.beatLength,o=0):(i=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:i,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,i,o){this.layoutObjects.push(new aa(e,r,i,o)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(e,r,i){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&i(o[a],c);else if(typeof a=="string"&&a.length>0){let l=o.filter(h=>h.name===a);if(l.forEach(h=>i(h,c)),l.length===0){let h=this.doc.getStaffGroup(a);if(h&&!u.includes(a)){let p=[...u,a];(A.Is.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(m=>{switch(h.verticalPosition){case"above":s(m,0,p);break;case"below":s(m,1,p);break;case"both":s(m,0,p),s(m,1,p);break;case"auto":s(m,r,p);break}})}}}};e===void 0?o.length>=2&&o[0]instanceof Tt&&o[0].staffConfig.clef==="G"&&o[0].isGrand()&&o[1]instanceof Tt&&o[1].staffConfig.clef==="F"&&o[1].isGrand()?s(r===1?1:0,r):s(0,r):A.Is.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let i=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new O(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(o,s)=>{this.addLayoutObject(new An(i,s),o,0,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof An&&r.anchor===e)}addNavigation(e,r,...i){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new O(6,"Cannot add ending beasure measure already has one.");let s=this,a=i;o={createObj:()=>new vi(s,a),layoutGroupId:3,defaultVerticalPos:0};break;case"D.C. al Coda":case"D.C. al Fine":case"D.S. al Coda":case"D.S. al Fine":{let c=this.barLineRight,u=wo(r);o={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0},this.addNavigation(e,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=wo(r);o={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=wo(r);o={createObj:()=>new $e(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=wo(r);o={createObj:()=>new $e(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case"endRepeat":if(i.length===0)this.endRepeatPlayCount=2;else if(A.Is.isIntegerGte(i[0],2))this.endRepeatPlayCount=i[0];else throw new O(6,"Invalid end repeat play count (should be 2 or greater integer): "+i[0]);if(this.endRepeatPlayCount!==2){let c={text:""+this.endRepeatPlayCount+"x",scale:.8};this.endRepeatPlayCountText=new lt(this,c,.5,1)}break}o&&this.forEachStaffGroup(e,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add annotation because annotation text is empty.")}else throw new O(6,"Cannot add annotation because anchor is undefined.");let s={text:i},a,c;switch(r){case"dynamics":a=5,c=0,s.italic=!0;break;case"tempo":a=4,c=0,s.italic=!0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(e,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add label because label text is empty.")}else throw new O(6,"Cannot add label because anchor is undefined.");let s={text:i},a,c;switch(r){case"note":a=1,c=1;break;case"chord":a=6,c=0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addConnective(e,...r){let i=this.lastAddedRhythmSymbol;if(!(i instanceof vt))throw new O(6,"Connective can be added to note group only.");if(e==="tie"){let o=A.Is.isInteger(r[0])||A.Is.isEnumValue(r[0],Ke)?r[0]:2,s=A.Is.isEnumValue(r[1],Le)?r[1]:"auto";i.startConnective(new _n("tie",o,s,i))}else if(e==="slur"){let o=A.Is.isInteger(r[0])?r[0]:2,s=A.Is.isEnumValue(r[1],Le)?r[1]:"auto";i.startConnective(new _n("slur",o,s,i))}else if(e==="slide"){let o=A.Is.isEnumValue(r[0],Le)?r[0]:"auto";i.startConnective(new _n("slide",2,o,i))}}addExtension(e,r){if(this.addExtensionToMusicObjects.forEach(i=>{let o=i.getParent();if(i instanceof lt&&o instanceof Tr){let s="dashed",a="bottom",c=new _i(i,o,wb(e),r,s,a);i.setLink(c)}else throw new O(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new O(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(e){this.addExtensionToMusicObjects.push(e)}disableExtension(){this.addExtensionToMusicObjects=[]}getEnding(){return this.layoutObjects.map(e=>e.musicObj).find(e=>e instanceof vi)}getEndRepeatPlayCount(){return this.endRepeatPlayCount}endSong(){this.isEndSong=!0,this.requestLayout(),this.disableExtension()}hasEndSong(){return this.isEndSong}endSection(){this.isEndSection=!0,this.requestLayout(),this.disableExtension()}hasEndSection(){return this.isEndSection}endRow(){this.doc.requestNewRow(),this.disableExtension()}addRhythmSymbol(e,r){let{col:i}=r;i.setVoiceSymbol(e,r),this.getVoiceSymbols(e),this.voiceSymbols[e].push(r),r.oldStyleTriplet&&this.createOldStyleTriplets(e),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=i,this.lastAddedRhythmSymbol=r}addNoteGroup(e,r,i,o,s){let a=r.map(l=>typeof l=="string"?W.getNote(l):l),c=this.getRhythmColumn(e),u=new vt(c,e,a,i,o,s);return this.addRhythmSymbol(e,u),u}addRest(e,r,i,o){let s=this.getRhythmColumn(e),a=new wr(s,e,r,i,o);return this.addRhythmSymbol(e,a),a}getRhythmColumn(e){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let o=this.columns[i],s=o.getVoiceSymbol(e);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let i=0;i<=this.columns.length;i++){let o=this.columns[i];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new Tr(this,r);return this.columns.splice(i,0,s),s}}throw new O(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(i=>{se().forEach(o=>{let s=i.getVoiceSymbol(o);s&&(e===void 0||e===o)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new B(this.barLineLeft.getRect().centerX,this.barLineRight.getRect().centerX,this.getRect().top,this.getRect().bottom)}getLeftSolidAreaWidth(){return this.leftSolidAreaWidth}getMinColumnsAreaWidth(){return this.minColumnsAreaWidth}getRightSolidAreaWidth(){return this.rightSolidAreaWidth}getSolidAreaWidth(){return this.leftSolidAreaWidth+this.rightSolidAreaWidth}getMinWidth(){return this.leftSolidAreaWidth+this.minColumnsAreaWidth+this.rightSolidAreaWidth}getStaffLineLeft(){let e=this.getPrevMeasure();return e&&e.row===this.row&&!e.hasPostMeasureBreak()?e.getStaffLineRight():this.getRect().left+this.tabStringNotesWidth}getStaffLineRight(){return this.barLineRight.getRect().centerX}getStaticObjects(e){let r=this.staticObjectsCache.get(e);r||(r=[],this.getColumns().forEach(o=>o.getStaticObjects(e).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(e,r));let i=this.layoutObjects.filter(o=>o.line===e&&o.isPositionResolved()).map(o=>o.musicObj);return i.length>0?[...r,...i]:r}removeLayoutObjects(e){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===e){let i=r.musicObj.getLink();return i&&i.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(e){this.connectives.push(e),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(e=>{var c;let{musicObj:r,measure:i,layoutGroupId:o,verticalPos:s,line:a}=e;if(r.getLink()instanceof _i){let u=r.getLink();if(u.getHead()===r){u.getTails().forEach(p=>i.removeLayoutObjects(p));let{startColumn:l,endColumn:h}=u.getExtensionRangeInfo();if(u.isVisible()&&l!==h)for(let p=l.measure;p!==void 0;p=p===h.measure?void 0:p.getNextMeasure()){let m=p===l.measure?u.getHead():p.getBarLineLeft(),f=p===h.measure?h:p.getBarLineRight(),g=p.row.getNotationLines(),y=(c=g.find(b=>b.name!==""&&b.name===a.name))!=null?c:g[a.id];y&&p.addLayoutObject(new Cn(p,y,u,m,f),y,o,s)}}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);for(let i=0;i<r.length;)if(r[i].oldStyleTriplet){let o=Xr.createOldStyleTriplet(r.slice(i,i+3));i+=o===0?1:o}else i++;this.requestLayout()}createBeams(){this.needBeamsUpdate&&(this.beamGroups=this.beamGroups.filter(e=>e.isTuplet()?!0:(e.detach(),!1)),se().forEach(e=>{let r=this.getVoiceSymbols(e);if(!(r.length<=2)&&!Zs.DisableBeams){let i=[],o=0,s=0;this.isUpBeat()&&(o=s=Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()));let a=this.getTimeSignature();r.forEach(c=>{for(i.push(c),s+=c.rhythmProps.ticks,o===0&&s===a.beamGroupLength&&jo.setupBeamGroup(i);s>=a.beamGroupLength;)i=[],o=s=s-a.beamGroupLength})}}),this.needBeamsUpdate=!1,this.requestLayout())}static setupBeamGroup(e){let r=e.map(o=>{var s;return o instanceof vt&&((s=o.getBeamGroup())==null?void 0:s.isTuplet())!==!0?o:void 0});vt.setBeamCounts(r);let i=[];r.forEach(o=>{o&&o.hasBeamCount()?i.push(o):(Xr.createBeam(i),i=[])}),Xr.createBeam(i)}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return ra(e),this.voiceSymbols[e]===void 0&&(this.voiceSymbols[e]=[]),this.voiceSymbols[e]}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(se().filter(r=>this.getConsumedTicks(r)>0));return}else if(A.Is.isArray(e)){e.forEach(r=>this.completeRests(r));return}else{ra(e);let r=this.getMeasureTicks(),i=this.getConsumedTicks(e),o=r-i,s=[];for(;o>0;)for(let a=Xt.LongestNoteSize;a<=Xt.ShortestNoteSize;a*=2){let c=Xt.create(a).noteLength;for(let u=Xt.get(c).maxDotCount;u>=0;u--){let l=Qt.get(c,u);for(;l.ticks<=o;)s.push(l),o-=l.ticks}}s.reverse().forEach(a=>this.addRest(e,a.noteLength,{dotted:a.dotCount}))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?at.PostMeasureBreakWidth*r:0;let i=this===this.row.getFirstMeasure(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.tabStringNotesWidth=i&&this.row.hasTab?r*4:0;let s=i||o,a=i&&!this.row.isFirstRow(),c=i||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;s||a||c||u||l?this.signatures=this.row.getStaves().map((f,g)=>{let y=this.signatures.find(I=>I.staff===f),b=y!=null?y:new Js(this,f);return b.staff.addObject(b),b.updateClefImage(e,s),b.updateMeasureNumber(a&&g===0),b.updateKeySignature(c),b.updateTimeSignature(u),b.updateTempo(l&&g===0),b}):this.signatures=[],this.signatures.forEach(f=>f.layout(e)),this.tabStringNotes.length=0,this===this.row.getFirstMeasure()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let y=f.getTuningStrings()[g].format(1,1),b=new lt(this,{text:y,scale:.8},1,.5);b.layout(e),b.offset(this.tabStringNotesWidth*.8,f.getStringY(g)),this.tabStringNotes.push(b),f.addObject(b)}}),this.barLineLeft.layout(e);let h=new Qs(this);this.columns.forEach(f=>f.layout(e,h)),this.barLineRight.layout(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(e),this.layoutObjects.forEach(f=>f.layout(e));let p=e.unitSize;this.leftSolidAreaWidth=this.tabStringNotesWidth+Math.max(0,...this.signatures.map(f=>f.getRect().width))+this.barLineLeft.getRect().width+p,this.rightSolidAreaWidth=p+this.barLineRight.getRect().width,this.minColumnsAreaWidth=0,this.columns.forEach(f=>this.minColumnsAreaWidth+=f.getRect().width),this.minColumnsAreaWidth=Math.max(this.minColumnsAreaWidth,jo.MinFlexContentWidth*r)}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new B,this.rect.centerX=this.rect.left+r/2,this.rect.right=this.rect.left+r;let i;this.signatures.forEach(p=>{i=p.getRect(),p.offset(this.rect.left+this.tabStringNotesWidth-i.left,-i.centerY)});let o=Math.max(0,...this.signatures.map(p=>p.getRect().width));i=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.tabStringNotesWidth+o-i.left,-i.centerY),i=this.barLineRight.getRect(),this.barLineRight.offset(this.rect.right-i.right,-i.centerY),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left,this.barLineRight.getRect().top);let s=this.rect.left+this.leftSolidAreaWidth,c=this.rect.right-this.rightSolidAreaWidth-s,u=A.Math.sum(this.columns.map(p=>p.getRect().width)),l=c/u,h=s;this.columns.forEach(p=>{i=p.getRect();let m=h+i.leftw*l;p.offset(m-i.centerX,-i.centerY),h+=i.width*l})}layoutConnectives(e){this.needLayout&&this.connectives.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(e){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}alignStemsToBeams(){this.beamGroups.forEach(e=>e.updateStemTips())}layoutDone(){this.columns.forEach(e=>e.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(e=>e.getRect().top),...this.tabStringNotes.map(e=>e.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(e=>e.getRect().top),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(e=>e.getRect().bottom),...this.tabStringNotes.map(e=>e.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(e=>e.getRect().bottom),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().bottom)),this===this.row.getLastMeasure()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(e=>e.isPositionResolved()&&e.musicObj instanceof An).map(e=>e.musicObj.getRect().right))),this.row.getNotationLines().forEach(e=>{this.rect.top=Math.min(this.rect.top,e.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,e.calcBottom())}),this.row.requestRectUpdate()}offset(e,r){this.signatures.forEach(i=>i.offset(e,0)),this.tabStringNotes.forEach(i=>i.offset(e,0)),this.barLineLeft.offset(e,r),this.columns.forEach(i=>i.offset(e,r)),this.barLineRight.offset(e,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(e,r),this.connectives.forEach(i=>i.offset(e,0)),this.beamGroups.forEach(i=>i.offset(e,r)),this.layoutObjects.forEach(i=>i.offset(e,0)),this.rect.offsetInPlace(e,r),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let r=this.getStaffLineLeft(),i=this.getStaffLineRight(),o=a=>e.drawLine(r,a,i,a),{row:s}=this;s.getNotationLines().forEach(a=>{if(a instanceof Tt)for(let c=a.bottomLineDiatonicId;c<=a.topLineDiatonicId;c+=2)o(a.getDiatonicIdY(c));else if(a instanceof Pe)for(let c=0;c<6;c++)o(a.getStringY(c))}),this.signatures.forEach(a=>a.draw(e)),this.tabStringNotes.forEach(a=>a.draw(e)),this.barLineLeft.draw(e),this.columns.forEach(a=>a.draw(e)),this.barLineRight.draw(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(e),this.connectives.forEach(a=>a.draw(e)),this.layoutObjects.forEach(a=>a.musicObj.draw(e)),this.beamGroups.forEach(a=>a.draw(e))}};d(jo,"MinFlexContentWidth",10);var vn=jo;var Tb=[1,6],Nb=[2,3,4,5,6];function Ob(n){for(;n;){if(n instanceof vn)return n;n=n.getParent()}throw new O(6,"Parent measure is required but not found!")}var ca=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},aa=class{constructor(t,e,r,i){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=i;d(this,"anchor");d(this,"measure");d(this,"row");d(this,"layoutGroup");d(this,"positionResolved",!0);this.measure=Ob(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new O(6,"Parent music object is required as an anchor.");this.anchor=o,this.anchor.addAnchoredLayoutObject(this),this.layoutGroup=this.line.getLayoutGroup(r),this.layoutGroup.add(this)}clearPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(t){let{musicObj:e,measure:r,verticalPos:i,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=t.unitSize*2,u=i===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,l=r.getStaticObjects(o),h=e.getShapeRects();return l.forEach(p=>{let m=p.getShapeRects();h.forEach(f=>{m.forEach(g=>{B.overlapX(f,g)&&(u=i===1?Math.max(u,g.bottom+f.toph+f.centerY):Math.min(u,g.top-f.bottomh-f.centerY))})})}),u}getTextContent(){if(this.musicObj instanceof lt||this.musicObj instanceof $e)return this.musicObj.getText()}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}getRect(){return this.musicObj.getRect()}},ua=class{constructor(t){this.layoutGroupId=t;d(this,"layoutObjectTable",[]);d(this,"rowAlign");d(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=Nb.indexOf(t)>=0,this.widensColumn=Tb.indexOf(t)>=0}getLayoutObjects(t){return this.layoutObjectTable[t]}add(t){this.layoutObjectTable[t.verticalPos].push(t)}remove(t){this.layoutObjectTable.forEach(e=>{let r=e.indexOf(t);r>=0&&e.splice(r,1)})}clearPositionAndLayout(t){this.layoutObjectTable.forEach(e=>{e.forEach(r=>{r.clearPositionResolved(),r.musicObj.layout(t)})})}};var la=class extends it{constructor(e){super(e);d(this,"objects",[]);d(this,"layoutGroups",[])}addObject(e){this.objects.push(e)}removeObjects(){this.objects.length=0}getLayoutGroup(e){let r=this.layoutGroups[e];return r||(r=this.layoutGroups[e]=new ua(e)),r}resetLayoutGroups(e){this.layoutGroups.forEach(r=>{r&&r.clearPositionAndLayout(e)})}layoutLayoutGroups(e){this.layoutGroups.forEach(r=>{r&&(this.layoutLayoutGroup(e,r,0),this.layoutLayoutGroup(e,r,1))})}setObjectY(e,r){r!==void 0&&(e.offset(0,r-e.getRect().centerY),e.setPositionResolved())}alignObjectsY(e,r){r=r.filter(o=>!o.isPositionResolved());let i;r.forEach(o=>{let s=o.resolveClosestToStaffY(e);i=o.verticalPos===1?Math.max(s,i!=null?i:s):Math.min(s,i!=null?i:s)}),r.forEach(o=>this.setObjectY(o,i))}layoutLayoutGroup(e,r,i){let o=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof vi||a instanceof Cn?a.layoutFitToMeasure(e):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(e,o):o.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=o.filter(l=>c.some(h=>h===l.musicObj));this.alignObjectsY(e,u)}else this.alignObjectsY(e,[s])})}},Tt=class extends la{constructor(e,r,i){super(e);this.row=e;this.staffConfig=r;this.id=i;d(this,"clefImageAsset");d(this,"clefLineDiatonicId");d(this,"topLineDiatonicId");d(this,"middleLineDiatonicId");d(this,"bottomLineDiatonicId");d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"joinedGrandStaff");d(this,"topLineY",0);d(this,"bottomLineY",0);d(this,"mi");let o=(s,a)=>W.getNote(s).diatonicId-(a?7:0);if(r.clef==="G")this.clefImageAsset=0,this.clefLineDiatonicId=o("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2;else if(r.clef==="F")this.clefImageAsset=1,this.clefLineDiatonicId=o("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2;else throw new O(6,`Invalid staffConfig.clef ${r.clef}.`);this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(o(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(o(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new Po(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var e;return(e=this.staffConfig.name)!=null?e:""}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(e){e!==this&&(this.joinedGrandStaff=e)}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(e){return W.validateDiatonicId(e),(this.minDiatonicId===void 0||e>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||e<=this.maxDiatonicId)}getDiatonicIdY(e){if(this.containsDiatonicId(e))return this.bottomLineY+(this.bottomLineDiatonicId-e)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff.getDiatonicIdY(e);throw new O(6,"Staff does not contain diatonicId "+e)}getActualStaff(e){if(this.containsDiatonicId(e))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff;throw new O(6,"Staff does not contain diatonicId "+e)}getDiatonicIdAt(e){let r=Math.round(this.bottomLineDiatonicId-(e-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(e){return e%2===this.middleLineDiatonicId%2}isSpace(e){return e%2!==this.middleLineDiatonicId%2}containsVoiceId(e){return!this.staffConfig.voiceIds||this.staffConfig.voiceIds.includes(e)}isGrand(){return this.staffConfig.isGrand===!0}calcTop(){let e=this.topLineY;if(this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),i=this.getDiatonicIdY(this.maxDiatonicId-1);e=Math.min(e,r-Math.abs(i-r)+1)}return e}calcBottom(){let e=this.bottomLineY;if(this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),i=this.getDiatonicIdY(this.minDiatonicId+1);e=Math.max(e,r+Math.abs(i-r)-1)}return e}pick(e,r){return[this]}layoutHeight(e){let{unitSize:r}=e,i=r*at.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new B(0,0,this.topLineY,this.bottomLineY)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}},Pe=class extends la{constructor(e,r,i){super(e);this.row=e;this.tabConfig=r;this.id=i;d(this,"top",0);d(this,"bottom",0);d(this,"tuningName");d(this,"tuningStrings");d(this,"mi");A.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>W.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=ic(r.tuning),this.tuningStrings=Ko(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=Ko(this.tuningName)),this.mi=new Fo(this)}getMusicInterface(){return this.mi}get name(){var e;return(e=this.tabConfig.name)!=null?e:""}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(e){return this.top+(this.bottom-this.top)/6*(e+.5)}getTopStringY(){return this.getStringY(0)}getBottomStringY(){return this.getStringY(5)}getTopLineY(){return this.getTopStringY()}getBottomLineY(){return this.getBottomStringY()}getTop(){return this.top}getBottom(){return this.bottom}containsVoiceId(e){return!this.tabConfig.voiceIds||this.tabConfig.voiceIds.includes(e)}containsDiatonicId(e){return!0}calcTop(){return this.top}calcBottom(){return this.bottom}pick(e,r){return[this]}layoutHeight(e){let{unitSize:r}=e,i=r*at.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new B(0,0,this.top,this.bottom)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.top+=r,this.bottom+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}};var ha=class extends it{constructor(e,r,i){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=i;d(this,"nextRow");d(this,"minWidth",0);d(this,"notationLines");d(this,"staves");d(this,"tabs");d(this,"measures",[]);d(this,"needLayout",!0);d(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(o=>o instanceof Tt),this.tabs=this.notationLines.filter(o=>o instanceof Pe),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new Bo(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,i)=>r.type==="staff"?new Tt(this,r,i):new Pe(this,r,i));for(let r=0;r<e.length-1;r++){let i=e[r],o=e[r+1];i instanceof Tt&&i.isGrand()&&i.staffConfig.clef==="G"&&o instanceof Tt&&o.isGrand()&&o.staffConfig.clef==="F"&&(i.joinGrandStaff(o),o.joinGrandStaff(i))}return e}getNotationLines(){return this.notationLines}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let e=this.staves[0];if(e)return e;throw new O(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new O(6,"Bottom staff is required!")}getStaff(e){W.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r];if(i instanceof Tt&&i.containsDiatonicId(e))return i}}resetLayoutGroups(e){this.notationLines.forEach(r=>r.resetLayoutGroups(e))}layoutLayoutGroups(e){this.notationLines.forEach(r=>r.layoutLayoutGroups(e))}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.measures.length;i++){let o=this.measures[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.notationLines.length;i++){let o=this.notationLines[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:e.left;return new B(i,(i+e.right)/2,e.right,e.top,e.centerY,e.bottom)}getDiatonicIdAt(e){for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r],o=i instanceof Tt?i.getDiatonicIdAt(e):void 0;if(o!==void 0)return o}}addMeasure(e){this.measures.push(e)}getMeasures(){return this.measures}isFirstRow(){return this===this.doc.getFirstRow()}isLastRow(){return this===this.doc.getLastRow()}getPrevRow(){return this.prevRow}getNextRow(){return this.nextRow}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}getMinWidth(){return this.minWidth}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(e){this.needLayout&&(this.requestRectUpdate(),this.notationLines.forEach(r=>{r.removeObjects(),r.layoutHeight(e)}),this.rect=new B(0,0,0,0),this.minWidth=0,this.measures.forEach(r=>{r.layout(e),this.minWidth+=r.getMinWidth(),this.minWidth+=r.getPostMeasureBreakWidth()}))}layoutWidth(e,r){if(!this.needLayout)return;let i=Math.max(r,this.minWidth);this.rect.centerX=this.rect.left+i/2,this.rect.right=this.rect.left+i,this.notationLines.forEach(u=>u.layoutWidth(e));let o=i,s=0;this.measures.forEach(u=>{o-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=o/s,c=0;this.measures.forEach(u=>{let l=u.getSolidAreaWidth()+u.getMinColumnsAreaWidth()*a;u.layoutWidth(e,l);let h=u.getRect();u.offset(c-h.left,-h.centerY),c+=h.width,c+=u.getPostMeasureBreakWidth()}),this.measures.forEach(u=>{u.layoutConnectives(e),u.layoutBeams(e)})}updateRect(){let e=this.measures.length>0?this.measures[0].getRect().left:0,r=this.measures.length>0?this.measures[this.measures.length-1].getRect().right:0,i=this.measures.length>0?Math.min(...this.measures.map(s=>s.getRect().top)):0,o=this.measures.length>0?Math.max(...this.measures.map(s=>s.getRect().bottom)):0;this.rect=new B(e,r,i,o)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutPositionLines(e){let{unitSize:r}=e;for(let i=1;i<this.notationLines.length;i++){let o=this.notationLines[i-1],s=this.notationLines[i];if(o instanceof Tt&&o.isGrand()&&o.staffConfig.clef==="G"&&s instanceof Tt&&s.isGrand()&&s.staffConfig.clef==="F"){let a=r*6;s.offset(0,o.getBottomLineY()-s.getTopLineY()+a)}else{let a=r*3;s.offset(0,o.calcBottom()-s.calcTop()+a)}}this.measures.forEach(i=>{i.requestRectUpdate(),i.getBarLineLeft().requestRectUpdate(),i.getBarLineRight().requestRectUpdate(),i.getColumns().forEach(o=>{o.requestRectUpdate(),se().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.alignStemsToBeams(),this.requestRectUpdate()}layoutPadding(e){let r=e.unitSize/2;this.getRect(),this.rect.left-=r,this.rect.right+=r,this.rect.top-=r,this.rect.bottom+=r}layoutDone(){this.measures.forEach(e=>e.layoutDone()),this.needLayout=!1}offset(e,r){this.measures.forEach(i=>i.offset(e,r)),this.rect.offsetInPlace(e,r),this.notationLines.forEach(i=>i.offset(e,r))}draw(e){let r=e.getCanvasContext();if(r){if(e.drawDebugRect(this.getRect()),r.save(),r.rect(this.getRect().left,this.getRect().top,this.getRect().width,this.getRect().height),r.clip(),this.getFirstMeasure()&&(this.notationLines.length>1||this.notationLines[0]instanceof Pe)){let i=this.getFirstMeasure().getStaffLineLeft(),o=Math.min(...this.notationLines.map(a=>a.getTopLineY())),s=Math.max(...this.notationLines.map(a=>a.getBottomLineY()));e.drawLine(i,o,i,s)}this.measures.forEach(i=>i.draw(e)),this.notationLines.forEach(i=>i.draw(e)),r.restore()}}};var pa=class extends it{constructor(e,r,i,o){super(e);this.title=r;this.composer=i;this.arranger=o;d(this,"titleText");d(this,"composerText");d(this,"arrangerText");d(this,"mi");this.mi=new Go(this),this.titleText=this.title?new lt(this,{text:this.title,scale:2},.5,0):void 0,this.composerText=this.composer?new lt(this,this.composer,1,0):void 0,this.arrangerText=this.arranger?new lt(this,"Arr.: "+this.arranger,1,0):void 0}getMusicInterface(){return this.mi}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.titleText){let i=this.titleText.pick(e,r);if(i)return[this,...i]}if(this.composerText){let i=this.composerText.pick(e,r);if(i)return[this,...i]}if(this.arrangerText){let i=this.arrangerText.pick(e,r);if(i)return[this,...i]}return[this]}layoutWidth(e,r){let i=0;this.rect=new B(0,r,0,0),this.titleText&&(this.titleText.layout(e),this.titleText.offset(r/2,i),i+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(e),this.composerText.offset(r,i),i+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(e),this.arrangerText.offset(r,i),i+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(e,r){this.titleText&&this.titleText.offset(e,r),this.composerText&&this.composerText.offset(e,r),this.arrangerText&&this.arrangerText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.titleText&&this.titleText.draw(e),this.composerText&&this.composerText.draw(e),this.arrangerText&&this.arrangerText.draw(e)}};var da=class extends it{constructor(){super(void 0);d(this,"needLayout",!0);d(this,"renderer");d(this,"rows",[]);d(this,"measures",[]);d(this,"measuresPerRow",1/0);d(this,"curScoreConfig",[{type:"staff",clef:"G"}]);d(this,"header");d(this,"newRowRequested",!1);d(this,"allConnectiveProps",[]);d(this,"staffGroups",new Map);d(this,"mi");this.mi=new Kr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(A.Is.isEnumValue(e,yn))switch(e){default:case"treble":this.curScoreConfig=[{type:"staff",clef:"G"}];break;case"bass":this.curScoreConfig=[{type:"staff",clef:"F"}];break;case"grand":this.curScoreConfig=[{type:"staff",clef:"G",isGrand:!0},{type:"staff",clef:"F",isGrand:!0}];break;case"guitarTreble":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case"guitarTab":this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case"guitarCombined":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else A.Is.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0;r<this.curScoreConfig.length-1;r++){let i=this.curScoreConfig[r],o=this.curScoreConfig[r+1];i.type==="staff"&&o.type==="staff"?i.clef==="G"&&i.isGrand&&o.clef==="F"&&o.isGrand?(i.minNote="C4",o.maxNote="B3",i.isOctaveDown=o.isOctaveDown=!1):i.isGrand=o.isGrand=!1:i.type==="staff"?i.isGrand=!1:o.type==="staff"&&(o.isGrand=!1)}this.requestNewRow()}setMeasuresPerRow(e){this.measuresPerRow=e}addConnectiveProps(e){this.allConnectiveProps.push(e)}setRenderer(e){if(this.renderer===e)return;let r=this.renderer;this.renderer=e,r&&r.setDocument(void 0),e&&e.setDocument(this.mi),this.requestFullLayout()}setHeader(e,r,i){this.header=new pa(this,e,r,i),this.requestLayout()}getTitle(){var e;return(e=this.header)==null?void 0:e.title}getComposer(){var e;return(e=this.header)==null?void 0:e.composer}getArranger(){var e;return(e=this.header)==null?void 0:e.arranger}hasSingleMeasure(){return this.measures.length===1}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}addNewRow(e){let r=new ha(this,e,this.curScoreConfig);return this.rows.push(r),r}getFirstRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[0]}getLastRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[this.rows.length-1]}getRows(){return this.rows}getMeasures(){return this.measures}requestNewRow(){this.newRowRequested=!0}addMeasure(){let e=this.rows[this.rows.length-1];(!e||this.newRowRequested&&e.getMeasures().length>0||e.getMeasures().length>=this.measuresPerRow)&&(e=this.addNewRow(e),this.newRowRequested=!1);let r=new vn(e);return this.measures.push(r),e.addMeasure(r),this.requestLayout(),r}addStaffGroup(e,r,i){this.staffGroups.set(e,new ca(e,r,i))}getStaffGroup(e){return this.staffGroups.get(e)}getVoiceSymbols(e){let r=[];return this.forEachMeasure(i=>r=r.concat(i.getVoiceSymbols(e))),r}removeLayoutObjects(e){this.forEachMeasure(r=>r.removeLayoutObjects(e))}forEachMeasure(e){let r=this.getFirstMeasure();for(;r;)e(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(e=>e.resetPassCount())}updateCursorRect(e){this.renderer&&this.renderer.updateCursorRect(e)}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(e=>e.requestLayout()),this.forEachMeasure(e=>{e.getColumns().forEach(r=>r.requestLayout()),e.requestLayout()}),this.requestLayout()}layout(){if(!this.needLayout)return;let{renderer:e}=this;if(!e)return;let{unitSize:r}=e;this.forEachMeasure(o=>o.createBeams()),this.forEachMeasure(o=>o.createExtensions()),this.allConnectiveProps.forEach(o=>o.removeConnectives()),this.allConnectiveProps.forEach(o=>o.createConnectives()),this.rows.forEach(o=>o.resetLayoutGroups(e)),this.rows.forEach(o=>o.layout(e));let i=Math.max(at.DocumentMinWidth*r,...this.rows.map(o=>1.4*o.getMinWidth()));this.rows.forEach(o=>o.layoutWidth(e,i)),this.rows.forEach(o=>o.layoutLayoutGroups(e)),this.rows.forEach(o=>o.layoutPositionLines(e)),this.rows.forEach(o=>o.layoutPadding(e)),this.rect=new B,this.header&&(this.header.layoutWidth(e,i),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(o=>{o.offset(-this.rect.left,this.rect.bottom+r*2-o.getRect().top),this.rect.expandInPlace(o.getRect())}),this.rows.forEach(o=>o.layoutDone()),this.needLayout=!1}drawContent(){let{renderer:e}=this;e&&(this.rows.forEach(r=>r.draw(e)),this.header&&this.header.draw(e))}pickStaffPosAt(e,r){if(this.rect.contains(e,r))for(let i=0;i<this.rows.length;i++){let o=this.rows[i];if(!o.hasStaff||!o.getRect().contains(e,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.header){let i=this.header.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.rows.length;i++){let o=this.rows[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}};function G(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function Au(n){if(typeof n!="string")return!1;{let t=W.parseNote(n);return t!==void 0&&t.octave!==void 0}}function In(n){return A.Is.isNumber(n)&&se().indexOf(n)>=0}function wm(n){return A.Is.isNumber(n)&&zs().indexOf(n)>=0}function Tm(n){G(A.Is.isObject(n),"staffConfig",n),G(n.type==="staff","staffConfig.type",n.type),G(A.Is.isEnumValue(n.clef,Sr),"staffConfig.clef",n.clef),G(A.Is.isBooleanOrUndefined(n.isOctaveDown),"staffConfig.isOctaveDown",n.isOctaveDown),G(A.Is.isUndefined(n.minNote)||Au(n.minNote),"staffConfig.minNote",n.minNote),G(A.Is.isUndefined(n.maxNote)||Au(n.maxNote),"staffConfig.maxNote",n.maxNote),G(A.Is.isUndefined(n.voiceIds)||A.Is.isArray(n.voiceIds)&&n.voiceIds.every(t=>A.Is.isNumber(t)),"staffConfig.voiceIds",n.voiceIds),G(A.Is.isBooleanOrUndefined(n.isGrand),"staffConfig.isGrand",n.isGrand)}function Nm(n){G(A.Is.isObject(n),"tabConfig",n),G(n.type==="tab","tabConfig.type",n.type),typeof n.tuning=="string"?G(jn.includes(n.tuning),"tabConfig.tuning",n.tuning):A.Is.isArray(n.tuning)&&G(n.tuning.length===zs().length&&n.tuning.every(t=>Au(t)),"tabConfig.tuning",n.tuning),G(A.Is.isUndefined(n.voiceIds)||A.Is.isArray(n.voiceIds)&&n.voiceIds.every(t=>A.Is.isNumber(t)),"tabConfig.voiceIds",n.voiceIds)}function ma(n){G(A.Is.isObject(n),"noteOptions",n),G(A.Is.isBooleanOrUndefined(n.dotted)||A.Is.isIntegerGte(n.dotted,0),"noteOptions.dotted",n.dotted),G(A.Is.isEnumValueOrUndefined(n.stem,Qe),"noteOptions.stem",n.stem),G(A.Is.isStringOrUndefined(n.color),"noteOptions.color",n.color),G(A.Is.isBooleanOrUndefined(n.arpeggio)||A.Is.isEnumValue(n.arpeggio,Hr),"noteOptions.arpeggio",n.arpeggio),G(A.Is.isBooleanOrUndefined(n.staccato),"noteOptions.staccato",n.staccato),G(A.Is.isBooleanOrUndefined(n.diamond),"noteOptions.diamond",n.diamond),G(A.Is.isBooleanOrUndefined(n.triplet),"noteOptions.triplet",n.triplet),G(A.Is.isUndefined(n.string)||wm(n.string)||A.Is.isNonEmptyArray(n.string)&&n.string.every(t=>wm(t)),"noteOptions.string",n.string),G(A.Is.isUndefined(n.tieSpan),'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)',""),G(A.Is.isUndefined(n.slurSpan),'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)',"")}function Om(n){G(A.Is.isObject(n),"restOptions",n),G(A.Is.isBooleanOrUndefined(n.dotted)||A.Is.isIntegerGte(n.dotted,0),"restOptions.dotted",n.dotted),G(A.Is.isStringOrUndefined(n.staffPos)||A.Is.isInteger(n.staffPos)||n.staffPos instanceof W,"restOptions.staffPos",n.staffPos),G(A.Is.isStringOrUndefined(n.color),"restOptions.color",n.color),G(A.Is.isBooleanOrUndefined(n.hide),"restOptions.hide",n.hide),G(A.Is.isBooleanOrUndefined(n.triplet),"restOptions.triplet",n.triplet)}function fa(n){G(A.Is.isStringOrUndefined(n)||A.Is.isIntegerGte(n,0)||A.Is.isNonEmptyArray(n)&&n.every(t=>A.Is.isString(t)||A.Is.isIntegerGte(t,0)),"staffTabOrGroup",n)}function Jr(n){try{return ni(n),!0}catch(t){return!1}}function Rb(n){try{return Jo(n),!0}catch(t){return!1}}var Or=class{constructor(){d(this,"doc");this.doc=new da}setScoreConfiguration(t){return A.Is.isEnumValue(t,yn)?this.doc.setScoreConfiguration(t):A.Is.isObject(t)&&t.type==="staff"?(Tm(t),this.doc.setScoreConfiguration(t)):A.Is.isObject(t)&&t.type==="tab"?(Nm(t),this.doc.setScoreConfiguration(t)):A.Is.isNonEmptyArray(t)?(t.forEach(e=>{A.Is.isObject(e)&&e.type==="staff"?Tm(e):A.Is.isObject(e)&&e.type==="tab"?Nm(e):G(!1,"config",t)}),this.doc.setScoreConfiguration(t)):G(!1,"config",t),this}getMeasure(){var t;return(t=this.doc.getLastMeasure())!=null?t:this.doc.addMeasure()}getDocument(){return this.doc.getMusicInterface()}setHeader(t,e,r){return G(A.Is.isStringOrUndefined(t),"title",t),G(A.Is.isStringOrUndefined(e),"composer",e),G(A.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return G(A.Is.isIntegerGte(t,1)||A.Is.isPosInfinity(t),"measuresPerRow",t),this.doc.setMeasuresPerRow(t),this}addMeasure(){return this.doc.addMeasure(),this}setKeySignature(...t){return G(t[0]instanceof jr||t[0]instanceof Fe||A.Is.isNonEmptyString(t[0])&&(t.length===1||A.Is.isEnumValue(t[1],ri)),"keySignature",t),this.getMeasure().setKeySignature(...t),this}setTimeSignature(t){return G(t instanceof gr||A.Is.isNonEmptyString(t),"timeSignature",t),this.getMeasure().setTimeSignature(t),this}setTempo(t,e,r){return G(A.Is.isIntegerGte(t,1),"beatsPerMinute",t),e===void 0?G(A.Is.isUndefined(r),"dotted",r):(G(A.Is.isEnumValue(e,Zt)||Jr(e),"beatLength",e),G(A.Is.isBooleanOrUndefined(r)||A.Is.isIntegerGte(r,0),"dotted",r)),this.getMeasure().setTempo(t,e,r),this}addNote(t,e,r,i){return G(In(t),"voiceId",t),G(e instanceof W||A.Is.isNonEmptyString(e),"note",e),G(A.Is.isEnumValue(r,Zt)||Jr(r),"noteLength",r),i!==void 0&&ma(i),this.getMeasure().addNoteGroup(t,[e],r,i),this}addChord(t,e,r,i){return G(In(t),"voiceId",t),G(A.Is.isNonEmptyArray(e)&&e.every(o=>o instanceof W||A.Is.isNonEmptyString(o)),"notes",e),G(A.Is.isEnumValue(r,Zt)||Jr(r),"noteLength",r),i!==void 0&&ma(i),this.getMeasure().addNoteGroup(t,e,r,i),this}addRest(t,e,r){return G(In(t),"voiceId",t),G(A.Is.isEnumValue(e,Zt)||Jr(e),"restLength",e),r!==void 0&&Om(r),this.getMeasure().addRest(t,e,r),this}addTuplet(t,e,r){G(In(t),"voiceId",t),G(A.Is.isFunction(r),"tupletBuilder",r),G(Rb(e)&&A.Is.isBooleanOrUndefined(e.showRatio),"tupletRatio",e);let i=[],o={addNote:(s,a,c)=>{G(s instanceof W||A.Is.isNonEmptyString(s),"note",s),G(A.Is.isEnumValue(a,Zt)||Jr(a),"noteLength",a),c!==void 0&&(delete c.triplet,ma(c));let u=this.getMeasure().addNoteGroup(t,[s],a,c,e);return i.push(u),o},addChord:(s,a,c)=>{G(A.Is.isNonEmptyArray(s)&&s.every(l=>l instanceof W||A.Is.isNonEmptyString(l)),"notes",s),G(A.Is.isEnumValue(a,Zt)||Jr(a),"noteLength",a),c!==void 0&&(delete c.triplet,ma(c));let u=this.getMeasure().addNoteGroup(t,s,a,c,e);return i.push(u),o},addRest:(s,a)=>{G(A.Is.isEnumValue(s,Zt)||Jr(s),"restLength",s),a!==void 0&&(delete a.triplet,Om(a));let c=this.getMeasure().addRest(t,s,a,e);return i.push(c),o}};return r(o),Xr.createTuplet(i,e),this}addFermataInternal(t,e){return fa(t),G(A.Is.isEnumValue(e,co),"fermata",e),this.getMeasure().addFermata(t,e),this}addFermata(t="atNote"){return this.addFermataInternal(void 0,t)}addFermataTo(t,e="atNote"){return this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return fa(t),G(A.Is.isEnumValue(e,Je),"navigation",e),e==="endRepeat"&&r.length>0?G(A.Is.isIntegerGte(r[0],1),"playCount",r[0]):e==="ending"&&r.length>0&&G(r.every(i=>A.Is.isIntegerGte(i,1)),"passages",r),this.getMeasure().addNavigation(t,e,...r),this}addNavigation(t,...e){return this.addNavigationInternal(void 0,t,...e)}addNavigationTo(t,e,...r){return this.addNavigationInternal(t,e,...r)}addAnnotationInternal(t,e,r){if(e!=null||(e=Im(r)),e===void 0)throw new O(6,`Annotation text "${r}" is not known annotation.`);return fa(t),G(A.Is.isEnumValue(e,xn),"annotation",e),G(A.Is.isNonEmptyString(r),"text",r),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(...t){return t.length===1?this.addAnnotationInternal(void 0,void 0,t[0]):this.addAnnotationInternal(void 0,t[0],t[1])}addAnnotationTo(t,...e){return e.length===1?this.addAnnotationInternal(t,void 0,e[0]):this.addAnnotationInternal(t,e[0],e[1])}addLabelInternal(t,e,r){return fa(t),G(A.Is.isEnumValue(e,uo),"label",e),G(A.Is.isNonEmptyString(r),"text",r),this.getMeasure().addLabel(t,e,r),this}addLabel(t,e){return this.addLabelInternal(void 0,t,e)}addLabelTo(t,e,r){return this.addLabelInternal(t,e,r)}addConnective(t,...e){if(G(A.Is.isEnumValue(t,Zr),"connective",t),t==="tie"){G(A.Is.isIntegerOrUndefined(e[0])||A.Is.isEnumValue(e[0],Ke),"tieSpan",e[0]),G(A.Is.isEnumValueOrUndefined(e[1],Le),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t==="slur"){G(A.Is.isIntegerOrUndefined(e[0]),"slurSpan",e[0]),G(A.Is.isEnumValueOrUndefined(e[1],Le),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t==="slide"){G(A.Is.isEnumValueOrUndefined(e[0],Le),"noteAnchor",e[0]);let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t){G(A.Is.isFunctionOrUndefined(t),"addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.",t);let e=0,r=!0,i={notes:(o,s)=>(G(A.Is.isEnumValue(o,Zt)||Jr(o),"noteLength",o),G(A.Is.isUndefined(s)||A.Is.isNumber(s)&&s>=0,"noteCount",s),e+=Qt.get(o).ticks*(s!=null?s:1),i),measures:o=>(G(A.Is.isNumber(o)&&o>=1,"measureCount",o),e+=this.getMeasure().getMeasureTicks()*o,i),infinity:()=>(e=1/0,i),hide:()=>(r=!1,i)};return t?t(i):e=1/0,this.getMeasure().addExtension(e,r),this}addStaffGroup(t,e,r="auto"){return G(A.Is.isNonEmptyString(t),"groupName",t),G(A.Is.isNonEmptyString(e)||A.Is.isIntegerGte(e,0)||A.Is.isNonEmptyArray(e)&&e.every(i=>A.Is.isNonEmptyString(i)||A.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",e),G(A.Is.isEnumValue(r,ao),"verticalPosition",r),this.doc.addStaffGroup(t,e,r),this}endSong(){return this.getMeasure().endSong(),this}endSection(){return this.getMeasure().endSection(),this}endRow(){var t;return(t=this.doc.getLastMeasure())==null||t.endRow(),this}completeRests(t){return G(A.Is.isUndefined(t)||In(t)||A.Is.isArray(t)&&t.every(e=>In(e)),"voiceId",t),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){G(A.Is.isNonEmptyString(e),"bottomNote",e),G(A.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),o=t.getScaleNotes(e,r);for(let s=0;s<o.length;s++){s%i.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,i.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}};var Vo=class{constructor(t){this.type=t}},bi=class extends Vo{constructor(e,r,i,o){super(e);this.renderer=r;this.scoreRow=i;this.diatonicId=o}},Ai=class extends Vo{constructor(e,r,i){super(e);this.renderer=r;this.objects=i;if(arguments.length===0)throw new O(6,"Empty array in score object event!")}get topObject(){return this.objects[this.objects.length-1]}findObject(e){return this.objects.find(r=>e(r))}};function xe(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function qo(n,t){if(n==null)throw new TypeError(t);return n}function Mb(n){return A.Is.isNumber(n)&&se().indexOf(n)>=0}function vu(n){if(n instanceof Tt||n instanceof Pe)return n.getMusicInterface();throw new O(6,"Notation line not staff nor tab.")}var bt=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},ga=class ga extends bt{constructor(e){super(ga.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};d(ga,"Name","Accidental");var ho=ga,ya=class ya extends bt{constructor(e){super(ya.Name);this.obj=e}getMusicObject(){return this.obj}};d(ya,"Name","Connective");var ko=ya,xa=class xa extends bt{constructor(e){super(xa.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return vu(this.obj.line)}};d(xa,"Name","Arpeggio");var fo=xa,ba=class ba extends bt{constructor(e){super(ba.Name);this.obj=e}getMusicObject(){return this.obj}};d(ba,"Name","BeamGroup");var bo=ba,Aa=class Aa extends bt{constructor(e){super(Aa.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(Aa,"Name","StaffBeamGroup");var Ao=Aa,Ca=class Ca extends bt{constructor(e){super(Ca.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}getRows(){return this.obj.getRows().map(e=>e.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}play(e){return xe(A.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),new Uo(this,e).play()}};d(Ca,"Name","Document");var Kr=Ca,_a=class _a extends bt{constructor(e){super(_a.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return xe(A.Is.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};d(_a,"Name","Ending");var Mo=_a,va=class va extends bt{constructor(e){super(va.Name);this.obj=e}getMusicObject(){return this.obj}};d(va,"Name","Fermata");var Do=va,Ia=class Ia extends bt{constructor(e){super(Ia.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};d(Ia,"Name","Header");var Go=Ia,Sa=class Sa extends bt{constructor(e){super(Sa.Name);this.obj=e}getMusicObject(){return this.obj}};d(Sa,"Name","Image");var lo=Sa,wa=class wa extends bt{constructor(e){super(wa.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};d(wa,"Name","Measure");var Lo=wa,Ta=class Ta extends bt{constructor(e){super(Ta.Name);this.obj=e}getMusicObject(){return this.obj}};d(Ta,"Name","BarLineRight");var No=Ta,Na=class Na extends bt{constructor(e){super(Na.Name);this.obj=e}getMusicObject(){return this.obj}};d(Na,"Name","BarLineLeft");var Oo=Na,Oa=class Oa extends bt{constructor(e){super(Oa.Name);this.obj=e}getMusicObject(){return this.obj}getBarLine(){let e=this.obj.barLine;if(e instanceof Qr||e instanceof Nr)return e.getMusicInterface();throw new O(6,"Bar line not let nor right.")}getNotationLine(){return vu(this.obj.line)}};d(Oa,"Name","StaffTabBarLine");var Ro=Oa,Ra=class Ra extends bt{constructor(e){super(Ra.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Ra,"Name","NoteGroup");var Co=Ra,Ma=class Ma extends bt{constructor(e){super(Ma.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Ma,"Name","StaffNoteGroup");var _o=Ma,Da=class Da extends bt{constructor(e){super(Da.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getTab(){return this.obj.tab.getMusicInterface()}};d(Da,"Name","TabNoteGroup");var vo=Da,Ea=class Ea extends bt{constructor(e){super(Ea.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Ea,"Name","Rest");var go=Ea,ka=class ka extends bt{constructor(e){super(ka.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}getRhythmColumn(){return this.getRest().getRhythmColumn()}getMeasure(){return this.getRest().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(ka,"Name","StaffRest");var yo=ka,ja=class ja extends bt{constructor(e){super(ja.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return xe(Mb(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}getVoiceSymbol(e){let r=this.obj.getVoiceSymbol(e);return r instanceof vt||r instanceof wr?r.getMusicInterface():void 0}};d(ja,"Name","RhythmColumn");var Io=ja,La=class La extends bt{constructor(e){super(La.Name);this.obj=e}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(e=>vu(e))}};d(La,"Name","ScoreRow");var Bo=La,Pa=class Pa extends bt{constructor(e){super(Pa.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Pa,"Name","Staff");var Po=Pa,Fa=class Fa extends bt{constructor(e){super(Fa.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Fa,"Name","Tab");var Fo=Fa,Ba=class Ba extends bt{constructor(e){super(Ba.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(Ba,"Name","Signature");var mo=Ba,Ga=class Ga extends bt{constructor(e){super(Ga.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Ga,"Name","SpecialText");var So=Ga,Va=class Va extends bt{constructor(e){super(Va.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Va,"Name","Text");var po=Va,qa=class qa extends bt{constructor(e){super(qa.Name);this.obj=e}getMusicObject(){return this.obj}};d(qa,"Name","ExtensionLine");var Eo=qa,Wo=class Wo{constructor(t,e){d(this,"player");xe(t instanceof Kr,"doc",t),xe(A.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new oa,this.player.setDocument(t.getMusicObject()),this.player.setCursorPositionChangeListener(r=>t.getMusicObject().updateCursorRect(r)),e&&this.player.setPlayStateChnageListener(e)}static stopAll(){this.currentlyPlaying.forEach(t=>t.stop()),pu()}play(){return Wo.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),Wo.currentlyPlaying.delete(this),this}};d(Wo,"currentlyPlaying",new Set);var Uo=Wo,Cu=class{constructor(){d(this,"renderer");this.renderer=new Xs(this)}setDocument(t){return xe(A.Is.isUndefined(t)||t instanceof Kr,"doc",t),this.renderer.setDocument(t),this}setCanvas(t){return t=qo(A.Dom.getCanvas(t),typeof t=="string"?"Cannot set renderer canvas because invalid canvas id: "+t:"Cannot set renderer canvas because given canvas is undefined."),this.renderer.setCanvas(t),this}setScoreEventListener(t){xe(A.Is.isFunctionOrUndefined(t),"scoreEventListener",t),this.renderer.setScoreEventListener(t)}hilightObject(t){this.renderer.hilightObject(t==null?void 0:t.getMusicObject())}hilightStaffPos(t){this.renderer.hilightStaffPos(t?{scoreRow:t.scoreRow.getMusicObject(),diatonicId:t.diatonicId}:void 0)}draw(){try{this.renderer.draw()}catch(t){console.log("Draw failed in music renderer."),console.log(t)}}},pe=class pe{constructor(){d(this,"playButton");d(this,"stopButton");d(this,"playStopButton");d(this,"pauseButton");d(this,"onPlay");d(this,"onStop");d(this,"onPlayStop");d(this,"onPause");d(this,"playLabel","Play");d(this,"stopLabel","Stop");d(this,"pauseLabel","Pause");d(this,"playState",2);d(this,"player");this.onPlay=()=>{var t;return(t=this.player)==null?void 0:t.play()},this.onStop=()=>{var t;return(t=this.player)==null?void 0:t.stop()},this.onPlayStop=()=>{var t,e;this.playState===0?(t=this.player)==null||t.stop():(e=this.player)==null||e.play()},this.onPause=()=>{var t;return(t=this.player)==null?void 0:t.pause()},this.updateButtons()}setDocument(t){return xe(A.Is.isUndefined(t)||t instanceof Kr,"doc",t),this.onStop(),t?this.player=new Uo(t,e=>{this.playState=e,this.updateButtons()}):this.player=void 0,this.updateButtons(),this}detachDocument(){this.setDocument(void 0)}updateButtons(){this.playButton&&(this.playButton.disabled=this.player?this.playState===0:!0,this.playButton.innerText=this.playLabel),this.stopButton&&(this.stopButton.disabled=this.player?this.playState===2:!0,this.stopButton.innerText=this.stopLabel),this.playStopButton&&(this.playStopButton.disabled=!this.player,this.playStopButton.innerText=this.playState===0?this.stopLabel:this.playLabel),this.pauseButton&&(this.pauseButton.disabled=this.player?this.playState!==0:!0,this.pauseButton.innerText=this.pauseLabel)}setPlayButton(t,e){return xe(A.Is.isStringOrUndefined(e),"btnLabel",e),pe.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=qo(A.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",pe.removeOnClickListeners(this.playButton,"all"),pe.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return xe(A.Is.isStringOrUndefined(e),"btnLabel",e),pe.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=qo(A.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",pe.removeOnClickListeners(this.stopButton,"all"),pe.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return xe(A.Is.isStringOrUndefined(e),"playLabel",e),xe(A.Is.isStringOrUndefined(r),"stopLabel",r),pe.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=qo(A.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",pe.removeOnClickListeners(this.playStopButton,"all"),pe.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return xe(A.Is.isStringOrUndefined(e),"btnLabel",e),pe.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=qo(A.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",pe.removeOnClickListeners(this.pauseButton,"all"),pe.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(t){let r=this.savedOnClickListeners.get(t)||[],i=[];r.forEach(o=>{e===o||e==="all"?t.removeEventListener("click",o):i.push(o)}),this.savedOnClickListeners.set(t,i)}}static addOnClickListener(t,e){xe(A.Is.isFunction(e),"onClick",e),t.addEventListener("click",e);let r=this.savedOnClickListeners.get(t)||[];this.savedOnClickListeners.set(t,[...r,e])}};d(pe,"savedOnClickListeners",new Map);var _u=pe;ei();var Su={};Ni(Su,{createAndanteByDiabelli:()=>kb,createFrereJacques:()=>Db,createGreensleeves:()=>Eb});function Db(){return new Or().setScoreConfiguration("guitarTreble").setHeader("Frere Jacques").addMeasure().setKeySignature("G","Major").setTimeSignature("4/4").addNote(0,"G3","4n").addNote(0,"A3","4n").addNote(0,"B3","4n").addNote(0,"G3","4n").addMeasure().addNote(0,"G3","4n").addNote(0,"A3","4n").addNote(0,"B3","4n").addNote(0,"G3","4n").addMeasure().addNote(0,"B3","4n").addNote(0,"C4","4n").addNote(0,"D4","2n").endRow().addMeasure().addNote(0,"B3","4n").addNote(0,"C4","4n").addNote(0,"D4","2n").addMeasure().addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(0,"C4","8n").addNote(0,"B3","4n").addNote(0,"G3","4n").endRow().addMeasure().addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(0,"C4","8n").addNote(0,"B3","4n").addNote(0,"G3","4n").addMeasure().addNote(0,"G3","4n").addNote(0,"D3","4n").addNote(0,"G3","2n").addMeasure().addNote(0,"G3","4n").addNote(0,"D3","4n").addNote(0,"G3","2n").getDocument()}function Eb(){return new Or().setScoreConfiguration("guitarTreble").setHeader("Greensleeves").addMeasure().setKeySignature("C","Major").setTimeSignature("6/8").setTempo(140).addNote(0,"A3","8n").addMeasure().addNavigation("startRepeat").addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4n").addNote(0,"A3","8n").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").endRow().addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").endRow().addMeasure().addChord(0,["C3","E3","G3","C4","G4"],"4.",{arpeggio:"up",stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addRest(1,"4.",{hide:!0}).addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4.").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","8n").addNote(1,"E3","8n").endRow().addMeasure().addNote(0,"G4","4.",{stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","8n").addNote(1,"C4","8n").addNote(1,"C3","8n").addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNavigation("ending",1).addNavigation("endRepeat").addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").addMeasure().addNavigation("ending",2).addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addFermata().addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").getDocument()}function kb(){return new Or().setScoreConfiguration("guitarTreble").setHeader("Andante","A. Diabelli").addMeasure().setKeySignature("D","Major").setTimeSignature("3/4").setTempo(80).addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n",{stem:"up"}).addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.",{stem:"down"}).addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").endRow().addMeasure().addNote(0,"D4","8n",{string:3}).addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","8n").addNote(0,"A4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n").addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.").addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).addNavigation("endRepeat").addMeasure().addRest(0,"8n",{staffPos:"D4"}).addAnnotation("dynamics","f").addNote(0,"D4","8n").addNote(0,"E4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"B3","8n").addNote(1,"E2","2.").endRow().addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"E4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","p").addNote(0,"E3","8n").addNote(0,"D#3","8n").addConnective("slur",2,"below").addNote(0,"E3","8n").addNote(0,"F#3","8n").addNote(0,"G#3","8n").addNote(1,"E2","2.").addMeasure().addNote(0,"A3","8n").addConnective("slur",2,"below").addNote(0,"G#3","8n").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","f").addNote(0,"G4","8n").addNote(0,"A4","8n").addConnective("slur",2,"below").addNote(0,"G4","8n").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","ff").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).endSong().getDocument()}return Pm(jb);})();
|
|
209
|
+
`;Fs(Am,Xx);var Yr=class n extends j{constructor(){let t=T(n.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}};var oJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var dJ=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var Ws=class n extends ye{constructor(){let t=T(n.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Et(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Et(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(ye.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Et(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Et(t,0),this._preDelay=t,this.generate()}generate(){return ht(this,void 0,void 0,function*(){let t=this.ready,e=new Ye(2,this._decay+this._preDelay,this.context.sampleRate),r=new fi({context:e}),i=new fi({context:e}),o=new Yr({context:e});r.connect(o,0,0),i.connect(o,0,1);let s=new Z({context:e}).toDestination();o.connect(s),r.start(0),i.start(0),s.gain.setValueAtTime(0,0),s.gain.setValueAtTime(1,this._preDelay),s.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);let a=e.render();return this.ready=a.then(et),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var fn=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new Z({context:this.context}),n._allSolos.has(this.context)||n._allSolos.set(this.context,new Set),n._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(),n._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){n._soloed.has(this.context)||n._soloed.set(this.context,new Set),n._soloed.get(this.context).add(this)}_removeSolo(){n._soloed.has(this.context)&&n._soloed.get(this.context).delete(this)}_isSoloed(){return n._soloed.has(this.context)&&n._soloed.get(this.context).has(this)}_noSolos(){return!n._soloed.has(this.context)||n._soloed.has(this.context)&&n._soloed.get(this.context).size===0}_updateSolo(){this._isSoloed()?this.input.gain.value=1:this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),n._allSolos.get(this.context).delete(this),this._removeSolo(),this}};fn._allSolos=new Map;fn._soloed=new Map;var Us=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new co({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new ke({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,q(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(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}};var lu=class n extends j{constructor(){let t=T(n.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new fn({solo:t.solo,context:this.context}),this._panVol=this.output=new Us({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),q(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(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return n.buses.has(t)||n.buses.set(t,new Z({context:this.context})),n.buses.get(t)}send(t,e=0){let r=this._getBus(t),i=new Z({context:this.context,units:"decibels",gain:e});return this.connect(i),i.connect(r),i}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}};lu.buses=new Map;var eit=Bt().transport;var rit=Bt().destination,iit=Bt().destination;var nit=Bt().listener;var oit=Bt().draw;var sit=Bt();var hu=class{constructor(){d(this,"audioSource");try{let t=new Ws({decay:3,wet:.4}).toDestination(),e=new Ir(800,"lowpass").connect(t);this.audioSource=new Bs(lr,{oscillator:{type:"triangle"},envelope:{attack:.001,decay:2,sustain:.1,release:1.2}}).connect(e)}catch(t){this.audioSource=void 0,console.error(t)}}getName(){return"Synthesizer"}playNote(t,e,r){try{this.audioSource&&(r!==void 0&&(this.audioSource.volume.value=A.Math.linearToDecibels(r)),this.audioSource.triggerAttackRelease(t,e!=null?e:"2n"))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},pu=new hu;ti();function ib(n){return typeof n=="string"?n:(typeof n=="number"&&(n=W.getChromaticNote(n)),n.format(0,0))}var zs=[pu],gn=pu;function nb(){return zs.map(n=>n.getName())}function ob(){return gn.getName()}function sb(n){zs.some(t=>t.getName()===n.getName())||(zs.push(n),_m(n.getName()))}function _m(n){if(n===gn.getName())return;gn.stop();let t=zs.find(e=>e.getName()===n);t&&(gn=t)}function Ys(n,t,e){gn.playNote(ib(n),t,e)}function du(){gn.stop()}var Su={};Ni(Su,{Annotation:()=>xn,Arpeggio:()=>Hr,Clef:()=>Sr,Connective:()=>Zr,DivRect:()=>B,DocumentBuilder:()=>Or,DynamicsAnnotation:()=>bn,Fermata:()=>ho,Label:()=>po,MAccidental:()=>fo,MArpeggio:()=>xo,MBarLineLeft:()=>Do,MBarLineRight:()=>Mo,MBeamGroup:()=>_o,MConnective:()=>Lo,MDocument:()=>Nr,MEnding:()=>ko,MExtensionLine:()=>Po,MFermata:()=>jo,MHeader:()=>Wo,MImage:()=>mo,MMeasure:()=>Bo,MNoteGroup:()=>Io,MPlaybackButtons:()=>Iu,MPlayer:()=>Tn,MRenderer:()=>vu,MRest:()=>bo,MRhythmColumn:()=>To,MScoreRow:()=>qo,MSignature:()=>yo,MSpecialText:()=>No,MStaff:()=>Go,MStaffBeamGroup:()=>vo,MStaffNoteGroup:()=>So,MStaffRest:()=>Ao,MStaffTabBarLine:()=>Eo,MTab:()=>Vo,MTabNoteGroup:()=>wo,MText:()=>go,MusicInterface:()=>bt,Navigation:()=>Ke,NoteAnchor:()=>je,PlayState:()=>Zs,ScoreEvent:()=>Uo,ScoreObjectEvent:()=>bi,ScoreStaffPosEvent:()=>xi,StaffPreset:()=>yn,Stem:()=>Xe,TempoAnnotation:()=>An,TieType:()=>Qe,VerticalPosition:()=>lo,getStringNumbers:()=>Hs,getVoiceIds:()=>se});var B=class n{constructor(...t){d(this,"left");d(this,"centerX");d(this,"right");d(this,"top");d(this,"centerY");d(this,"bottom");if(t.length===6)this.left=t[0],this.centerX=t[1],this.right=t[2],this.top=t[3],this.centerY=t[4],this.bottom=t[5];else if(t.length===4)this.left=t[0],this.right=t[1],this.centerX=(this.left+this.right)/2,this.top=t[2],this.bottom=t[3],this.centerY=(this.top+this.bottom)/2;else if(t.length===0)this.left=this.centerX=this.right=0,this.top=this.centerY=this.bottom=0;else throw new O(1,`Invalid DivRect args: ${t}`)}static create(t,e,r,i){return new n(t,t+r,e,e+i)}static createCentered(t,e,r,i){return new n(t-r/2,t+r/2,e-i/2,e+i/2)}static createSections(t,e,r,i){return new n(-t,0,e,-r,0,i)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get leftw(){return this.centerX-this.left}get rightw(){return this.right-this.centerX}get toph(){return this.centerY-this.top}get bottomh(){return this.bottom-this.centerY}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}static overlap(t,e){return t.right>e.left&&t.left<e.right&&t.bottom>e.top&&t.top<e.bottom}static overlapX(t,e){return t.right>e.left&&t.left<e.right}static equals(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.centerX===e.centerX&&t.right===e.right&&t.top===e.top&&t.centerY===e.centerY&&t.bottom===e.bottom}static equalsFrame(t,e){return t==null&&e==null?!0:t==null||e==null?!1:t===e||t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom}copy(){return new n(this.left,this.centerX,this.right,this.top,this.centerY,this.bottom)}offsetInPlace(t,e){return this.left+=t,this.centerX+=t,this.right+=t,this.top+=e,this.centerY+=e,this.bottom+=e,this}offsetCopy(t,e){return this.copy().offsetInPlace(t,e)}expandInPlace(t){return this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this}expandCopy(t){return this.copy().expandInPlace(t)}clipInPlace(t){return this.left=Math.max(this.left,t.left),this.right=Math.min(this.right,t.right),this.centerX=A.Math.clamp(this.centerX,this.left,this.right),this.top=Math.max(this.top,t.top),this.bottom=Math.min(this.bottom,t.bottom),this.centerY=A.Math.clamp(this.centerY,this.top,this.bottom),this}clipCopy(t){return this.copy().clipInPlace(t)}scaleInPlace(t,e){return e=e!=null?e:t,this.left=this.centerX-this.leftw*t,this.right=this.centerX+this.rightw*t,this.top=this.centerY-this.toph*e,this.bottom=this.centerY+this.bottomh*e,this}scaleCopy(t,e){return this.copy().scaleInPlace(t,e)}getRect(){return this}};var yn=(s=>(s.Treble="treble",s.Bass="bass",s.Grand="grand",s.GuitarTreble="guitarTreble",s.GuitarTab="guitarTab",s.GuitarCombined="guitarCombined",s))(yn||{}),Sr=(e=>(e.G="G",e.F="F",e))(Sr||{});function se(){return[0,1,2,3]}function Hs(){return[1,2,3,4,5,6]}var Xe=(r=>(r.Auto="auto",r.Up="up",r.Down="down",r))(Xe||{}),Hr=(e=>(e.Up="up",e.Down="down",e))(Hr||{}),Qe=(e=>(e.Stub="stub",e.ToMeasureEnd="toMeasureEnd",e))(Qe||{}),je=(o=>(o.Auto="auto",o.Above="above",o.Center="center",o.Below="below",o.StemTip="stemTip",o))(je||{}),Zr=(r=>(r.Tie="tie",r.Slur="slur",r.Slide="slide",r))(Zr||{}),lo=(i=>(i.Auto="auto",i.Above="above",i.Below="below",i.Both="both",i))(lo||{}),ho=(e=>(e.AtNote="atNote",e.AtMeasureEnd="atMeasureEnd",e))(ho||{}),Ke=(h=>(h.DC_al_Fine="D.C. al Fine",h.DC_al_Coda="D.C. al Coda",h.DS_al_Fine="D.S. al Fine",h.DS_al_Coda="D.S. al Coda",h.Coda="Coda",h.toCoda="toCoda",h.Segno="Segno",h.Fine="Fine",h.StartRepeat="startRepeat",h.EndRepeat="endRepeat",h.Ending="ending",h))(Ke||{}),xn=(e=>(e.Dynamics="dynamics",e.Tempo="tempo",e))(xn||{}),bn=(p=>(p.cresc="cresc.",p.decresc="decresc.",p.dim="dim.",p.ppp="ppp",p.pp="pp",p.p="p",p.mp="mp",p.m="m",p.mf="mf",p.f="f",p.ff="ff",p.fff="fff",p))(bn||{}),An=(r=>(r.accel="accel.",r.rit="rit.",r.a_tempo="a tempo",r))(An||{}),po=(e=>(e.Note="note",e.Chord="chord",e))(po||{}),Zs=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(Zs||{});var Xs=class{constructor(t){d(this,"head");d(this,"tail");this.head=t,this.tail=[]}getHead(){return this.head}getTails(){return this.tail}addTail(t){this.tail.push(t)}detachTail(t){let e=this.tail.indexOf(t);e>=0&&this.tail.splice(e,1)}},it=class{constructor(t){this.parent=t;d(this,"anchoredLayoutObjects",[]);d(this,"link");d(this,"rect",new B);d(this,"needRectUpdate",!0)}getParent(){return this.parent}requestRectUpdate(){this.needRectUpdate=!0}updateRect(){}getRect(){return this.needRectUpdate&&(this.updateRect(),this.needRectUpdate=!1),this.rect}getShapeRects(){return[this.rect]}addAnchoredLayoutObject(t){this.anchoredLayoutObjects.push(t)}getAnchoredLayoutObjects(){return this.anchoredLayoutObjects}setLink(t){this.link=t}getLink(){return this.link}isLinked(){return this.link!==null}};var Qs={DrawDebugRects:!1,DisableBeams:!1},at={DocumentScale:1,DocumentMinWidth:75,PostMeasureBreakWidth:10,NoteDotSpace:.5,NoteAccSpace:.5,NoteHeadWidth:2,NoteHeadHeight:1.3,DiamondNoteHeadSize:1.8,DotSize:.8,StemHeight:7,FlagWidth:1.5,FlagHeight:4,FlagSeparation:2,BeamSeparation:1.25,BeamAngleFactor:.5,RestDotSpace:.5,LedgerLineWidth:3.6,StubTieLength:5,StaffHeight:8,TabHeight:20};var vm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAACWCAYAAACCe+v6AAADHXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZZRcu0mDIbfWUWXgCSExHIwmJnu4C6/Pxg7J2kyTdv7GJhjsJCF0CfZJ5y//hzhDzRK5iGpeS45R7RUUuGKicerHetKMa3ratL2Gr2Xh5L3AkMkU/O6LbzlJ+SY074vexO69W9D94QqZvq2UOuWH+/lxzbI/tHQ9kDo2jn2/cA2JLw9Std92x7l4vbuaH2fGYqXyN9+SYyzZrKEa+JolgvmzjEZ4tmno6NxWYb0CugjuO9vVYZPfApJxFUkXV7K/IlUjBlXrAYokhhuFMK5UFbgI1DCBXha9kY1PsF8jc1bjL5o3zlWxCbjnMov1J7xQ97k/HnePLOdBg81z3tB3mON+Rk/lZPehu4Fefbh1529PTu/k4vE9BqK8Ip7jO5jHRqnqCkjFnkf6j7KmkHvmFFcT2V0izkgax2T2Qu6xxobcqrHhko7MC/EoDsoUadKg841NmpwMfHJhpG5BZYldEAq3GQmQ5qdBpsU6eLImHblkPDjC61ty9qukcceYieoMsEY4ZH/3MN3FceYtUQU/YoT0gJ+8axOeBEJ+OcANTCgsYOqK8B3/9gm18lMV5gdB6zxCJeJQ+ktuWSBFigqxgsyWd8GECJsrXCGBARiJlHK8MiYjQiBdACqcJ0l8QECpModTnISyYCD6sDeeMZoqbLyJcZbVVJAsWYUrYNQBayUFPljyZFDVUWTqmY1dS1as+RZeTlbnq/namLJ1LIZ3tlWrLp4cvXs5u7Fa+EieH1rQZ0WL6XUik0rLFc8XaFQ68GHHOnQIx92+FHCURvSp6WmLTdr3kqrnbt0FHjP3br30utJJ1LpTKee+bTTz3LWgVQbMtLQkYeF4aOM+lCjXbYf+7+gRpsaL1JT0R5qkJrdJmi+TnQyAzFOBOAGaiCGxJ7MolNKPMlNZvgeoSqU4aROOJ0mMRBMJ7EOethtcoHr7+EWzBc3/r/kwkT3TXJ/5/YZtT6/Em0Ru8pwBjUKqg/rp1f2Oj+vX47hnxS+O/4Y+jH0Y+jrcYwROv51hb8AKbCqdGIdCl0AAAGFaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDQBzFX1O1UqoOdhBxyFCd7OAH0rFUsQgWSluhVQeTS7+gSUOS4uIouBYc/FisOrg46+rgKgiCHyCuLk6KLlLi/5JCi1gPjvvx7t7j7h0gNCpMNXuigKpZRioeE7O5VdH3ij74MYgpRCRm6on0YgZdx9c9PHy9C/Os7uf+HANK3mSARySOMt2wiDeI5zYtnfM+cZCVJIX4nHjSoAsSP3JddvmNc9FhgWcGjUxqnjhILBY7WO5gVjJU4lnikKJqlC9kXVY4b3FWKzXWuid/YSCvraS5TnMMcSwhgSREyKihjAoshGnVSDGRov1YF/+o40+SSyZXGYwcC6hCheT4wf/gd7dmYWbaTQrEgN4X2/4YB3y7QLNu29/Htt08AbzPwJXW9lcbQOST9HpbCx0BQ9vAxXVbk/eAyx1g5EmXDMmRvDSFQgF4P6NvygHDt4B/ze2ttY/TByBDXS3fAAeHwESRste7vLu/s7d/z7T6+wEMNXLkxtwRywAADzRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+Cjx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wLUV4aXYyIj4KIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgIHhtbG5zOkdJTVA9Imh0dHA6Ly93d3cuZ2ltcC5vcmcveG1wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICB4bXBNTTpEb2N1bWVudElEPSJnaW1wOmRvY2lkOmdpbXA6NDA3ODVjMzYtNDAxZC00YTZlLTkxODctMDQ1NTI4MmM0ZGY2IgogICB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjhiZTJkYzc1LTVlYjQtNDk0Yy1iNWRlLWQ2MzZkNzZhNjI2YiIKICAgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOmU3YWE0MWNhLTNiYjMtNGU5Yi05NDQxLTllNTNmZTJiZjM5ZiIKICAgZGM6Rm9ybWF0PSJpbWFnZS9wbmciCiAgIEdJTVA6QVBJPSIyLjAiCiAgIEdJTVA6UGxhdGZvcm09IldpbmRvd3MiCiAgIEdJTVA6VGltZVN0YW1wPSIxNjg2NDA4NjA5MzE2NDM4IgogICBHSU1QOlZlcnNpb249IjIuMTAuMzQiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiCiAgIHhtcDpDcmVhdG9yVG9vbD0iR0lNUCAyLjEwIgogICB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzOjA2OjEwVDE3OjUwOjA5KzAzOjAwIgogICB4bXA6TW9kaWZ5RGF0ZT0iMjAyMzowNjoxMFQxNzo1MDowOSswMzowMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjI3MzY2YmY0LWVkZDMtNDE5OC05NjJhLWU5ZTM5MTBlNThiZSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOC0yMlQwMjo1NTozNiIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NjVlMTM3OS0wZDlmLTQ5ODItYWQ3MC05MzhjOWMzOWE0ZjMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjItMDktMTFUMTY6MzU6MDAiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MTBmYmEwYTMtOTI5Yi00NTRlLThjNGMtOGVkOGM4YWJhZGRjIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEwVDE3OjUwOjA5Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/Ppn4NIQAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgoOMgm5WlWBAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAACHtJREFUeNrtnXuQVmMcxz+77cauTWUpbGSVu2w3BpnUEBq3chkmBjGayG1GBuNWLtUgw5SJkBkjl4QKg1wyQyarK0lRSlstU20bWam9+OM8O3P6vc8553nOe97tnO18Z84f57zP7XvOc/ndnueFfQx5e6neUmAI0B3oDPwD/AJ8Dvzcml5we+Al4D+gyeOaB1S0BrLHAut9iLqvf4ERSSZbBmwwJOu+RieV8JwQZJuARjXWE4WBIck2X38AByaJ8MwsCTcBTyWFbCFQFwHhv4DiKBqUn2PCPYEin9+bgI3AUuBPn3TtgMuT8IWv8vlq7wLdRPrTgPke6d9JAuFbPBo/3UfKK1TCh8yzIQmEb/cYjx0C8pUDuzV5D477GN6mefY+UBuQby0wV/O8U9wJr9E8W2iY92vNs45xJ6zTfKoN827UPNsdd8K1SlJyo8Awb7XhEIkVYYAVmjXVBPtr1uyqJBBeLu5LDPMdppkPdiaRcHvDfKeJ+++SIFoCLBP3R1toWW58lhQFogiodwkPlYZf1y1w/AcclCQVcYWQtILwqiA8M2lGgDcFgSN90nbXiJUXRdWQ/BYiLMdxH5+0k8VavRb4JGmEl4j7vh7pRgDni2fj1RyQKBwiuqjui/Un015dBbQloXCbaTdrZuUajTp4IwnGbEHmKPX8QmCHhuwC9p4rKBI8IghdB0zCsT1Lsg0+4zwxuEiQqqcVmGWDlAETk+zSJE9Ublyjuqof2TrgxKQT7anMNSZfd1iSiZYCUwy+avP1dJLJXglsxdyV8hHQJolEDwBewc5v9J3Klzj0xYnTsCG7W4mdicMdwC7CeQaPTBLRAjUxZeMKvSwpZPcDPghBUGpE45JAthjH92NLdiUwSDz7NO5k24YkuwTHGZYvtKMtcSabD7wVguy37OkilU7v8rgSfjoE2c816+wkkebKOJK9NgTZ2Wpykxgu0k2IG9lTcMIBbchOx9tTWKHpBbFBoZpwbMi+iL9FtEC8wG1xIvyQJdlJhuVWinzd4kD2cJxYZlOyky3KfkHkvSoOhF+2IPu8Zdk3x82O1QV96JDumhJSu5KB4XsVEwzJziCcy2Z/8UK3K5G1PZnhDi2iBW02IDvPY501xY8BuvJ6JcY+AQzAPCDGGucZkF2GefiCxFk4AWoN2K0AG4HHiSBATWJqQMXr1Qxui3Jlv8o2nHiHIl4UFeF1+G/ACOMGuZVoYqfd12qgX7ZkuwZUMjyEoWBaxETd1y5gVDaEr/YpfGqIyW9ODsm6r7FhCY/z6T625tTpLUS2+bo3DOHZHoVdYFnOqBYmG3rbz1JNQbZ2p2MsZfAor604G8OMsUVTyEBLwjMsv4r7vkapl28AH+PEWNqu1++ZNjRPk3mFJdnjDBu4HBipVoUGsewVaGb6fjgRPSsMSQ8wNb/KjA9bEp5osIzcLUitEml6BNQxxGPoWVtROmoynmFJ+CefRvytxFaJt0W6GwwtqE8GkA56cZSSGVxiI74FhTUM9ch3f0irCerleNU3wbZL2xrJzwhp+hks0s6PaBitMsnsXk7WWlY8xKPi7fjvOZI94x/sHOQFPobGw+U4kHBvrrDVRrw2RE4L6C3V7Ln3sBg43qLeeuAxj996BxHeJCYxm2i4Gh8RMwjL/BpqgA/VpKgTgnwJuzdXtbWUWpZpntUCiwwlPDf6WBLeBSzWPO8URFjuHOthUWm1ptJFaizZErb9wvJjNaMkiLDck2CrYD8n7k13hUrCvUIYB3Vdui6I8FI1qzbjUstKXwe+EV3aBKtE40pwjsKwwQEeuoEv4d3ALNf9ycCpFpU24ngRVrvkYNN8y7Ps1rqlb3MQYXCc3m7YytOb1FCYa2lhzHbiqjAoU4s2GoG+D+Fg85VGijq/ssh7qEboqLGZB6QDvBLHdZpLnK6R0EzlgNs0hGfZVJ6v1lV3ARNzTLhYo0sfY5h3sYWy4ole7Blh16ismrnEStFok/ou05BdR8iA1QfJDN2/PoeEZZTQkwZL0RoN4bvCNiCPzONlGpVJNBe7Tu4TdX1h2bbmmLCCbMfWAvTew6iDQy/QzLReZJ/RtKk+pFiagXZqmdCdyzGG8J5Eic6aOuSe4yK8A+RGRfn2/SqqwdmbVBZBPX/gHbh2MfAbEbtbTAQEr7itehyX6DDCn6zyCZlhUHcoTc7Ltj2WHKNcLexBRvaFaqxdr0Q/k2OixmNudN9uo+BEMcsOAB4AzrXIU6vUxlrVU3YqJaMEOELZoUzW0PeBezz04JyjN07o0mZy7zD7EjiTmKAQOAfHJlyJ/xmWtsHlo1UPCI28FnoBJym9urtaYspwdrOUKkmprerC/6pl7lel/HdxlTORBB/7aIJnLSQuK40orlisUWRaNXpoxnHX1ky4DZlhTkNbc5duwAlNjLRb58f8Ky/e1wgv2dcmrr6aiSur3agFOWxsL6XM91a6crUSCWfi+H9NoDtEsIKY7YI52sNQ4D5uZpBFeTKMamScyJqeFL4L8yOjfhB5x8Rp0ppoaPEoBF4j86A/HerEfUlcCB8GXGGRvqPSZYPQIeAF7DXC/bE3fJsY2eWsvCEuhMtC9oouAROgPPxveVwIN4TM53f08tnifgfmh/nmnPC6kPk2+fx2k7ifpWb4WKAT9mG+foFvMqqvkRj+pYntFp0HPMrZj8wg1VieEd8Tc6NdFXr3TCFOgLc77TZifE7AaAOyv+MY9iS64pxBK7vyJXHWcLy8eu4T0dybo9vhBMBMJvMwwEbgzqSodnfhvxOtDieQzOv3ncRkE7UNytV4tJ295+LsnUgsugKPAt/jvQm7DmcX2+Bcj7eWRjFwAo4rtYOa1avUMrSTFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIkWKFClSpEiRIgL8D6ed2EKeJMaTAAAAAElFTkSuQmCC";var Im="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABGCAYAAACQRffVAAADInpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7VdbktwgDPznFDkCkgCJ4/AwVblBjp8GY+/OZFPZPD7yMVADWIiWUEt2jTu+fR3uCxplTi5EtZRT8mghh8wFC/Nnq2skH9a4mrS9R49yF9LeYIhkap6Pmbf8gBxr2s95G6FL/wK6FlSwim8bpWx5fZTXDcj2DLQ3hE7Lvu8DG0h4exTO57Y9Stn04Wp93xmKp8jefkGUU0ykAWNgr5oy1sY+KOLZp6PcznP31S7B9XypMnziQ0g8RpFweinzJ1IwJ4wk4qA4hUXiGlmWGTiUEG4Fbj6BR/F3MN/H5i1GP2mfuZaHkXFM5XdXu+envOn147y5VzsN3JU3lvaGPNLq0z1/KKd4AV0bctvh95at3ZYf5ENWdt3Nvad7jG5jXRq3KCEhFmlf6rrKWkGvziiuUwldfXLANSxmz+jmi2/Iqe4bKq1inYnB/aBAnQoNOtbcqMHFwAcrZubmWJbQQFLmhlQgCbPTYJUsXQwp0c4cEr59oWU2L3ONzHfnO0GVCWCEI3/c3WcVx5i1ROTtjBM8g188qxNeeAL9c4IaGKGxgxpXgK/+3CavAgbjCrPhgsVXd0LUSG/JJYvoSW/EfFY9ad8ACBFMRzhDAgZ8IomU4JEyKxECaSCowHWWwBUMUIzc4SQHkQRyUB2wjTNKS5Ujn2K8VSU4FGsSBTdZCsgKISJ/NBhyqESJIcaYokaLOZYkaVZeSprm67moaNCoSVXNadZiYsGiJVMzy1YyZ8HrO2bUabaccykwWoBccLpAoZTKVWqosaaq1Wp2tTSkTwstttS0WcutdO7SUeA9de3Wcy8HHUilIxzxSIceduSjDKTakBFGHGmoGzbyKDdrtMv2uf8Ga7RZ48XUVNSbNUhVLwiar5M4OQNjHAiEK1gDY0jsyZk3CoEnc5MzfI9QFZHhZJzkdJqMgcFwEMdBN3ebOcfl3/Dm1BZv/LfMuUndJ5n7kbePWOvzK9EWY2cZzqB6QfVh/7DCVubn9aez+5XCZ+cX0AvoBfQCegG9gP57oIEPJ/4Bue+bLIaQwqExNwAAAYVpQ0NQSUNDIHByb2ZpbGUAAHicfZE9SMNAHMVfU7UiFQeLijhkqE4WREUcSxWLYKG0FVp1MLn0Q2jSkKS4OAquBQc/FqsOLs66OrgKguAHiKuLk6KLlPi/pNAixoPjfry797h7Bwj1MlPNjiigapaRisfEbG5FDLyiC0EMYgIDEjP1RHohA8/xdQ8fX+8iPMv73J+jV8mbDPCJxFGmGxbxOvHMpqVz3icOsZKkEJ8Tjxt0QeJHrssuv3EuOizwzJCRSc0Rh4jFYhvLbcxKhko8TRxWVI3yhazLCuctzmq5ypr35C8M5rXlNNdpjiCORSSQhAgZVWygDAsRWjVSTKRoP+bhH3b8SXLJ5NoAI8c8KlAhOX7wP/jdrVmYmnSTgjGg88W2P0aBwC7QqNn297FtN04A/zNwpbX8lTow+0l6raWFj4C+beDiuqXJe8DlDjD0pEuG5Eh+mkKhALyf0TflgP5boGfV7a25j9MHIENdLd0AB4fAWJGy1zze3d3e279nmv39ANCccsygwwDVAAAQE2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDo0MDc4NWMzNi00MDFkLTRhNmUtOTE4Ny0wNDU1MjgyYzRkZjYiCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Nzg3YjYxN2YtMjg1MS00YzhlLTg2MTYtZWM3NGMwYzYwMWVlIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZTdhYTQxY2EtM2JiMy00ZTliLTk0NDEtOWU1M2ZlMmJmMzlmIgogICBkYzpGb3JtYXQ9ImltYWdlL3BuZyIKICAgR0lNUDpBUEk9IjIuMCIKICAgR0lNUDpQbGF0Zm9ybT0iV2luZG93cyIKICAgR0lNUDpUaW1lU3RhbXA9IjE2ODY2MTM5NDcxOTU2ODAiCiAgIEdJTVA6VmVyc2lvbj0iMi4xMC4zNCIKICAgdGlmZjpPcmllbnRhdGlvbj0iMSIKICAgeG1wOkNyZWF0b3JUb29sPSJHSU1QIDIuMTAiCiAgIHhtcDpNZXRhZGF0YURhdGU9IjIwMjM6MDY6MTNUMDI6NTI6MjUrMDM6MDAiCiAgIHhtcDpNb2RpZnlEYXRlPSIyMDIzOjA2OjEzVDAyOjUyOjI1KzAzOjAwIj4KICAgPHhtcE1NOkhpc3Rvcnk+CiAgICA8cmRmOlNlcT4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MjczNjZiZjQtZWRkMy00MTk4LTk2MmEtZTllMzkxMGU1OGJlIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIyLTA4LTIyVDAyOjU1OjM2Ii8+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjk2NWUxMzc5LTBkOWYtNDk4Mi1hZDcwLTkzOGM5YzM5YTRmMyIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wOS0xMVQxNjozNTowMCIvPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMGZiYTBhMy05MjliLTQ1NGUtOGM0Yy04ZWQ4YzhhYmFkZGMiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoV2luZG93cykiCiAgICAgIHN0RXZ0OndoZW49IjIwMjMtMDYtMTBUMTc6NTA6MDkiLz4KICAgICA8cmRmOmxpCiAgICAgIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiCiAgICAgIHN0RXZ0OmNoYW5nZWQ9Ii8iCiAgICAgIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDBmYjM4YTMtZjZiMi00NjQ1LTliMTYtMjlhNWE0ODZlMjhhIgogICAgICBzdEV2dDpzb2Z0d2FyZUFnZW50PSJHaW1wIDIuMTAgKFdpbmRvd3MpIgogICAgICBzdEV2dDp3aGVuPSIyMDIzLTA2LTEzVDAyOjUyOjI3Ii8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/PsIRrtIAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnBgwXNBsqJURsAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAABF9JREFUeNrtmluIF1Ucxz9/E8P1VnnJ9dJWC4Frmq2JJmqolGEILoQvK2gZeXlRCSm1Fx9UEsJQERWsXhRftECs0Gq70EK9ZHlbFyHbds3VVXFX91+7664P81tYhpnfmft//st84TzMzDm/8/vOnPO7nYEMGTJkyJAhQ4YMGSJBLkJZw4FyYAIwDHgU+A9oAxqBv4C7xfyySoBlwKfAFaAb6DG0euAzoAoYXCxEnwH2A60eCGrtFrALGJNWokNEwY6QRO2tFXgPGJAmss8DlyImam/fASPTQHaeGJueBFod8FQhrfSLwM+ynDX8L1/oV+BP4LZY58eBUUAlMB94ycPSvQTMERmJ4jGgwYPh2Qg84VFmGbAP6DTI/aoQS/lzg1JfA2MDyn4ZuGaQvyZJspUGv3oKGBhyjmeBJmWOmxLMJIITiiIXIgwaZgFdylxbDeNHANXAZmAVUBpEiScNe2xRxC/3Y2WuRmUlLRHD1rd/HljvV4F3FAVqYlhNo4B7Pl/wdPEMbmOq/ShwRBH0Vkxb6LAy536fW64HuOpn8vOKoLKYCC9Q5rzs0L/JQxDjyYPkgHYXAW0xGslByrLuFuPUFw0eCI92mmiAQ4LgZoEbYyTcAZxVPsJk271ag7x6cWueCLvhfsyu8LzybKLtersUF9ywxe2BnXBnAZOUJuXZeNv1OSki3LLdzwPrgONuguw+7g7wAHjEoW+vEagAXgeelr1yUSZoCUn4hvJsqMO9byRaWyLGtFkiwOtBJnYzBKcVg/ZuSMIrlHl3RrWMnFK1OqX/q8oXOAisDqFLVxL7xonw9yHk7Q5RoxpuyLdjI3wmhLzBwMqAY0ck4SGcCNeKIQqKOTF84RtxEu4BPgohc2QM467HSRjgqBL5mBDUPU1Rnl1JwqBNUuJqrW0M+OLdYuk8Cdas38Rf4b3FR0HP/nLdZNYaioKbxSVuA6ZGQfoNvNWlO6VvEKxW5O5yGbNc4ml7ZrUtCtLjgGMSdjop9Q+wMIT8GoXwKw79ZxrKUG9r+a8flMoyr5AA4ybwo1QgggYHpZJ6Ou3Ta5IpddvufwEsVWQ2xFisCI1Nypf6RMmsIql4JI0S8bFuSs9UvmCgikeh8b6i8C/KuKOYD+VShzGSwLsprRnByYYYoSqNhE8qCv/kYfxrYjT7jmuPIC+PBWsVsl1YRzBeE45qqWGtwjo1SR0WoZ8a7KAfYa5h7/2OVaPuF1gqtS83srclpi565IAP0c+b7wOz+wPZckOc3Jt0LC52oiXABx7y6VasGnfRYgiwwRAu9raGqPLXQmAGcADvvyN+m9bgXnP4i4E9wN8+KiJ5WQG5QilumnioJP9lwHPANKw/fF7A+fxJw2ms/y9SFdiPBf4Vn9hJNL8T/iFxbyoxgej+m6zBOtnLpXlvhiXcDOyVJV8UCEL4KnBI/OnAtBP0q+ADMTq/SfshrdUFr4TzwJdY9d57WIdYzRIk1GMdeXSQIUOGDBmSwUMtd8u2ArdcUAAAAABJRU5ErkJggg==";var ab="#55cc55",cb="#55cc55",ub="#44aa44",mu=new Map([[0,{src:vm}],[1,{src:Im}]]);function lb(n,t){return!n&&!t?!0:!n||!t?!1:n.scoreRow===t.scoreRow&&n.diatonicId===t.diatonicId}function hb(n,t){return!n&&!t?!0:!n||!t?!1:n.length===t.length&&n.every((e,r)=>e===t[r])}var Ks=class{constructor(t){this.mi=t;d(this,"devicePixelRatio");d(this,"fontSize");d(this,"unitSize");d(this,"lineWidth");d(this,"beamThickness");d(this,"scoreEventListener");d(this,"canvas");d(this,"ctx");d(this,"mdoc");d(this,"cursorRect");d(this,"mousePos");d(this,"curStaffPos");d(this,"curObjects");d(this,"hilightedStaffPos");d(this,"hilightedObj");d(this,"usingTouch",!1);d(this,"onClickFn");d(this,"onMouseMoveFn");d(this,"onMouseLeaveFn");d(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=kn.FontSize*at.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this.lineWidth=this.unitSize*.2,this.beamThickness=this.unitSize*.8,mu.forEach(e=>{if(e.finished!==!0){let r=new Image;r.src=e.src,r.onload=()=>{e.img=r,this.finishImageAsset(e)},r.onerror=()=>{throw this.finishImageAsset(e),new O(6,"Failed to load image: "+e.src)}}}),this.onClickFn=this.onClick.bind(this),this.onMouseMoveFn=this.onMouseMove.bind(this),this.onMouseLeaveFn=this.onMouseLeave.bind(this),this.onTouchEndFn=this.onTouchEnd.bind(this)}getMusicInterface(){return this.mi}get doc(){var t;return(t=this.mdoc)==null?void 0:t.getMusicObject()}finishImageAsset(t){t.finished=!0,Array.from(mu).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(t){var e;return(e=mu.get(t))==null?void 0:e.img}setDocument(t){if(this.mdoc===t)return;this.updateCursorRect(void 0);let e=this.mdoc;this.mdoc=t,e&&e.getMusicObject().setRenderer(void 0),t&&t.getMusicObject().setRenderer(this)}setCanvas(t){var e,r;this.canvas!==t&&(this.canvas&&(this.canvas.removeEventListener("click",this.onClickFn),this.canvas.removeEventListener("mousemove",this.onMouseMoveFn),this.canvas.removeEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.removeEventListener("touchend",this.onTouchEndFn)),this.canvas=t,this.canvas.addEventListener("click",this.onClickFn),this.canvas.addEventListener("mousemove",this.onMouseMoveFn),this.canvas.addEventListener("mouseleave",this.onMouseLeaveFn),this.canvas.addEventListener("touchend",this.onTouchEndFn),this.canvas.style.position="relative"),this.ctx=(r=(e=this.canvas)==null?void 0:e.getContext("2d"))!=null?r:void 0}setScoreEventListener(t){this.scoreEventListener=t}needMouseInput(){return this.scoreEventListener!==void 0}getMousePos(t){return new qu(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!lb(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=this.curStaffPos;this.scoreEventListener(new xi("leave",this.getMusicInterface(),i.getMusicInterface(),o))}if(r&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=t;this.scoreEventListener(new xi("enter",this.getMusicInterface(),i.getMusicInterface(),o))}if(e&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:o}=t;this.scoreEventListener(new xi("click",this.getMusicInterface(),i.getMusicInterface(),o))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!hb(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new bi("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new bi("enter",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new bi("click",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),this.curObjects=t,r}onClick(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),this.scoreEventListener)){let r=e.pick(this.mousePos.x,this.mousePos.y),i=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(o||s)&&this.draw()}}onMouseMove(t){let{doc:e}=this;if(!(!this.needMouseInput()||!e)&&(this.mousePos=this.txFromScreenCoord(this.getMousePos(t)),!this.usingTouch)){let r=e.pick(this.mousePos.x,this.mousePos.y),i=e.pickStaffPosAt(this.mousePos.x,this.mousePos.y),o=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(o||s)&&this.draw()}}onMouseLeave(t){if(!this.needMouseInput())return;this.mousePos=void 0;let e=this.updateCurStaffPos(void 0,!1),r=this.updateCurObjects(void 0,!1);(e||r)&&this.draw()}onTouchEnd(t){this.usingTouch=!0}onLoad(){this.doc&&(this.doc.requestFullLayout(),this.draw())}hilightObject(t){this.hilightedObj=t}hilightStaffPos(t){this.hilightedStaffPos=t}updateCursorRect(t){this.cursorRect=t,this.draw()}updateCanvasSize(){let{canvas:t,doc:e}=this;if(t&&e){let r=e.getRect(),i=r.width+1,o=r.height+1;t.width=i,t.height=o,t.style.width=i/this.devicePixelRatio+"px",t.style.height=o/this.devicePixelRatio+"px"}}draw(){let{ctx:t,doc:e}=this;!t||!e||(e.layout(),this.updateCanvasSize(),this.clearCanvas(),this.drawHilightStaffPosRect(),this.drawHilightObjectRect(),this.drawPlayCursor(),e.drawContent())}drawHilightStaffPosRect(){let t=this.getCanvasContext(),{mousePos:e,hilightedStaffPos:r,unitSize:i}=this;if(!t||!r)return;let{scoreRow:o,diatonicId:s}=r,a=o.getStaff(s);a&&(t.fillStyle=ab,t.fillRect(0,a.getDiatonicIdY(s)-i,t.canvas.width,2*i),e!==void 0&&this.drawLedgerLines(a,s,e.x))}drawHilightObjectRect(){let t=this.getCanvasContext(),{hilightedObj:e}=this;if(!t||!e)return;let r=e.getRect();t.strokeStyle=cb,t.strokeRect(r.left,r.top,r.width,r.height)}drawPlayCursor(){let{cursorRect:t,lineWidth:e}=this;t&&this.drawLine(t.centerX,t.top,t.centerX,t.bottom,ub,e*2)}txFromScreenCoord(t){return t.mul(this.devicePixelRatio)}txToScreenCoord(t){return t.div(this.devicePixelRatio)}getCanvasContext(){return this.ctx}clearCanvas(){let t=this.getCanvasContext();t&&t.clearRect(0,0,t.canvas.width,t.canvas.height)}getTextWidth(t,e){let r=this.getCanvasContext();if(r){let i=r.font;r.font=e;let o=r.measureText(t);return r.font=i,o.width}else return A.Dom.getCanvasTextWidth(t,e)}drawDebugRect(t){if(!Qs.DrawDebugRects)return;let e=this.getCanvasContext();e&&(e.lineWidth=1,e.strokeStyle="red",e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.stroke())}fillCircle(t,e,r,i){let o=this.getCanvasContext();o&&(i!==void 0&&(o.fillStyle=i),o.beginPath(),o.arc(t,e,r,0,2*Math.PI),o.fill())}drawLine(t,e,r,i,o,s){let a=this.getCanvasContext();a&&(a.strokeStyle=o!=null?o:"black",a.lineWidth=s!=null?s:this.lineWidth,a.beginPath(),a.moveTo(t,e),a.lineTo(r,i),a.stroke())}drawPartialLine(t,e,r,i,o,s,a,c){let u=this.getCanvasContext();if(u){let l=t+(r-t)*o,h=e+(i-e)*o,p=t+(r-t)*s,m=e+(i-e)*s;u.strokeStyle=a!=null?a:"black",u.lineWidth=c!=null?c:this.lineWidth,u.beginPath(),u.moveTo(l,h),u.lineTo(p,m),u.stroke()}}drawLedgerLines(t,e,r){let{unitSize:i}=this,o=i*at.LedgerLineWidth;if(e>=t.topLineDiatonicId+2){for(let s=t.topLineDiatonicId+2;s<=e;s+=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}else if(e<=t.bottomLineDiatonicId-2){for(let s=t.bottomLineDiatonicId-2;s>=e;s-=2)if(t.containsDiatonicId(s)){let a=t.getDiatonicIdY(s);this.drawLine(r-o/2,a,r+o/2,a)}}}};var Js=class{constructor(t){this.measure=t;d(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===W.getDiatonicClass(t));return r?r.accidental:void 0}setAccidental(t){this.accidentalByDiatonicId[t.diatonicId]=t.accidental}needAccidental(t){var r,i;let e=(i=(r=this.accidentalByDiatonicId[t.diatonicId])!=null?r:this.getAccidentalFromKeySignature(t.diatonicId))!=null?i:0;return t.accidental!==e}};var $s=class extends it{constructor(e,r,i,o,s){super(e);this.image=r;this.anchorX=i;this.anchorY=o;this.imageScale=s;d(this,"mi");this.mi=new mo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:i,image:o,imageScale:s}=this,{unitSize:a}=e;try{let c=o.naturalWidth*s*a,u=o.naturalHeight*s*a;this.rect=B.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new B}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let i=this.rect;e.drawDebugRect(i);try{r.drawImage(this.image,i.centerX-i.leftw,i.centerY-i.toph,i.width,i.height)}catch(o){}}};var Ai=class extends it{constructor(e,r,i,o="black"){super(e);this.diatonicId=r;this.accidental=i;this.color=o;d(this,"mi");this.mi=new fo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;switch(this.accidental){case-2:this.rect=B.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=B.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=B.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=B.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=B.createSections(r*1,r*1,r*1,r*1);break;default:throw new O(6,"Invalid accidental value: "+this.accidental)}}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;e.drawDebugRect(this.rect);let{unitSize:i,lineWidth:o}=e,{accidental:s}=this,a=this.rect.centerX,c=this.rect.centerY;r.strokeStyle=r.fillStyle=this.color;function u(l,h){r&&(r.lineWidth=o,r.beginPath(),r.moveTo(l-i*.75,h-i*4),r.lineTo(l-i*.75,h+i*1.1),r.bezierCurveTo(l+i*.75,h-i*0,l+i*.75,h-i*2.2,l-i*.75,h-i*.5),r.stroke())}s===-2?(u(a-i*.5,c),u(a+i*.5,c)):s===-1&&u(a,c),s===0?(r.beginPath(),r.lineWidth=o,r.moveTo(a-i*.5,c-i*2.2),r.lineTo(a-i*.5,c+i*1),r.moveTo(a+i*.5,c+i*2.2),r.lineTo(a+i*.5,c-i*1),r.stroke(),r.beginPath(),r.lineWidth=o*2,r.moveTo(a-i*.5,c+i*1),r.lineTo(a+i*.5,c+i*.6),r.moveTo(a+i*.5,c-i*1),r.lineTo(a-i*.5,c-i*.6),r.stroke()):s===1?(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.3,c-i*1.6),r.lineTo(a-i*.3,c+i*2),r.moveTo(a+i*.3,c-i*2),r.lineTo(a+i*.3,c+i*1.6),r.stroke(),r.lineWidth=o*2,r.beginPath(),r.moveTo(a-i*.75,c-i*.5),r.lineTo(a+i*.75,c-i*.9),r.moveTo(a-i*.75,c+i*.9),r.lineTo(a+i*.75,c+i*.5),r.stroke()):s===2&&(r.lineWidth=o,r.beginPath(),r.moveTo(a-i*.75,c-i*.75),r.lineTo(a+i*.75,c+i*.75),r.moveTo(a-i*.75,c+i*.75),r.lineTo(a+i*.75,c-i*.75),r.stroke(),r.fillRect(a-i*1,c-i*1,i*.7,i*.7),r.fillRect(a+i*.3,c-i*1,i*.7,i*.7),r.fillRect(a-i*1,c+i*.3,i*.7,i*.7),r.fillRect(a+i*.3,c+i*.3,i*.7,i*.7))}};var pb=.5,lt=class extends it{constructor(e,r,i,o){var a,c,u,l,h,p;super(e);this.anchorX=i;this.anchorY=o;d(this,"text");d(this,"scale");d(this,"color");d(this,"bold");d(this,"italic");d(this,"boxed");d(this,"padding");d(this,"bgcolor");d(this,"font","");d(this,"textLines");d(this,"lineWidths",[]);d(this,"lineHeight",0);d(this,"mi");let s=typeof r=="string"?{text:r}:r;this.text=s.text,this.scale=(a=s.scale)!=null?a:1,this.color=(c=s.color)!=null?c:"black",this.bold=(u=s.bold)!=null?u:!1,this.italic=(l=s.italic)!=null?l:!1,this.boxed=(h=s.boxed)!=null?h:!1,this.padding=(p=s.padding)!=null?p:this.boxed?pb:0,this.bgcolor=s.bgcolor,(!isFinite(this.padding)||this.padding<0)&&(this.padding=0),this.textLines=this.text.split(`
|
|
210
|
+
`),this.textLines.length===0&&(this.textLines=[""]),this.rect=new B,this.mi=new go(this)}getMusicInterface(){return this.mi}getText(){return this.text}updateAnchorX(e){this.anchorX=e;let{width:r}=this.rect;this.rect.left=this.rect.centerX-r*e,this.rect.right=this.rect.centerX+r*(1-e)}updateAnchorY(e){this.anchorY=e;let{height:r}=this.rect;this.rect.top=this.rect.centerY-r*e,this.rect.bottom=this.rect.centerY+r*(1-e)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{scale:r,anchorX:i,anchorY:o,bold:s,italic:a}=this,c=e.fontSize*r;this.font=(a?"italic ":"")+(s?"bold ":"")+c+"px Times New Roman",this.lineWidths=this.textLines.map(p=>e.getTextWidth(p,this.font)),this.lineHeight=c;let u=this.padding*e.unitSize,l=u+Math.max(...this.lineWidths)+u,h=u+this.lineHeight*this.textLines.length+u;(this.boxed==="square"||this.boxed==="circle")&&(h=l=Math.max(h,l)),this.rect=B.createSections(l*i,l*(1-i),h*o,h*(1-o))}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;e.drawDebugRect(this.rect),r.lineWidth=e.lineWidth,r.strokeStyle=r.fillStyle=this.color,r.font=this.font;let{rect:i,padding:o,lineHeight:s,lineWidths:a,anchorX:c,anchorY:u,italic:l}=this;this.bgcolor!==void 0&&(r.save(),r.fillStyle=this.bgcolor,r.beginPath(),r.fillRect(i.left,i.top,i.width,i.height),r.fill(),r.restore());let p=this.textLines.length*s,m=-s*(l?.25:.175),f=o*e.unitSize,g=(i.left+f)*(1-c)+(i.right-f)*c,y=(i.top+f)*(1-u)+(i.bottom-f)*u;switch(this.textLines.forEach((b,I)=>{let S=g-a[I]*c,w=y-p*u+s*(I+1)+m;r.fillText(b,S,w)}),this.boxed){case"square":case"rectangle":r.strokeRect(i.left,i.top,i.width,i.height);break;case"circle":case"ellipse":let b=(i.left+i.right)/2,I=(i.top+i.bottom)/2,S=(i.right-i.left)/2,w=(i.bottom-i.top)/2;r.beginPath(),r.ellipse(b,I,S,w,0,0,2*Math.PI),r.stroke();break}}};var ta=class extends it{constructor(e,r){super(e);this.measure=e;this.staff=r;d(this,"clefImage");d(this,"eightBelowClef");d(this,"measureNumber");d(this,"ksNeutralizeAccidentals",[]);d(this,"ksNewAccidentals",[]);d(this,"beatCountText");d(this,"beatSizeText");d(this,"tempoText");d(this,"mi");this.mi=new yo(this)}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let i=e.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new $s(this,i,0,.5,.1):void 0,this.eightBelowClef=this.clefImage&&this.staff.isOctaveDown?new lt(this,"8",.5,0):void 0}else this.clefImage=void 0}updateMeasureNumber(e){if(e){let r=this.measure.getMeasureNumber().toString();this.measureNumber=new lt(this,r,0,1)}else this.measureNumber=void 0}updateKeySignature(e){if(e){let{measure:r}=this,i=r.getPrevMeasure(),o=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],o&&!Le.equals(s,o)&&o.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new Ai(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new Ai(this,this.getAccidentalDiatonicId(a),a.accidental))})}else this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[]}updateTimeSignature(e){if(e){let r=this.measure.getTimeSignature(),i=r.beatCount.toString();this.beatCountText=new lt(this,{text:i,scale:1.4},0,.5);let o=r.beatSize.toString();this.beatSizeText=new lt(this,{text:o,scale:1.4},0,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=ac(this.measure.getTempo());this.tempoText=new lt(this,r,.5,1)}else this.tempoText=void 0}getAccidentalDiatonicId(e){let{clef:r}=this.staff.staffConfig,i;if(r==="G"?e.accidental>0?i=this.staff.bottomLineDiatonicId+3:e.accidental<0&&(i=this.staff.bottomLineDiatonicId+1):r==="F"&&(e.accidental>0?i=this.staff.bottomLineDiatonicId+1:e.accidental<0&&(i=this.staff.bottomLineDiatonicId-1)),i!==void 0)return W.findNextDiatonicIdAbove(e.diatonicId,i,!1);throw new O(6,"Cannot get accidental diatonicId because note has no accidental.")}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.eightBelowClef){let i=this.eightBelowClef.pick(e,r);if(i.length>0)return[this,...i]}if(this.clefImage){let i=this.clefImage.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.ksNeutralizeAccidentals.length;i++){let o=this.ksNeutralizeAccidentals[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.ksNewAccidentals.length;i++){let o=this.ksNewAccidentals[i].pick(e,r);if(o.length>0)return[this,...o]}if(this.beatCountText){let i=this.beatCountText.pick(e,r);if(i.length>0)return[this,...i]}if(this.beatSizeText){let i=this.beatSizeText.pick(e,r);if(i.length>0)return[this,...i]}if(this.tempoText){let i=this.tempoText.pick(e,r);if(i.length>0)return[this,...i]}if(this.measureNumber){let i=this.measureNumber.pick(e,r);if(i.length>0)return[this,...i]}return[this]}layout(e){let{unitSize:r}=e,{staff:i}=this,o=r,s=0;if(this.rect=new B,this.clefImage&&(s+=o,this.clefImage.layout(e),this.clefImage.offset(s,i.getDiatonicIdY(i.clefLineDiatonicId)),this.rect.expandInPlace(this.clefImage.getRect()),s=this.rect.right,this.eightBelowClef)){let c=this.clefImage.getRect();this.eightBelowClef.layout(e),this.eightBelowClef.offset(c.left+c.width/2,Math.max(c.centerY+c.height*.3,i.getBottomLineY())),this.rect.expandInPlace(this.eightBelowClef.getRect())}if(this.measureNumber){this.measureNumber.layout(e);let c=this.clefImage?this.clefImage.getRect().top:i.getTopLineY();this.measureNumber.offset(0,c),this.rect.expandInPlace(this.measureNumber.getRect()),s=Math.max(s,this.rect.right)}this.ksNeutralizeAccidentals.length>0&&(s+=o,this.ksNeutralizeAccidentals.forEach(c=>{c.layout(e),c.offset(s+c.getRect().leftw,i.getDiatonicIdY(c.diatonicId)),this.rect.expandInPlace(c.getRect()),s=this.rect.right})),this.ksNewAccidentals&&(s+=o,this.ksNewAccidentals.forEach(c=>{c.layout(e),c.offset(s+c.getRect().leftw,i.getDiatonicIdY(c.diatonicId)),this.rect.expandInPlace(c.getRect()),s=this.rect.right}));let a=s;this.beatCountText&&(this.beatCountText.layout(e),this.beatCountText.offset(s+o,i.getDiatonicIdY(i.middleLineDiatonicId+2)),this.rect.expandInPlace(this.beatCountText.getRect()),a=Math.max(a,this.rect.right)),this.beatSizeText&&(this.beatSizeText.layout(e),this.beatSizeText.offset(s+o,i.getDiatonicIdY(i.bottomLineDiatonicId+2)),this.rect.expandInPlace(this.beatSizeText.getRect()),a=Math.max(a,this.rect.right)),s=a,this.tempoText&&(this.tempoText.layout(e),this.tempoText.offset(s,Math.min(this.rect.top,i.getTopLineY())),this.rect.expandInPlace(this.tempoText.getRect())),this.rect.right+=o}offset(e,r){this.clefImage&&this.clefImage.offset(e,r),this.eightBelowClef&&this.eightBelowClef.offset(e,r),this.measureNumber&&this.measureNumber.offset(e,r),this.ksNeutralizeAccidentals.forEach(i=>i.offset(e,r)),this.ksNewAccidentals.forEach(i=>i.offset(e,r)),this.beatCountText&&this.beatCountText.offset(e,r),this.beatSizeText&&this.beatSizeText.offset(e,r),this.tempoText&&this.tempoText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.clefImage&&this.clefImage.draw(e),this.eightBelowClef&&this.eightBelowClef.draw(e),this.measureNumber&&this.measureNumber.draw(e),this.ksNeutralizeAccidentals.forEach(r=>r.draw(e)),this.ksNewAccidentals.forEach(r=>r.draw(e)),this.beatCountText&&this.beatCountText.draw(e),this.beatSizeText&&this.beatSizeText.draw(e),this.tempoText&&this.tempoText.draw(e)}};var ea=class extends it{constructor(e,r,i){super(e);this.col=e;this.line=r;this.arpeggioDir=i;d(this,"topArrowHeight",0);d(this,"bottomArrowHeight",0);d(this,"cycleHeight",0);d(this,"numCycles",0);d(this,"color","black");d(this,"mi");this.mi=new xo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e;this.topArrowHeight=this.arpeggioDir==="up"?r:0,this.bottomArrowHeight=this.arpeggioDir==="down"?r:0;let i=this.line.getTopLineY(),o=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((o-i)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new B(-s/2,s/2,-a/2-this.topArrowHeight,a/2+this.bottomArrowHeight)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i}=e,{rect:o,topArrowHeight:s,bottomArrowHeight:a}=this;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i*2,r.beginPath();for(let c=0,u=o.top+s;c<this.numCycles;c++,u+=this.cycleHeight)r.moveTo(o.centerX,u),r.quadraticCurveTo(o.left,u+this.cycleHeight/4,o.centerX,u+this.cycleHeight/2),r.quadraticCurveTo(o.right,u+this.cycleHeight*3/4,o.centerX,u+this.cycleHeight);r.stroke(),s>0&&(r.beginPath(),r.moveTo(o.centerX,o.top),r.lineTo(o.right,o.top+s),r.lineTo(o.left,o.top+s),r.fill()),a>0&&(r.beginPath(),r.moveTo(o.centerX,o.bottom),r.lineTo(o.left,o.bottom-a),r.lineTo(o.right,o.bottom-a),r.fill())}};function db(n){return typeof n=="number"?W.getChromaticNote(n).diatonicId:typeof n=="string"?W.getNote(n).diatonicId:n instanceof W?n.diatonicId:void 0}var ra=class extends it{constructor(e,r){super(e);this.staff=e;this.rest=r;d(this,"restRect",new B);d(this,"dotRects",[]);d(this,"mi");e.addObject(this),this.mi=new Ao(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){this.restRect.offsetInPlace(e,r),this.dotRects.forEach(i=>i.offsetInPlace(e,r)),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRects.forEach(e=>this.rect.expandInPlace(e))}},Ci=class extends it{constructor(e,r,i,o,s){var l,h;super(e);this.col=e;this.voiceId=r;d(this,"ownStemDir");d(this,"ownDiatonicId");d(this,"color");d(this,"hide");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"mi");let a=db(o==null?void 0:o.staffPos);if(a!==void 0){let p=this.row.hasStaff,m=this.row.getStaff(a);if(p&&!m)throw new O(6,"Rest staffPos is out of staff boundaries!")}this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,a),this.ownStemDir=this.measure.updateOwnStemDir(this);let c=this.row.getStaff(this.ownDiatonicId);c&&c.isSpace(this.ownDiatonicId)&&(this.ownDiatonicId+=this.ownDiatonicId>=c.middleLineDiatonicId?1:-1),this.color=(l=o==null?void 0:o.color)!=null?l:"black",this.hide=(h=o==null?void 0:o.hide)!=null?h:!1,this.oldStyleTriplet=s===void 0&&((o==null?void 0:o.triplet)===!0||Xt.get(i).isTriplet);let u=typeof(o==null?void 0:o.dotted)=="number"?o.dotted>0?o.dotted:void 0:(o==null?void 0:o.dotted)===!0?1:void 0;this.rhythmProps=Qt.get(i,u,(s!=null?s:this.oldStyleTriplet)?fr.Triplet:void 0),this.mi=new bo(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get noteLength(){return this.rhythmProps.noteLength}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}getStaticObjects(e){let r=[];return this.staffObjects.forEach(i=>{i.staff===e&&r.push(i)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{let r=e.staff,i=e.getRect().centerX,o=this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ra&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case"1n":return 1;case"2n":return-1;case"4n":return-1;case"8n":return-1;case"16n":return-1;case"32n":return-3;case"64n":return-3;default:throw new O(6,"Cannot get rest dot vertical displacement because note length is invalid.")}}updateAccidentalState(e){}layout(e,r){if(this.requestRectUpdate(),this.staffObjects.length=0,this.hide)return;let{unitSize:i}=e,{ownDiatonicId:o}=this,{noteLength:s,dotCount:a,flagCount:c}=this.rhythmProps,u=0,l=0,h=0,p=0;if(s==="1n")u=i,l=i,h=0,p=i;else if(s==="2n")u=i,l=i,h=i,p=0;else if(s==="4n")u=i*1,l=i*1,h=i*3.2,p=i*3;else{let m=1-c%2;u=i*(1+c*.25),l=i*(1+c*.125),h=i*(.5+c-m),p=i*(1+c+m)}this.row.getStaves().forEach(m=>{if(!m.containsDiatonicId(o)||!m.containsVoiceId(this.voiceId))return;let f=new ra(m,this);f.restRect=new B(-u,0,l,-h,0,p);for(let g=0;g<a;g++){let y=at.DotSize*i,b=l+(at.RestDotSpace+at.DotSize*i)+g*at.DotSize*i*1.5,I=this.getRestDotVerticalDisplacement(s)*i;f.dotRects.push(B.createCentered(b,I,y,y))}f.offset(0,m.getDiatonicIdY(o)),this.staffObjects.push(f)})}updateRect(){if(this.staffObjects.length===0)this.rect=new B;else if(this.rect=this.staffObjects[0].getRect().copy(),this.staffObjects.length>1)for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let r=e.getCanvasContext();if(!r||this.staffObjects.length===0)return;e.drawDebugRect(this.getRect());let{unitSize:i,lineWidth:o}=e,{color:s}=this,{noteLength:a,flagCount:c}=this.rhythmProps;r.strokeStyle=r.fillStyle=s,r.lineWidth=o,this.staffObjects.forEach(u=>{let{dotRects:l,restRect:h}=u,p=h.centerX,m=h.centerY;if(a==="1n")r.fillRect(p-i,m,i*2,i);else if(a==="2n")r.fillRect(p-i,m-i,i*2,i);else if(a==="4n")r.beginPath(),r.moveTo(p-i*.6,m-i*3.2),r.lineTo(p+i*.7,m-i*1.5),r.quadraticCurveTo(p-i*.8,m-i*.5,p+i*1,m+i*1.5),r.lineTo(p-i*1,m-i*.75),r.quadraticCurveTo(p+i*.2,m-i*1.5,p-i*.6,m-i*3.2),r.moveTo(p+i*1,m+i*1.5),r.quadraticCurveTo(p-i*.8,m+i*1,p-i*.2,m+i*2.8),r.bezierCurveTo(p-i*1.8,m+i*1.5,p-i*.6,m-i*.2,p+i*.9,m+i*1.5),r.fill(),r.stroke();else if(c>0){let f=1-c%2,g=b=>p+(-b*.25+.5)*i,y=b=>m+(b+f)*i;r.beginPath(),r.moveTo(g(1+c),y(1+c)),r.lineTo(g(-.5-c),y(-.5-c)),r.stroke();for(let b=0;b<c;b++){let I=c-b*2;r.beginPath(),r.moveTo(g(I-2.5),y(I-2.5)),r.quadraticCurveTo(g(I-.5)+i*.25,y(I-1.5),g(I-1.5)-i*1.5,y(I-1.5)),r.stroke(),r.beginPath(),r.arc(g(I-2)-i*1.5,y(I-2),i*.5,0,Math.PI*2),r.fill()}}l.forEach(f=>{e.fillCircle(f.centerX,f.centerY,f.width/2)})})}};var mb=(n,t)=>{let e=at.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=n/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),n/r*e}},Co=class{constructor(t,e,r,i,o){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=i;this.y=o;d(this,"topBeamsHeight",0);d(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new B(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},fu=class extends it{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;d(this,"tupletNumber");d(this,"tupletNumberOffsetY",0);d(this,"points",[]);d(this,"mi");e.addObject(this),this.mi=new vo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.points.forEach(o=>o.offset(e,0)),(i=this.tupletNumber)==null||i.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().copy():this.tupletNumber&&(this.rect=this.tupletNumber.getRect().copy()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tupletNumber&&this.rect.expandInPlace(this.tupletNumber.getRect())}},Xr=class n extends it{constructor(e,r){super(e[0].measure);this.symbols=e;this.tupletRatio=r;d(this,"mi");d(this,"type");d(this,"staffObjects",[]);this.mi=new _o(this);let i=r?"Tuplet":"BeamGroup";if(e.every(o=>o.measure===e[0].measure)){if(e.length<2)throw new O(6,`${i} needs minimum 2 symbols, but ${e.length} given.`)}else throw new O(6,`All ${i} symbols are not in same measure.`);if(r!==void 0){let o=e.length<3||e.some(s=>!(s instanceof St))||e.some(s=>s.rhythmProps.flagCount!==e[0].rhythmProps.flagCount);e.length>=3&&e[0]instanceof St&&e[e.length-1]instanceof St&&e[0].rhythmProps.flagCount===e[e.length-1].rhythmProps.flagCount&&(o=!1),e.some(s=>Xt.cmp(s.rhythmProps.noteLength,"4n")>=0)&&(o=!0),this.type=o?2:1,St.setTupletBeamCounts(this)}else this.type=0;if(e.every(o=>o.getBeamGroup()===void 0))e.forEach(o=>o.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new O(6,`Cannot add ${i} because some symbol already has one.`)}get showTupletRatio(){var e;return((e=this.tupletRatio)==null?void 0:e.showRatio)===!0}static createBeam(e){e.length>1&&new n(e,void 0)}static createOldStyleTriplet(e){let r=e.slice(0,2),i=r.map(a=>a.rhythmProps.noteSize);if(r.length===2&&r.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&(i[0]*2===i[1]||i[1]*2===i[0]))return new n(r,fr.Triplet),2;let o=e.slice(0,3),s=o.map(a=>a.rhythmProps.noteSize);return o.length===3&&o.every(a=>a.oldStyleTriplet&&a.getBeamGroup()===void 0)&&s.every(a=>a===s[0])?(new n(o,fr.Triplet),3):0}static createTuplet(e,r){new n(e,r)}getMusicInterface(){return this.mi}detach(){this.getSymbols().forEach(e=>e.resetBeamGroup())}isEmpty(){return this.staffObjects.length===0}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getType(){return this.type}isTuplet(){return this.type===1||this.type===2}getSymbols(){return this.symbols}getFirstSymbol(){return this.symbols[0]}getLastSymbol(){return this.symbols[this.symbols.length-1]}get stemDir(){return this.symbols[0].ownStemDir}layout(e){this.requestRectUpdate(),this.staffObjects.length=0;let r=this.getSymbols();if(r.length===0)return;let i=r[0].voiceId;if(r.some(c=>c.voiceId!==i))return;let{unitSize:o}=e,{stemDir:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var U,E;if(!c)return;let l=a.map(P=>{var L;return(L=P[u])==null?void 0:L.x}),h=a.map(P=>{var L;return(L=P[u])==null?void 0:L.y}),p=a.map(P=>{var L;return(L=P[u])==null?void 0:L.staff}),m=a.map(P=>{var L;return(L=P[u])==null?void 0:L.stemHeight}),f=r[0],g=l[0],y=h[0],b=p[0],I=r[r.length-1],S=l[l.length-1],w=h[h.length-1],_=p[h.length-1];if(g===void 0||y===void 0||b===void 0||S===void 0||w===void 0||_===void 0)return;let v=(U=m[0])!=null?U:0,C=(E=m[m.length-1])!=null?E:0;if(this.type!==2){let P=v<C?Math.sqrt(C-v):0,L=C<v?Math.sqrt(v-C):0;s==="up"&&(P*=-1,L*=-1),P!==0&&(y+=P,h[0]+=P),L!==0&&(w+=L,h[h.length-1]+=L)}let x=o*2*(s==="up"?-1:1),N=(w+y)/2,k=mb(S-g,w-y)/2;y=N-k,w=N+k;let R=0;h.forEach((P,L)=>{let V=l[L];if(V!==void 0&&P!==void 0){let Q=A.Math.interpolateY(g,y,S,w,V),Y=P-Q;s==="up"&&Y<0?R=Math.min(R,Y):s==="down"&&Y>0&&(R=Math.max(R,Y))}}),y+=R,w+=R,h=h.map(P=>P===void 0?void 0:P+R);let D=new fu(c,this);if(this.type===2){let P=o/(S-g),L=A.Math.interpolateCoord(g,y+x,S,w+x,-P),V=A.Math.interpolateCoord(g,y+x,S,w+x,1+P);D.points.push(new Co(b,this,f,L.x,L.y)),D.points.push(new Co(_,this,I,V.x,V.y)),D.tupletNumberOffsetY=0}else if(this.type===0||this.type===1){R*=.5;let{beamThickness:P}=e,L=V=>{let Q=r[V];if(Q instanceof St){let Y=Q instanceof St?Math.max(Q.getLeftBeamCount(),Q.getRightBeamCount()):0;return at.BeamSeparation*o*(this.stemDir==="up"?Y-1:0)}else return 0};r.forEach((V,Q)=>{let Y=p[Q],F=l[Q],ct=h[Q];if(Y&&F!==void 0&&ct!==void 0){let xt=new Co(Y,this,V,F,ct);xt.topBeamsHeight=P/2+(s==="down"?L(Q):0),xt.bottomBeamsHeight=P/2+(s==="up"?L(Q):0),D.points.push(xt)}}),D.tupletNumberOffsetY=x}if(this.isTuplet()&&this.tupletRatio){let P=this.showTupletRatio?String(this.tupletRatio.parts)+":"+String(this.tupletRatio.inTimeOf):String(this.tupletRatio.parts);D.tupletNumber=new lt(this,P,.5,.5),D.tupletNumber.layout(e),D.tupletNumber.offset((g+S)/2,(y+w)/2+D.tupletNumberOffsetY)}D.points.length>=2&&this.staffObjects.push(D)})}updateRect(){if(this.staffObjects.length===0)this.rect=new B;else{this.staffObjects.forEach(e=>e.updateRect()),this.rect=this.staffObjects[0].getRect().copy();for(let e=1;e<this.staffObjects.length;e++)this.rect.expandInPlace(this.staffObjects[e].getRect())}}updateStemTips(){this.staffObjects.forEach(e=>{let r=e.points[0],i=e.points[e.points.length-1];if(this.type!==2&&e.points.forEach(o=>{o.symbol instanceof St&&(o!==r&&o!==i&&(o.y=A.Math.interpolateY(r.x,r.y,i.x,i.y,o.x)),o.symbol.setStemTipY(o.staff,o.y))}),e.tupletNumber){let o=(r.y+i.y)/2+e.tupletNumberOffsetY;e.tupletNumber.offset(0,-e.tupletNumber.getRect().centerY+o)}})}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r,beamThickness:i,lineWidth:o}=e,s="black";this.staffObjects.forEach(a=>{if(this.type===2){let c=a.points[0],u=a.points[a.points.length-1];if(c&&u){let l=a.tupletNumber?a.tupletNumber.getRect().width/(u.x-c.x)*1.2:0,h=A.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5-l/2),p=A.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5+l/2),m=this.stemDir==="up"?r:-r;e.drawLine(c.x,c.y,h.x,h.y,s,o),e.drawLine(p.x,p.y,u.x,u.y,s,o),e.drawLine(c.x,c.y,c.x,c.y+m,s,o),e.drawLine(u.x,u.y,u.x,u.y+m,s,o)}}else if(this.type===0||this.type===1){let c=at.BeamSeparation*r*(this.stemDir==="up"?1:-1),u=a.points.filter(l=>l.symbol instanceof St);for(let l=0;l<u.length-1;l++){let h=u[l],p=u[l+1];if(!(h.symbol instanceof St&&p.symbol instanceof St))continue;let m=h.symbol.getRightBeamCount(),f=p.symbol.getLeftBeamCount(),g=h.x,y=h.y,b=p.x,I=p.y;for(let S=0;S<Math.max(m,f);S++)S<m&&S<f?e.drawLine(g,y,b,I,s,i):m>f?e.drawPartialLine(g,y,b,I,0,.25,s,i):f>m&&e.drawPartialLine(g,y,b,I,.75,1,s,i),y+=c,I+=c}}a.tupletNumber&&a.tupletNumber.draw(e)})}};function fb(n){return A.Is.isEnumValue(n,Xe)?n:void 0}function gb(n){return A.Is.isEnumValue(n,Hr)?n:n===!0?"up":void 0}function yb(n,t){let e=A.Arr.isArray(t)?t:t!==void 0?[t]:[],r=n.map((i,o)=>({note:i,string:e[o]}));return r=A.Arr.removeDuplicatesCmp(r,(i,o)=>W.equals(i.note,o.note)).sort((i,o)=>W.compareFunc(i.note,o.note)),{notes:r.map(i=>i.note),strings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}var ia=class extends it{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;d(this,"noteHeadRects",[]);d(this,"dotRects",[]);d(this,"accidentals",[]);d(this,"stemTip");d(this,"stemBase");d(this,"flagRects",[]);d(this,"prevTopNoteY",0);d(this,"prevBottomNoteY",0);d(this,"mi");this.mi=new So(this)}getMusicInterface(){return this.mi}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.accidentals.length;i++){let o=this.accidentals[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}updateRect(){this.rect=this.noteHeadRects[0].copy(),this.noteHeadRects.forEach(e=>this.rect.expandInPlace(e)),this.stemTip&&this.rect.expandInPlace(this.stemTip),this.stemBase&&this.rect.expandInPlace(this.stemBase),this.dotRects.forEach(e=>this.rect.expandInPlace(e)),this.flagRects.forEach(e=>this.rect.expandInPlace(e)),this.accidentals.forEach(e=>this.rect.expandInPlace(e.getRect()))}getRect(){let e=this.noteHeadRects[0],r=this.noteHeadRects[this.noteHeadRects.length-1];return(this.prevTopNoteY!==r.centerY||this.prevBottomNoteY!==e.centerY)&&(this.prevTopNoteY=r.centerY,this.prevBottomNoteY=e.centerY,this.requestRectUpdate()),super.getRect()}offset(e,r){var i,o;this.noteHeadRects.forEach(s=>s.offsetInPlace(e,r)),this.dotRects.forEach(s=>s.offsetInPlace(e,r)),this.accidentals.forEach(s=>s.offset(e,r)),(i=this.stemTip)==null||i.offsetInPlace(e,r),(o=this.stemBase)==null||o.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},gu=class extends it{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;d(this,"fretNumbers",[]);d(this,"mi");e.addObject(this),this.mi=new wo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}updateRect(){this.rect=this.fretNumbers[0].getRect().copy(),this.fretNumbers.forEach(e=>this.rect.expandInPlace(e.getRect()))}offset(e,r){this.fretNumbers.forEach(i=>i.offset(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},St=class n extends it{constructor(e,r,i,o,s,a){var l,h,p;super(e);this.col=e;this.voiceId=r;this.notes=i;d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"ownDiatonicId");d(this,"ownStemDir");d(this,"ownString");d(this,"color");d(this,"staccato");d(this,"diamond");d(this,"arpeggio");d(this,"oldStyleTriplet");d(this,"rhythmProps");d(this,"startConnnectives",[]);d(this,"runningConnectives",[]);d(this,"leftBeamCount",0);d(this,"rightBeamCount",0);d(this,"beamGroup");d(this,"staffObjects",[]);d(this,"tabObjects",[]);d(this,"mi");if(!A.Is.isIntegerGte(i.length,1))throw new O(6,"Cannot create note group object because notes array is empty.");let c=yb(i,s==null?void 0:s.string);this.notes=c.notes,this.minDiatonicId=this.notes[0].diatonicId,this.maxDiatonicId=this.notes[this.notes.length-1].diatonicId,this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,Math.round((this.minDiatonicId+this.maxDiatonicId)/2)),this.ownStemDir=this.measure.updateOwnStemDir(this,fb(s==null?void 0:s.stem)),this.ownString=this.measure.updateOwnString(this,c.strings),this.color=(l=s==null?void 0:s.color)!=null?l:"black",this.staccato=(h=s==null?void 0:s.staccato)!=null?h:!1,this.diamond=(p=s==null?void 0:s.diamond)!=null?p:!1,this.arpeggio=gb(s==null?void 0:s.arpeggio),this.oldStyleTriplet=a===void 0&&((s==null?void 0:s.triplet)===!0||Xt.get(o).isTriplet);let u=typeof(s==null?void 0:s.dotted)=="number"?s.dotted>0?s.dotted:void 0:(s==null?void 0:s.dotted)===!0?1:void 0;this.rhythmProps=Qt.get(o,u,(a!=null?a:this.oldStyleTriplet)?fr.Triplet:void 0),this.mi=new Io(this)}getMusicInterface(){return this.mi}get doc(){return this.col.doc}get measure(){return this.col.measure}get row(){return this.col.row}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof Pe||e.containsDiatonicId(this.ownDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective==="tie")throw new O(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective==="slur")throw new O(6,"Slurs not implemented for guitar tabs alone, staff is required!");this.startConnnectives.push(e),this.doc.addConnectiveProps(e)}getStaticObjects(e){let r=[];return this.staffObjects.forEach(i=>{i.staff===e&&r.push(i)}),this.tabObjects.forEach(i=>{i.tab===e&&r.push(i)}),r}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffObjects.length;i++){let o=this.staffObjects[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabObjects.length;i++){let o=this.tabObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,i,o,s){if(r instanceof Tt){let a=r;if(i<0||i>=this.notes.length)throw new O(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(_=>_.staff===a);if(!c||i<0||i>=c.noteHeadRects.length){let _=this.getRect();return{x:_.centerX,y:_.bottom}}let u=c.noteHeadRects[i],l=c.stemTip,h=this.stemDir,p=l!==void 0,m=p?h==="up"?"right":"left":void 0,f=u.height/2,g=u.centerX,y=u.centerY,b=u.left-f,I=u.right+f,S=u.top-f,w=u.bottom+f;switch(o==="auto"?o="below":o==="stemTip"&&!p&&(o=h==="up"?"above":"below"),o){case"center":return s==="left"?{x:I,y}:{x:b,y};case"above":return!p||h==="down"?{x:g,y:S}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?b:g,y:S};case"below":return!p||h==="up"?{x:g,y:w}:{x:s==="left"&&m==="right"?I:s==="right"&&m==="left"?b:g,y:w};case"stemTip":return{x:g,y:l.centerY+(h==="up"?-f:f)};default:throw new O(6,"Invalid noteAnchor: "+o)}}else{let a=r,c=this.tabObjects.find(f=>f.tab===a),u=c==null?void 0:c.fretNumbers[i];if(!c||!u)return{x:0,y:0};let l=u.getRect(),h=s==="right"?l.left:l.right,p,m=.9;if(e.connective==="slide"){let f=e.noteGroups[0].getFretNumber(c,0),g=e.noteGroups[1].getFretNumber(c,0),y=f===void 0||g===void 0||f<=g;s==="left"?p=y?l.centerY+l.bottomh*m:l.centerY-l.toph*m:p=y?l.centerY-l.toph*m:l.centerY+l.bottomh*m}else p=l.centerY+l.bottomh*m;return{x:h,y:p}}}getFretNumberString(e){return this.ownString[e]}getFretNumber(e,r){let i=e.fretNumbers[r];return i===void 0?void 0:+i.getText()}getNextNoteGroup(){let e=this.measure.getVoiceSymbols(this.voiceId).filter(o=>o instanceof n),r=e.indexOf(this);if(r<0)return;if(r<e.length-1)return e[r+1];let i=this.measure.getNextMeasure();for(;i;){let o=i.getVoiceSymbols(this.voiceId).filter(s=>s instanceof n);if(o.length>0)return o[0];i=i.getNextMeasure()}}collectConnectiveProps(){this.startConnnectives.forEach(e=>{this.runningConnectives.push(e);let r=this.getNextNoteGroup();for(;r&&e.addNoteGroup(r);)r.runningConnectives.push(e),r=r.getNextNoteGroup()})}removeConnectiveProps(){this.runningConnectives=[]}getPlaySlur(){let e=this.runningConnectives.filter(r=>r.connective==="slur").map(r=>r.startsWith(this)?"first":"slurred");return e.indexOf("first")>=0?"first":e.indexOf("slurred")>=0?"slurred":void 0}getBeamGroup(){return this.beamGroup}setBeamGroup(e){this.beamGroup=e}resetBeamGroup(){this.leftBeamCount=this.rightBeamCount=0,this.beamGroup=void 0}getBeamCoords(){return this.staffObjects.map(e=>{var a,c,u,l;let r=e.staff,i=(c=(a=e.stemTip)==null?void 0:a.centerX)!=null?c:e.noteHeadRects[0].centerX,o=(l=(u=e.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir==="up"?e.getRect().top:e.getRect().bottom,s=this.stemDir==="up"?Math.abs(e.noteHeadRects[0].centerY-o):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].centerY-o);return{staff:r,x:i,y:o,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{flagCount:i,hasStem:o}=this.rhythmProps;if(o){let s=this.hasBeamCount()?at.BeamSeparation:at.FlagSeparation;return(at.StemHeight+Math.max(0,i-1)*s)*r}else return 0}hasBeamCount(){return this.leftBeamCount>0||this.rightBeamCount>0}getLeftBeamCount(){return this.leftBeamCount}getRightBeamCount(){return this.rightBeamCount}isEmpty(){return this.staffObjects.length===0&&this.tabObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof ia&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(i=>i.connective==="tie").map(i=>{let o=i.noteGroups,s=o.indexOf(this);if(s<0)return 0;if(i.span==="stub"||i.span==="toMeasureEnd")return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=o[s-1];return a&&a.notes.some(c=>W.equals(c,e))?0:(o=o.slice(s),s=o.findIndex(c=>c.notes.every(u=>!W.equals(u,e))),s>=0&&(o=o.slice(0,s)),A.Math.sum(o.map(c=>c.rhythmProps.ticks)))});return r.length===0?this.rhythmProps.ticks:Math.max(...r)}updateAccidentalState(e){this.notes.forEach(r=>{e.needAccidental(r)&&e.setAccidental(r)})}layout(e,r){this.requestRectUpdate();let{unitSize:i}=e,{row:o,stemDir:s}=this,{dotCount:a,flagCount:c,hasStem:u}=this.rhythmProps,l=at.DotSize*i,h=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadWidth)*i,p=(this.diamond?at.DiamondNoteHeadSize:at.NoteHeadHeight)*i;this.staffObjects.length=0,o.getStaves().forEach(m=>{if(!m.containsDiatonicId(this.ownDiatonicId)||!m.containsVoiceId(this.voiceId))return;let f=new ia(m,this),g=m,y=m;this.notes.forEach((C,x)=>{var L;let N=x===0,k=x===this.notes.length-1,R=(L=m.getActualStaff(C.diatonicId))!=null?L:m,D=this.col.getNoteHeadDisplacement(this,C)*h,U=R.getDiatonicIdY(C.diatonicId),E=R.isLine(C.diatonicId);N&&s==="up"&&(g=R),k&&s==="up"&&(y=R),N&&s==="down"&&(y=R),k&&s==="down"&&(g=R);let P=f.noteHeadRects[x]=B.createCentered(D,U,h,p);if(R.addObject(P),r.needAccidental(C)){let V=f.accidentals[x]=new Ai(this,C.diatonicId,C.accidental,this.color);V&&(V.layout(e),V.offset(-P.leftw-i*at.NoteAccSpace-V.getRect().rightw,U)),R.addObject(V)}for(let V=0;V<a;V++){let Q=P.right+at.NoteDotSpace*i+l/2+V*l*1.5,Y=U+this.getDotVerticalDisplacement(m,C.diatonicId,s)*i,F=B.createCentered(Q,Y,l,l);f.dotRects.push(F),R.addObject(F)}if(this.staccato){if(s==="up"&&N){let V=D,Q=U+i*(E?3:2),Y=B.createCentered(V,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}else if(s==="down"&&k){let V=D,Q=U-i*(E?3:2),Y=B.createCentered(V,Q,l,l);f.dotRects.push(Y),g.addObject(Y)}}});let b=f.noteHeadRects[0].centerY,I=f.noteHeadRects[f.noteHeadRects.length-1].centerY,S=s==="up"?h/2:-h/2,w=this.getStemHeight(e),_=s==="up"?I-w:b+w,v=s==="up"?b:I;if(u&&(f.stemTip=new B(S,S,_,_),f.stemBase=new B(S,S,v,v),y.addObject(f.stemTip),g.addObject(f.stemBase)),!this.hasBeamCount()){let C=c===0?0:at.FlagWidth*i,x=c===0?0:at.FlagHeight*i;for(let N=0;N<c;N++){let k=N*i*at.FlagSeparation,R=f.flagRects[N]=s==="up"?new B(S,S+C,_+k,_+x+k):new B(S,S+C,_-x-k,_-k);y.addObject(R)}}this.staffObjects.push(f)}),this.tabObjects.length=0,o.getTabs().forEach(m=>{if(!m.containsVoiceId(this.voiceId))return;let f=new gu(m,this);this.notes.forEach((g,y)=>{if(this.ownString[y]!==void 0){let b=this.ownString[y]-1,I=g.chromaticId-m.getTuningStrings()[b].chromaticId,S=I<0?"red":"black",w=new lt(this,{text:String(I),color:S,bgcolor:"white"},.5,.5);f.fretNumbers.push(w),w.layout(e);let _=this.col.getRect().centerX,v=m.getStringY(b);w.offset(_,v)}}),f.fretNumbers.length>0&&this.tabObjects.push(f)})}updateRect(){if(this.staffObjects.length>0)this.rect=this.staffObjects[0].noteHeadRects[0].copy();else if(this.tabObjects.length>0&&this.tabObjects[0].fretNumbers.length>0)this.rect=this.tabObjects[0].fretNumbers[0].getRect().copy();else{this.rect=new B;return}this.staffObjects.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tabObjects.forEach(e=>this.rect.expandInPlace(e.getRect()))}setStemTipY(e,r){let i=this.staffObjects.find(o=>o.staff===e);!(i!=null&&i.stemTip)||r===i.stemTip.centerY||(i.stemTip.top=i.stemTip.centerY=i.stemTip.bottom=r,this.requestRectUpdate())}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.tabObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let r=e.getCanvasContext();if(!r)return;e.drawDebugRect(this.getRect());let{lineWidth:i}=e,{color:o,stemDir:s}=this,{isSolidNoteHead:a}=this.rhythmProps;this.staffObjects.forEach(c=>{c.accidentals.forEach(u=>u.draw(e)),r.strokeStyle=r.fillStyle=o,r.lineWidth=i,c.noteHeadRects.forEach(u=>{this.diamond?a?(r.beginPath(),r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.lineTo(u.left,u.centerY),r.lineTo(u.centerX,u.top),r.fill()):(r.beginPath(),r.lineWidth=i*2.5,r.moveTo(u.centerX,u.top),r.lineTo(u.right,u.centerY),r.moveTo(u.left,u.centerY),r.lineTo(u.centerX,u.bottom),r.stroke(),r.beginPath(),r.lineWidth=i,r.moveTo(u.right,u.centerY),r.lineTo(u.centerX,u.bottom),r.moveTo(u.centerX,u.top),r.lineTo(u.left,u.centerY),r.stroke()):(r.beginPath(),r.ellipse(u.centerX,u.centerY,u.leftw,u.toph,-.3,0,Math.PI*2),a?r.fill():r.stroke())}),c.dotRects.forEach(u=>e.fillCircle(u.centerX,u.centerY,u.width/2)),c.stemTip&&c.stemBase&&(r.beginPath(),r.moveTo(c.stemBase.centerX,c.stemBase.centerY),r.lineTo(c.stemTip.centerX,c.stemTip.centerY),r.stroke()),c.flagRects.forEach(u=>{let l=u.left,p=u.right-l,m=s==="up"?u.top:u.bottom,f=s==="up"?u.bottom:u.top;r.beginPath(),r.moveTo(l,m),r.bezierCurveTo(l,m*.75+f*.25,l+p*1.5,m*.5+f*.5,l+p*.5,f),r.stroke()})}),this.tabObjects.forEach(c=>c.fretNumbers.forEach(u=>u.draw(e)))}static setBeamCounts(e){let r=(o,s)=>{let{flagCount:a,noteSize:c,dotCount:u}=o.rhythmProps,{flagCount:l,noteSize:h,dotCount:p}=s.rhythmProps;return a>0&&l>0&&u>0&&p===0&&c*Math.pow(2,u)===h};for(let o=0;o<e.length;o++){let s=e[o],a=e[o-1],c=e[o+1];s&&(s.leftBeamCount=0,s.rightBeamCount=0,a&&(a.rhythmProps.flagCount===s.rhythmProps.flagCount||r(a,s)||r(s,a)?s.leftBeamCount=s.rhythmProps.flagCount:s.leftBeamCount=Math.min(a.rhythmProps.flagCount,s.rhythmProps.flagCount)),c&&(c.rhythmProps.flagCount===s.rhythmProps.flagCount||r(c,s)||r(s,c)?s.rightBeamCount=s.rhythmProps.flagCount:s.rightBeamCount=Math.min(c.rhythmProps.flagCount,s.rhythmProps.flagCount)))}let i;do{i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=e[o-1],c=e[o+1];s&&s.leftBeamCount!==s.rhythmProps.flagCount&&s.rightBeamCount!==s.rhythmProps.flagCount&&(s.leftBeamCount=s.rightBeamCount=0,a&&a.rightBeamCount>0&&(a.rightBeamCount=0,i=!0),c&&c.leftBeamCount>0&&(c.leftBeamCount=0,i=!0))}}while(i)}static setTupletBeamCounts(e){let r=e.getType(),i=e.getSymbols();r===1?i.forEach((o,s)=>{o instanceof n&&(o.leftBeamCount=s===0?0:o.rhythmProps.flagCount,o.rightBeamCount=s===i.length-1?0:o.rhythmProps.flagCount)}):r===2&&i.forEach(o=>{o instanceof n&&(o.leftBeamCount=o.rightBeamCount=0)})}getDotVerticalDisplacement(e,r,i){return e.isLine(r)?i==="up"?-1:1:0}static hasSameNotes(e,r){if(e.notes.length!==r.notes.length)return!1;for(let i=0;i<e.notes.length;i++){let o=e.notes[i],s=r.notes[i];if(o.diatonicId!==s.diatonicId||o.accidental!==s.accidental)return!1}return!0}};var xb=(n,t)=>{let e=W.compareFunc(n.note,t.note);return e===0&&(e=n.noteGroup.stemDir===t.noteGroup.stemDir?0:n.noteGroup.stemDir==="up"?1:-1),e},wr=class extends it{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;d(this,"voiceSymbol",[]);d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"staffMinDiatonicId",new Map);d(this,"staffMaxDiatonicId",new Map);d(this,"arpeggioDir");d(this,"arpeggios",[]);d(this,"noteHeadDisplacements",[]);d(this,"playerProps");d(this,"needLayout",!0);d(this,"shapeRects",[]);d(this,"mi");this.playerProps=new Cn(this),this.mi=new To(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}getNextColumnInMeasure(){let e=this.measure.getColumns().indexOf(this);if(e>=0&&e<this.measure.getColumnCount())return this.measure.getColumn(e+1);throw new O(6,"Cannot get next column in measure because current column's id in mesure is invalid.")}getNextColumn(){var r;let e=this.getNextColumnInMeasure();return e||((r=this.measure.getNextMeasure())==null?void 0:r.getColumn(0))}getTicksToNextColumn(){let e=this.getNextColumnInMeasure(),r=this.positionTicks,i=e?e.positionTicks:this.measure.getConsumedTicks();return Math.max(0,i-r)}getShapeRects(){return this.getRect(),this.shapeRects}getStaticObjects(e){let r=[];return this.voiceSymbol.forEach(i=>{i&&(i.getRect(),i.getStaticObjects(e).forEach(o=>r.push(o)))}),this.arpeggios.forEach(i=>{i.line===e&&(i.getRect(),r.push(i))}),r}get doc(){return this.measure.doc}get row(){return this.measure.row}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.voiceSymbol.length;i++)if(this.voiceSymbol[i]){let o=this.voiceSymbol[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.arpeggios.length;i++){let o=this.arpeggios[i].pick(e,r);if(o.length>0)return[this,...o]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:"up"}setVoiceSymbol(e,r){na(e),this.voiceSymbol[e]=r,r instanceof Ci&&!r.hide?(this.minDiatonicId=this.minDiatonicId===void 0?r.ownDiatonicId:Math.min(this.minDiatonicId,r.ownDiatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.ownDiatonicId:Math.max(this.maxDiatonicId,r.ownDiatonicId)):r instanceof St&&(this.minDiatonicId=this.minDiatonicId===void 0?r.notes[0].diatonicId:Math.min(this.minDiatonicId,r.notes[0].diatonicId),this.maxDiatonicId=this.maxDiatonicId===void 0?r.notes[r.notes.length-1].diatonicId:Math.max(this.maxDiatonicId,r.notes[r.notes.length-1].diatonicId),r.arpeggio!==void 0&&(this.arpeggioDir=r.arpeggio),this.setupNoteHeadDisplacements()),this.requestLayout(),this.requestRectUpdate()}getVoiceSymbol(e){return this.voiceSymbol[e]}getMinWidth(){let e=Math.max(...this.voiceSymbol.map(i=>i.rhythmProps.noteSize)),r=at.NoteHeadWidth;switch(e){case 1:return r*5;case 2:return r*3;case 4:return r*2;default:return r}}setupNoteHeadDisplacements(){if(this.noteHeadDisplacements=[],this.voiceSymbol.forEach(e=>{e instanceof St&&e.notes.forEach(r=>{this.noteHeadDisplacements.push({noteGroup:e,note:r})})}),this.noteHeadDisplacements.sort(xb),!(this.noteHeadDisplacements.length<2)){for(let e=0;e<this.noteHeadDisplacements.length;e++){let r=this.noteHeadDisplacements[e],i=this.noteHeadDisplacements[e+1];i&&r.note.diatonicId===i.note.diatonicId&&(r.displacement=i.displacement=0)}for(let e=0;e<this.noteHeadDisplacements.length;e++){let r=this.noteHeadDisplacements[e-1],i=this.noteHeadDisplacements[e],o=this.noteHeadDisplacements[e+1];if(i.displacement!==void 0)continue;let s=i.noteGroup.stemDir==="down"?-1:1;r&&i.note.diatonicId-r.note.diatonicId<=1?i.displacement=r.displacement===0?s:0:o&&o.note.diatonicId-i.note.diatonicId<=1&&(i.displacement=o.displacement===0?s:0)}}}getNoteHeadDisplacement(e,r){let i=this.noteHeadDisplacements.find(o=>o.noteGroup===e&&W.equals(o.note,r));return(i==null?void 0:i.displacement)!==void 0?i.displacement:0}isEmpty(){for(let e=0;e<this.voiceSymbol.length;e++)if(this.voiceSymbol[e]!==void 0&&!this.voiceSymbol[e].isEmpty())return!1;return!0}getPlayerNotes(){let e=[];function r(i,o,s,a){if(o<=0)return;e.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,o),!0):!1)||e.push({note:i,ticks:o,staccato:s,slur:a})}return se().forEach(i=>{let o=this.getVoiceSymbol(i);if(o instanceof St){let s=o.getPlaySlur();o.notes.forEach(a=>{let c=o.getPlayTicks(a),u=o.staccato;r(a,c,u,s)})}}),e.sort((i,o)=>W.compareFunc(i.note,o.note)),this.hasArpeggio()&&this.getArpeggioDir()==="down"&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new B;let{row:i}=this,{unitSize:o}=e,s=this.getMinWidth()*o/2,a=s,c=s;if(this.voiceSymbol.forEach(l=>{l.layout(e,r);let h=l.getRect();a=Math.max(a,h.leftw),c=Math.max(c,h.rightw)}),this.arpeggioDir!==void 0){let l=0;this.arpeggios=i.getNotationLines().map(h=>{let p=new ea(this,h,this.getArpeggioDir());return p.layout(e),p.offset(-a-p.getRect().right,h.getRect().centerY-p.getRect().centerY),l=Math.max(l,p.getRect().width),h.addObject(p),p}),a+=l}else this.arpeggios=[];let u=this.getAnchoredLayoutObjects().filter(l=>l.layoutGroup.widensColumn);u.length>0&&u.forEach(l=>{a=Math.max(a,l.musicObj.getRect().leftw),c=Math.max(c,l.musicObj.getRect().rightw)}),this.voiceSymbol.forEach(l=>l.updateAccidentalState(r)),this.rect.left=-a,this.rect.centerX=0,this.rect.right=c,this.row.getStaves().forEach(l=>{let h,p;this.voiceSymbol.forEach(m=>{m.visibleInStaff(l)&&(m instanceof St?(h=h===void 0?m.minDiatonicId:Math.min(h,m.minDiatonicId),p=p===void 0?m.maxDiatonicId:Math.max(p,m.maxDiatonicId)):m instanceof Ci&&(h=h===void 0?m.ownDiatonicId:Math.min(h,m.ownDiatonicId),p=p===void 0?m.ownDiatonicId:Math.max(p,m.ownDiatonicId)))}),h!==void 0?this.staffMinDiatonicId.set(l,h):this.staffMinDiatonicId.delete(l),p!==void 0?this.staffMaxDiatonicId.set(l,p):this.staffMaxDiatonicId.delete(l)})}layoutDone(){this.needLayout=!1}updateRect(){this.shapeRects=[...this.voiceSymbol.filter(e=>!!e).map(e=>e.getRect().copy()),...this.arpeggios.map(e=>e.getRect().copy())],this.rect.top=Math.min(...this.shapeRects.map(e=>e.top)),this.rect.bottom=Math.max(...this.shapeRects.map(e=>e.bottom)),this.rect.centerY=(this.rect.top+this.rect.bottom)/2}offset(e,r){this.voiceSymbol.forEach(i=>i==null?void 0:i.offset(e,0)),this.arpeggios.forEach(i=>i.offset(e,0)),this.shapeRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){this.row.getStaves().forEach(r=>{let i=this.staffMinDiatonicId.get(r),o=this.staffMaxDiatonicId.get(r);i!==void 0&&e.drawLedgerLines(r,i,this.getRect().centerX),o!==void 0&&e.drawLedgerLines(r,o,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(e)}),this.arpeggios.forEach(r=>r.draw(e))}};var hr=class hr extends it{constructor(e,r){super(e);this.text=r;d(this,"components",[]);d(this,"mi");switch(this.text){case hr.Coda:this.components=[new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new lt(this," Coda",0,1)];break;case hr.toCoda:this.components=[new lt(this,"toCoda ",1,1),new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case hr.Segno:this.components=[new lt(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new No(this)}getMusicInterface(){return this.mi}getText(){return this.text}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){switch(this.text){case hr.Coda:{let r=this.components[0],i=this.components[1];r.layout(e),i.layout(e),r.offset(0,(i.getRect().top+i.getRect().bottom)/2),i.offset(r.getRect().right,0),this.rect=new B(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case hr.toCoda:{let r=this.components[0],i=this.components[1];r.layout(e),i.layout(e),i.offset(0,(r.getRect().top+r.getRect().bottom)/2),r.offset(i.getRect().left,0),this.rect=new B(r.getRect().left,i.getRect().centerX,i.getRect().right,r.getRect().top,r.getRect().centerY,r.getRect().bottom);break}default:{let r=this.components[0];r.layout(e),this.rect=r.getRect().copy();break}}}offset(e,r){this.components.forEach(i=>i.offset(e,r)),this.rect.offsetInPlace(e,r)}draw(e){e.drawDebugRect(this.rect),this.components.forEach(r=>r.draw(e))}};d(hr,"toCoda","\u{1D10C} toCoda"),d(hr,"Coda","Coda \u{1D10C}"),d(hr,"Segno","\u{1D10B}");var Je=hr;function Oo(n){switch(n){case"D.C. al Coda":return"D.C. al Coda";case"D.C. al Fine":return"D.C. al Fine";case"D.S. al Coda":return"D.S. al Coda";case"D.S. al Fine":return"D.S. al Fine";case"Fine":return"Fine";case"Segno":return Je.Segno;case"Coda":return Je.Coda;case"toCoda":return Je.toCoda;default:return n[0].toUpperCase()+n.substring(1)}}function yu(n){return A.Is.isEnumValue(n,bn)}function Ro(n){if(/^(p+|f+|m|mp|mf)$/.test(n)){let t=.5-A.Str.charCount(n,"p")*.1+A.Str.charCount(n,"f")*.1;return A.Math.clamp(t,0,1)}else return}function xu(n){return A.Is.isEnumValue(n,An)}function Sm(n){return A.Is.isEnumValue(n,bn)?"dynamics":A.Is.isEnumValue(n,An)?"tempo":void 0}function bb(n){switch(n){case"bottom":return .8;case"middle":return .5}}function Ab(n){return yu(n)?2:xu(n)?1:0}var _i=class extends Xs{constructor(e,r,i,o,s,a){super(e);d(this,"length");d(this,"visible");d(this,"lineStyle");d(this,"linePos");d(this,"startColumn");d(this,"context");if(this.length=i,this.visible=o,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=e instanceof lt?Ab(e.getText()):0,e instanceof lt)e.updateAnchorY(bb(a));else throw new O(6,"Update anchor's y-coordinate is only implemented for text objects.")}isVisible(){return this.visible}getLineStyle(){return this.lineStyle}getLinePos(){return this.linePos}getSpanBreakText(e,r){if(e===e.measure.getColumn(0)){let i=e.measure.getPrevMeasure();if(i){if(i.hasEndSection()||i.hasEndSong())return"section-break";let o=["endRepeat","ending"];for(let s=0;s<o.length;s++)if(i.hasNavigation(o[s]))return"section-break"}}if(r===1){let i=e.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&xu(s))return s}}else if(r===2){let i=e.getAnchoredLayoutObjects();for(let o=0;o<i.length;o++){let s=i[o].getTextContent();if(s&&yu(s))return s}}}getExtensionRangeInfo(){let{startColumn:e,length:r,context:i}=this,o=[e];if(r<=0)return{startColumn:e,endColumn:e,columnRange:o,extensionBreakText:void 0};let s=r,a=e;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:e,endColumn:a,columnRange:o,extensionBreakText:void 0};a=c,o.push(a)}}};var Cb=2,_b=2,vb=.5,Ib=.5;function Sb(n,t){let e=Qt.get(t.options.beatLength,t.options.dotCount).ticks,r=t.beatsPerMinute*e;return 60*n/r}function bu(){return Ro("m")}function wb(n){return n*1.25}var Tb=.5,Cn=class{constructor(t){this.col=t;d(this,"speed");d(this,"volume");this.speed=1,this.volume=bu()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=bu()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=A.Math.clamp(this.getSpeed(),.1,10);return cc(this.measure.getTempo(),t)}setVolume(t){this.volume=t}getVolume(){return this.volume}hasFermata(){return this.measure.hasFermata(this.col)}getFermataHoldTicks(){if(!this.hasFermata())return 0;let{col:t}=this;if(t instanceof Tr)return this.measure.getMeasureTicks()/2;{let r=se().map(i=>t.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:A.Math.sum(r)/r.length}}},oa=class n{constructor(){d(this,"playTimer");d(this,"playPos");d(this,"playState",2);d(this,"doc");d(this,"cursorPositionChangeListener");d(this,"playStateChnageListener");d(this,"playerColumnSequence",[])}setDocument(t){this.doc=t,this.doc.resetMeasures(),this.playerColumnSequence=this.collectPlayerColumnSequence(),this.updatePlayerProps()}setCursorPositionChangeListener(t){this.cursorPositionChangeListener=t}setPlayStateChnageListener(t){this.playStateChnageListener=t}notifyCursorPositionChanged(){this.cursorPositionChangeListener&&this.cursorPositionChangeListener(this.getCursorRect())}notifyPlayStateChanged(){let t=this.playPos!==void 0&&this.playTimer!==void 0?0:this.playPos!==void 0&&this.playTimer===void 0?1:2;this.playState!==t&&(this.playStateChnageListener&&this.playStateChnageListener(t),this.playState=t)}collectPlayerMeasureSequence(){var a;if(!this.doc)return[];let t=[],e=this.doc.getFirstMeasure(),r=e,i,o=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=n.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation("startRepeat")&&(r=e),e.hasNavigation("Segno")&&(i=e),s&&e.hasNavigation("toCoda"))for(;e&&!e.hasNavigation("Coda");)e=e.getNextMeasure();else if(o&&e.hasNavigation("Fine"))e=void 0;else if(e.hasNavigation("D.C. al Coda"))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.C. al Fine"))o=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation("D.S. al Coda"))s=!0,e=i;else if(e.hasNavigation("D.S. al Fine"))o=!0,e=i;else if(e.hasNavigation("endRepeat")){let u=e.getPassCount(),l=e.getEndRepeatPlayCount()-1,h=((a=e.getNextMeasure())==null?void 0:a.hasNavigation("ending"))===!0;u<=l||h?e=r:e=e.getNextMeasure()}else e.hasEndSong()?e=void 0:e=e.getNextMeasure()}return t}collectPlayerColumnSequence(){let t=this.collectPlayerMeasureSequence(),e=[];for(let r=0;r<t.length;r++){let i=t[r];e=e.concat(i.getColumns()),i.hasFermata(i.getBarLineRight())&&e.push(i.getBarLineRight())}return e}updatePlayerProps(){if(this.playerColumnSequence.forEach(a=>a.getPlayerProps().reset()),!this.doc)return;let t=1,e=bu(),r=new Map,i=new Map,o=(a,c)=>{var u;return r.set(a,[...(u=r.get(a))!=null?u:[],c])},s=(a,c)=>{var u;return i.set(a,[...(u=i.get(a))!=null?u:[],c])};this.playerColumnSequence.forEach(a=>{var l,h;if(!(a instanceof wr))return;a.getAnchoredLayoutObjects().forEach(p=>{var g;let m=(g=p.getTextContent())!=null?g:"",f;if(m==="a tempo")t=1;else if((f=Ro(m))!==void 0)e=f;else if(p.musicObj.getLink()instanceof _i){let y=p.musicObj.getLink(),{columnRange:b,extensionBreakText:I}=y.getExtensionRangeInfo(),S=A.Math.sum(b.map(w=>w.getTicksToNextColumn()));switch(m){case"accel.":{let w=t,_=w*Cb,v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,w+(_-w)*v/S)});break}case"rit.":{let w=t,_=w/_b,v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),o(C,w+(_-w)*v/S)});break}case"cresc.":{let w=e,_=w+vb;I&&(f=Ro(I))!==void 0&&f>w&&(_=f);let v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,w+(_-w)*v/S)});break}case"decresc.":case"dim.":{let w=e,_=w-Ib;I&&(f=Ro(I))!==void 0&&f<w&&(_=f);let v=0;b.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,w+(_-w)*v/S)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(t=A.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(e=A.Math.sum(u)/u.length),a.getPlayerProps().setSpeed(t),a.getPlayerProps().setVolume(e)})}static getMeasureByEndingPassage(t,e){for(let r=t;;r=r.getNextMeasure()){let i=r==null?void 0:r.getEnding();if(i&&i.hasPassage(e))return r;let o=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!o||o.hasNavigation("startRepeat"))return}}playStep(){if(this.notifyCursorPositionChanged(),this.notifyPlayStateChanged(),this.playPos===void 0){this.stop();return}let t=this.playerColumnSequence[this.playPos],e=(s,a)=>{let c=Sb(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),i=t.getPlayerProps().getFermataHoldTicks(),o;t instanceof Tr?o=e(i,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?Qt.get("32n").ticks*c:0,l=e(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(e(Qt.get("8n").ticks,r)/2,l/2));let h=wb(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=Tb),u>0){let p=e(u,r);window.setTimeout(()=>Ys(a.note,l,h),p*1e3)}else Ys(a.note,l,h)}}),o=e(t.getTicksToNextColumn()+i,r)),this.playTimer=window.setTimeout(()=>this.playStep(),o*1e3),this.playPos=this.getNextPlayPosition(this.playPos),this.notifyPlayStateChanged()}play(){if(this.playState===0)this.stop();else if(this.playState===1){this.playStep();return}let{doc:t}=this;if(!t)return;t.getFirstMeasure()?(this.playPos=0,this.playStep()):this.playPos=void 0,this.notifyPlayStateChanged()}pause(){this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}stop(){this.playPos=void 0,this.playTimer&&(window.clearTimeout(this.playTimer),this.playTimer=void 0),this.notifyCursorPositionChanged(),this.notifyPlayStateChanged()}getNextPlayPosition(t){return this.playPos!==void 0&&++this.playPos>=this.playerColumnSequence.length&&(this.playPos=void 0),this.playPos}getCursorRect(){if(this.playPos===void 0)return;let t=this.playerColumnSequence[this.playPos],e=t.measure,r=t.getRect().centerX,i=e.row.getRect().top,o=e.row.getRect().bottom;return new B(r,r,i,o)}};var Au=class extends it{constructor(e,r){super(r);this.barLine=e;this.line=r;d(this,"lineRects",[]);d(this,"dotRects",[]);d(this,"mi");r.addObject(this),this.mi=new Eo(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}setRect(e){this.rect=e}offset(e,r){this.lineRects.forEach(i=>i.offsetInPlace(e,r)),this.dotRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}},sa=class extends it{constructor(e){super(e);this.measure=e;d(this,"staffTabObjects",[]);d(this,"barLineType",0)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let o=this.staffTabObjects[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}layout(e){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,lineWidth:i}=e,{measure:o,barLineType:s}=this,{row:a}=o,c=i,u=.7*r,l=.7*r,h=at.DotSize*r,p=h/2;a.getNotationLines().forEach(m=>{let f=new Au(this,m),g,y,b,I,S=(_,v)=>{f.lineRects.push(new B(_,_+v/2,_+v,b,0,I))},w=_=>{for(let v=-1;v<=1;v+=2){let C=g+v*y;f.dotRects.push(new B(_-p,_,_+p,C-p,C,C+p))}};switch(m instanceof Tt?(g=m.getMiddleLineY(),y=m.getDiatonicSpacing()):(g=(m.getBottomLineY()+m.getTopLineY())/2,y=(m.getBottomLineY()-m.getTopLineY())/6),b=m.getTopLineY(),I=m.getBottomLineY(),s){case 0:f.setRect(new B(0,0,0,b,0,I));break;case 1:f.setRect(new B(-c,0,0,b,0,I)),S(-c,c);break;case 2:f.setRect(new B(-c-l-c,0,0,b,0,I)),S(-c-l-c,c),S(-c,c);break;case 3:f.setRect(new B(-u-l-c,0,0,b,0,I)),S(-c-l-u,c),S(-u,u);break;case 4:f.setRect(new B(0,0,u+l+c+l+h,b,0,I)),S(0,u),S(u+l,c),w(u+l+c+l+p);break;case 5:f.setRect(new B(-u-l-c-l-h,0,0,b,0,I)),S(-c-l-u,c),S(-u,u),w(-c-l-u-l-p);break;case 6:f.setRect(new B(-h-l-c-l-u/2,0,u/2+l+c+l+h,b,0,I)),S(-u/2,u),S(-u/2-l-c,c),S(u/2+l,c),w(-u/2-l-c-l-p),w(u/2+l+c+l+p);break}this.staffTabObjects.push(f)})}updateRect(){if(this.staffTabObjects.length>0){this.rect=this.staffTabObjects[0].getRect().copy();for(let e=1;e<this.staffTabObjects.length;e++)this.rect.expandInPlace(this.staffTabObjects[e].getRect())}else this.rect=new B}offset(e,r){this.staffTabObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let r=e.getCanvasContext();!r||this.barLineType===0||(e.drawDebugRect(this.getRect()),r.strokeStyle=r.fillStyle="black",this.staffTabObjects.forEach(i=>{i.lineRects.forEach(o=>r.fillRect(o.left,o.top,o.width,o.height)),i.dotRects.forEach(o=>e.fillCircle(o.centerX,o.centerY,o.width/2))}))}},Qr=class extends sa{constructor(e){super(e);d(this,"mi");this.mi=new Do(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation("startRepeat")?r&&r.row===e.row&&r.hasNavigation("endRepeat")?0:4:0}},Tr=class extends sa{constructor(e){super(e);d(this,"playerProps");d(this,"mi");this.playerProps=new Cn(this),this.mi=new Mo(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation("endRepeat")?r&&r.row===e.row&&r.hasNavigation("startRepeat")?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation("startRepeat")?2:r&&r.hasNavigation("startRepeat")?0:1}};var vi=class extends it{constructor(e,r){super(e);this.measure=e;this.passages=r;d(this,"endingText");d(this,"shapeRects",[]);d(this,"mi");if(this.mi=new ko(this),A.Is.isIntegerGte(r.length,1)){if(!this.passages.every(o=>A.Is.isIntegerGte(o,1)))throw new O(6,"Invalid passages: "+this.passages)}else throw new O(6,"Passages is empty.");this.passages.sort((o,s)=>o-s);let i=this.passages.map(o=>o+".").join("");this.endingText=new lt(this,i,0,1)}getMusicInterface(){return this.mi}getShapeRects(){return this.shapeRects}isSingleMeasureEnding(){let{measure:e}=this,r=e.getNextMeasure();return(r==null?void 0:r.hasNavigation("ending"))===!0||e.hasNavigation("endRepeat")||e.isLastMeasure()}hasPassage(e){return this.passages.some(r=>r===e)}getHighestPassage(){return Math.max(0,...this.passages)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new B,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:i}=this;this.endingText.layout(e);let o=this.endingText.getRect(),s=i.getColumnsContentRect(),a=o.height;this.rect=new B(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new B(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new B(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new B(this.rect.right-1,this.rect.right,this.rect.top,this.rect.bottom),this.endingText.getRect().copy()]}offset(e,r){this.endingText.offset(e,r),this.shapeRects.forEach(i=>i.offsetInPlace(e,r)),this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i}=e,{rect:o}=this;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle="black",r.lineWidth=i,r.beginPath(),r.moveTo(o.left,o.bottom),r.lineTo(o.left,o.top),r.lineTo(o.right,o.top),this.isSingleMeasureEnding()&&r.lineTo(o.right,o.bottom),r.stroke(),this.endingText.draw(e)}};var _n=class extends it{constructor(e,r){super(e);this.pos=r;d(this,"color","black");d(this,"mi");this.mi=new jo(this)}getMusicInterface(){return this.mi}static getFermataPositions(e){let{measure:r}=e,{row:i}=r;return i.getTopStaff()!==i.getBottomStaff()?[0,1]:[0]}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,i=r*4,o=r*3;this.rect=new B(-i/2,i/2,-o,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i,unitSize:o}=e,s=this.pos===1,a=(s?o:-o)*.7,c=this.rect.left,u=this.rect.right,l=(s?this.rect.bottom:this.rect.top)+a,h=(s?this.rect.top:this.rect.bottom)+a,p=h-l;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle=this.color,r.lineWidth=i,r.beginPath(),r.moveTo(c,h),r.bezierCurveTo(c,l,u,l,u,h),r.bezierCurveTo(u,l+p/5,c,l+p/5,c,h),r.stroke(),r.fill();let m=p/6;e.fillCircle((c+u)/2,h-m,Math.abs(m))}};var vn=class extends it{constructor(e,r,i,o,s){super(e);this.measure=e;this.line=r;this.extension=i;this.leftObj=o;this.rightObj=s;d(this,"mi");i.addTail(this),this.mi=new Po(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(){return this.leftObj instanceof Qr?this.leftObj.getRect().centerX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof wr){let e=this.rightObj,r=e.getNextColumn();return r&&r.measure===e.measure?(e.getRect().right+r.getRect().left)/2:(e.getRect().right+e.measure.getBarLineRight().getRect().left)/2}else return this.rightObj.getRect().centerX}layoutFitToMeasure(e){let{unitSize:r}=e,i=this.getLineLeft(),o=this.getLineRight(),s=r;this.rect=new B(i,o,-s/2,s/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new B}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{rect:i}=this;this.extension.getLineStyle()==="dashed"&&r.setLineDash([7,3]),e.drawLine(i.left,i.centerY,i.right,i.centerY,"black",e.lineWidth),r.setLineDash([]);let o=this.extension.getTails();if(o.length>0&&this===o[o.length-1]){let s=i.centerY>this.line.getRect().centerY?-e.unitSize:e.unitSize;e.drawLine(i.right,i.centerY,i.right,i.centerY+s,"black",e.lineWidth)}}};var Ii=class extends it{constructor(e,r,i,o,s,...a){super(i);this.connectiveProps=e;this.line=r;this.measure=i;d(this,"lx",0);d(this,"ly",0);d(this,"rx",0);d(this,"ry",0);d(this,"cp1x",0);d(this,"cp1y",0);d(this,"cp2x",0);d(this,"cp2y",0);d(this,"arcHeight",0);d(this,"leftNoteGroup");d(this,"leftNoteId");d(this,"rightNoteGroup");d(this,"rightNoteId");d(this,"tieType");d(this,"mi");this.leftNoteGroup=o,this.leftNoteId=s,a[0]instanceof St&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):A.Is.isEnumValue(a[0],Qe)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new Lo(this)}getMusicInterface(){return this.mi}isInsideMeasure(){return this.rightNoteGroup===void 0||this.leftNoteGroup.measure===this.rightNoteGroup.measure}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{unitSize:r}=e,{measure:i,line:o,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:p}=l,{row:m}=i,f=m.getPrevRow(),g=m.getNextRow(),y=m.getConnectivesContentRect(),b,I;b=s.getConnectiveAnchorPoint(l,o,a,h,"left"),c!==void 0&&u!==void 0?I=c.getConnectiveAnchorPoint(l,o,u,h,"right"):I=this.tieType==="toMeasureEnd"?{x:i.getColumnsContentRect().right,y:b.y}:{x:b.x+r*at.StubTieLength,y:b.y};let S,w,_,v;if(c===void 0)S=b.x,w=b.y,_=I.x,v=I.y;else if(s.row===m&&c.row===m)S=b.x,w=b.y,_=I.x,v=I.y;else if(s.row===f&&c.row===m){let D=f.getConnectivesContentRect().right-b.x,U=I.x-y.left;S=y.left,w=b.y+(I.y-b.y)*D/(D+U),_=I.x,v=I.y}else if(s.row===m&&c.row===g){let R=g.getConnectivesContentRect(),D=y.right-b.x,U=I.x-R.left;S=b.x,w=b.y,_=y.right,v=b.y+(I.y-b.y)*D/(D+U)}else throw new O(6,"Cannot layout connective object because no valid left and right note groups.");let x=(p==="up"?-1:1)*r*Math.log2(_-S)/3;this.lx=S,this.ly=w,this.rx=_,this.ry=v,this.arcHeight=this.connectiveProps.connective==="slide"?0:x;let{nx:N,ny:k}=A.Math.calcNormal(S,w,_,v);this.cp1x=S*.7+_*.3+N*this.arcHeight,this.cp1y=w*.7+v*.3+k*this.arcHeight,this.cp2x=S*.3+_*.7+N*this.arcHeight,this.cp2y=w*.3+v*.7+k*this.arcHeight,this.rect=new B(Math.min(this.lx,this.cp1x,this.cp2x,this.rx),Math.max(this.lx,this.cp1x,this.cp2x,this.rx),Math.min(this.ly,this.cp1y,this.cp2y,this.ry),Math.max(this.ly,this.cp1y,this.cp2y,this.ry)),this.line.addObject(this)}offset(e,r){this.lx+=e,this.ly+=r,this.rx+=e,this.ry+=r,this.cp1x+=e,this.cp1y+=r,this.cp2x+=e,this.cp2y+=r,this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;if(this.rightNoteGroup!==void 0){if(this.leftNoteGroup.measure!==this.rightNoteGroup.measure){if(this.leftNoteGroup.row.getNextRow()!==this.rightNoteGroup.row){if(this.measure!==this.rightNoteGroup.measure)return}}}let{rect:i}=this,{lineWidth:o}=e;e.drawDebugRect(i);let s=o*1.5,a=o*.25;r.strokeStyle=r.fillStyle="black",r.lineWidth=o,this.arcHeight===0?(r.beginPath(),r.moveTo(this.lx,this.ly),r.lineTo(this.rx,this.ry),r.stroke()):(r.beginPath(),r.moveTo(this.lx,this.ly-a),r.bezierCurveTo(this.cp1x,this.cp1y-s,this.cp2x,this.cp2y-s,this.rx,this.ry-a),r.lineTo(this.rx,this.ry+a),r.bezierCurveTo(this.cp2x,this.cp2y+s,this.cp1x,this.cp1y+s,this.lx,this.ly+a),r.fill())}};var In=class{constructor(t,e,r,i){this.connective=t;this.span=e;this.noteAnchor=r;d(this,"noteGroups");d(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span==="stub"||this.span==="toMeasureEnd"?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(){let{stemDir:t}=this.noteGroups[0],{hasStem:e}=this.noteGroups[0].rhythmProps;if(this.noteAnchor==="stemTip")this.arcDir=t==="up"?"up":"down";else if(this.noteAnchor==="auto")this.arcDir=t==="up"||!e?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor="center":this.connective==="slide"?this.noteAnchor="center":this.arcDir==="up"?this.noteAnchor="above":this.noteAnchor="below";else if(this.noteAnchor==="center"){let{row:r}=this.noteGroups[0].measure,i=this.noteGroups[0].ownDiatonicId,o=r.getStaff(i);this.arcDir=!o||i<o.middleLineDiatonicId?"down":"up"}else this.noteAnchor==="above"?this.arcDir="up":this.noteAnchor==="below"&&(this.arcDir="down")}removeConnectives(){this.noteGroups.forEach(t=>{t.measure.removeConnectiveObjects(),t.removeConnectiveProps()}),this.noteGroups.length=1}createConnectives(){this.getStartNoteGroup().collectConnectiveProps(),this.computeParams();let{connective:t,span:e}=this;if(t==="tie"){if(A.Is.isEnumValue(e,Qe)){let r=this.noteGroups[0];for(let i=0;i<r.notes.length;i++)this.createObjConnectiveWithTieType(r,i,e)}else if(this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];i.notes.forEach((s,a)=>{let c=o.notes.findIndex(u=>W.equals(u,s));c>=0&&this.createObjConnective(i,a,o,c)})}}else if(t==="slur"){if(typeof e=="number"&&e>=2&&this.noteGroups.length===e){let r=this.noteGroups[0],i=this.noteGroups[this.noteGroups.length-1];this.createObjConnective(r,0,i,0)}}else if(t==="slide"&&this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],o=this.noteGroups[r+1];this.createObjConnective(i,0,o,0)}}createObjConnectiveWithTieType(t,e,r){t.row.getNotationLines().filter(i=>t.enableConnective(i)).forEach(i=>{i instanceof Tt?new Ii(this,i,t.measure,t,e,r):t.getFretNumberString(e)!==void 0&&new Ii(this,i,t.measure,t,e,r)})}createObjConnective(t,e,r,i){let o=(s,a,c,u,l)=>{s.row.getNotationLines().filter(h=>a.enableConnective(h)&&u.enableConnective(h)).forEach(h=>{if(h instanceof Tt)new Ii(this,h,s,a,c,u,l);else{let p=a.getFretNumberString(c),m=u.getFretNumberString(l);p!==void 0&&m!==void 0&&(p===m||this.connective==="slur")&&new Ii(this,h,s,a,c,u,l)}})};if(t.measure===r.measure)o(t.measure,t,e,r,i);else if(t.measure.getNextMeasure()===r.measure)o(t.measure,t,e,r,i),o(r.measure,t,e,r,i);else throw new O(6,"Cannot create connective because it is jumping measures.")}};function na(n){if(se().indexOf(n)<0)throw new O(6,"Invalid voiceId: "+n);return n}function Nb(n){if(typeof n=="string"&&(n=[n]),A.Is.isArray(n)){let t=0;for(let e=0;e<n.length;){let r=n[e],i=n[e+1];if(typeof r=="string"){e++;let o=Qt.get(r).ticks;typeof i=="number"&&(e++,o*=i),t+=o}else e++}return t}else return n}var Fo=class Fo extends it{constructor(e){super(e);this.row=e;d(this,"prevMeasure");d(this,"nextMeasure");d(this,"keySignature",Ko());d(this,"timeSignature",es());d(this,"tempo",rs());d(this,"alterKeySignature");d(this,"alterTimeSignature");d(this,"alterTempo");d(this,"signatures",[]);d(this,"tabStringNotes",[]);d(this,"barLineLeft");d(this,"columns",[]);d(this,"barLineRight");d(this,"connectives",[]);d(this,"beamGroups",[]);d(this,"tabStringNotesWidth",0);d(this,"measureId");d(this,"needLayout",!0);d(this,"leftSolidAreaWidth",0);d(this,"minColumnsAreaWidth",0);d(this,"rightSolidAreaWidth",0);d(this,"useDiatonicId",[]);d(this,"useStemDir",[]);d(this,"useString",[]);d(this,"voiceSymbols",[]);d(this,"lastAddedRhythmColumn");d(this,"lastAddedRhythmSymbol");d(this,"addExtensionToMusicObjects",[]);d(this,"layoutObjects",[]);d(this,"postMeasureBreakWidth",0);d(this,"passCount",0);d(this,"needBeamsUpdate",!0);d(this,"navigationSet",new Set);d(this,"isEndSong",!1);d(this,"isEndSection",!1);d(this,"endRepeatPlayCount",2);d(this,"endRepeatPlayCountText");d(this,"staticObjectsCache",new Map);d(this,"mi");this.mi=new Bo(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new Qr(this),this.barLineRight=new Tr(this),this.measureId=this.prevMeasure?this.prevMeasure.measureId+1:0,this.updateKeySignature(),this.updateTimeSignature(),this.updateTempo()}getMusicInterface(){return this.mi}get doc(){return this.row.doc}isPartialMeasure(){return this.getConsumedTicks()<this.getMeasureTicks()}isUpBeat(){return this===this.doc.getFirstMeasure()}resetPassCount(){this.passCount=0}incPassCount(){this.passCount++}getPassCount(){return this.passCount}updateOwnDiatonicId(e,r){if(typeof r=="number")this.useDiatonicId[e]=r;else if(this.useDiatonicId[e]===void 0){let o=this.getPrevMeasure();o&&o.useDiatonicId[e]!==void 0&&(this.useDiatonicId[e]=o.useDiatonicId[e])}let i=this.useDiatonicId[e];return i===void 0&&(this.row.hasStaff?i=this.row.getTopStaff().middleLineDiatonicId:i=W.getNote("C4").diatonicId),this.useDiatonicId[e]=W.validateDiatonicId(i)}updateOwnStemDir(e,r){var s,a;let{voiceId:i}=e;r!==void 0?this.useStemDir[i]=r:this.useStemDir[i]===void 0&&(this.useStemDir[i]=(a=(s=this.getPrevMeasure())==null?void 0:s.useStemDir[i])!=null?a:"auto");let o=this.useStemDir[i];if(o==="auto"||o===void 0){let c=this.row.getStaff(e.ownDiatonicId);return c?e.ownDiatonicId>c.middleLineDiatonicId?"down":"up":"up"}else return o}updateOwnString(e,r){var o,s;let{voiceId:i}=e;return r!==void 0?this.useString[i]=r:this.useString[i]===void 0&&(this.useString[i]=(s=(o=this.getPrevMeasure())==null?void 0:o.useString[i])!=null?s:[]),this.useString[i]}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.signatures.length;i++){let o=this.signatures[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.tabStringNotes.length;i++){let o=this.tabStringNotes[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.columns.length;i++){let o=this.columns[i].pick(e,r);if(o.length>0)return[this,...o]}if(this.barLineLeft){let i=this.barLineLeft.pick(e,r);if(i.length>0)return[this,...i]}if(this.barLineRight){let i=this.barLineRight.pick(e,r);if(i.length>0)return[this,...i]}if(this.endRepeatPlayCountText){let i=this.endRepeatPlayCountText.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.connectives.length;i++){let o=this.connectives[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.beamGroups.length;i++){let o=this.beamGroups[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.layoutObjects.length;i++){let o=this.layoutObjects[i].musicObj.pick(e,r);if(o.length>0)return[this,...o]}return[this]}getMeasureNumber(){let e=this.doc.getFirstMeasure();return e&&e.isPartialMeasure()?this.measureId:this.measureId+1}getColumns(){return this.columns}getColumnCount(){return this.columns.length}getColumn(e){return this.getColumns()[e]}isFirstMeasure(){return this.prevMeasure===void 0}isLastMeasure(){return this.nextMeasure===void 0}getNextMeasure(){return this.nextMeasure}getPrevMeasure(){return this.prevMeasure}getKeySignature(){return this.keySignature}setKeySignature(...e){var r;if((r=this.getPrevMeasure())==null||r.endSection(),e[0]instanceof Le)this.alterKeySignature=e[0];else if(e[0]instanceof jr)this.alterKeySignature=e[0];else if(A.Is.isNonEmptyString(e[0])){if(e.length===1)this.alterKeySignature=dr(e[0]);else if(e.length===2)try{let i=""+e[0],o=Ln(""+e[1]);this.alterKeySignature=dr(i,o)}catch(i){throw new O(6,"Cannot set key signature because invalid args: "+e)}}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:Ko(),this.alterKeySignature&&(this.keySignature=this.alterKeySignature),this.nextMeasure&&this.nextMeasure.updateKeySignature(),this.requestLayout()}getTimeSignature(){return this.timeSignature}setTimeSignature(e){var r;(r=this.getPrevMeasure())==null||r.endSection(),this.alterTimeSignature=e instanceof gr?e:new gr(e),this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:es(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r,i){var o;if((o=this.getPrevMeasure())==null||o.endSection(),r===void 0)this.alterTempo={beatsPerMinute:e};else{let s=typeof i=="number"&&i>0?i:i===!0?1:Xt.get(r).dotCount,a={beatLength:ii(r),dotCount:s>0?s:void 0};this.alterTempo={beatsPerMinute:e,options:a}}this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:rs(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,o;this.alterTempo.options?(i=this.alterTempo.options.beatLength,o=(e=this.alterTempo.options.dotCount)!=null?e:0):this.alterTimeSignature?(i=this.alterTimeSignature.beatLength,o=0):(i=this.tempo.options.beatLength,o=this.tempo.options.dotCount),this.tempo={beatsPerMinute:r,options:{beatLength:i,dotCount:o}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,i,o){this.layoutObjects.push(new aa(e,r,i,o)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(e,r,i){let o=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")o[a]&&i(o[a],c);else if(typeof a=="string"&&a.length>0){let l=o.filter(h=>h.name===a);if(l.forEach(h=>i(h,c)),l.length===0){let h=this.doc.getStaffGroup(a);if(h&&!u.includes(a)){let p=[...u,a];(A.Is.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(m=>{switch(h.verticalPosition){case"above":s(m,0,p);break;case"below":s(m,1,p);break;case"both":s(m,0,p),s(m,1,p);break;case"auto":s(m,r,p);break}})}}}};e===void 0?o.length>=2&&o[0]instanceof Tt&&o[0].staffConfig.clef==="G"&&o[0].isGrand()&&o[1]instanceof Tt&&o[1].staffConfig.clef==="F"&&o[1].isGrand()?s(r===1?1:0,r):s(0,r):A.Is.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let i=r==="atMeasureEnd"?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new O(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(o,s)=>{this.addLayoutObject(new _n(i,s),o,0,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof _n&&r.anchor===e)}addNavigation(e,r,...i){let o;switch(r){case"ending":if(this.navigationSet.has(r))throw new O(6,"Cannot add ending beasure measure already has one.");let s=this,a=i;o={createObj:()=>new vi(s,a),layoutGroupId:3,defaultVerticalPos:0};break;case"D.C. al Coda":case"D.C. al Fine":case"D.S. al Coda":case"D.S. al Fine":{let c=this.barLineRight,u=Oo(r);o={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0},this.addNavigation(e,"endRepeat"),this.endSong();break}case"Fine":{let c=this.barLineRight,u=Oo(r);o={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0};break}case"Segno":case"Coda":{let c=this.barLineLeft,u=Oo(r);o={createObj:()=>new Je(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case"toCoda":{let c=this.barLineRight,u=Oo(r);o={createObj:()=>new Je(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case"endRepeat":if(i.length===0)this.endRepeatPlayCount=2;else if(A.Is.isIntegerGte(i[0],2))this.endRepeatPlayCount=i[0];else throw new O(6,"Invalid end repeat play count (should be 2 or greater integer): "+i[0]);if(this.endRepeatPlayCount!==2){let c={text:""+this.endRepeatPlayCount+"x",scale:.8};this.endRepeatPlayCountText=new lt(this,c,.5,1)}break}o&&this.forEachStaffGroup(e,o.defaultVerticalPos,(s,a)=>{this.addLayoutObject(o.createObj(),s,o.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add annotation because annotation text is empty.")}else throw new O(6,"Cannot add annotation because anchor is undefined.");let s={text:i},a,c;switch(r){case"dynamics":a=5,c=0,s.italic=!0;break;case"tempo":a=4,c=0,s.italic=!0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(e,r,i){let o=this.lastAddedRhythmColumn;if(o){if(i.length===0)throw new O(6,"Cannot add label because label text is empty.")}else throw new O(6,"Cannot add label because anchor is undefined.");let s={text:i},a,c;switch(r){case"note":a=1,c=1;break;case"chord":a=6,c=0;break}this.disableExtension(),this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(o,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addConnective(e,...r){let i=this.lastAddedRhythmSymbol;if(!(i instanceof St))throw new O(6,"Connective can be added to note group only.");if(e==="tie"){let o=A.Is.isInteger(r[0])||A.Is.isEnumValue(r[0],Qe)?r[0]:2,s=A.Is.isEnumValue(r[1],je)?r[1]:"auto";i.startConnective(new In("tie",o,s,i))}else if(e==="slur"){let o=A.Is.isInteger(r[0])?r[0]:2,s=A.Is.isEnumValue(r[1],je)?r[1]:"auto";i.startConnective(new In("slur",o,s,i))}else if(e==="slide"){let o=A.Is.isEnumValue(r[0],je)?r[0]:"auto";i.startConnective(new In("slide",2,o,i))}}addExtension(e,r){if(this.addExtensionToMusicObjects.forEach(i=>{let o=i.getParent();if(i instanceof lt&&o instanceof wr){let s="dashed",a="bottom",c=new _i(i,o,Nb(e),r,s,a);i.setLink(c)}else throw new O(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new O(6,"Cannot add extension because music object to attach it to is undefined.");this.disableExtension(),this.requestLayout()}enableExtension(e){this.addExtensionToMusicObjects.push(e)}disableExtension(){this.addExtensionToMusicObjects=[]}getEnding(){return this.layoutObjects.map(e=>e.musicObj).find(e=>e instanceof vi)}getEndRepeatPlayCount(){return this.endRepeatPlayCount}endSong(){this.isEndSong=!0,this.requestLayout(),this.disableExtension()}hasEndSong(){return this.isEndSong}endSection(){this.isEndSection=!0,this.requestLayout(),this.disableExtension()}hasEndSection(){return this.isEndSection}endRow(){this.doc.requestNewRow(),this.disableExtension()}addRhythmSymbol(e,r){let{col:i}=r;i.setVoiceSymbol(e,r),this.getVoiceSymbols(e),this.voiceSymbols[e].push(r),r.oldStyleTriplet&&this.createOldStyleTriplets(e),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=i,this.lastAddedRhythmSymbol=r}addNoteGroup(e,r,i,o,s){let a=r.map(l=>typeof l=="string"?W.getNote(l):l),c=this.getRhythmColumn(e),u=new St(c,e,a,i,o,s);return this.addRhythmSymbol(e,u),u}addRest(e,r,i,o){let s=this.getRhythmColumn(e),a=new Ci(s,e,r,i,o);return this.addRhythmSymbol(e,a),a}getRhythmColumn(e){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let o=this.columns[i],s=o.getVoiceSymbol(e);s&&(r=o.positionTicks+s.rhythmProps.ticks)}for(let i=0;i<=this.columns.length;i++){let o=this.columns[i];if(o&&o.positionTicks===r)return o;if(!o||o.positionTicks>r){let s=new wr(this,r);return this.columns.splice(i,0,s),s}}throw new O(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(i=>{se().forEach(o=>{let s=i.getVoiceSymbol(o);s&&(e===void 0||e===o)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new B(this.barLineLeft.getRect().centerX,this.barLineRight.getRect().centerX,this.getRect().top,this.getRect().bottom)}getLeftSolidAreaWidth(){return this.leftSolidAreaWidth}getMinColumnsAreaWidth(){return this.minColumnsAreaWidth}getRightSolidAreaWidth(){return this.rightSolidAreaWidth}getSolidAreaWidth(){return this.leftSolidAreaWidth+this.rightSolidAreaWidth}getMinWidth(){return this.leftSolidAreaWidth+this.minColumnsAreaWidth+this.rightSolidAreaWidth}getStaffLineLeft(){let e=this.getPrevMeasure();return e&&e.row===this.row&&!e.hasPostMeasureBreak()?e.getStaffLineRight():this.getRect().left+this.tabStringNotesWidth}getStaffLineRight(){return this.barLineRight.getRect().centerX}getStaticObjects(e){let r=this.staticObjectsCache.get(e);r||(r=[],this.getColumns().forEach(o=>o.getStaticObjects(e).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(e,r));let i=this.layoutObjects.filter(o=>o.line===e&&o.isPositionResolved()).map(o=>o.musicObj);return i.length>0?[...r,...i]:r}removeLayoutObjects(e){this.layoutObjects=this.layoutObjects.filter(r=>{if(r.musicObj===e){let i=r.musicObj.getLink();return i&&i.detachTail(r.musicObj),r.layoutGroup.remove(r),!1}else return!0})}addConnectiveObject(e){this.connectives.push(e),this.requestLayout()}removeConnectiveObjects(){this.connectives.length>0&&(this.connectives=[],this.requestLayout())}createExtensions(){this.layoutObjects.forEach(e=>{var c;let{musicObj:r,measure:i,layoutGroupId:o,verticalPos:s,line:a}=e;if(r.getLink()instanceof _i){let u=r.getLink();if(u.getHead()===r){u.getTails().forEach(p=>i.removeLayoutObjects(p));let{startColumn:l,endColumn:h}=u.getExtensionRangeInfo();if(u.isVisible()&&l!==h)for(let p=l.measure;p!==void 0;p=p===h.measure?void 0:p.getNextMeasure()){let m=p===l.measure?u.getHead():p.getBarLineLeft(),f=p===h.measure?h:p.getBarLineRight(),g=p.row.getNotationLines(),y=(c=g.find(b=>b.name!==""&&b.name===a.name))!=null?c:g[a.id];y&&p.addLayoutObject(new vn(p,y,u,m,f),y,o,s)}}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);for(let i=0;i<r.length;)if(r[i].oldStyleTriplet){let o=Xr.createOldStyleTriplet(r.slice(i,i+3));i+=o===0?1:o}else i++;this.requestLayout()}createBeams(){this.needBeamsUpdate&&(this.beamGroups=this.beamGroups.filter(e=>e.isTuplet()?!0:(e.detach(),!1)),se().forEach(e=>{let r=this.getVoiceSymbols(e);if(!(r.length<=2)&&!Qs.DisableBeams){let i=[],o=0,s=0;this.isUpBeat()&&(o=s=Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()));let a=this.getTimeSignature();r.forEach(c=>{for(i.push(c),s+=c.rhythmProps.ticks,o===0&&s===a.beamGroupLength&&Fo.setupBeamGroup(i);s>=a.beamGroupLength;)i=[],o=s=s-a.beamGroupLength})}}),this.needBeamsUpdate=!1,this.requestLayout())}static setupBeamGroup(e){let r=e.map(o=>{var s;return o instanceof St&&((s=o.getBeamGroup())==null?void 0:s.isTuplet())!==!0?o:void 0});St.setBeamCounts(r);let i=[];r.forEach(o=>{o&&o.hasBeamCount()?i.push(o):(Xr.createBeam(i),i=[])}),Xr.createBeam(i)}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return na(e),this.voiceSymbols[e]===void 0&&(this.voiceSymbols[e]=[]),this.voiceSymbols[e]}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):this.completeRests(se().filter(r=>this.getConsumedTicks(r)>0));return}else if(A.Is.isArray(e)){e.forEach(r=>this.completeRests(r));return}else{na(e);let r=this.getMeasureTicks(),i=this.getConsumedTicks(e),o=r-i,s=[];for(;o>0;)for(let a=Xt.LongestNoteSize;a<=Xt.ShortestNoteSize;a*=2){let c=Xt.create(a).noteLength;for(let u=Xt.get(c).maxDotCount;u>=0;u--){let l=Qt.get(c,u);for(;l.ticks<=o;)s.push(l),o-=l.ticks}}s.reverse().forEach(a=>this.addRest(e,a.noteLength,{dotted:a.dotCount}))}}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var m;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?at.PostMeasureBreakWidth*r:0;let i=this===this.row.getFirstMeasure(),o=((m=this.getPrevMeasure())==null?void 0:m.hasPostMeasureBreak())===!0;this.tabStringNotesWidth=i&&this.row.hasTab?r*4:0;let s=i||o,a=i&&!this.row.isFirstRow(),c=i||o||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;s||a||c||u||l?this.signatures=this.row.getStaves().map((f,g)=>{let y=this.signatures.find(I=>I.staff===f),b=y!=null?y:new ta(this,f);return b.staff.addObject(b),b.updateClefImage(e,s),b.updateMeasureNumber(a&&g===0),b.updateKeySignature(c),b.updateTimeSignature(u),b.updateTempo(l&&g===0),b}):this.signatures=[],this.signatures.forEach(f=>f.layout(e)),this.tabStringNotes.length=0,this===this.row.getFirstMeasure()&&this.row.getTabs().forEach(f=>{for(let g=0;g<6;g++){let y=f.getTuningStrings()[g].format(1,1),b=new lt(this,{text:y,scale:.8},1,.5);b.layout(e),b.offset(this.tabStringNotesWidth*.8,f.getStringY(g)),this.tabStringNotes.push(b),f.addObject(b)}}),this.barLineLeft.layout(e);let h=new Js(this);this.columns.forEach(f=>f.layout(e,h)),this.barLineRight.layout(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.layout(e),this.layoutObjects.forEach(f=>f.layout(e));let p=e.unitSize;this.leftSolidAreaWidth=this.tabStringNotesWidth+Math.max(0,...this.signatures.map(f=>f.getRect().width))+this.barLineLeft.getRect().width+p,this.rightSolidAreaWidth=p+this.barLineRight.getRect().width,this.minColumnsAreaWidth=0,this.columns.forEach(f=>this.minColumnsAreaWidth+=f.getRect().width),this.minColumnsAreaWidth=Math.max(this.minColumnsAreaWidth,Fo.MinFlexContentWidth*r)}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new B,this.rect.centerX=this.rect.left+r/2,this.rect.right=this.rect.left+r;let i;this.signatures.forEach(p=>{i=p.getRect(),p.offset(this.rect.left+this.tabStringNotesWidth-i.left,-i.centerY)});let o=Math.max(0,...this.signatures.map(p=>p.getRect().width));i=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.tabStringNotesWidth+o-i.left,-i.centerY),i=this.barLineRight.getRect(),this.barLineRight.offset(this.rect.right-i.right,-i.centerY),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(this.barLineRight.getRect().left,this.barLineRight.getRect().top);let s=this.rect.left+this.leftSolidAreaWidth,c=this.rect.right-this.rightSolidAreaWidth-s,u=A.Math.sum(this.columns.map(p=>p.getRect().width)),l=c/u,h=s;this.columns.forEach(p=>{i=p.getRect();let m=h+i.leftw*l;p.offset(m-i.centerX,-i.centerY),h+=i.width*l})}layoutConnectives(e){this.needLayout&&this.connectives.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}layoutBeams(e){this.needLayout&&this.beamGroups.forEach(r=>{r.layout(e),this.rect.top=Math.min(this.rect.top,r.getRect().top),this.rect.bottom=Math.max(this.rect.bottom,r.getRect().bottom)})}alignStemsToBeams(){this.beamGroups.forEach(e=>e.updateStemTips())}layoutDone(){this.columns.forEach(e=>e.layoutDone()),this.needLayout=!1}updateRect(){this.rect.top=Math.min(...this.signatures.map(e=>e.getRect().top),...this.tabStringNotes.map(e=>e.getRect().top),this.barLineLeft.getRect().top,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),this.barLineRight.getRect().top,...this.connectives.map(e=>e.getRect().top),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().top),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().top)),this.rect.bottom=Math.max(...this.signatures.map(e=>e.getRect().bottom),...this.tabStringNotes.map(e=>e.getRect().bottom),this.barLineLeft.getRect().bottom,...this.columns.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),this.barLineRight.getRect().bottom,...this.connectives.map(e=>e.getRect().bottom),...this.beamGroups.filter(e=>!e.isEmpty()).map(e=>e.getRect().bottom),...this.layoutObjects.filter(e=>e.isPositionResolved()).map(e=>e.musicObj.getRect().bottom)),this===this.row.getLastMeasure()&&(this.rect.right=Math.max(this.rect.right,...this.layoutObjects.filter(e=>e.isPositionResolved()&&e.musicObj instanceof _n).map(e=>e.musicObj.getRect().right))),this.row.getNotationLines().forEach(e=>{this.rect.top=Math.min(this.rect.top,e.calcTop()),this.rect.bottom=Math.max(this.rect.bottom,e.calcBottom())}),this.row.requestRectUpdate()}offset(e,r){this.signatures.forEach(i=>i.offset(e,0)),this.tabStringNotes.forEach(i=>i.offset(e,0)),this.barLineLeft.offset(e,r),this.columns.forEach(i=>i.offset(e,r)),this.barLineRight.offset(e,r),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.offset(e,r),this.connectives.forEach(i=>i.offset(e,0)),this.beamGroups.forEach(i=>i.offset(e,r)),this.layoutObjects.forEach(i=>i.offset(e,0)),this.rect.offsetInPlace(e,r),this.requestRectUpdate()}draw(e){e.drawDebugRect(this.getRect());let r=this.getStaffLineLeft(),i=this.getStaffLineRight(),o=a=>e.drawLine(r,a,i,a),{row:s}=this;s.getNotationLines().forEach(a=>{if(a instanceof Tt)for(let c=a.bottomLineDiatonicId;c<=a.topLineDiatonicId;c+=2)o(a.getDiatonicIdY(c));else if(a instanceof Pe)for(let c=0;c<6;c++)o(a.getStringY(c))}),this.signatures.forEach(a=>a.draw(e)),this.tabStringNotes.forEach(a=>a.draw(e)),this.barLineLeft.draw(e),this.columns.forEach(a=>a.draw(e)),this.barLineRight.draw(e),this.endRepeatPlayCountText&&this.endRepeatPlayCountText.draw(e),this.connectives.forEach(a=>a.draw(e)),this.layoutObjects.forEach(a=>a.musicObj.draw(e)),this.beamGroups.forEach(a=>a.draw(e))}};d(Fo,"MinFlexContentWidth",10);var Sn=Fo;var Ob=[1,6],Rb=[2,3,4,5,6];function Mb(n){for(;n;){if(n instanceof Sn)return n;n=n.getParent()}throw new O(6,"Parent measure is required but not found!")}var ca=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},aa=class{constructor(t,e,r,i){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=i;d(this,"anchor");d(this,"measure");d(this,"row");d(this,"layoutGroup");d(this,"positionResolved",!0);this.measure=Mb(this.musicObj),this.row=this.measure.row;let o=this.musicObj.getParent();if(!o)throw new O(6,"Parent music object is required as an anchor.");this.anchor=o,this.anchor.addAnchoredLayoutObject(this),this.layoutGroup=this.line.getLayoutGroup(r),this.layoutGroup.add(this)}clearPositionResolved(){this.positionResolved=!1}setPositionResolved(){this.positionResolved=!0}isPositionResolved(){return this.positionResolved}resolveClosestToStaffY(t){let{musicObj:e,measure:r,verticalPos:i,line:o}=this,s=o.getTopLineY(),a=o.getBottomLineY(),c=t.unitSize*2,u=i===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,l=r.getStaticObjects(o),h=e.getShapeRects();return l.forEach(p=>{let m=p.getShapeRects();h.forEach(f=>{m.forEach(g=>{B.overlapX(f,g)&&(u=i===1?Math.max(u,g.bottom+f.toph+f.centerY):Math.min(u,g.top-f.bottomh-f.centerY))})})}),u}getTextContent(){if(this.musicObj instanceof lt||this.musicObj instanceof Je)return this.musicObj.getText()}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}getRect(){return this.musicObj.getRect()}},ua=class{constructor(t){this.layoutGroupId=t;d(this,"layoutObjectTable",[]);d(this,"rowAlign");d(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=Rb.indexOf(t)>=0,this.widensColumn=Ob.indexOf(t)>=0}getLayoutObjects(t){return this.layoutObjectTable[t]}add(t){this.layoutObjectTable[t.verticalPos].push(t)}remove(t){this.layoutObjectTable.forEach(e=>{let r=e.indexOf(t);r>=0&&e.splice(r,1)})}clearPositionAndLayout(t){this.layoutObjectTable.forEach(e=>{e.forEach(r=>{r.clearPositionResolved(),r.musicObj.layout(t)})})}};var la=class extends it{constructor(e){super(e);d(this,"objects",[]);d(this,"layoutGroups",[])}addObject(e){this.objects.push(e)}removeObjects(){this.objects.length=0}getLayoutGroup(e){let r=this.layoutGroups[e];return r||(r=this.layoutGroups[e]=new ua(e)),r}resetLayoutGroups(e){this.layoutGroups.forEach(r=>{r&&r.clearPositionAndLayout(e)})}layoutLayoutGroups(e){this.layoutGroups.forEach(r=>{r&&(this.layoutLayoutGroup(e,r,0),this.layoutLayoutGroup(e,r,1))})}setObjectY(e,r){r!==void 0&&(e.offset(0,r-e.getRect().centerY),e.setPositionResolved())}alignObjectsY(e,r){r=r.filter(o=>!o.isPositionResolved());let i;r.forEach(o=>{let s=o.resolveClosestToStaffY(e);i=o.verticalPos===1?Math.max(s,i!=null?i:s):Math.min(s,i!=null?i:s)}),r.forEach(o=>this.setObjectY(o,i))}layoutLayoutGroup(e,r,i){let o=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());o.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof vi||a instanceof vn?a.layoutFitToMeasure(e):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(e,o):o.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=o.filter(l=>c.some(h=>h===l.musicObj));this.alignObjectsY(e,u)}else this.alignObjectsY(e,[s])})}},Tt=class extends la{constructor(e,r,i){super(e);this.row=e;this.staffConfig=r;this.id=i;d(this,"clefImageAsset");d(this,"clefLineDiatonicId");d(this,"topLineDiatonicId");d(this,"middleLineDiatonicId");d(this,"bottomLineDiatonicId");d(this,"minDiatonicId");d(this,"maxDiatonicId");d(this,"joinedGrandStaff");d(this,"topLineY",0);d(this,"bottomLineY",0);d(this,"mi");let o=(s,a)=>W.getNote(s).diatonicId-(a?7:0);if(r.clef==="G")this.clefImageAsset=0,this.clefLineDiatonicId=o("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2;else if(r.clef==="F")this.clefImageAsset=1,this.clefLineDiatonicId=o("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2;else throw new O(6,`Invalid staffConfig.clef ${r.clef}.`);this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(o(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(o(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new Go(this)}getMusicInterface(){return this.mi}get isOctaveDown(){return this.staffConfig.isOctaveDown===!0}get name(){var e;return(e=this.staffConfig.name)!=null?e:""}getTopLineY(){return this.topLineY}getMiddleLineY(){return(this.topLineY+this.bottomLineY)/2}getBottomLineY(){return this.bottomLineY}joinGrandStaff(e){e!==this&&(this.joinedGrandStaff=e)}getLineSpacing(){return(this.bottomLineY-this.topLineY)/4}getDiatonicSpacing(){return this.getLineSpacing()/2}containsDiatonicId(e){return W.validateDiatonicId(e),(this.minDiatonicId===void 0||e>=this.minDiatonicId)&&(this.maxDiatonicId===void 0||e<=this.maxDiatonicId)}getDiatonicIdY(e){if(this.containsDiatonicId(e))return this.bottomLineY+(this.bottomLineDiatonicId-e)*this.getDiatonicSpacing();if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff.getDiatonicIdY(e);throw new O(6,"Staff does not contain diatonicId "+e)}getActualStaff(e){if(this.containsDiatonicId(e))return this;if(this.joinedGrandStaff&&this.joinedGrandStaff.containsDiatonicId(e))return this.joinedGrandStaff;throw new O(6,"Staff does not contain diatonicId "+e)}getDiatonicIdAt(e){let r=Math.round(this.bottomLineDiatonicId-(e-this.bottomLineY)/this.getDiatonicSpacing());return this.containsDiatonicId(r)?r:void 0}isLine(e){return e%2===this.middleLineDiatonicId%2}isSpace(e){return e%2!==this.middleLineDiatonicId%2}containsVoiceId(e){return!this.staffConfig.voiceIds||this.staffConfig.voiceIds.includes(e)}isGrand(){return this.staffConfig.isGrand===!0}calcTop(){let e=this.topLineY;if(this.objects.forEach(r=>e=Math.min(e,r.getRect().top)),this.maxDiatonicId!==void 0){let r=this.getDiatonicIdY(this.maxDiatonicId),i=this.getDiatonicIdY(this.maxDiatonicId-1);e=Math.min(e,r-Math.abs(i-r)+1)}return e}calcBottom(){let e=this.bottomLineY;if(this.objects.forEach(r=>e=Math.max(e,r.getRect().bottom)),this.minDiatonicId!==void 0){let r=this.getDiatonicIdY(this.minDiatonicId),i=this.getDiatonicIdY(this.minDiatonicId+1);e=Math.max(e,r+Math.abs(i-r)-1)}return e}pick(e,r){return[this]}layoutHeight(e){let{unitSize:r}=e,i=r*at.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new B(0,0,this.topLineY,this.bottomLineY)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.topLineY+=r,this.bottomLineY+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}},Pe=class extends la{constructor(e,r,i){super(e);this.row=e;this.tabConfig=r;this.id=i;d(this,"top",0);d(this,"bottom",0);d(this,"tuningName");d(this,"tuningStrings");d(this,"mi");A.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(o=>W.getNote(o)).reverse()):typeof r.tuning=="string"?(this.tuningName=nc(r.tuning),this.tuningStrings=$o(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=$o(this.tuningName)),this.mi=new Vo(this)}getMusicInterface(){return this.mi}get name(){var e;return(e=this.tabConfig.name)!=null?e:""}getTuningName(){return this.tuningName}getTuningStrings(){return this.tuningStrings}getStringY(e){return this.top+(this.bottom-this.top)/6*(e+.5)}getTopStringY(){return this.getStringY(0)}getBottomStringY(){return this.getStringY(5)}getTopLineY(){return this.getTopStringY()}getBottomLineY(){return this.getBottomStringY()}getTop(){return this.top}getBottom(){return this.bottom}containsVoiceId(e){return!this.tabConfig.voiceIds||this.tabConfig.voiceIds.includes(e)}containsDiatonicId(e){return!0}calcTop(){return this.top}calcBottom(){return this.bottom}pick(e,r){return[this]}layoutHeight(e){let{unitSize:r}=e,i=r*at.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new B(0,0,this.top,this.bottom)}layoutWidth(e){this.rect.left=this.row.getRect().left,this.rect.right=this.row.getRect().right}offset(e,r){this.top+=r,this.bottom+=r,this.objects.forEach(i=>{i.offsetInPlace?i.offsetInPlace(0,r):i.offset&&i.offset(0,r)}),this.rect.offsetInPlace(e,r)}draw(e){}};var ha=class extends it{constructor(e,r,i){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=i;d(this,"nextRow");d(this,"minWidth",0);d(this,"notationLines");d(this,"staves");d(this,"tabs");d(this,"measures",[]);d(this,"needLayout",!0);d(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(o=>o instanceof Tt),this.tabs=this.notationLines.filter(o=>o instanceof Pe),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new qo(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,i)=>r.type==="staff"?new Tt(this,r,i):new Pe(this,r,i));for(let r=0;r<e.length-1;r++){let i=e[r],o=e[r+1];i instanceof Tt&&i.isGrand()&&i.staffConfig.clef==="G"&&o instanceof Tt&&o.isGrand()&&o.staffConfig.clef==="F"&&(i.joinGrandStaff(o),o.joinGrandStaff(i))}return e}getNotationLines(){return this.notationLines}getStaves(){return this.staves}getTabs(){return this.tabs}get hasStaff(){return this.staves.length>0}get hasTab(){return this.tabs.length>0}getTopStaff(){let e=this.staves[0];if(e)return e;throw new O(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new O(6,"Bottom staff is required!")}getStaff(e){W.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r];if(i instanceof Tt&&i.containsDiatonicId(e))return i}}resetLayoutGroups(e){this.notationLines.forEach(r=>r.resetLayoutGroups(e))}layoutLayoutGroups(e){this.notationLines.forEach(r=>r.layoutLayoutGroups(e))}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.measures.length;i++){let o=this.measures[i].pick(e,r);if(o.length>0)return[this,...o]}for(let i=0;i<this.notationLines.length;i++){let o=this.notationLines[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:e.left;return new B(i,(i+e.right)/2,e.right,e.top,e.centerY,e.bottom)}getDiatonicIdAt(e){for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r],o=i instanceof Tt?i.getDiatonicIdAt(e):void 0;if(o!==void 0)return o}}addMeasure(e){this.measures.push(e)}getMeasures(){return this.measures}isFirstRow(){return this===this.doc.getFirstRow()}isLastRow(){return this===this.doc.getLastRow()}getPrevRow(){return this.prevRow}getNextRow(){return this.nextRow}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}getMinWidth(){return this.minWidth}requestLayout(){this.needLayout||(this.needLayout=!0,this.doc.requestLayout())}layout(e){this.needLayout&&(this.requestRectUpdate(),this.notationLines.forEach(r=>{r.removeObjects(),r.layoutHeight(e)}),this.rect=new B(0,0,0,0),this.minWidth=0,this.measures.forEach(r=>{r.layout(e),this.minWidth+=r.getMinWidth(),this.minWidth+=r.getPostMeasureBreakWidth()}))}layoutWidth(e,r){if(!this.needLayout)return;let i=Math.max(r,this.minWidth);this.rect.centerX=this.rect.left+i/2,this.rect.right=this.rect.left+i,this.notationLines.forEach(u=>u.layoutWidth(e));let o=i,s=0;this.measures.forEach(u=>{o-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=o/s,c=0;this.measures.forEach(u=>{let l=u.getSolidAreaWidth()+u.getMinColumnsAreaWidth()*a;u.layoutWidth(e,l);let h=u.getRect();u.offset(c-h.left,-h.centerY),c+=h.width,c+=u.getPostMeasureBreakWidth()}),this.measures.forEach(u=>{u.layoutConnectives(e),u.layoutBeams(e)})}updateRect(){let e=this.measures.length>0?this.measures[0].getRect().left:0,r=this.measures.length>0?this.measures[this.measures.length-1].getRect().right:0,i=this.measures.length>0?Math.min(...this.measures.map(s=>s.getRect().top)):0,o=this.measures.length>0?Math.max(...this.measures.map(s=>s.getRect().bottom)):0;this.rect=new B(e,r,i,o)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutPositionLines(e){let{unitSize:r}=e;for(let i=1;i<this.notationLines.length;i++){let o=this.notationLines[i-1],s=this.notationLines[i];if(o instanceof Tt&&o.isGrand()&&o.staffConfig.clef==="G"&&s instanceof Tt&&s.isGrand()&&s.staffConfig.clef==="F"){let a=r*6;s.offset(0,o.getBottomLineY()-s.getTopLineY()+a)}else{let a=r*3;s.offset(0,o.calcBottom()-s.calcTop()+a)}}this.measures.forEach(i=>{i.requestRectUpdate(),i.getBarLineLeft().requestRectUpdate(),i.getBarLineRight().requestRectUpdate(),i.getColumns().forEach(o=>{o.requestRectUpdate(),se().forEach(s=>{var a;return(a=o.getVoiceSymbol(s))==null?void 0:a.requestRectUpdate()})})}),this.alignStemsToBeams(),this.requestRectUpdate()}layoutPadding(e){let r=e.unitSize/2;this.getRect(),this.rect.left-=r,this.rect.right+=r,this.rect.top-=r,this.rect.bottom+=r}layoutDone(){this.measures.forEach(e=>e.layoutDone()),this.needLayout=!1}offset(e,r){this.measures.forEach(i=>i.offset(e,r)),this.rect.offsetInPlace(e,r),this.notationLines.forEach(i=>i.offset(e,r))}draw(e){let r=e.getCanvasContext();if(r){if(e.drawDebugRect(this.getRect()),r.save(),r.rect(this.getRect().left,this.getRect().top,this.getRect().width,this.getRect().height),r.clip(),this.getFirstMeasure()&&(this.notationLines.length>1||this.notationLines[0]instanceof Pe)){let i=this.getFirstMeasure().getStaffLineLeft(),o=Math.min(...this.notationLines.map(a=>a.getTopLineY())),s=Math.max(...this.notationLines.map(a=>a.getBottomLineY()));e.drawLine(i,o,i,s)}this.measures.forEach(i=>i.draw(e)),this.notationLines.forEach(i=>i.draw(e)),r.restore()}}};var pa=class extends it{constructor(e,r,i,o){super(e);this.title=r;this.composer=i;this.arranger=o;d(this,"titleText");d(this,"composerText");d(this,"arrangerText");d(this,"mi");this.mi=new Wo(this),this.titleText=this.title?new lt(this,{text:this.title,scale:2},.5,0):void 0,this.composerText=this.composer?new lt(this,this.composer,1,0):void 0,this.arrangerText=this.arranger?new lt(this,"Arr.: "+this.arranger,1,0):void 0}getMusicInterface(){return this.mi}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.titleText){let i=this.titleText.pick(e,r);if(i)return[this,...i]}if(this.composerText){let i=this.composerText.pick(e,r);if(i)return[this,...i]}if(this.arrangerText){let i=this.arrangerText.pick(e,r);if(i)return[this,...i]}return[this]}layoutWidth(e,r){let i=0;this.rect=new B(0,r,0,0),this.titleText&&(this.titleText.layout(e),this.titleText.offset(r/2,i),i+=this.titleText.getRect().height,this.rect.expandInPlace(this.titleText.getRect())),this.composerText&&(this.composerText.layout(e),this.composerText.offset(r,i),i+=this.composerText.getRect().height,this.rect.expandInPlace(this.composerText.getRect())),this.arrangerText&&(this.arrangerText.layout(e),this.arrangerText.offset(r,i),i+=this.arrangerText.getRect().height,this.rect.expandInPlace(this.arrangerText.getRect()))}offset(e,r){this.titleText&&this.titleText.offset(e,r),this.composerText&&this.composerText.offset(e,r),this.arrangerText&&this.arrangerText.offset(e,r),this.rect.offsetInPlace(e,r)}draw(e){this.titleText&&this.titleText.draw(e),this.composerText&&this.composerText.draw(e),this.arrangerText&&this.arrangerText.draw(e)}};var da=class extends it{constructor(){super(void 0);d(this,"needLayout",!0);d(this,"renderer");d(this,"rows",[]);d(this,"measures",[]);d(this,"measuresPerRow",1/0);d(this,"curScoreConfig",[{type:"staff",clef:"G"}]);d(this,"header");d(this,"newRowRequested",!1);d(this,"allConnectiveProps",[]);d(this,"staffGroups",new Map);d(this,"mi");this.mi=new Nr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(A.Is.isEnumValue(e,yn))switch(e){default:case"treble":this.curScoreConfig=[{type:"staff",clef:"G"}];break;case"bass":this.curScoreConfig=[{type:"staff",clef:"F"}];break;case"grand":this.curScoreConfig=[{type:"staff",clef:"G",isGrand:!0},{type:"staff",clef:"F",isGrand:!0}];break;case"guitarTreble":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case"guitarTab":this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case"guitarCombined":this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else A.Is.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0;r<this.curScoreConfig.length-1;r++){let i=this.curScoreConfig[r],o=this.curScoreConfig[r+1];i.type==="staff"&&o.type==="staff"?i.clef==="G"&&i.isGrand&&o.clef==="F"&&o.isGrand?(i.minNote="C4",o.maxNote="B3",i.isOctaveDown=o.isOctaveDown=!1):i.isGrand=o.isGrand=!1:i.type==="staff"?i.isGrand=!1:o.type==="staff"&&(o.isGrand=!1)}this.requestNewRow()}setMeasuresPerRow(e){this.measuresPerRow=e}addConnectiveProps(e){this.allConnectiveProps.push(e)}setRenderer(e){if(this.renderer===e)return;let r=this.renderer;this.renderer=e,r&&r.setDocument(void 0),e&&e.setDocument(this.mi),this.requestFullLayout()}setHeader(e,r,i){this.header=new pa(this,e,r,i),this.requestLayout()}getTitle(){var e;return(e=this.header)==null?void 0:e.title}getComposer(){var e;return(e=this.header)==null?void 0:e.composer}getArranger(){var e;return(e=this.header)==null?void 0:e.arranger}hasSingleMeasure(){return this.measures.length===1}getFirstMeasure(){return this.measures.length>0?this.measures[0]:void 0}getLastMeasure(){return this.measures.length>0?this.measures[this.measures.length-1]:void 0}addNewRow(e){let r=new ha(this,e,this.curScoreConfig);return this.rows.push(r),r}getFirstRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[0]}getLastRow(){return this.rows.length===0?this.addNewRow(void 0):this.rows[this.rows.length-1]}getRows(){return this.rows}getMeasures(){return this.measures}requestNewRow(){this.newRowRequested=!0}addMeasure(){let e=this.rows[this.rows.length-1];(!e||this.newRowRequested&&e.getMeasures().length>0||e.getMeasures().length>=this.measuresPerRow)&&(e=this.addNewRow(e),this.newRowRequested=!1);let r=new Sn(e);return this.measures.push(r),e.addMeasure(r),this.requestLayout(),r}addStaffGroup(e,r,i){this.staffGroups.set(e,new ca(e,r,i))}getStaffGroup(e){return this.staffGroups.get(e)}getVoiceSymbols(e){let r=[];return this.forEachMeasure(i=>r=r.concat(i.getVoiceSymbols(e))),r}removeLayoutObjects(e){this.forEachMeasure(r=>r.removeLayoutObjects(e))}forEachMeasure(e){let r=this.getFirstMeasure();for(;r;)e(r),r=r.getNextMeasure()}resetMeasures(){this.measures.forEach(e=>e.resetPassCount())}updateCursorRect(e){this.renderer&&this.renderer.updateCursorRect(e)}requestLayout(){this.needLayout=!0}requestFullLayout(){this.rows.forEach(e=>e.requestLayout()),this.forEachMeasure(e=>{e.getColumns().forEach(r=>r.requestLayout()),e.requestLayout()}),this.requestLayout()}layout(){if(!this.needLayout)return;let{renderer:e}=this;if(!e)return;let{unitSize:r}=e;this.forEachMeasure(o=>o.createBeams()),this.forEachMeasure(o=>o.createExtensions()),this.allConnectiveProps.forEach(o=>o.removeConnectives()),this.allConnectiveProps.forEach(o=>o.createConnectives()),this.rows.forEach(o=>o.resetLayoutGroups(e)),this.rows.forEach(o=>o.layout(e));let i=Math.max(at.DocumentMinWidth*r,...this.rows.map(o=>1.4*o.getMinWidth()));this.rows.forEach(o=>o.layoutWidth(e,i)),this.rows.forEach(o=>o.layoutLayoutGroups(e)),this.rows.forEach(o=>o.layoutPositionLines(e)),this.rows.forEach(o=>o.layoutPadding(e)),this.rect=new B,this.header&&(this.header.layoutWidth(e,i),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(o=>{o.offset(-this.rect.left,this.rect.bottom+r*2-o.getRect().top),this.rect.expandInPlace(o.getRect())}),this.rows.forEach(o=>o.layoutDone()),this.needLayout=!1}drawContent(){let{renderer:e}=this;e&&(this.rows.forEach(r=>r.draw(e)),this.header&&this.header.draw(e))}pickStaffPosAt(e,r){if(this.rect.contains(e,r))for(let i=0;i<this.rows.length;i++){let o=this.rows[i];if(!o.hasStaff||!o.getRect().contains(e,r))continue;let s=o.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:o,diatonicId:s}}}pick(e,r){if(!this.rect.contains(e,r))return[];if(this.header){let i=this.header.pick(e,r);if(i.length>0)return[this,...i]}for(let i=0;i<this.rows.length;i++){let o=this.rows[i].pick(e,r);if(o.length>0)return[this,...o]}return[this]}};function G(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function Cu(n){if(typeof n!="string")return!1;{let t=W.parseNote(n);return t!==void 0&&t.octave!==void 0}}function wn(n){return A.Is.isNumber(n)&&se().indexOf(n)>=0}function Tm(n){return A.Is.isNumber(n)&&Hs().indexOf(n)>=0}function Nm(n){G(A.Is.isObject(n),"staffConfig",n),G(n.type==="staff","staffConfig.type",n.type),G(A.Is.isEnumValue(n.clef,Sr),"staffConfig.clef",n.clef),G(A.Is.isBooleanOrUndefined(n.isOctaveDown),"staffConfig.isOctaveDown",n.isOctaveDown),G(A.Is.isUndefined(n.minNote)||Cu(n.minNote),"staffConfig.minNote",n.minNote),G(A.Is.isUndefined(n.maxNote)||Cu(n.maxNote),"staffConfig.maxNote",n.maxNote),G(A.Is.isUndefined(n.voiceIds)||A.Is.isArray(n.voiceIds)&&n.voiceIds.every(t=>A.Is.isNumber(t)),"staffConfig.voiceIds",n.voiceIds),G(A.Is.isBooleanOrUndefined(n.isGrand),"staffConfig.isGrand",n.isGrand)}function Om(n){G(A.Is.isObject(n),"tabConfig",n),G(n.type==="tab","tabConfig.type",n.type),typeof n.tuning=="string"?G(Fn.includes(n.tuning),"tabConfig.tuning",n.tuning):A.Is.isArray(n.tuning)&&G(n.tuning.length===Hs().length&&n.tuning.every(t=>Cu(t)),"tabConfig.tuning",n.tuning),G(A.Is.isUndefined(n.voiceIds)||A.Is.isArray(n.voiceIds)&&n.voiceIds.every(t=>A.Is.isNumber(t)),"tabConfig.voiceIds",n.voiceIds)}function ma(n){G(A.Is.isObject(n),"noteOptions",n),G(A.Is.isBooleanOrUndefined(n.dotted)||A.Is.isIntegerGte(n.dotted,0),"noteOptions.dotted",n.dotted),G(A.Is.isEnumValueOrUndefined(n.stem,Xe),"noteOptions.stem",n.stem),G(A.Is.isStringOrUndefined(n.color),"noteOptions.color",n.color),G(A.Is.isBooleanOrUndefined(n.arpeggio)||A.Is.isEnumValue(n.arpeggio,Hr),"noteOptions.arpeggio",n.arpeggio),G(A.Is.isBooleanOrUndefined(n.staccato),"noteOptions.staccato",n.staccato),G(A.Is.isBooleanOrUndefined(n.diamond),"noteOptions.diamond",n.diamond),G(A.Is.isBooleanOrUndefined(n.triplet),"noteOptions.triplet",n.triplet),G(A.Is.isUndefined(n.string)||Tm(n.string)||A.Is.isNonEmptyArray(n.string)&&n.string.every(t=>Tm(t)),"noteOptions.string",n.string),G(A.Is.isUndefined(n.tieSpan),'NoteOptions.tieSpan was removed. Use addConnective("tie", tieSpan)',""),G(A.Is.isUndefined(n.slurSpan),'NoteOptions.slurSpan was removed. Use addConnective("slur", slurSpan)',"")}function Rm(n){G(A.Is.isObject(n),"restOptions",n),G(A.Is.isBooleanOrUndefined(n.dotted)||A.Is.isIntegerGte(n.dotted,0),"restOptions.dotted",n.dotted),G(A.Is.isStringOrUndefined(n.staffPos)||A.Is.isInteger(n.staffPos)||n.staffPos instanceof W,"restOptions.staffPos",n.staffPos),G(A.Is.isStringOrUndefined(n.color),"restOptions.color",n.color),G(A.Is.isBooleanOrUndefined(n.hide),"restOptions.hide",n.hide),G(A.Is.isBooleanOrUndefined(n.triplet),"restOptions.triplet",n.triplet)}function fa(n){G(A.Is.isStringOrUndefined(n)||A.Is.isIntegerGte(n,0)||A.Is.isNonEmptyArray(n)&&n.every(t=>A.Is.isString(t)||A.Is.isIntegerGte(t,0)),"staffTabOrGroup",n)}function Kr(n){try{return ii(n),!0}catch(t){return!1}}function Db(n){try{return ts(n),!0}catch(t){return!1}}var Or=class{constructor(){d(this,"doc");this.doc=new da}setScoreConfiguration(t){return A.Is.isEnumValue(t,yn)?this.doc.setScoreConfiguration(t):A.Is.isObject(t)&&t.type==="staff"?(Nm(t),this.doc.setScoreConfiguration(t)):A.Is.isObject(t)&&t.type==="tab"?(Om(t),this.doc.setScoreConfiguration(t)):A.Is.isNonEmptyArray(t)?(t.forEach(e=>{A.Is.isObject(e)&&e.type==="staff"?Nm(e):A.Is.isObject(e)&&e.type==="tab"?Om(e):G(!1,"config",t)}),this.doc.setScoreConfiguration(t)):G(!1,"config",t),this}getMeasure(){var t;return(t=this.doc.getLastMeasure())!=null?t:this.doc.addMeasure()}getDocument(){return this.doc.getMusicInterface()}setHeader(t,e,r){return G(A.Is.isStringOrUndefined(t),"title",t),G(A.Is.isStringOrUndefined(e),"composer",e),G(A.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return G(A.Is.isIntegerGte(t,1)||A.Is.isPosInfinity(t),"measuresPerRow",t),this.doc.setMeasuresPerRow(t),this}addMeasure(){return this.doc.addMeasure(),this}setKeySignature(...t){return G(t[0]instanceof jr||t[0]instanceof Le||A.Is.isNonEmptyString(t[0])&&(t.length===1||A.Is.isEnumValue(t[1],ei)),"keySignature",t),this.getMeasure().setKeySignature(...t),this}setTimeSignature(t){return G(t instanceof gr||A.Is.isNonEmptyString(t),"timeSignature",t),this.getMeasure().setTimeSignature(t),this}setTempo(t,e,r){return G(A.Is.isIntegerGte(t,1),"beatsPerMinute",t),e===void 0?G(A.Is.isUndefined(r),"dotted",r):(G(A.Is.isEnumValue(e,Zt)||Kr(e),"beatLength",e),G(A.Is.isBooleanOrUndefined(r)||A.Is.isIntegerGte(r,0),"dotted",r)),this.getMeasure().setTempo(t,e,r),this}addNote(t,e,r,i){return G(wn(t),"voiceId",t),G(e instanceof W||A.Is.isNonEmptyString(e),"note",e),G(A.Is.isEnumValue(r,Zt)||Kr(r),"noteLength",r),i!==void 0&&ma(i),this.getMeasure().addNoteGroup(t,[e],r,i),this}addChord(t,e,r,i){return G(wn(t),"voiceId",t),G(A.Is.isNonEmptyArray(e)&&e.every(o=>o instanceof W||A.Is.isNonEmptyString(o)),"notes",e),G(A.Is.isEnumValue(r,Zt)||Kr(r),"noteLength",r),i!==void 0&&ma(i),this.getMeasure().addNoteGroup(t,e,r,i),this}addRest(t,e,r){return G(wn(t),"voiceId",t),G(A.Is.isEnumValue(e,Zt)||Kr(e),"restLength",e),r!==void 0&&Rm(r),this.getMeasure().addRest(t,e,r),this}addTuplet(t,e,r){G(wn(t),"voiceId",t),G(A.Is.isFunction(r),"tupletBuilder",r),G(Db(e)&&A.Is.isBooleanOrUndefined(e.showRatio),"tupletRatio",e);let i=[],o={addNote:(s,a,c)=>{G(s instanceof W||A.Is.isNonEmptyString(s),"note",s),G(A.Is.isEnumValue(a,Zt)||Kr(a),"noteLength",a),c!==void 0&&(delete c.triplet,ma(c));let u=this.getMeasure().addNoteGroup(t,[s],a,c,e);return i.push(u),o},addChord:(s,a,c)=>{G(A.Is.isNonEmptyArray(s)&&s.every(l=>l instanceof W||A.Is.isNonEmptyString(l)),"notes",s),G(A.Is.isEnumValue(a,Zt)||Kr(a),"noteLength",a),c!==void 0&&(delete c.triplet,ma(c));let u=this.getMeasure().addNoteGroup(t,s,a,c,e);return i.push(u),o},addRest:(s,a)=>{G(A.Is.isEnumValue(s,Zt)||Kr(s),"restLength",s),a!==void 0&&(delete a.triplet,Rm(a));let c=this.getMeasure().addRest(t,s,a,e);return i.push(c),o}};return r(o),Xr.createTuplet(i,e),this}addFermataInternal(t,e){return fa(t),G(A.Is.isEnumValue(e,ho),"fermata",e),this.getMeasure().addFermata(t,e),this}addFermata(t="atNote"){return this.addFermataInternal(void 0,t)}addFermataTo(t,e="atNote"){return this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return fa(t),G(A.Is.isEnumValue(e,Ke),"navigation",e),e==="endRepeat"&&r.length>0?G(A.Is.isIntegerGte(r[0],1),"playCount",r[0]):e==="ending"&&r.length>0&&G(r.every(i=>A.Is.isIntegerGte(i,1)),"passages",r),this.getMeasure().addNavigation(t,e,...r),this}addNavigation(t,...e){return this.addNavigationInternal(void 0,t,...e)}addNavigationTo(t,e,...r){return this.addNavigationInternal(t,e,...r)}addAnnotationInternal(t,e,r){if(e!=null||(e=Sm(r)),e===void 0)throw new O(6,`Annotation text "${r}" is not known annotation.`);return fa(t),G(A.Is.isEnumValue(e,xn),"annotation",e),G(A.Is.isNonEmptyString(r),"text",r),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(...t){return t.length===1?this.addAnnotationInternal(void 0,void 0,t[0]):this.addAnnotationInternal(void 0,t[0],t[1])}addAnnotationTo(t,...e){return e.length===1?this.addAnnotationInternal(t,void 0,e[0]):this.addAnnotationInternal(t,e[0],e[1])}addLabelInternal(t,e,r){return fa(t),G(A.Is.isEnumValue(e,po),"label",e),G(A.Is.isNonEmptyString(r),"text",r),this.getMeasure().addLabel(t,e,r),this}addLabel(t,e){return this.addLabelInternal(void 0,t,e)}addLabelTo(t,e,r){return this.addLabelInternal(t,e,r)}addConnective(t,...e){if(G(A.Is.isEnumValue(t,Zr),"connective",t),t==="tie"){G(A.Is.isIntegerOrUndefined(e[0])||A.Is.isEnumValue(e[0],Qe),"tieSpan",e[0]),G(A.Is.isEnumValueOrUndefined(e[1],je),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t==="slur"){G(A.Is.isIntegerOrUndefined(e[0]),"slurSpan",e[0]),G(A.Is.isEnumValueOrUndefined(e[1],je),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t==="slide"){G(A.Is.isEnumValueOrUndefined(e[0],je),"noteAnchor",e[0]);let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t){G(A.Is.isFunctionOrUndefined(t),"addExtension() has new usage, for e.g. addExtension(ext => ext.measures(2)). Please refer to README or API Reference.",t);let e=0,r=!0,i={notes:(o,s)=>(G(A.Is.isEnumValue(o,Zt)||Kr(o),"noteLength",o),G(A.Is.isUndefined(s)||A.Is.isNumber(s)&&s>=0,"noteCount",s),e+=Qt.get(o).ticks*(s!=null?s:1),i),measures:o=>(G(A.Is.isNumber(o)&&o>=1,"measureCount",o),e+=this.getMeasure().getMeasureTicks()*o,i),infinity:()=>(e=1/0,i),hide:()=>(r=!1,i)};return t?t(i):e=1/0,this.getMeasure().addExtension(e,r),this}addStaffGroup(t,e,r="auto"){return G(A.Is.isNonEmptyString(t),"groupName",t),G(A.Is.isNonEmptyString(e)||A.Is.isIntegerGte(e,0)||A.Is.isNonEmptyArray(e)&&e.every(i=>A.Is.isNonEmptyString(i)||A.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",e),G(A.Is.isEnumValue(r,lo),"verticalPosition",r),this.doc.addStaffGroup(t,e,r),this}endSong(){return this.getMeasure().endSong(),this}endSection(){return this.getMeasure().endSection(),this}endRow(){var t;return(t=this.doc.getLastMeasure())==null||t.endRow(),this}completeRests(t){return G(A.Is.isUndefined(t)||wn(t)||A.Is.isArray(t)&&t.every(e=>wn(e)),"voiceId",t),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){G(A.Is.isNonEmptyString(e),"bottomNote",e),G(A.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),o=t.getScaleNotes(e,r);for(let s=0;s<o.length;s++){s%i.beatCount===0&&s>0&&this.addMeasure();let a=o[s];this.addNote(0,a,i.beatLength),this.addLabel("note",a.formatOmitOctave(1))}return this}};var Uo=class{constructor(t){this.type=t}},xi=class extends Uo{constructor(e,r,i,o){super(e);this.renderer=r;this.scoreRow=i;this.diatonicId=o}},bi=class extends Uo{constructor(e,r,i){super(e);this.renderer=r;this.objects=i;if(arguments.length===0)throw new O(6,"Empty array in score object event!")}get topObject(){return this.objects[this.objects.length-1]}findObject(e){return this.objects.find(r=>e(r))}};function ga(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function Mm(n){return A.Is.isNumber(n)&&se().indexOf(n)>=0}function _u(n){if(n instanceof Tt||n instanceof Pe)return n.getMusicInterface();throw new O(6,"Notation line not staff nor tab.")}var bt=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},ya=class ya extends bt{constructor(e){super(ya.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};d(ya,"Name","Accidental");var fo=ya,xa=class xa extends bt{constructor(e){super(xa.Name);this.obj=e}getMusicObject(){return this.obj}};d(xa,"Name","Connective");var Lo=xa,ba=class ba extends bt{constructor(e){super(ba.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return _u(this.obj.line)}};d(ba,"Name","Arpeggio");var xo=ba,Aa=class Aa extends bt{constructor(e){super(Aa.Name);this.obj=e}getMusicObject(){return this.obj}};d(Aa,"Name","BeamGroup");var _o=Aa,Ca=class Ca extends bt{constructor(e){super(Ca.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(Ca,"Name","StaffBeamGroup");var vo=Ca,_a=class _a extends bt{constructor(e){super(_a.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}getRows(){return this.obj.getRows().map(e=>e.getMusicInterface())}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}play(e){return ga(A.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),new Tn(this,e).play()}};d(_a,"Name","Document");var Nr=_a,va=class va extends bt{constructor(e){super(va.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return ga(A.Is.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};d(va,"Name","Ending");var ko=va,Ia=class Ia extends bt{constructor(e){super(Ia.Name);this.obj=e}getMusicObject(){return this.obj}};d(Ia,"Name","Fermata");var jo=Ia,Sa=class Sa extends bt{constructor(e){super(Sa.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};d(Sa,"Name","Header");var Wo=Sa,wa=class wa extends bt{constructor(e){super(wa.Name);this.obj=e}getMusicObject(){return this.obj}};d(wa,"Name","Image");var mo=wa,Ta=class Ta extends bt{constructor(e){super(Ta.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}getRow(){return this.obj.row.getMusicInterface()}};d(Ta,"Name","Measure");var Bo=Ta,Na=class Na extends bt{constructor(e){super(Na.Name);this.obj=e}getMusicObject(){return this.obj}};d(Na,"Name","BarLineRight");var Mo=Na,Oa=class Oa extends bt{constructor(e){super(Oa.Name);this.obj=e}getMusicObject(){return this.obj}};d(Oa,"Name","BarLineLeft");var Do=Oa,Ra=class Ra extends bt{constructor(e){super(Ra.Name);this.obj=e}getMusicObject(){return this.obj}getBarLine(){let e=this.obj.barLine;if(e instanceof Qr||e instanceof Tr)return e.getMusicInterface();throw new O(6,"Bar line not let nor right.")}getNotationLine(){return _u(this.obj.line)}};d(Ra,"Name","StaffTabBarLine");var Eo=Ra,Ma=class Ma extends bt{constructor(e){super(Ma.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Ma,"Name","NoteGroup");var Io=Ma,Da=class Da extends bt{constructor(e){super(Da.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(Da,"Name","StaffNoteGroup");var So=Da,Ea=class Ea extends bt{constructor(e){super(Ea.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}getRhythmColumn(){return this.getNoteGroup().getRhythmColumn()}getMeasure(){return this.getNoteGroup().getMeasure()}getTab(){return this.obj.tab.getMusicInterface()}};d(Ea,"Name","TabNoteGroup");var wo=Ea,ka=class ka extends bt{constructor(e){super(ka.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}getRhythmColumn(){return this.obj.col.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(ka,"Name","Rest");var bo=ka,ja=class ja extends bt{constructor(e){super(ja.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}getRhythmColumn(){return this.getRest().getRhythmColumn()}getMeasure(){return this.getRest().getMeasure()}getStaff(){return this.obj.staff.getMusicInterface()}};d(ja,"Name","StaffRest");var Ao=ja,Pa=class Pa extends bt{constructor(e){super(Pa.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return ga(Mm(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getVoiceSymbol(e){var r;return ga(Mm(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}getMeasure(){return this.obj.measure.getMusicInterface()}};d(Pa,"Name","RhythmColumn");var To=Pa,La=class La extends bt{constructor(e){super(La.Name);this.obj=e}getMusicObject(){return this.obj}getDocument(){return this.obj.doc.getMusicInterface()}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}getNotationLines(){return this.obj.getNotationLines().map(e=>_u(e))}};d(La,"Name","ScoreRow");var qo=La,Fa=class Fa extends bt{constructor(e){super(Fa.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Fa,"Name","Staff");var Go=Fa,Ba=class Ba extends bt{constructor(e){super(Ba.Name);this.obj=e}getMusicObject(){return this.obj}getId(){return this.obj.id}getName(){return this.obj.name.length>0?this.obj.name:void 0}getRow(){return this.obj.row.getMusicInterface()}};d(Ba,"Name","Tab");var Vo=Ba,Ga=class Ga extends bt{constructor(e){super(Ga.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};d(Ga,"Name","Signature");var yo=Ga,Va=class Va extends bt{constructor(e){super(Va.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(Va,"Name","SpecialText");var No=Va,qa=class qa extends bt{constructor(e){super(qa.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};d(qa,"Name","Text");var go=qa,Wa=class Wa extends bt{constructor(e){super(Wa.Name);this.obj=e}getMusicObject(){return this.obj}};d(Wa,"Name","ExtensionLine");var Po=Wa;function $e(n,t,e){if(!n)throw new O(6,`Invalid arg: ${t} = ${e}`)}function zo(n,t){if(n==null)throw new TypeError(t);return n}var Yo=class Yo{constructor(t,e){d(this,"player");$e(t instanceof Nr,"doc",t),$e(A.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new oa,this.player.setDocument(t.getMusicObject()),this.player.setCursorPositionChangeListener(r=>t.getMusicObject().updateCursorRect(r)),e&&this.player.setPlayStateChnageListener(e)}static stopAll(){this.currentlyPlaying.forEach(t=>t.stop()),du()}play(){return Yo.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),Yo.currentlyPlaying.delete(this),this}};d(Yo,"currentlyPlaying",new Set);var Tn=Yo,vu=class{constructor(){d(this,"renderer");this.renderer=new Ks(this)}setDocument(t){return $e(A.Is.isUndefined(t)||t instanceof Nr,"doc",t),this.renderer.setDocument(t),this}setCanvas(t){return t=zo(A.Dom.getCanvas(t),typeof t=="string"?"Cannot set renderer canvas because invalid canvas id: "+t:"Cannot set renderer canvas because given canvas is undefined."),this.renderer.setCanvas(t),this}setScoreEventListener(t){$e(A.Is.isFunctionOrUndefined(t),"scoreEventListener",t),this.renderer.setScoreEventListener(t)}hilightObject(t){this.renderer.hilightObject(t==null?void 0:t.getMusicObject())}hilightStaffPos(t){this.renderer.hilightStaffPos(t?{scoreRow:t.scoreRow.getMusicObject(),diatonicId:t.diatonicId}:void 0)}draw(){try{this.renderer.draw()}catch(t){console.log("Draw failed in music renderer."),console.log(t)}}},pe=class pe{constructor(){d(this,"playButton");d(this,"stopButton");d(this,"playStopButton");d(this,"pauseButton");d(this,"onPlay");d(this,"onStop");d(this,"onPlayStop");d(this,"onPause");d(this,"playLabel","Play");d(this,"stopLabel","Stop");d(this,"pauseLabel","Pause");d(this,"playState",2);d(this,"player");this.onPlay=()=>{var t;return(t=this.player)==null?void 0:t.play()},this.onStop=()=>{var t;return(t=this.player)==null?void 0:t.stop()},this.onPlayStop=()=>{var t,e;this.playState===0?(t=this.player)==null||t.stop():(e=this.player)==null||e.play()},this.onPause=()=>{var t;return(t=this.player)==null?void 0:t.pause()},this.updateButtons()}setDocument(t){return $e(A.Is.isUndefined(t)||t instanceof Nr,"doc",t),this.onStop(),t?this.player=new Tn(t,e=>{this.playState=e,this.updateButtons()}):this.player=void 0,this.updateButtons(),this}detachDocument(){this.setDocument(void 0)}updateButtons(){this.playButton&&(this.playButton.disabled=this.player?this.playState===0:!0,this.playButton.innerText=this.playLabel),this.stopButton&&(this.stopButton.disabled=this.player?this.playState===2:!0,this.stopButton.innerText=this.stopLabel),this.playStopButton&&(this.playStopButton.disabled=!this.player,this.playStopButton.innerText=this.playState===0?this.stopLabel:this.playLabel),this.pauseButton&&(this.pauseButton.disabled=this.player?this.playState!==0:!0,this.pauseButton.innerText=this.pauseLabel)}setPlayButton(t,e){return $e(A.Is.isStringOrUndefined(e),"btnLabel",e),pe.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=zo(A.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",pe.removeOnClickListeners(this.playButton,"all"),pe.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return $e(A.Is.isStringOrUndefined(e),"btnLabel",e),pe.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=zo(A.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",pe.removeOnClickListeners(this.stopButton,"all"),pe.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return $e(A.Is.isStringOrUndefined(e),"playLabel",e),$e(A.Is.isStringOrUndefined(r),"stopLabel",r),pe.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=zo(A.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",pe.removeOnClickListeners(this.playStopButton,"all"),pe.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return $e(A.Is.isStringOrUndefined(e),"btnLabel",e),pe.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=zo(A.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",pe.removeOnClickListeners(this.pauseButton,"all"),pe.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(t){let r=this.savedOnClickListeners.get(t)||[],i=[];r.forEach(o=>{e===o||e==="all"?t.removeEventListener("click",o):i.push(o)}),this.savedOnClickListeners.set(t,i)}}static addOnClickListener(t,e){$e(A.Is.isFunction(e),"onClick",e),t.addEventListener("click",e);let r=this.savedOnClickListeners.get(t)||[];this.savedOnClickListeners.set(t,[...r,e])}};d(pe,"savedOnClickListeners",new Map);var Iu=pe;ti();var wu={};Ni(wu,{createAndanteByDiabelli:()=>jb,createFrereJacques:()=>Eb,createGreensleeves:()=>kb});function Eb(){return new Or().setHeader("Frere Jacques").setScoreConfiguration([{type:"staff",clef:"G",voiceIds:[0]},{type:"staff",clef:"F",voiceIds:[1]}]).setMeasuresPerRow(2).addMeasure().setKeySignature("D Major").setTimeSignature("4/4").addNote(0,"D4","4n",{stem:"up"}).addNote(0,"E4","4n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addRest(1,"1n",{staffPos:"F3"}).addMeasure().addNote(0,"D4","4n").addNote(0,"E4","4n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addRest(1,"1n",{staffPos:"F3"}).addMeasure().addNavigation("startRepeat").addNote(0,"F#4","4n").addNote(0,"G4","4n").addNote(0,"A4","2n").addNote(1,"D3","4n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F#3","4n").addNote(1,"D3","4n").addMeasure().addNote(0,"F#4","4n").addNote(0,"G4","4n").addNote(0,"A4","2n").addNote(1,"D3","4n").addNote(1,"E3","4n").addNote(1,"F#3","4n").addNote(1,"D3","4n").addMeasure().addNote(0,"A4","8n").addNote(0,"B4","8n").addNote(0,"A4","8n").addNote(0,"G4","8n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addNote(1,"F#3","4n").addNote(1,"G3","4n").addNote(1,"A3","2n").addMeasure().addNote(0,"A4","8n").addNote(0,"B4","8n").addNote(0,"A4","8n").addNote(0,"G4","8n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addNote(1,"F#3","4n").addNote(1,"G3","4n").addNote(1,"A3","2n").addMeasure().addNote(0,"D4","4n").addChord(0,["C#4","A4"],"4n").addNote(0,"D4","4n").addRest(0,"4n").addNote(1,"A3","8n").addNote(1,"B3","8n").addNote(1,"A3","8n").addNote(1,"G3","8n").addNote(1,"F#3","4n").addNote(1,"D3","4n").addMeasure().addNote(0,"D4","4n").addChord(0,["C#4","A4"],"4n").addNote(0,"D4","4n").addRest(0,"4n").addNote(1,"A3","8n").addNote(1,"B3","8n").addNote(1,"A3","8n").addNote(1,"G3","8n").addNote(1,"F#3","4n").addNote(1,"D3","4n").addMeasure().setMeasuresPerRow(4).addNavigation("ending",1).addNote(0,"D4","4n").addNote(0,"E4","4n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addNote(1,"D3","4n").addChord(1,["C#3","A3"],"4n").addNote(1,"D3","4n").addRest(1,"4n").addMeasure().addNavigation("endRepeat").addNote(0,"D4","4n").addNote(0,"E4","4n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addNote(1,"D3","4n").addChord(1,["C#3","A3"],"4n").addNote(1,"D3","4n").addRest(1,"4n").addMeasure().addNavigation("ending",2).addNote(0,"F#4","4n").addNote(0,"D4","4n").addNote(0,"F#4","4n").addNote(0,"D4","4n").addNote(1,"A3","4n").addNote(1,"F#3","4n").addNote(1,"A3","4n").addNote(1,"F#3","4n").addMeasure().addNote(0,"A3","4n").addNote(0,"C#4","8n").addNote(0,"C#4","8n").addNote(0,"D4","2n").addNote(1,"D3","4n").addNote(1,"E3","4n").addNote(1,"F#3","2n").getDocument()}function kb(){return new Or().setScoreConfiguration("guitarTreble").setHeader("Greensleeves").addMeasure().setKeySignature("C","Major").setTimeSignature("6/8").setTempo(140).addNote(0,"A3","8n").addMeasure().addNavigation("startRepeat").addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4n").addNote(0,"A3","8n").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").endRow().addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"D4","8n").addNote(0,"E4","8.").addNote(0,"F4","16n").addNote(0,"E4","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"A2","8n").addNote(1,"E3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").endRow().addMeasure().addChord(0,["C3","E3","G3","C4","G4"],"4.",{arpeggio:"up",stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addRest(1,"4.",{hide:!0}).addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","4n",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","8n").addNote(0,"A3","8.").addLabel("chord","F").addNote(0,"G#3","16n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"F2","8n").addNote(1,"A2","4n").addMeasure().addNote(0,"B3","4n",{stem:"up"}).addLabel("chord","E").addNote(0,"G#3","8n").addNote(0,"E3","4.").addNote(1,"E2","8n",{stem:"down"}).addNote(1,"B2","4n").addNote(1,"E2","8n").addNote(1,"B2","8n").addNote(1,"E3","8n").endRow().addMeasure().addNote(0,"G4","4.",{stem:"up"}).addLabel("chord","C").addNote(0,"G4","8.").addNote(0,"F#4","16n").addNote(0,"E4","8n").addNote(1,"C3","8n",{stem:"down"}).addNote(1,"G3","8n").addNote(1,"C4","8n").addNote(1,"C3","8n").addNote(1,"G3","4n").addMeasure().addNote(0,"D4","4n",{stem:"up"}).addLabel("chord","G").addNote(0,"B3","8n").addNote(0,"G3","8.").addLabel("chord","Em").addNote(0,"A3","16n").addNote(0,"B3","8n").addNote(1,"G2","8n",{stem:"down"}).addNote(1,"D3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNote(0,"C4","8.",{stem:"up"}).addLabel("chord","Am").addNote(0,"B3","16n").addNote(0,"A3","8n").addNote(0,"G#3","8.").addLabel("chord","E").addNote(0,"F#3","16n").addNote(0,"G#3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","4n").addNote(1,"E2","8n").addNote(1,"B2","4n").addMeasure().addNavigation("ending",1).addNavigation("endRepeat").addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4n").addNote(0,"A3","8n").addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").addMeasure().addNavigation("ending",2).addNote(0,"A3","4.",{stem:"up"}).addLabel("chord","Am").addNote(0,"A3","4.").addFermata().addNote(1,"A2","8n",{stem:"down"}).addNote(1,"E3","8n").addNote(1,"C4","8n").addNote(1,"A2","4.").getDocument()}function jb(){return new Or().setScoreConfiguration("guitarTreble").setHeader("Andante","A. Diabelli").addMeasure().setKeySignature("D","Major").setTimeSignature("3/4").setTempo(80).addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n",{stem:"up"}).addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.",{stem:"down"}).addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").endRow().addMeasure().addNote(0,"D4","8n",{string:3}).addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","8n").addNote(0,"A4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","p").addNote(0,"F#4","8n").addNote(0,"G4","8n").addConnective("slur",2,"below").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(0,"D4","8n").addNote(1,"D3","2.").addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"G4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","f").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).addNavigation("endRepeat").addMeasure().addRest(0,"8n",{staffPos:"D4"}).addAnnotation("dynamics","f").addNote(0,"D4","8n").addNote(0,"E4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"B3","8n").addNote(1,"E2","2.").endRow().addMeasure().addNote(0,"C#4","8n").addConnective("slur",2,"below").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","8n").addNote(0,"E4","4n").addNote(1,"A2","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","p").addNote(0,"E3","8n").addNote(0,"D#3","8n").addConnective("slur",2,"below").addNote(0,"E3","8n").addNote(0,"F#3","8n").addNote(0,"G#3","8n").addNote(1,"E2","2.").addMeasure().addNote(0,"A3","8n").addConnective("slur",2,"below").addNote(0,"G#3","8n").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","4n").addNote(1,"A2","2.").endRow().addMeasure().addRest(0,"8n",{staffPos:"G4"}).addAnnotation("dynamics","f").addNote(0,"G4","8n").addNote(0,"A4","8n").addConnective("slur",2,"below").addNote(0,"G4","8n").addNote(0,"F#4","8n").addNote(0,"E4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","8n").addNote(0,"C#4","8n").addNote(0,"D4","8n").addNote(0,"E4","8n").addNote(0,"F#4","4n").addNote(1,"D3","2.").addMeasure().addRest(0,"8n",{staffPos:"B3"}).addAnnotation("dynamics","ff").addNote(0,"A3","8n").addNote(0,"G#3","8n").addConnective("slur",2,"below").addNote(0,"A3","8n").addNote(0,"B3","8n").addNote(0,"C#4","8n").addNote(1,"A2","2.").addMeasure().addNote(0,"D4","4n").addRest(1,"4n",{staffPos:"D3"}).addNote(0,"D3","4n").addNote(1,"D3","4n").addRest(1,"4n",{staffPos:"B3"}).endSong().getDocument()}return Bm(Pb);})();
|
|
211
211
|
/*! Bundled license information:
|
|
212
212
|
|
|
213
213
|
tone/build/esm/core/Tone.js:
|