@tspro/web-music-score 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/audio/index.js +1 -1
- package/dist/audio/index.mjs +2 -2
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +2 -2
- package/dist/{chunk-PU4J7K4Z.mjs → chunk-LCTM7BID.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +3 -3
- package/dist/iife/index.global.js +11 -11
- package/dist/{interface-Fn8ufBQx.d.ts → interface-BlNl69uT.d.ts} +42 -2
- package/dist/{interface-Bz_525zj.d.mts → interface-Bn5HFt_U.d.mts} +42 -2
- package/dist/pieces/index.d.mts +1 -1
- package/dist/pieces/index.d.ts +1 -1
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +1 -1
- package/dist/react-ui/index.d.ts +1 -1
- package/dist/react-ui/index.js +1 -1
- package/dist/react-ui/index.mjs +2 -2
- package/dist/score/index.d.mts +2 -2
- package/dist/score/index.d.ts +2 -2
- package/dist/score/index.js +222 -80
- package/dist/score/index.mjs +223 -81
- package/dist/theory/index.js +1 -1
- package/dist/theory/index.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* WebMusicScore v3.
|
|
2
|
-
"use strict";var WebMusicScore=(()=>{var Fn=Object.defineProperty,Cm=Object.defineProperties,_m=Object.getOwnPropertyDescriptor,vm=Object.getOwnPropertyDescriptors,Im=Object.getOwnPropertyNames,Pn=Object.getOwnPropertySymbols;var Da=Object.prototype.hasOwnProperty,gu=Object.prototype.propertyIsEnumerable;var xu=Math.pow,Ma=(o,t,e)=>t in o?Fn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,R=(o,t)=>{for(var e in t||(t={}))Da.call(t,e)&&Ma(o,e,t[e]);if(Pn)for(var e of Pn(t))gu.call(t,e)&&Ma(o,e,t[e]);return o},Z=(o,t)=>Cm(o,vm(t));var Nr=(o,t)=>{var e={};for(var r in o)Da.call(o,r)&&t.indexOf(r)<0&&(e[r]=o[r]);if(o!=null&&Pn)for(var r of Pn(o))t.indexOf(r)<0&&gu.call(o,r)&&(e[r]=o[r]);return e};var Ci=(o,t)=>{for(var e in t)Fn(o,e,{get:t[e],enumerable:!0})},Sm=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Im(t))!Da.call(o,i)&&i!==e&&Fn(o,i,{get:()=>t[i],enumerable:!(r=_m(t,i))||r.enumerable});return o};var wm=o=>Sm(Fn({},"__esModule",{value:!0}),o);var m=(o,t,e)=>Ma(o,typeof t!="symbol"?t+"":t,e);var X=(o,t,e)=>new Promise((r,i)=>{var n=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(n,s);a((e=e.apply(o,t)).next())});var ab={};Ci(ab,{Audio:()=>tn,Core:()=>Ba,Pieces:()=>fu,Score:()=>mu,Theory:()=>Ja});var tn={};Ci(tn,{getCurrentInstrument:()=>Ey,getInstrumentList:()=>Ry,playNote:()=>Ls,registerInstrument:()=>My,setInstrument:()=>hm,stop:()=>eu});var Ja={};Ci(Ja,{AccidentalType:()=>Va,Chord:()=>Wa,DefaultGuitarNoteLabel:()=>qf,DefaultHandedness:()=>mg,DefaultPitchNotation:()=>Gf,DefaultTuningName:()=>gg,GuitarNoteLabel:()=>Gn,GuitarNoteLabelList:()=>Wf,Handedness:()=>za,Interval:()=>No,KeySignature:()=>Pe,MaxNoteLength:()=>Yu,MinNoteLength:()=>Ii,Mode:()=>Ga,Note:()=>V,NoteLength:()=>Gt,PitchNotation:()=>Rr,PitchNotationList:()=>Bf,RhythmProps:()=>$t,Scale:()=>Dr,ScaleFactory:()=>Yt,ScaleType:()=>Je,SymbolSet:()=>Or,TimeSignature:()=>dr,TuningNameList:()=>Oo,alterTempoSpeed:()=>Xa,getDefaultKeySignature:()=>Vn,getDefaultScale:()=>sg,getDefaultTempo:()=>zn,getDefaultTimeSignature:()=>Un,getPitchNotationName:()=>Vf,getScale:()=>Mr,getScaleFactory:()=>Wu,getScaleFactoryList:()=>og,getTempoString:()=>Za,getTuningStrings:()=>Wn,validateGuitarNoteLabel:()=>Uf,validateHandedness:()=>fg,validateIntervalQuality:()=>$f,validateNoteLength:()=>Hu,validatePitchNotation:()=>ku,validateScaleType:()=>qa,validateTuningName:()=>Ya});var bu=Object.defineProperty,Tm=(o,t,e)=>t in o?bu(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,hr=(o,t)=>{for(var e in t)bu(o,e,{get:t[e],enumerable:!0})},Xe=(o,t,e)=>Tm(o,typeof t!="symbol"?t+"":t,e),_={};hr(_,{Arr:()=>Au,Dom:()=>Iu,Enum:()=>Su,Is:()=>wu,Map:()=>Nu,Math:()=>Cu,Obj:()=>Ou,Str:()=>Ru});var Au={};hr(Au,{arrayContains:()=>Um,chunckArray:()=>zm,duplicate:()=>Fm,fillArray:()=>Vm,getRangeArray:()=>Wm,getSequenceArray:()=>qm,isArray:()=>La,mapRangeArray:()=>vu,mapSequenceArray:()=>_u,removeDuplicates:()=>Bm,removeDuplicatesCmp:()=>Gm,toArray:()=>Pm});var Cu={};hr(Cu,{calcNormal:()=>Lm,clamp:()=>km,interpolateCoord:()=>Mm,interpolateY:()=>Dm,isInteger:()=>we,linearToDecibels:()=>Nm,mod:()=>Om,romanize:()=>Rm,sum:()=>jm,toOrdinalNumber:()=>Em});function we(o){return typeof o=="number"&&isFinite(o)&&o===Math.trunc(o)}function Nm(o){if(isFinite(o))return o<=0?-1/0:20*Math.log10(o);throw new Error("linearToDecibel: Invalid linearVolume = "+o)}function Om(o,t){return(o%t+t)%t}function Rm(o){if(!we(o)||o<0)throw new Error("romanize: Invalid n = "+o);for(var t=String(+o).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 Em(o){if(!we(o))throw new Error("toOrdinalNumber: Invalid n = "+o);let t=o.toString(),e=Number(t.charAt(t.length-1));return o===1||o>=20&&e===1?t+"st":o===2||o>=20&&e===2?t+"nd":o===3||o>=20&&e===3?t+"rd":t+"th"}function Mm(o,t,e,r,i){return{x:o+(e-o)*i,y:t+(r-t)*i}}function Dm(o,t,e,r,i){let n=(i-o)/(e-o);return t+(r-t)*n}function km(o,t,e){return Math.min(Math.max(o,t),e)}function Lm(o,t,e,r){let i=e-o,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 jm(o){return o.reduce((t,e)=>e+t,0)}function La(o){return!!o&&Object.prototype.toString.call(o)==="[object Array]"}function Pm(o){return La(o)?o:[o]}function Fm(o){return o===void 0?o:o.slice()}function Bm(o){return o.filter((t,e,r)=>r.indexOf(t)===e)}function Gm(o,t){return o.filter((e,r,i)=>r===i.findIndex(n=>t(e,n)))}function Vm(o,t){if(!we(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(o)}function _u(o,t){if(!we(o)||o<0)throw new Error("mapSequenceArray: Invalid len = "+o);let e=new Array(o);for(let r=0;r<o;r++)e[r]=t(r);return e}function qm(o){return _u(o,t=>t)}function vu(o,t,e){if(!we(o))throw new Error("mapRangeArray: Invalid start = "+t);if(!we(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-o)+1,i=new Array(r);for(let n=0,s=o,a=Math.sign(t-o);n<r;s+=a,n++)i[n]=e(s);return i}function Wm(o,t){return vu(o,t,e=>e)}function Um(o,t){return o.indexOf(t)>=0}function zm(o,t){if(!we(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<o.length;r+=t)e.push(o.slice(r,r+t));return e}var Iu={};hr(Iu,{addClass:()=>Ym,appendTo:()=>tf,getButton:()=>nf,getCanvas:()=>sf,getCanvasTextWidth:()=>lf,getDimension:()=>cf,getHeight:()=>Km,getOffset:()=>Zm,getPadding:()=>af,getWidth:()=>Xm,hasClass:()=>ja,removeClass:()=>Hm,removeFromParent:()=>ef,setHeight:()=>$m,setOffset:()=>Qm,setRect:()=>of,setVisibility:()=>rf,setWidth:()=>Jm,styleLayoutChanged:()=>uf});var Su={};hr(Su,{getEnumValues:()=>Bn});function Bn(o){return Object.keys(o).filter(t=>Number.isNaN(Number(t))).map(t=>o[t])}var ka;(o=>{let t=Error;function e(y){t=y!=null?y:Error}o.setErrorClass=e;function r(y,N){throw new t("Assertion Error: "+y+(N?" "+N:""))}function i(y){return typeof y=="number"&&isFinite(y)&&y===Math.trunc(y)}function n(y){return typeof y=="number"}function s(y,N){y||r(N!=null?N:"Assertion failed!")}o.assert=s;function a(y,N,D="value"){if(!Bn(N).some(M=>M===y))throw new TypeError(`Invalid ${D} enum value: ${y}`)}o.assertEnum=a;function c(y){r(y!=null?y:"Interrupted!")}o.interrupt=c;function u(y,N){return i(y)||r(`Expected ${y} to be integer.`,N),y}o.int=u;function l(y,N,D){return y!==N&&r(`Expected ${y} to equal ${N}.`,D),y}o.eq=l;function h(y,N,D){return i(y)&&n(N)&&y===N||r(`Expected ${y} to be integer equal to ${N}.`,D),y}o.int_eq=h;function p(y,N,D){return i(y)&&n(N)&&y<N||r(`Expected ${y} to be integer less than ${N}.`,D),y}o.int_lt=p;function d(y,N,D){return i(y)&&n(N)&&y<=N||r(`Expected ${y} to be integer less than or equal to ${N}.`,D),y}o.int_lte=d;function f(y,N,D){return i(y)&&n(N)&&y>N||r(`Expected ${y} to be integer greater than ${N}.`,D),y}o.int_gt=f;function g(y,N,D){return i(y)&&n(N)&&y>=N||r(`Expected ${y} to be integer greater than or equal to ${N}.`,D),y}o.int_gte=g;function x(y,N,D,M){return i(y)&&n(N)&&n(D)&&y>=N&&y<=D||r(`Expected ${y} to be integer between ${N} and ${D}.`,M),y}o.int_between=x;function b(y,N){return i(y)&&y%2===1||r(`Expected ${y} to be odd number.`,N),y}o.odd=b;function I(y,N){return i(y)&&y%2===0||r(`Expected ${y} to be even number.`,N),y}o.even=I;function S(y,N,D){if(!N.some(M=>M===y)){let M=N.map(O=>String(O)).join(", ");r(`Expected ${y} to be in group [${M}].`,D)}return y}o.in_group=S;function T(y,N){return n(y)&&isFinite(y)||r(`Expected ${y} to be finite number.`,N),y}o.finite=T;function v(y,N,D){return i(N)&&N>=0&&N<y.length||r(`Expected ${N} to be array index in bounds [0..${y.length-1}].`,D),N}o.array_id=v;function C(y,N,D){return y[v(y,N,D)]}o.array_elem=C;function A(y,N){if(y===void 0)r("Required value is undefined.",N);else return y}o.require=A})(ka||(ka={}));var wo;(o=>{function t(){let p=document.createElement("div");p.style.width="1in",document.body.appendChild(p);let d=p.offsetWidth;return p.remove(),d||96}function e(){try{let p=document.createElement("div");p.style.visibility="hidden",p.style.width="100px",document.body.appendChild(p);let d=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),d-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 d=p.offsetHeight;return document.body.removeChild(p),d}function i(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var p=" -webkit- -moz- -o- -ms- ".split(" "),d=function(g){return window.matchMedia(g).matches},f=["(",p.join("touch-enabled),("),"heartz",")"].join("");return d(f)}function n(){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\\.]+)(.*)$/;o.DPI=t(),o.PxPerMm=o.DPI/25.4,o.ScrollbarWidth=e(),o.FontSize=r(),o.IsTouchDevice=i(),o.IsMobileDevice=n(),o.HostAddress=s();function u(p){return p/o.PxPerMm}o.pxToMm=u;function l(p){return p*o.PxPerMm}o.mmToPx=l;function h(p){if(typeof p=="number")return p;let d=NaN,f,g=p.toString().match(c);if(g&&g[1]){d=parseFloat(g[1]);let x=g[2]?g[2].toLowerCase():"undefined";f=a.test(x)?x:void 0,f||console.log("Unknown unit '"+x+"' => using 'px'.")}else d=parseFloat(p);switch(ka.finite(d,"value in function toPx"),f){case"mm":return l(d);case"cm":return l(d)*10;case"in":case"inch":return l(d)*25.4;case"em":return o.FontSize*d;default:case"px":return d}}o.toPx=h})(wo||(wo={}));function vt(o){return o===void 0?void 0:wo.toPx(o)}function ja(o,t){return t.length===0?!1:o.classList?o.classList.contains(t):!!o.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function Ym(o,t){t.length!==0&&(o.classList?o.classList.add(t):ja(o,t)||(o.className+=" "+t))}function Hm(o,t){if(t.length!==0){if(o.classList)o.classList.remove(t);else if(ja(o,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");o.className=o.className.replace(e," ")}}}function Qm(o,t,e,r="px"){o.style.left=t+r,o.style.top=e+r}function Zm(o){let t=o.getBoundingClientRect(),e=document.documentElement;return{top:t.top+window.pageYOffset-e.clientTop,left:t.left+window.pageXOffset-e.clientLeft}}function Xm(o){if(o instanceof Window)return o.innerWidth;{let t=parseFloat(getComputedStyle(o,null).width.replace("px",""));return isNaN(t)?0:t}}function Jm(o,t){o.style.width=t+"px"}function Km(o){if(o instanceof Window)return o.innerHeight;{let t=parseFloat(getComputedStyle(o,null).height.replace("px",""));return isNaN(t)?0:t}}function $m(o,t){o.style.height=t+"px"}function tf(o,t){t.appendChild(o)}function ef(o){o.remove()}function rf(o,t){o.style.display=t?"block":"none"}function of(o,t,e,r,i,n="px"){o.style.left=t+n,o.style.top=e+n,o.style.width=r+n,o.style.height=i+n}function nf(o){let t=typeof o=="string"?document.getElementById(o):o;return t instanceof HTMLButtonElement?t:void 0}function sf(o){let t=typeof o=="string"?document.getElementById(o):o;return t instanceof HTMLCanvasElement?t:void 0}function af(o){var s;if(!o)return{top:0,right:0,bottom:0,left:0};let t=vt(o.paddingTop),e=vt(o.paddingRight),r=vt(o.paddingBottom),i=vt(o.paddingLeft),n=((s=o.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(n.length){case 0:break;case 1:t!=null||(t=vt(n[0])),e!=null||(e=vt(n[0])),r!=null||(r=vt(n[0])),i!=null||(i=vt(n[0]));break;case 2:t!=null||(t=vt(n[0])),e!=null||(e=vt(n[1])),r!=null||(r=vt(n[0])),i!=null||(i=vt(n[1]));break;case 3:t!=null||(t=vt(n[0])),e!=null||(e=vt(n[1])),r!=null||(r=vt(n[2])),i!=null||(i=vt(n[1]));break;case 4:default:t!=null||(t=vt(n[0])),e!=null||(e=vt(n[1])),r!=null||(r=vt(n[2])),i!=null||(i=vt(n[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(o){let t=vt(o==null?void 0:o.left),e=vt(o==null?void 0:o.right),r=vt(o==null?void 0:o.top),i=vt(o==null?void 0:o.bottom),n=vt(o==null?void 0:o.width),s=vt(o==null?void 0:o.height);return n===void 0&&t!==void 0&&e!==void 0&&(n=e-t),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:t,top:r,width:n,height:s}}function uf(o,t){return!o&&!t?!1:!o||!t?!0:o.left!==t.left||o.top!==t.top||o.right!==t.right||o.bottom!==t.bottom||o.width!==t.width||o.height!==t.height}var Io;function lf(o,t){Io!=null||(Io=document.createElement("canvas"));let e=Io.getContext("2d");return e?(e.font=t,e.measureText(o).width):0}var wu={};hr(wu,{isArray:()=>Pa,isArrayOrUndefined:()=>mf,isBoolean:()=>xf,isBooleanOrUndefined:()=>yf,isEnumValue:()=>vf,isEnumValueOrUndefined:()=>If,isFunction:()=>bf,isFunctionOrUndefined:()=>Af,isInteger:()=>_i,isIntegerEq:()=>Sf,isIntegerGt:()=>wf,isIntegerGte:()=>Tf,isIntegerLt:()=>Nf,isIntegerLte:()=>Of,isNull:()=>pf,isNumber:()=>Cf,isNumberOrUndefined:()=>_f,isObject:()=>Tu,isObjectOrUndefined:()=>df,isString:()=>ff,isStringOrUndefined:()=>gf,isUndefined:()=>hf});function hf(o){return o===void 0}function pf(o){return o===null}function Tu(o){return typeof o=="object"&&o!==null&&!Pa(o)}function df(o){return o===void 0||Tu(o)}function Pa(o){return!!o&&Object.prototype.toString.call(o)==="[object Array]"}function mf(o){return o===void 0||Pa(o)}function ff(o){return typeof o=="string"}function gf(o){return o===void 0||typeof o=="string"}function xf(o){return typeof o=="boolean"}function yf(o){return o===void 0||typeof o=="boolean"}function bf(o){return typeof o=="function"}function Af(o){return o===void 0||typeof o=="function"}function Cf(o){return typeof o=="number"}function _f(o){return o===void 0||typeof o=="number"}function vf(o,t,e="value"){return Bn(t).some(r=>r===o)}function If(o,t,e="value"){return o===void 0||Bn(t).some(r=>r===o)}function _i(o){return typeof o=="number"&&isFinite(o)&&o===Math.trunc(o)}function Sf(o,t){return _i(o)&&o===t}function wf(o,t){return _i(o)&&o>t}function Tf(o,t){return _i(o)&&o>=t}function Nf(o,t){return _i(o)&&o<t}function Of(o,t){return _i(o)&&o<=t}var Nu={};hr(Nu,{getMapKeys:()=>Rf});function Rf(o){let t=[];return o.forEach((e,r)=>t.push(r)),t}var Ou={};hr(Ou,{isObject:()=>Ef});function Ef(o){return typeof o=="object"&&o!==null&&!La(o)}var Ru={};hr(Ru,{chunkString:()=>kf,insertAt:()=>Lf,makeSentenceFromPascal:()=>Pf,removeAt:()=>jf,repeatString:()=>Df,replaceAt:()=>Fa,toCharArray:()=>Mf});function Mf(o){return o.split("")}function Df(o,t){if(!we(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(o)}function kf(o,t){if(!we(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<o.length;r+=t)e.push(o.slice(r,r+t));return e}function Fa(o,t,e,r){if(!we(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!we(t)||t<0||t+e>o.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+o.length);return o.substring(0,t)+r+o.substring(t+e)}function Lf(o,t,e){return Fa(o,t,0,e)}function jf(o,t,e){return Fa(o,t,e,"")}function Pf(o){if(o==="")return"";let t=o.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},i=n=>n.toUpperCase()!==n.toLowerCase()&&n===n.toUpperCase();for(let n=1;n<o.length;n++){let s=o.charAt(n);i(s)&&r(),t+=s.toLowerCase()}return r(),e}var yu;(o=>{let t="ConsentCookie",e;(T=>{T.Accept="accept",T.Decline="decline"})(e||(e={}));let r,i,n=p(t);r=n==="accept"||n==="decline"?n:void 0;function s(T){i=new Date,i.setDate(i.getDate()+T)}o.setExpireDays=s;function a(){return r===void 0}o.isConsentPending=a;function c(){r="accept",h(t,r)}o.accept=c;function u(){r="decline",h(t,r)}o.decline=u;function l(){return document.cookie.split(";").map(v=>v.trim())}function h(T,v){let C=T+"="+v.toString()+";sameSite=Lax;";return i&&(C+="expires="+i.toUTCString()+";"),document.cookie=C,v}function p(T,v){let C=l().find(A=>A.startsWith(T+"="));return C===void 0?v:C.substring(T.length+1)}function d(T){document.cookie=T+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(T,v){return r==="accept"&&h(T,v),v}o.save=f;function g(T,v){return r==="accept"&&p(T,v)||v}o.read=g;function x(T,v){if(r==="accept"){let C=p(T);return C===void 0?v:parseInt(C)}else return v}o.readInt=x;function b(T,v){if(r==="accept"){let C=p(T);return C===void 0?v:/true|1/i.test(C)}else return v}o.readBool=b;function I(T){(r==="accept"||T===t)&&d(T)}o.erase=I;function S(){document.cookie.split(";").forEach(T=>I(T.trim().split("=")[0]))}o.eraseAll=S})(yu||(yu={}));var Eu=class So{constructor(t,e){Xe(this,"x"),Xe(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 So(this.x+t.x,this.y+t.y)}sub(t){return new So(this.x-t.x,this.y-t.y)}mul(t){return new So(this.x*t,this.y*t)}div(t){return new So(this.x/t,this.y/t)}},Mu=class{constructor(o,t=1/0){Xe(this,"cache"),Xe(this,"next"),Xe(this,"prev"),Xe(this,"head"),Xe(this,"tail"),Xe(this,"capacity"),Xe(this,"size"),Xe(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=o,this.size=0,this.maxKeyLength=t}get(o){if(!(o.length>this.maxKeyLength)&&this.cache[o]!==void 0)return this.touch(o),this.cache[o]}set(o,t){if(!(o.length>this.maxKeyLength)){if(this.cache[o]!==void 0){this.cache[o]=t,this.touch(o);return}this.size>=this.capacity&&this.evict(),this.cache[o]=t,this.addToTail(o),this.size++}}touch(o){this.tail!==o&&(this.removeKey(o),this.addToTail(o))}evict(){if(this.head!==null){let o=this.head;this.removeKey(o),delete this.cache[o],this.size--}}removeKey(o){let t=this.prev[o],e=this.next[o];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[o],delete this.next[o]}addToTail(o){this.tail!==null?(this.next[this.tail]=o,this.prev[o]=this.tail):this.head=o,this.tail=o}};var Ba={};Ci(Ba,{MusicError:()=>E,MusicErrorType:()=>gt,init:()=>Hr});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 Ff(o){return o===void 0?"":`[${gt[o]}] `}var E=class extends Error{constructor(...e){let[r,i]=e.length===1?[0,e[0]]:e;super(Ff(r)+i);m(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var Du=!1;function Hr(){Du||(Du=!0,console.log("%cWebMusicScore v3.1.1 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Or=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(Or||{}),Rr=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(Rr||{}),Bf=_.Enum.getEnumValues(Rr),Gf=0;function ku(o){if(_.Is.isEnumValue(o,Rr))return o;throw new E(1,`Invalid pitchNotation: ${o}`)}function Vf(o){return Rr[ku(o)]}var Gn=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Gn||{}),qf="Default",Wf=_.Enum.getEnumValues(Gn);function Uf(o){if(_.Is.isEnumValue(o,Gn))return o;throw new E(5,`Invalid guitarNoteLabel: ${o}`)}function Lu(o,t){return(o%t+t)%t}var ju=12,Pu=7,zf=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),Yf=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Fu=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),To=["C","D","E","F","G","A","B"],Bu=[0,2,4,5,7,9,11],Gu=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,st=class st{constructor(t,e,r){m(this,"diatonicClass");m(this,"accidental");m(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 E(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return st.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return st.getChromaticIdInOctave(Bu[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return st.getChromaticClass(Bu[this.diatonicClass]+this.accidental)}get noteLetter(){return To[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:i}=this,n=st.getAccidentalSymbol(this.accidental,e);return t===1?i>=3?r.toLowerCase()+n+"\u2032".repeat(i-3):r.toUpperCase()+n+"\u0375".repeat(2-i):r+n+i}formatOmitOctave(t){let e=To[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 E(2,`Invalid noteName: ${t}`);if(r.octave===void 0)throw new E(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),n=st.parseNote(i);if(!n)throw new E(2,`Invalid noteName: ${i}`);if(n.octave===void 0)throw new E(2,"Octave is required for note.");e=new st(n.noteLetter,n.accidental,n.octave),this.chromaticNoteCache.set(t,e)}return e}static getDiatonicClass(t){if(typeof t=="number")return Lu(t,7);if(typeof t=="string"&&t.length>0)return To.indexOf(st.validateNoteLetter(t[0]));throw new E(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-Pu)/7)}static getDiatonicIdInOctave(t,e){return st.getDiatonicClass(t)+e*7+Pu}static getChromaticClass(t){return Lu(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-ju)/12)}static getChromaticIdInOctave(t,e){return st.getChromaticClass(t)+e*12+ju}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 Gu.test(t)}static parseNote(t){var c;let e=Gu.exec(t);if(!e)return;let r=st.validateNoteLetter(e[1]),i=e[2],n=st.validateAccidental((c=Fu.get(i))!=null?c:0),s=e[3],a=s?st.validateOctave(+s):void 0;return{noteLetter:r,accidental:n,octave:a}}static getScientificNoteName(t,e){let r=st.parseNote(t);if(!r)throw new E(2,`Invalid noteName: ${t}`);let{noteLetter:i,accidental:n,octave:s}=r;return i+st.getAccidentalSymbol(n,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?Yf.get(t):zf.get(t)}static getAccidental(t){let e=Fu.get(t);if(e===void 0)throw new E(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return To[st.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let i=st.getDiatonicClass(t),n=st.getDiatonicClass(e),s=r?i<=n?1:0:i<n?1:0;return st.getDiatonicIdInOctave(i,st.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(_.Is.isInteger(t))return t;throw new E(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(_.Is.isInteger(t)&&t>=0&&t<7)return t;throw new E(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(_.Is.isInteger(t))return t;throw new E(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(_.Is.isInteger(t)&&t>=0&&t<12)return t;throw new E(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(To.some(e=>e===t))return t;throw new E(2,`Invalid note: ${t}`)}static validateOctave(t){if(_.Is.isInteger(t))return t;throw new E(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(_.Is.isInteger(t)&&t>=-2&&t<=2)return t;throw new E(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}};m(st,"noteByNameCache",new Map),m(st,"chromaticNoteCache",new Map);var V=st;function Hf(o,t){let e=V.getChromaticClass(o)-new V(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return V.validateAccidental(e)}var Qf=/^(bb?|b?|#?|x?)([0-9]*)$/;function Zf(o){var i,n;let t=Qf.exec(""+o);if(!t)throw new E(4,`Invalid degree: ${o}`);let e=(n=V.getAccidental((i=t[1])!=null?i:""))!=null?n:0,r=+t[2];if(!_.Is.isInteger(e)||e<-2||e>2||!_.Is.isInteger(r)||r<1)throw new E(4,`Invalid degree: ${o}`);return{deg:r,acc:e}}var Ga=(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))(Ga||{}),Va=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(Va||{});function Vn(){return Mr("C","Major")}var Er=class Er{constructor(t,e){this.tonic=t;this.mode=e;m(this,"naturalScaleNotes");m(this,"accidentalByDiatonicClass");m(this,"orderedAccidentedNotes");if(!_.Is.isEnumValue(e,Ga))throw new E(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=V.getDiatonicClass(t[0]),n=V.getNote(t+"0").chromaticId;for(let c=0;c<7;i++,n+=r[c],c++){let u=new V(V.getDiatonicClass(i),Hf(n,i));if(Math.abs(u.accidental)>=2)throw new E(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=Er.OrderOfSharps.indexOf(c.noteLetter),h=Er.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new E(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=Er.OrderOfFlats.indexOf(c.noteLetter),h=Er.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new E(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new E(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[V.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=Zf(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let i=this.naturalScaleNotes[(e-1)%7];return new V(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}};m(Er,"OrderOfSharps","FCGDAEB"),m(Er,"OrderOfFlats","BEADGCF");var Pe=Er;var Xf=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),Jf={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 Kf(o,t){for(;o<1;)o+=7,t+=12;for(;o>8;)o-=7,t-=12;let e=Jf[o];if(e)return e[t]}function $f(o){if(o==="Perfect"||o==="Major"||o==="minor"||o==="Augmented"||o==="diminished"||o==="Doubly Augmented"||o==="doubly diminished")return o;throw new E(1,`Invalid interval quality: ${o}`)}function tg(o){if(_.Is.isIntegerGte(o,1))return _.Math.toOrdinalNumber(o);throw new E(1,`Invalid interval quantity: ${o}`)}var qn=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},No=class o{constructor(t,e){this.note1=t;this.note2=e;m(this,"direction");m(this,"semitones");m(this,"quantity");m(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=Kf(this.quantity,this.semitones);if(r)this.quality=r;else throw new qn("Unknown interval quality")}static get(t,e){try{return new o(t,e)}catch(r){if(r instanceof qn)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=Xf.get(this.quality))!=null?i:"?",r=this.quantity;return t+e+r}};function eg(o){let t=V.getDiatonicClass("CCDDEFFGGAAB"[V.getChromaticClass(o)]),e=V.getOctaveFromChromaticId(o);return V.getDiatonicIdInOctave(t,e)}var rg=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],Je=(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))(Je||{});function ig(o){switch(o){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 E(3,`Invalid scaleType: ${o}`)}}var Dr=class extends Pe{constructor(e,r){super(e,ig(r));this.tonic=e;this.scaleType=r;m(this,"scaleDegrees");m(this,"scaleNotes");m(this,"chromaticClassDegree");m(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 n=this.scaleNotes.findIndex(s=>s.chromaticClass===i);return n>=0?this.scaleDegrees[n]: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 V.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!_.Is.isIntegerGte(r,1))throw new E(3,`Invalid numOctaves: ${r}`);let i=[];for(let s=1;s<=r;s++)i=[...i,...this.scaleNotes];i.push(this.scaleNotes[0]);let n=V.getNote(e).diatonicId;return i.map(s=>(n=V.findNextDiatonicIdAbove(s.diatonicId,n,!1),new V(n,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(_.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 V(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new E(3,"Note is below rootNote.");let i=No.get(r,e);if(i===void 0)throw new E(3,"Interval is undefined.");return i}getPreferredChromaticNote(e){V.validateChromaticId(e);let r=this.preferredChromaticNoteCache.get(e);if(r)return r;let i=V.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new V(h.diatonicClass,h.accidental,i+1):h.noteLetter==="B"&&h.accidental>0?new V(h.diatonicClass,h.accidental,i-1):new V(h.diatonicClass,h.accidental,i)).find(h=>V.getChromaticClass(e)===h.chromaticClass),r)return this.preferredChromaticNoteCache.set(e,r),r;let s=eg(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 d=Math.max(0,a);d<=c;d++)if(r=new V(d,p),e===r.chromaticId)return this.preferredChromaticNoteCache.set(e,r),r}return r=V.getChromaticNote(e),this.preferredChromaticNoteCache.set(e,r),r}},Yt=class{constructor(t){this.type=t;m(this,"tonicList",[]);m(this,"scaleMap",new Map);let e=[],r=[],i=[];if(rg.forEach(s=>{try{let a=new Dr(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 E(3,"Expected natural scale.");let n=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(n).map(s=>s.tonic),"- Sharps -",...r.sort(n).map(s=>s.tonic),"- Flats -",...i.sort(n).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 E(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},Vu=[new Yt("Major"),new Yt("Natural Minor"),new Yt("Harmonic Minor"),"- Modes -",new Yt("Ionian"),new Yt("Dorian"),new Yt("Phrygian"),new Yt("Lydian"),new Yt("Mixolydian"),new Yt("Aeolian"),new Yt("Locrian"),"- Pentatonic -",new Yt("Major Pentatonic"),new Yt("Minor Pentatonic"),"- Blues -",new Yt("Major Hexatonic Blues"),new Yt("Minor Hexatonic Blues"),new Yt("Heptatonic Blues")];function og(){return Vu}var qu=new Map;Vu.forEach(o=>{o instanceof Yt&&qu.set(o.getType(),o)});function Wu(o){let t=qu.get(o);if(t)return t;throw new E(3,`Invalid scaleType: ${o}`)}function qa(o){if(_.Is.isEnumValue(o,Je))return o;throw new E(3,`Invalid scaleType: ${o}`)}function Mr(o,t){return Wu(t).getScale(o)}var ng=Mr("C","Major");function sg(){return ng}var pr=(o,t)=>o.chromaticClass===t.chromaticClass,ag=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(o=>V.getNote(o+"0")),Uu=new Map;function cg(o){let t=o.chromaticClass,e=Uu.get(t);if(!e){if(e=ag.find(r=>pr(r,o)),!e)throw new E(1,`Invalid chord root note: ${o.formatOmitOctave(1)}`);Uu.set(t,e)}return e}function ug(o,t){let e=o.formatOmitOctave(0);return Mr(e,"Major").getNoteByDegree(t)}function lg(o){return _.Arr.removeDuplicatesCmp(o,pr)}var hg=[{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 pg(o,t){return o.degrees.every(e=>e!==t)?!0:o.degrees.length>=4&&t===5||o.degrees.length>=6&&t===9||o.degrees.length>=7&&t===11}var vi=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},Wa=class o{constructor(t,e,r,i){this.chordInfo=t;this.rootNote=r;m(this,"name");m(this,"notes");m(this,"omitNotes");m(this,"slashBassNote");this.name=t.name;let n=e.slice();!n.some(a=>pr(a,i))&&n.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]=ug(this.rootNote,c),l=n.findIndex(h=>pr(h,u));if(l>=0)this.omitNotes[a]=!1,n.splice(l,1);else if(pg(t,c))this.omitNotes[a]=!0;else throw new vi("Missing chord note!");pr(i,u)&&(i=u)}if(n.length>0)if(n.every(a=>pr(a,i)))this.slashBassNote=i;else throw new vi("Got some extra notes that are not bass note!");else this.slashBassNote=pr(i,this.rootNote)?void 0:i;if(t.name==="5"&&this.slashBassNote)throw new vi("Power chord no bass note allowed!")}static getChords(t){let e=[],r=V.sort(t),i=r[0],n=lg(r);for(let s=0;s<n.length;s++){let a=cg(n[s]);hg.forEach(c=>{try{let u=new o(c,n,a,i),l=e.findIndex(h=>h.replaceWith(u));l>=0?e[l]=u:e.push(u)}catch(u){if(!(u instanceof vi))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!pr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!pr(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,n)=>this.getDegreeStr(n)+"("+(i?"-":this.getNoteStr(n))+")").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 V.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var Ua={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 za=(e=>(e[e.RightHanded=0]="RightHanded",e[e.LeftHanded=1]="LeftHanded",e))(za||{}),mg=0;function fg(o){if(_.Is.isEnumValue(o,za))return o;throw new E(1,`Invalid handedness: ${o}`)}var Oo=Ua.list.map(o=>o.name),gg=Oo[0];function Ya(o){if(Oo.indexOf(o)<0)throw new E(1,`Invalid tuning name: ${o}`);return o}var zu=new Mu(100);function Wn(o){let t=zu.get(o);if(!t){let e=Ua.list.find(r=>r.name===o);if(!e)throw new E(1,`Invalid tuningName: ${o}`);if(t=e.strings.slice().reverse().map(r=>V.getNote(r)),!_.Is.isIntegerEq(t.length,6))throw new E(0,`Tuning has ${t.length} strings.`);zu.set(o,t)}return t}var Gt=(a=>(a[a.Whole=192]="Whole",a[a.Half=96]="Half",a[a.Quarter=48]="Quarter",a[a.Eighth=24]="Eighth",a[a.Sixteenth=12]="Sixteenth",a[a.ThirtySecond=6]="ThirtySecond",a[a.SixtyFourth=3]="SixtyFourth",a))(Gt||{}),Yu=192,Ii=3,xg=new Map([[192,0],[96,0],[48,0],[24,1],[12,2],[6,3],[3,4]]),yg=new Map([[192,"\u{1D15D}"],[96,"\u{1D15E}"],[48,"\u{1D15F}"],[24,"\u{1D160}"],[12,"\u{1D161}"],[6,"\u{1D162}"],[3,"\u{1D163}"]]);function Hu(o){if(_.Is.isEnumValue(o,Gt))return o;throw new E(1,`Invalid noteLength: ${o}`)}var $t=class o{constructor(t,e,r){m(this,"noteLength");m(this,"dotted");m(this,"triplet");m(this,"ticks");m(this,"flagCount");var i;if(this.noteLength=Hu(t),this.dotted=e===!0,this.triplet=r===!0,this.ticks=this.noteLength,this.flagCount=(i=xg.get(this.noteLength))!=null?i:0,this.dotted&&this.triplet)throw new E(2,"Note cannot be both dotted and triplet!");if(this.dotted&&this.noteLength===Ii)throw new E(2,"Shortest note cannot be dotted!");this.dotted&&(this.ticks+=this.noteLength/2),this.triplet&&(this.ticks=this.ticks*2/3)}static createFromNoteSize(t){return new o(Yu/t)}canDot(){return!this.dotted&&this.noteLength!==Ii}hasStem(){return this.noteLength<192}toString(){return yg.get(this.noteLength)+(this.dotted?".":"")}};var dr=class{constructor(...t){m(this,"beatCount");m(this,"beatSize");m(this,"beatLength");m(this,"measureTicks");m(this,"beamGroupCount");m(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 E(5,`Invalid args: ${t}`);if(_.Is.isIntegerGte(this.beatCount,1)){if(!_.Is.isIntegerGte(this.beatSize,1))throw new E(5,`Invalid beatSize: ${this.beatSize}`)}else throw new E(5,`Invalid beatCount: ${this.beatCount}`);let e=$t.createFromNoteSize(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,!_.Is.isIntegerGte(this.beamGroupLength,1))throw new E(5,`Invalid beamGroupLength: ${this.beamGroupLength}`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},Ha;function Un(){return Ha||(Ha=new dr(4,4)),Ha}var Qa;function zn(){return Qa||(Qa={beatsPerMinute:120,options:{beatLength:48,dotted:!1}}),Qa}function Za(o){return new $t(o.options.beatLength,o.options.dotted).toString()+"="+o.beatsPerMinute}function Xa(o,t){return{beatsPerMinute:o.beatsPerMinute*t,options:{beatLength:o.options.beatLength,dotted:o.options.dotted}}}Hr();var Ro="15.1.22";var Ka=(o,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:o});var $a=(o,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:o});var Si=(o,t)=>({startTime:t,type:"setValue",value:o});var Eo=(o,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:o});var Yn=(o,t,{startTime:e,target:r,timeConstant:i})=>r+(t-r)*Math.exp((e-o)/i);var mr=o=>o.type==="exponentialRampToValue";var Qr=o=>o.type==="linearRampToValue";var Fe=o=>mr(o)||Qr(o);var wi=o=>o.type==="setValue";var Te=o=>o.type==="setValueCurve";var Ti=(o,t,e,r)=>{let i=o[t];return i===void 0?r:Fe(i)||wi(i)?i.value:Te(i)?i.values[i.values.length-1]:Yn(e,Ti(o,t-1,i.startTime,r),i)};var tc=(o,t,e,r,i)=>e===void 0?[r.insertTime,i]:Fe(e)?[e.endTime,e.value]:wi(e)?[e.startTime,e.value]:Te(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,Ti(o,t-1,e.startTime,i)];var Mo=o=>o.type==="cancelAndHold";var Do=o=>o.type==="cancelScheduledValues";var fr=o=>Mo(o)||Do(o)?o.cancelTime:mr(o)||Qr(o)?o.endTime:o.startTime;var ec=(o,t,e,{endTime:r,value:i})=>e===i?i:0<e&&0<i||e<0&&i<0?e*xu(i/e,(o-t)/(r-t)):0;var rc=(o,t,e,{endTime:r,value:i})=>e+(o-t)/(r-t)*(i-e);var Qu=(o,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?o[e]:(1-(t-e))*o[e]+(1-(r-t))*o[r]};var Zu=(o,{duration:t,startTime:e,values:r})=>{let i=(o-e)/t*(r.length-1);return Qu(r,i)};var ko=o=>o.type==="setTarget";var Lo=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=fr(t);if(Mo(t)||Do(t)){let r=this._automationEvents.findIndex(n=>Do(t)&&Te(n)?n.startTime+n.duration>=e:fr(n)>=e),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),Mo(t)){let n=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Fe(i)){if(n!==void 0&&ko(n))throw new Error("The internal list is malformed.");let s=n===void 0?i.insertTime:Te(n)?n.startTime+n.duration:fr(n),a=n===void 0?this._defaultValue:Te(n)?n.values[n.values.length-1]:n.value,c=mr(i)?ec(e,s,a,i):rc(e,s,a,i),u=mr(i)?Ka(c,e,this._currenTime):$a(c,e,this._currenTime);this._automationEvents.push(u)}if(n!==void 0&&ko(n)&&this._automationEvents.push(Si(this.getValue(e),e)),n!==void 0&&Te(n)&&n.startTime+n.duration>e){let s=e-n.startTime,a=(n.values.length-1)/n.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,l=n.values.slice(0,c);if(u<1)for(let h=1;h<c;h+=1){let p=u*h%1;l[h]=n.values[h-1]*(1-p)+n.values[h]*p}this._automationEvents[this._automationEvents.length-1]=Eo(l,n.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>fr(s)>e),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&Te(i)&&fr(i)+i.duration>e)return!1;let n=mr(t)?Ka(t.value,t.endTime,this._currenTime):Qr(t)?$a(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(n);else{if(Te(t)&&e+t.duration>fr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,n)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>fr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),i=r[0];ko(i)&&r.unshift(Si(Ti(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=>fr(s)>t),r=this._automationEvents[e],i=(e===-1?this._automationEvents.length:e)-1,n=this._automationEvents[i];if(n!==void 0&&ko(n)&&(r===void 0||!Fe(r)||r.insertTime>t))return Yn(t,Ti(this._automationEvents,i-1,n.startTime,this._defaultValue),n);if(n!==void 0&&wi(n)&&(r===void 0||!Fe(r)))return n.value;if(n!==void 0&&Te(n)&&(r===void 0||!Fe(r)||n.startTime+n.duration>t))return t<n.startTime+n.duration?Zu(t,n):n.values[n.values.length-1];if(n!==void 0&&Fe(n)&&(r===void 0||!Fe(r)))return n.value;if(r!==void 0&&mr(r)){let[s,a]=tc(this._automationEvents,i,n,r,this._defaultValue);return ec(t,s,a,r)}if(r!==void 0&&Qr(r)){let[s,a]=tc(this._automationEvents,i,n,r,this._defaultValue);return rc(t,s,a,r)}return this._defaultValue}};var ic=o=>({cancelTime:o,type:"cancelAndHold"});var oc=o=>({cancelTime:o,type:"cancelScheduledValues"});var nc=(o,t)=>({endTime:t,type:"exponentialRampToValue",value:o});var sc=(o,t)=>({endTime:t,type:"linearRampToValue",value:o});var ac=(o,t,e)=>({startTime:t,target:o,timeConstant:e,type:"setTarget"});var Xu=()=>new DOMException("","AbortError");var Ju=o=>(t,e,[r,i,n],s)=>{o(t[i],[e,r,n],a=>a[0]===e&&a[1]===r,s)};var Ku=o=>(t,e,r)=>{let i=[];for(let n=0;n<r.numberOfInputs;n+=1)i.push(new Set);o.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var $u=o=>(t,e)=>{o.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var Ke=new WeakSet,Hn=new WeakMap,Ni=new WeakMap,Qn=new WeakMap,jo=new WeakMap,Oi=new WeakMap,Zn=new WeakMap,Po=new WeakMap,Fo=new WeakMap,Bo=new WeakMap;var tl={construct(){return tl}},el=o=>{try{let t=new Proxy(o,tl);new t}catch(t){return!1}return!0};var rl=/^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]*);?/,cc=(o,t)=>{let e=[],r=o.replace(/^[\s]+/,""),i=r.match(rl);for(;i!==null;){let n=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(n,new URL(n,t).toString());e.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(rl)}return[e.join(";"),r]};var il=o=>{if(o!==void 0&&!Array.isArray(o))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},ol=o=>{if(!el(o))throw new TypeError("The given value for processorCtor should be a constructor.");if(o.prototype===null||typeof o.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},nl=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>{let d=0;return(f,g,x={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 v=I.get(g);if(v!==void 0)return v}let S=n(f),T=S.audioWorklet===void 0?i(g).then(([v,C])=>{let[A,y]=cc(v,C),N=`${A};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${y}
|
|
3
|
-
})})(window,'_AWGS')`;return e(N)}).then(()=>{let v=p._AWGS.pop();if(v===void 0)throw new SyntaxError;r(S.currentTime,S.sampleRate,()=>v(class{},void 0,(C,A)=>{if(C.trim()==="")throw t();let y=Fo.get(S);if(y!==void 0){if(y.has(C))throw t();
|
|
4
|
-
})(${A?"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{${A?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${A?"":"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${y}',class extends AudioWorkletProcessor{process(){return !1}})`,P=new Blob([k],{type:"application/javascript; charset=utf-8"}),L=URL.createObjectURL(P);return S.audioWorklet.addModule(L,x).then(()=>{if(a(S))return S;let q=s(S);return q.audioWorklet.addModule(L,x).then(()=>q)}).then(q=>{if(c===null)throw new SyntaxError;try{new c(q,`__sac${y}`)}catch(H){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(L))});return I===void 0?u.set(f,new Map([[g,T]])):I.set(g,T),T.then(()=>{let v=l.get(f);v===void 0?l.set(f,new Set([g])):v.add(g)}).finally(()=>{let v=u.get(f);v!==void 0&&v.delete(g)}),T}};var Vt=(o,t)=>{let e=o.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var kr=(o,t)=>{let e=Array.from(o).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 o.delete(r),r};var Xn=(o,t,e,r)=>{let i=Vt(o,t),n=kr(i,s=>s[0]===e&&s[1]===r);return i.size===0&&o.delete(t),n};var $e=o=>Vt(Zn,o);var Be=o=>{if(Ke.has(o))throw new Error("The AudioNode is already stored.");Ke.add(o),$e(o).forEach(t=>t(!0))};var Jn=o=>"port"in o;var tr=o=>{if(!Ke.has(o))throw new Error("The AudioNode is not stored.");Ke.delete(o),$e(o).forEach(t=>t(!1))};var Go=(o,t)=>{!Jn(o)&&t.every(e=>e.size===0)&&tr(o)};var sl=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>{let d=new WeakMap;return(f,g,x,b,I)=>{let{activeInputs:S,passiveInputs:T}=n(g),{outputs:v}=n(f),C=a(f),A=y=>{let N=c(g),D=c(f);if(y){let M=Xn(T,f,x,b);o(S,f,M,!1),!I&&!h(f)&&e(D,N,x,b),p(g)&&Be(g)}else{let M=r(S,f,x,b);t(T,b,M,!1),!I&&!h(f)&&i(D,N,x,b);let O=s(g);if(O===0)l(g)&&Go(g,S);else{let W=d.get(g);W!==void 0&&clearTimeout(W),d.set(g,setTimeout(()=>{l(g)&&Go(g,S)},O*1e3))}}};return u(v,[g,x,b],y=>y[0]===g&&y[1]===x&&y[2]===b,!0)?(C.add(A),l(f)?o(S,f,[x,b,A],!0):t(T,b,[f,x,A],!0),!0):!1}};var al=o=>(t,e,[r,i,n],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[i,e,n]])):o(a,[i,e,n],c=>c[0]===i&&c[1]===e,s)};var cl=o=>(t,e)=>{let r=o(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 ul=o=>(t,e)=>{o(t).add(e)};var bg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},ll=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=i(a),l=R(R({},bg),c),h=r(u,l),p=n(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=(o,t)=>o.context===t;var hl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);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=o(s,u)}return r.set(s,a),yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Ri=o=>{try{o.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var Ne=()=>new DOMException("","IndexSizeError");var Ei=o=>{o.getChannelData=(t=>e=>{try{return t.call(o,e)}catch(r){throw r.code===12?Ne():r}})(o.getChannelData)};var Ag={numberOfChannels:1},pl=(o,t,e,r,i,n,s,a)=>{let c=null;return class dl{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:p,sampleRate:d}=R(R({},Ag),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&t(n,n)?new r({length:h,numberOfChannels:p,sampleRate:d}):c.createBuffer(p,h,d);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),Ei(f)):t(Ri,()=>Ri(f))||a(f),o.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===dl.prototype||o.has(l)}}};var jt=-34028234663852886e22,Et=-jt;var ne=o=>Ke.has(o);var Cg={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},ml=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=R(R({},Cg),l),d=i(h,p),f=s(h),g=f?t():null;super(u,!1,d,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=d,this._onended=null,this._playbackRate=e(this,f,d.playbackRate,Et,jt)}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),ne(this)&&tr(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var fl=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=null,a=null,c=(u,l)=>X(null,null,function*(){let h=e(u),p=pt(h,l);if(!p){let d={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,d),s!==null&&h.start(...s),a!==null&&h.stop(a)}return n.set(l,h),p?yield o(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=n.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var gl=o=>"playbackRate"in o;var xl=o=>"frequency"in o&&"gain"in o;var yl=o=>"offset"in o;var bl=o=>!("frequency"in o)&&"gain"in o;var Al=o=>"detune"in o&&"frequency"in o&&!("gain"in o);var Cl=o=>"pan"in o;var Ht=o=>Vt(Hn,o);var Lr=o=>Vt(Qn,o);var Kn=(o,t)=>{let{activeInputs:e}=Ht(o);e.forEach(i=>i.forEach(([n])=>{t.includes(o)||Kn(n,[...t,o])}));let r=gl(o)?[o.playbackRate]:Jn(o)?Array.from(o.parameters.values()):xl(o)?[o.Q,o.detune,o.frequency,o.gain]:yl(o)?[o.offset]:bl(o)?[o.gain]:Al(o)?[o.detune,o.frequency]:Cl(o)?[o.pan]:[];for(let i of r){let n=Lr(i);n!==void 0&&n.activeInputs.forEach(([s])=>Kn(s,t))}ne(o)&&tr(o)};var jr=o=>{Kn(o.destination,[])};var $n=o=>o===void 0||typeof o=="number"||typeof o=="string"&&(o==="balanced"||o==="interactive"||o==="playback");var _l=(o,t,e,r,i,n,s,a,c)=>class extends o{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(!$n(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:d}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/d:p==="interactive"||p===void 0?256/d:p==="playback"?1024/d:Math.max(2,Math.min(128,Math.round(p*d/128)))*128/d,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()),jr(this)}))}createMediaElementSource(l){return new i(this,{mediaElement:l})}createMediaStreamDestination(){return new n(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 vl=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=s(h),d=i(h,l,p),f=p?t(a):null;super(u,!1,d,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=d}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 Il=o=>{let t=new WeakMap,e=(r,i)=>X(null,null,function*(){let n=i.destination;return t.set(i,n),yield o(r,i,n),n});return{render(r,i){let n=t.get(i);return n!==void 0?Promise.resolve(n):e(r,i)}}};var Sl=(o,t,e,r,i,n,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let v=new Float32Array(1),C=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),A=s(u),y=!1,N=[0,0,-1,0,1,0],D=[0,0,0],M=()=>{if(y)return;y=!0;let P=r(u,256,9,0);P.onaudioprocess=({inputBuffer:L})=>{let q=[n(L,v,0),n(L,v,1),n(L,v,2),n(L,v,3),n(L,v,4),n(L,v,5)];q.some((Q,et)=>Q!==N[et])&&(l.setOrientation(...q),N=q);let H=[n(L,v,6),n(L,v,7),n(L,v,8)];H.some((Q,et)=>Q!==D[et])&&(l.setPosition(...H),D=H)},C.connect(P)},O=P=>L=>{L!==N[P]&&(N[P]=L,l.setOrientation(...N))},W=P=>L=>{L!==D[P]&&(D[P]=L,l.setPosition(...D))},k=(P,L,q)=>{let H=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:L});H.connect(C,0,P),H.start(),Object.defineProperty(H.offset,"defaultValue",{get(){return L}});let Q=o({context:c},A,H.offset,Et,jt);return a(Q,"value",et=>()=>et.call(Q),et=>at=>{try{et.call(Q,at)}catch(yt){if(yt.code!==9)throw yt}M(),A&&q(at)}),Q.cancelAndHoldAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.cancelAndHoldAtTime),Q.cancelScheduledValues=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.cancelScheduledValues),Q.exponentialRampToValueAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.exponentialRampToValueAtTime),Q.linearRampToValueAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.linearRampToValueAtTime),Q.setTargetAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.setTargetAtTime),Q.setValueAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.setValueAtTime),Q.setValueCurveAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return M(),yt})(Q.setValueCurveAtTime),Q};return{forwardX:k(0,0,O(0)),forwardY:k(1,0,O(1)),forwardZ:k(2,-1,O(2)),positionX:k(6,0,W(0)),positionY:k(7,0,W(1)),positionZ:k(8,0,W(2)),upX:k(3,0,O(3)),upY:k(4,1,O(4)),upZ:k(5,0,O(5))}},{forwardX:p,forwardY:d,forwardZ:f,positionX:g,positionY:x,positionZ:b,upX:I,upY:S,upZ:T}=l.forwardX===void 0?h():l;return{get forwardX(){return p},get forwardY(){return d},get forwardZ(){return f},get positionX(){return g},get positionY(){return x},get positionZ(){return b},get upX(){return I},get upY(){return S},get upZ(){return T}}};var Zr=o=>"context"in o;var Pr=o=>Zr(o[0]);var Ge=(o,t,e,r)=>{for(let i of o)if(e(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return o.add(t),!0};var uc=(o,t,[e,r],i)=>{Ge(o,[t,e,r],n=>n[0]===t&&n[1]===e,i)};var lc=(o,[t,e,r],i)=>{let n=o.get(t);n===void 0?o.set(t,new Set([[e,r]])):Ge(n,[e,r],s=>s[0]===e,i)};var Oe=o=>"inputs"in o;var Mi=(o,t,e,r)=>{if(Oe(t)){let i=t.inputs[r];return o.connect(i,e,0),[i,e,0]}return o.connect(t,e,r),[t,e,r]};var hc=(o,t,e)=>{for(let r of o)if(r[0]===t&&r[1]===e)return o.delete(r),r;return null};var wl=(o,t,e)=>kr(o,r=>r[0]===t&&r[1]===e);var pc=(o,t)=>{if(!$e(o).delete(t))throw new Error("Missing the expected event listener.")};var dc=(o,t,e)=>{let r=Vt(o,t),i=kr(r,n=>n[0]===e);return r.size===0&&o.delete(t),i};var Di=(o,t,e,r)=>{Oe(t)?o.disconnect(t.inputs[r],e,0):o.disconnect(t,e,r)};var Ct=o=>Vt(Ni,o);var Xr=o=>Vt(jo,o);var gr=o=>Po.has(o);var ki=o=>!Ke.has(o);var mc=(o,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=o.createScriptProcessor(256,1,1),i=o.createGain(),n=o.createBuffer(1,2,44100),s=n.getChannelData(0);s[0]=1,s[1]=1;let a=o.createBufferSource();a.buffer=n,a.loop=!0,a.connect(r).connect(o.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(o.destination)},a.start()}});var ts=(o,t)=>{let e=new Map;for(let r of o)for(let i of r){let n=e.get(i);e.set(i,n===void 0?1:n+1)}e.forEach((r,i)=>t(i,r))};var Jr=o=>"context"in o;var Tl=o=>{let t=new Map;o.connect=(e=>(r,i=0,n=0)=>{let s=Jr(r)?e(r,i,n):e(r,i),a=t.get(r);return a===void 0?t.set(r,[{input:n,output:i}]):a.every(c=>c.input!==n||c.output!==i)&&a.push({input:n,output:i}),s})(o.connect.bind(o)),o.disconnect=(e=>(r,i,n)=>{if(e.apply(o),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!==n||n===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{Jr(s)?o.connect(s,c.output,c.input):o.connect(s,c.output)})})(o.disconnect)};var _g=(o,t,e,r)=>{let{activeInputs:i,passiveInputs:n}=Lr(t),{outputs:s}=Ht(o),a=$e(o),c=u=>{let l=Ct(o),h=Xr(t);if(u){let p=dc(n,o,e);uc(i,o,p,!1),!r&&!gr(o)&&l.connect(h,e)}else{let p=wl(i,o,e);lc(n,p,!1),!r&&!gr(o)&&l.disconnect(h,e)}};return Ge(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),ne(o)?uc(i,o,[e,c],!0):lc(n,[o,e,c],!0),!0):!1},vg=(o,t,e,r)=>{let{activeInputs:i,passiveInputs:n}=Ht(t),s=hc(i[r],o,e);return s===null?[Xn(n,o,e,r)[2],!1]:[s[2],!0]},Ig=(o,t,e)=>{let{activeInputs:r,passiveInputs:i}=Lr(t),n=hc(r,o,e);return n===null?[dc(i,o,e)[1],!1]:[n[2],!0]},fc=(o,t,e,r,i)=>{let[n,s]=vg(o,e,r,i);if(n!==null&&(pc(o,n),s&&!t&&!gr(o)&&Di(Ct(o),Ct(e),r,i)),ne(e)){let{activeInputs:a}=Ht(e);Go(e,a)}},gc=(o,t,e,r)=>{let[i,n]=Ig(o,e,r);i!==null&&(pc(o,i),n&&!t&&!gr(o)&&Ct(o).disconnect(Xr(e),r))},Sg=(o,t)=>{let e=Ht(o),r=[];for(let i of e.outputs)Pr(i)?fc(o,t,...i):gc(o,t,...i),r.push(i[0]);return e.outputs.clear(),r},wg=(o,t,e)=>{let r=Ht(o),i=[];for(let n of r.outputs)n[1]===e&&(Pr(n)?fc(o,t,...n):gc(o,t,...n),i.push(n[0]),r.outputs.delete(n));return i},Tg=(o,t,e,r,i)=>{let n=Ht(o);return Array.from(n.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Pr(s)?fc(o,t,...s):gc(o,t,...s),n.outputs.delete(s),s[0]))},Nl=(o,t,e,r,i,n,s,a,c,u,l,h,p,d,f,g)=>class extends u{constructor(b,I,S,T){super(S),this._context=b,this._nativeAudioNode=S;let v=l(b);h(v)&&e(mc,()=>mc(v,g))!==!0&&Tl(S),Ni.set(this,S),Zn.set(this,new Set),b.state!=="closed"&&I&&Be(this),o(this,T,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 T=l(this._context),v=f(T);if(p(b)||d(b))throw n();if(Zr(b)){let y=Ct(b);try{let D=Mi(this._nativeAudioNode,y,I,S),M=ki(this);(v||M)&&this._nativeAudioNode.disconnect(...D),this.context.state!=="closed"&&!M&&ki(b)&&Be(b)}catch(D){throw D.code===12?n():D}if(t(this,b,I,S,v)){let D=c([this],b);ts(D,r(v))}return b}let C=Xr(b);if(C.name==="playbackRate"&&C.maxValue===1024)throw s();try{this._nativeAudioNode.connect(C,I),(v||ki(this))&&this._nativeAudioNode.disconnect(C,I)}catch(y){throw y.code===12?n():y}if(_g(this,b,I,v)){let y=c([this],b);ts(y,r(v))}}disconnect(b,I,S){let T,v=l(this._context),C=f(v);if(b===void 0)T=Sg(this,C);else if(typeof b=="number"){if(b<0||b>=this.numberOfOutputs)throw i();T=wg(this,C,b)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||Zr(b)&&S!==void 0&&(S<0||S>=b.numberOfInputs))throw i();if(T=Tg(this,C,b,I,S),T.length===0)throw n()}for(let A of T){let y=c([this],A);ts(y,a)}}};var Ol=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>(d,f,g,x=null,b=null)=>{let I=g.value,S=new Lo(I),T=f?r(S):null,v={get defaultValue(){return I},get maxValue(){return x===null?g.maxValue:x},get minValue(){return b===null?g.minValue:b},get value(){return g.value},set value(C){g.value=C,v.setValueAtTime(C,d.context.currentTime)},cancelAndHoldAtTime(C){if(typeof g.cancelAndHoldAtTime=="function")T===null&&S.flush(d.context.currentTime),S.add(i(C)),g.cancelAndHoldAtTime(C);else{let A=Array.from(S).pop();T===null&&S.flush(d.context.currentTime),S.add(i(C));let y=Array.from(S).pop();g.cancelScheduledValues(C),A!==y&&y!==void 0&&(y.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(y.value,y.endTime):y.type==="linearRampToValue"?g.linearRampToValueAtTime(y.value,y.endTime):y.type==="setValue"?g.setValueAtTime(y.value,y.startTime):y.type==="setValueCurve"&&g.setValueCurveAtTime(y.values,y.startTime,y.duration))}return v},cancelScheduledValues(C){return T===null&&S.flush(d.context.currentTime),S.add(n(C)),g.cancelScheduledValues(C),v},exponentialRampToValueAtTime(C,A){if(C===0)throw new RangeError;if(!Number.isFinite(A)||A<0)throw new RangeError;let y=d.context.currentTime;return T===null&&S.flush(y),Array.from(S).length===0&&(S.add(u(I,y)),g.setValueAtTime(I,y)),S.add(s(C,A)),g.exponentialRampToValueAtTime(C,A),v},linearRampToValueAtTime(C,A){let y=d.context.currentTime;return T===null&&S.flush(y),Array.from(S).length===0&&(S.add(u(I,y)),g.setValueAtTime(I,y)),S.add(a(C,A)),g.linearRampToValueAtTime(C,A),v},setTargetAtTime(C,A,y){return T===null&&S.flush(d.context.currentTime),S.add(c(C,A,y)),g.setTargetAtTime(C,A,y),v},setValueAtTime(C,A){return T===null&&S.flush(d.context.currentTime),S.add(u(C,A)),g.setValueAtTime(C,A),v},setValueCurveAtTime(C,A,y){let N=C instanceof Float32Array?C:new Float32Array(C);if(h!==null&&h.name==="webkitAudioContext"){let D=A+y,M=d.context.sampleRate,O=Math.ceil(A*M),W=Math.floor(D*M),k=W-O,P=new Float32Array(k);for(let q=0;q<k;q+=1){let H=(N.length-1)/y*((O+q)/M-A),Q=Math.floor(H),et=Math.ceil(H);P[q]=Q===et?N[Q]:(1-(H-Q))*N[Q]+(1-(et-H))*N[et]}T===null&&S.flush(d.context.currentTime),S.add(l(P,A,y)),g.setValueCurveAtTime(P,A,y);let L=W/M;L<D&&p(v,P[P.length-1],L),p(v,N[N.length-1],D)}else T===null&&S.flush(d.context.currentTime),S.add(l(N,A,y)),g.setValueCurveAtTime(N,A,y);return v}};return e.set(v,g),t.set(v,d),o(v,T),v};var Rl=o=>({replay(t){for(let e of o)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:n}=e;t.setTargetAtTime(i,r,n)}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:n}=e;t.setValueCurveAtTime(n,i,r)}else throw new Error("Can't apply an unknown automation.")}});var Li=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 Ng={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},El=(o,t,e,r,i,n,s,a,c,u,l,h,p,d)=>class extends t{constructor(g,x,b){var I;let S=a(g),T=c(S),v=l(R(R({},Ng),b));p(v);let C=Fo.get(S),A=C==null?void 0:C.get(x),y=T||S.state!=="closed"?S:(I=s(S))!==null&&I!==void 0?I:S,N=i(y,T?null:g.baseLatency,u,x,A,v),D=T?r(x,v,A):null;super(g,!0,N,D);let M=[];N.parameters.forEach((W,k)=>{let P=e(this,T,W);M.push([k,P])}),this._nativeAudioWorkletNode=N,this._onprocessorerror=null,this._parameters=new Li(M),T&&o(S,this);let{activeInputs:O}=n(this);h(N,O)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let x=typeof g=="function"?d(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=x;let b=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=b!==null&&b===x?g:b}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function ji(o,t,e,r,i){if(typeof o.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),o.copyFromChannel(t[e],r,i);else{let n=o.getChannelData(r);if(t[e].byteLength===0)t[e]=n.slice(i,i+128);else{let s=new Float32Array(n.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var es=(o,t,e,r,i)=>{typeof o.copyToChannel=="function"?t[e].byteLength!==0&&o.copyToChannel(t[e],r,i):t[e].byteLength!==0&&o.getChannelData(r).set(t[e],i)};var Pi=(o,t)=>{let e=[];for(let r=0;r<o;r+=1){let i=[],n=typeof t=="number"?t:t[r];for(let s=0;s<n;s+=1)i.push(new Float32Array(128));e.push(i)}return e};var Ml=(o,t)=>{let e=Vt(Bo,o),r=Ct(t);return Vt(e,r)};var Og=(o,t,e,r,i,n,s)=>X(null,null,function*(){let a=t===null?Math.ceil(o.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((x,b)=>x+b,0),l=u===0?null:e.createBuffer(u,a,e.sampleRate);if(n===void 0)throw new Error("Missing the processor constructor.");let h=Ht(o),p=yield Ml(e,o),d=Pi(r.numberOfInputs,r.channelCount),f=Pi(r.numberOfOutputs,i),g=Array.from(o.parameters.keys()).reduce((x,b)=>Z(R({},x),{[b]:new Float32Array(128)}),{});for(let x=0;x<a;x+=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)ji(t,d[b],I,I,x);n.parameterDescriptors!==void 0&&t!==null&&n.parameterDescriptors.forEach(({name:b},I)=>{ji(t,g,b,c+I,x)});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=d.map((S,T)=>h.activeInputs[T].size===0?[]:S),I=s(x/e.sampleRate,e.sampleRate,()=>p.process(b,f,g));if(l!==null)for(let S=0,T=0;S<r.numberOfOutputs;S+=1){for(let v=0;v<i[S];v+=1)es(l,f[S],v,T+v,x);T+=i[S]}if(!I)break}catch(b){o.dispatchEvent(new ErrorEvent("processorerror",{colno:b.colno,filename:b.filename,lineno:b.lineno,message:b.message}));break}}return l}),Dl=(o,t,e,r,i,n,s,a,c,u,l,h,p,d,f,g)=>(x,b,I)=>{let S=new WeakMap,T=null,v=(C,A)=>X(null,null,function*(){let y=l(C),N=null,D=pt(y,A),M=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(h===null){let O=M.reduce((L,q)=>L+q,0),W=i(A,{channelCount:Math.max(1,O),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,O)}),k=[];for(let L=0;L<C.numberOfOutputs;L+=1)k.push(r(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:M[L]}));let P=s(A,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1});P.connect=t.bind(null,k),P.disconnect=c.bind(null,k),N=[W,k,P]}else D||(y=new h(A,x));if(S.set(A,N===null?y:N[2]),N!==null){if(T===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let q=C.channelCount*C.numberOfInputs,H=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,Q=q+H;T=Og(C,Q===0?null:yield X(null,null,function*(){let at=new p(Q,Math.ceil(C.context.length/128)*128,A.sampleRate),yt=[],Lt=[];for(let At=0;At<b.numberOfInputs;At+=1)yt.push(s(at,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),Lt.push(i(at,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let xe=yield Promise.all(Array.from(C.parameters.values()).map(At=>X(null,null,function*(){let ot=n(at,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:At.value});return yield d(at,At,ot.offset),ot}))),ye=r(at,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,q+H)});for(let At=0;At<b.numberOfInputs;At+=1){yt[At].connect(Lt[At]);for(let ot=0;ot<b.channelCount;ot+=1)Lt[At].connect(ye,ot,At*b.channelCount+ot)}for(let[At,ot]of xe.entries())ot.connect(ye,0,q+At),ot.start(0);return ye.connect(at.destination),yield Promise.all(yt.map(At=>f(C,at,At))),g(at)}),A,b,M,I,u)}let O=yield T,W=e(A,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[k,P,L]=N;O!==null&&(W.buffer=O,W.start(0)),W.connect(k);for(let q=0,H=0;q<C.numberOfOutputs;q+=1){let Q=P[q];for(let et=0;et<M[q];et+=1)k.connect(Q,H+et,et);H+=M[q]}return L}if(D)for(let[O,W]of C.parameters.entries())yield o(A,W,y.parameters.get(O));else for(let[O,W]of C.parameters.entries())yield d(A,W,y.parameters.get(O));return yield f(C,A,y),y});return{render(C,A){a(A,C);let y=S.get(A);return y!==void 0?Promise.resolve(y):v(C,A)}}};var kl=(o,t,e,r,i,n,s,a,c,u,l,h,p,d,f,g,x,b,I,S)=>class extends f{constructor(v,C){super(v,C),this._nativeContext=v,this._audioWorklet=o===void 0?void 0:{addModule:(A,y)=>o(this,A,y)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(v,C,A){return new e({length:C,numberOfChannels:v,sampleRate:A})}createBufferSource(){return new r(this)}createChannelMerger(v=6){return new n(this,{numberOfInputs:v})}createChannelSplitter(v=6){return new s(this,{numberOfOutputs:v})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(v=1){return new l(this,{maxDelayTime:v})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(v,C){return new d(this,{feedback:C,feedforward:v})}createOscillator(){return new g(this)}createPanner(){return new x(this)}createPeriodicWave(v,C,A={disableNormalization:!1}){return new b(this,Z(R({},A),{imag:C,real:v}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new S(this)}decodeAudioData(v,C,A){return u(this._nativeContext,v).then(y=>(typeof C=="function"&&C(y),y),y=>{throw typeof A=="function"&&A(y),y})}};var Rg={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Ll=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=R(R({},Rg),l),d=i(h,p),f=s(h),g=f?e():null;super(u,!1,d,g),this._Q=t(this,f,d.Q,Et,jt),this._detune=t(this,f,d.detune,1200*Math.log2(Et),-1200*Math.log2(Et)),this._frequency=t(this,f,d.frequency,u.sampleRate/2,0),this._gain=t(this,f,d.gain,40*Math.log10(Et),jt),this._nativeBiquadFilterNode=d,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 jl=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?(yield o(c,a.Q,u.Q),yield o(c,a.detune,u.detune),yield o(c,a.frequency,u.frequency),yield o(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=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Pl=(o,t)=>(e,r)=>{let i=t.get(e);if(i!==void 0)return i;let n=o.get(e);if(n!==void 0)return n;try{let s=r();return s instanceof Promise?(o.set(e,s),s.catch(()=>!1).then(a=>(o.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var Eg={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Fl=(o,t,e,r,i)=>class extends o{constructor(s,a){let c=r(s),u=R(R({},Eg),a),l=e(c,u),h=i(c)?t():null;super(s,!1,l,h)}};var Bl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=o(s,u)}return r.set(s,a),yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Mg={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Gl=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=r(a),l=n(R(R({},Mg),c)),h=e(u,l),p=i(u)?t():null;super(a,!1,h,p)}};var Vl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=o(s,u)}return r.set(s,a),yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var ql=o=>(t,e,r)=>o(e,t,r);var Wl=o=>(t,e,r=0,i=0)=>{let n=t[r];if(n===void 0)throw o();return Jr(e)?n.connect(e,0,i):n.connect(e,0)};var Ul=o=>(t,e)=>{let r=o(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 Dg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},zl=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Dg),u),p=r(l,h),d=n(l),f=d?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,d,p.offset,Et,jt),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),ne(this)&&tr(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var Yl=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=null,a=null,c=(u,l)=>X(null,null,function*(){let h=e(u),p=pt(h,l);if(!p){let d={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,d),s!==null&&h.start(s),a!==null&&h.stop(a)}return n.set(l,h),p?yield o(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=n.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var Hl=o=>t=>(o[0]=t,o[0]);var kg={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Ql=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=r(a),l=R(R({},kg),c),h=e(u,l),d=i(u)?t():null;super(a,!1,h,d),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&n(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,n(this,0)}else this._isBufferNullified=!1,n(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var Zl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=o(s,u)}return r.set(s,a),Oe(a)?yield e(n,s,a.inputs[0]):yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Xl=(o,t)=>(e,r,i)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,i)}catch(n){throw n.name==="SyntaxError"?o():n}};var Jl=()=>new DOMException("","DataCloneError");var xc=o=>{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(o,[o])}catch(n){}finally{i()}})};var Kl=(o,t,e,r,i,n,s,a,c,u,l)=>(h,p)=>{let d=s(h)?h:n(h);if(i.has(p)){let f=e();return Promise.reject(f)}try{i.add(p)}catch(f){}return t(c,()=>c(d))?d.decodeAudioData(p).then(f=>(xc(p).catch(()=>{}),t(a,()=>a(f))||l(f),o.add(f),f)):new Promise((f,g)=>{let x=()=>X(null,null,function*(){try{yield xc(p)}catch(I){}}),b=I=>{g(I),x()};try{d.decodeAudioData(p,I=>{typeof I.copyFromChannel!="function"&&(u(I),Ei(I)),o.add(I),x().then(()=>f(I))},I=>{b(I===null?r():I)})}catch(I){b(I)}})};var $l=(o,t,e,r,i,n,s,a)=>(c,u)=>{let l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=n(c.context),p=a(h);if(l===u){if(t.delete(c),!p&&s(c)){let d=r(c),{outputs:f}=e(c);for(let g of f)if(Pr(g)){let x=r(g[0]);o(d,x,g[1],g[2])}else{let x=i(g[0]);d.connect(x,g[1])}}}else t.set(c,l-u)};var Lg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},th=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Lg),u),p=r(l,h),d=n(l),f=d?e(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,d,p.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var eh=(o,t,e,r,i)=>n=>{let s=new WeakMap,a=(c,u)=>X(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:n};l=t(u,p)}return s.set(u,l),h?yield o(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 rh=o=>(t,e,r,i)=>o(t[i],n=>n[0]===e&&n[1]===r);var ih=o=>(t,e)=>{o(t).delete(e)};var oh=o=>"delayTime"in o;var nh=(o,t,e)=>function r(i,n){let s=Zr(n)?n:e(o,n);if(oh(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 rs=(o,t,e)=>{let r=t[e];if(r===void 0)throw o();return r},sh=o=>(t,e=void 0,r=void 0,i=0)=>e===void 0?t.forEach(n=>n.disconnect()):typeof e=="number"?rs(o,t,e).disconnect():Jr(e)?r===void 0?t.forEach(n=>n.disconnect(e)):i===void 0?rs(o,t,r).disconnect(e,0):rs(o,t,r).disconnect(e,0,i):r===void 0?t.forEach(n=>n.disconnect(e)):rs(o,t,r).disconnect(e,0);var jg={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},ah=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=R(R({},jg),l),d=r(h,p),f=s(h),g=f?e():null;super(u,!1,d,g),this._attack=t(this,f,d.attack),this._knee=t(this,f,d.knee),this._nativeDynamicsCompressorNode=d,this._ratio=t(this,f,d.ratio),this._release=t(this,f,d.release),this._threshold=t(this,f,d.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 ch=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?(yield o(c,a.attack,u.attack),yield o(c,a.knee,u.knee),yield o(c,a.ratio,u.ratio),yield o(c,a.release,u.release),yield o(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=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var uh=()=>new DOMException("","EncodingError");var lh=o=>t=>new Promise((e,r)=>{if(o===null){r(new SyntaxError);return}let i=o.document.head;if(i===null)r(new SyntaxError);else{let n=o.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=o.onerror,u=()=>{o.onerror=c,URL.revokeObjectURL(a)};o.onerror=(l,h,p,d,f)=>{if(h===a||h===o.location.href&&p===1&&d===1)return u(),r(f),!1;if(c!==null)return c(l,h,p,d,f)},n.onerror=()=>{u(),r(new SyntaxError)},n.onload=()=>{u(),e()},n.src=a,n.type="module",i.appendChild(n)}});var hh=o=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,i){if(r!==null){let n=this._listeners.get(r);n===void 0&&(n=o(this,r),typeof r=="function"&&this._listeners.set(r,n)),this._nativeEventTarget.addEventListener(e,n,i)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,i){let n=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,n===void 0?null:n,i)}};var ph=o=>(t,e,r)=>{Object.defineProperties(o,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{o!==null&&(delete o.currentFrame,delete o.currentTime)}};var dh=o=>t=>X(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw o()});var Pg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},mh=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=i(a),l=R(R({},Pg),c),h=r(u,l),p=n(u),d=p?e():null;super(a,!1,h,d),this._gain=t(this,p,h.gain,Et,jt)}get gain(){return this._gain}};var fh=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?yield o(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield i(a,c,u),u});return{render(a,c){let u=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var gh=(o,t)=>e=>t(o,e);var xh=o=>t=>{let e=o(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var yh=o=>t=>{var e;return(e=o.get(t))!==null&&e!==void 0?e:0};var bh=o=>t=>{let e=o(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var Ah=o=>t=>o.get(t);var wt=()=>new DOMException("","InvalidStateError");var Ch=o=>t=>{let e=o.get(t);if(e===void 0)throw wt();return e};var _h=(o,t)=>e=>{let r=o.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),o.set(e,r),r};var vh=o=>t=>{let e=o.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var Fi=()=>new DOMException("","InvalidAccessError");var Ih=o=>{o.getFrequencyResponse=(t=>(e,r,i)=>{if(e.length!==r.length||r.length!==i.length)throw Fi();return t.call(o,e,r,i)})(o.getFrequencyResponse)};var Fg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Sh=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=r(a),l=i(u),h=R(R({},Fg),c),p=t(u,l?null:a.baseLatency,h),d=l?e(h.feedback,h.feedforward):null;super(a,!1,p,d),Ih(p),this._nativeIIRFilterNode=p,n(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var is=(o,t,e,r,i,n,s,a,c,u,l)=>{let h=u.length,p=a;for(let d=0;d<h;d+=1){let f=e[0]*u[d];for(let g=1;g<i;g+=1){let x=p-g&c-1;f+=e[g]*n[x],f-=o[g]*s[x]}for(let g=i;g<r;g+=1)f+=e[g]*n[p-g&c-1];for(let g=i;g<t;g+=1)f-=o[g]*s[p-g&c-1];n[p]=u[d],s[p]=f,p=p+1&c-1,l[d]=f}return p};var Bg=(o,t,e,r)=>{let i=e instanceof Float64Array?e:new Float64Array(e),n=r instanceof Float64Array?r:new Float64Array(r),s=i.length,a=n.length,c=Math.min(s,a);if(i[0]!==1){for(let f=0;f<s;f+=1)n[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(o.numberOfChannels,o.length,o.sampleRate),d=o.numberOfChannels;for(let f=0;f<d;f+=1){let g=o.getChannelData(f),x=p.getChannelData(f);l.fill(0),h.fill(0),is(i,s,n,a,c,l,h,0,u,g,x)}return p},wh=(o,t,e,r,i)=>(n,s)=>{let a=new WeakMap,c=null,u=(l,h)=>X(null,null,function*(){let p=null,d=t(l),f=pt(d,h);if(h.createIIRFilter===void 0?p=o(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(d=h.createIIRFilter(s,n)),a.set(h,p===null?d:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let x=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=X(null,null,function*(){yield r(l,x,x.destination);let b=yield i(x);return Bg(b,h,n,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(l,h,d),d});return{render(l,h){let p=a.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Th=(o,t,e,r,i,n)=>s=>(a,c)=>{let u=o.get(a);if(u===void 0){if(!s&&n(a)){let l=r(a),{outputs:h}=e(a);for(let p of h)if(Pr(p)){let d=r(p[0]);t(l,d,p[1],p[2])}else{let d=i(p[0]);l.disconnect(d,p[1])}}o.set(a,c)}else o.set(a,u+c)};var Nh=(o,t)=>e=>{let r=o.get(e);return t(r)||t(e)};var Oh=(o,t)=>e=>o.has(e)||t(e);var Rh=(o,t)=>e=>o.has(e)||t(e);var Eh=(o,t)=>e=>{let r=o.get(e);return t(r)||t(e)};var Mh=o=>t=>o!==null&&t instanceof o;var Dh=o=>t=>o!==null&&typeof o.AudioNode=="function"&&t instanceof o.AudioNode;var kh=o=>t=>o!==null&&typeof o.AudioParam=="function"&&t instanceof o.AudioParam;var Lh=(o,t)=>e=>o(e)||t(e);var jh=o=>t=>o!==null&&t instanceof o;var Ph=o=>o!==null&&o.isSecureContext;var Fh=(o,t,e,r)=>class extends o{constructor(n,s){let a=e(n),c=t(a,s);if(r(a))throw TypeError();super(n,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var Gg={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Bh=(o,t,e,r)=>class extends o{constructor(n,s){let a=e(n);if(r(a))throw new TypeError;let c=R(R({},Gg),s),u=t(a,c);super(n,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Gh=(o,t,e,r)=>class extends o{constructor(n,s){let a=e(n),c=t(a,s);if(r(a))throw new TypeError;super(n,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var Vh=(o,t,e)=>class extends o{constructor(i,n){let s=e(i),a=t(s,n);super(i,!0,a,null)}};var qh=(o,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(!$n(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 o()}):(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()),jr(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?o():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?o():s})}};var Wh=(o,t,e,r,i,n)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,Oi.set(this,a),r(a)&&i.set(a,new Set),this._destination=new o(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"?n(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=o=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=o.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var Vg={numberOfChannels:1},Uh=(o,t,e,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=R(R({},Vg),s),l=e(c,a,u);o(Ve,()=>Ve(l))||l.addEventListener("statechange",(()=>{let h=0,p=d=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",p),d.stopImmediatePropagation(),this._waitForThePromiseToSettle(d)):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,jr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var zh=(o,t)=>(e,r,i)=>{let n=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let l=n.size===0;if(t(a))return s.call(e,a,c,u),o(n,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(e,a,c),o(n,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let l=n.size>0;if(a===void 0)s.apply(e),n.clear();else if(typeof a=="number"){s.call(e,a);for(let p of n)p[1]===a&&n.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of n)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&n.delete(p)}let h=n.size===0;l&&h&&i()})(e.disconnect),e};var dt=(o,t,e)=>{let r=t[e];r!==void 0&&r!==o[e]&&(o[e]=r)};var ut=(o,t)=>{dt(o,t,"channelCount"),dt(o,t,"channelCountMode"),dt(o,t,"channelInterpretation")};var yc=o=>typeof o.getFloatTimeDomainData=="function";var Yh=o=>{o.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);o.getByteTimeDomainData(e);let r=Math.max(e.length,o.fftSize);for(let i=0;i<r;i+=1)t[i]=(e[i]-128)*.0078125;return t}};var Hh=(o,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"),o(yc,()=>yc(i))||Yh(i),i};var Qh=o=>o===null?null:o.hasOwnProperty("AudioBuffer")?o.AudioBuffer:null;var xt=(o,t,e)=>{let r=t[e];r!==void 0&&r!==o[e].value&&(o[e].value=r)};var Zh=o=>{o.start=(t=>{let e=!1;return(r=0,i=0,n)=>{if(e)throw wt();t.call(o,r,i,n),e=!0}})(o.start)};var Bi=o=>{o.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(o,e,r,i)})(o.start)};var Gi=o=>{o.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(o,e)})(o.stop)};var Xh=(o,t,e,r,i,n,s,a,c,u,l)=>(h,p)=>{let d=h.createBufferSource();return ut(d,p),xt(d,p,"playbackRate"),dt(d,p,"buffer"),dt(d,p,"loop"),dt(d,p,"loopEnd"),dt(d,p,"loopStart"),t(e,()=>e(h))||Zh(d),t(r,()=>r(h))||c(d),t(i,()=>i(h))||u(d,h),t(n,()=>n(h))||Bi(d),t(s,()=>s(h))||l(d,h),t(a,()=>a(h))||Gi(d),o(h,d),d};var Jh=o=>o===null?null:o.hasOwnProperty("AudioContext")?o.AudioContext:o.hasOwnProperty("webkitAudioContext")?o.webkitAudioContext:null;var Kh=(o,t)=>(e,r,i)=>{let n=e.destination;if(n.channelCount!==r)try{n.channelCount=r}catch(a){}i&&n.channelCountMode!=="explicit"&&(n.channelCountMode="explicit"),n.maxChannelCount===0&&Object.defineProperty(n,"maxChannelCount",{value:r});let s=o(e,{channelCount:r,channelCountMode:n.channelCountMode,channelInterpretation:n.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{n.channelCount=c}catch(u){if(c>n.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),n.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),n.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>n.maxChannelCount}),s.connect(n),s};var $h=o=>o===null?null:o.hasOwnProperty("AudioWorkletNode")?o.AudioWorkletNode:null;var tp=o=>{let{port1:t}=new MessageChannel;try{t.postMessage(o)}finally{t.close()}};var ep=(o,t,e,r,i)=>(n,s,a,c,u,l)=>{if(a!==null)try{let h=new a(n,c,l),p=new Map,d=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw o()}},channelCountMode:{get:()=>"explicit",set:()=>{throw o()}},onprocessorerror:{get:()=>d,set:f=>{typeof d=="function"&&h.removeEventListener("processorerror",d),d=typeof f=="function"?f:null,typeof d=="function"&&h.addEventListener("processorerror",d)}}}),h.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let x=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(x!==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"}}),x(I)):x(new ErrorEvent(g[0],R({},I)))},p.set(x,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 x=p.get(g[1]);x!==void 0&&(p.delete(g[1]),g[1]=x)}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(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(n.destination),i(h,()=>f.disconnect(),()=>f.connect(n.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return tp(l),t(n,s,u,l)};var os=(o,t)=>o===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(o*t)))));var rp=o=>new Promise((t,e)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:n})=>{r.close(),i.close(),t(n)},r.onmessageerror=({data:n})=>{r.close(),i.close(),e(n)},i.postMessage(o)});var ip=(o,t)=>X(null,null,function*(){let e=yield rp(t);return new o(e)});var op=(o,t,e,r)=>{let i=Bo.get(o);i===void 0&&(i=new WeakMap,Bo.set(o,i));let n=ip(e,r);return i.set(t,n),n};var np=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>(d,f,g,x)=>{if(x.numberOfInputs===0&&x.numberOfOutputs===0)throw c();let b=Array.isArray(x.outputChannelCount)?x.outputChannelCount:Array.from(x.outputChannelCount);if(b.some(z=>z<1))throw c();if(b.length!==x.numberOfOutputs)throw t();if(x.channelCountMode!=="explicit")throw c();let I=x.channelCount*x.numberOfInputs,S=b.reduce((z,rt)=>z+rt,0),T=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+T>6||S>6)throw c();let v=new MessageChannel,C=[],A=[];for(let z=0;z<x.numberOfInputs;z+=1)C.push(s(d,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1})),A.push(i(d,{channelCount:x.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:x.channelCount}));let y=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:z,maxValue:rt,minValue:zt,name:Tt}of g.parameterDescriptors){let ft=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:x.parameterData[Tt]!==void 0?x.parameterData[Tt]:z===void 0?0:z});Object.defineProperties(ft.offset,{defaultValue:{get:()=>z===void 0?0:z},maxValue:{get:()=>rt===void 0?Et:rt},minValue:{get:()=>zt===void 0?jt:zt}}),y.push(ft)}let N=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+T)}),D=os(f,d.sampleRate),M=a(d,D,I+T,Math.max(1,S)),O=i(d,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),W=[];for(let z=0;z<x.numberOfOutputs;z+=1)W.push(r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:b[z]}));for(let z=0;z<x.numberOfInputs;z+=1){C[z].connect(A[z]);for(let rt=0;rt<x.channelCount;rt+=1)A[z].connect(N,rt,z*x.channelCount+rt)}let k=new Li(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:z},rt)=>{let zt=y[rt];return zt.connect(N,0,I+rt),zt.start(0),[z,zt.offset]}));N.connect(M);let P=x.channelInterpretation,L=null,q=x.numberOfOutputs===0?[M]:W,H={get bufferSize(){return D},get channelCount(){return x.channelCount},set channelCount(z){throw e()},get channelCountMode(){return x.channelCountMode},set channelCountMode(z){throw e()},get channelInterpretation(){return P},set channelInterpretation(z){for(let rt of C)rt.channelInterpretation=z;P=z},get context(){return M.context},get inputs(){return C},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},get onprocessorerror(){return L},set onprocessorerror(z){typeof L=="function"&&H.removeEventListener("processorerror",L),L=typeof z=="function"?z:null,typeof L=="function"&&H.addEventListener("processorerror",L)},get parameters(){return k},get port(){return v.port2},addEventListener(...z){return M.addEventListener(z[0],z[1],z[2])},connect:o.bind(null,q),disconnect:u.bind(null,q),dispatchEvent(...z){return M.dispatchEvent(z[0])},removeEventListener(...z){return M.removeEventListener(z[0],z[1],z[2])}},Q=new Map;v.port1.addEventListener=(z=>(...rt)=>{if(rt[0]==="message"){let zt=typeof rt[1]=="function"?rt[1]:typeof rt[1]=="object"&&rt[1]!==null&&typeof rt[1].handleEvent=="function"?rt[1].handleEvent:null;if(zt!==null){let Tt=Q.get(rt[1]);Tt!==void 0?rt[1]=Tt:(rt[1]=ft=>{l(d.currentTime,d.sampleRate,()=>zt(ft))},Q.set(zt,rt[1]))}}return z.call(v.port1,rt[0],rt[1],rt[2])})(v.port1.addEventListener),v.port1.removeEventListener=(z=>(...rt)=>{if(rt[0]==="message"){let zt=Q.get(rt[1]);zt!==void 0&&(Q.delete(rt[1]),rt[1]=zt)}return z.call(v.port1,rt[0],rt[1],rt[2])})(v.port1.removeEventListener);let et=null;Object.defineProperty(v.port1,"onmessage",{get:()=>et,set:z=>{typeof et=="function"&&v.port1.removeEventListener("message",et),et=typeof z=="function"?z:null,typeof et=="function"&&(v.port1.addEventListener("message",et),v.port1.start())}}),g.prototype.port=v.port1;let at=null;op(d,H,g,x).then(z=>at=z);let Lt=Pi(x.numberOfInputs,x.channelCount),xe=Pi(x.numberOfOutputs,b),ye=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((z,{name:rt})=>Z(R({},z),{[rt]:new Float32Array(128)}),{}),At=!0,ot=()=>{x.numberOfOutputs>0&&M.disconnect(O);for(let z=0,rt=0;z<x.numberOfOutputs;z+=1){let zt=W[z];for(let Tt=0;Tt<b[z];Tt+=1)O.disconnect(zt,rt+Tt,Tt);rt+=b[z]}},yi=new Map;M.onaudioprocess=({inputBuffer:z,outputBuffer:rt})=>{if(at!==null){let zt=h(H);for(let Tt=0;Tt<D;Tt+=128){for(let ft=0;ft<x.numberOfInputs;ft+=1)for(let Rt=0;Rt<x.channelCount;Rt+=1)ji(z,Lt[ft],Rt,Rt,Tt);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:ft},Rt)=>{ji(z,ye,ft,I+Rt,Tt)});for(let ft=0;ft<x.numberOfInputs;ft+=1)for(let Rt=0;Rt<b[ft];Rt+=1)xe[ft][Rt].byteLength===0&&(xe[ft][Rt]=new Float32Array(128));try{let ft=Lt.map((Se,Tr)=>{if(zt[Tr].size>0)return yi.set(Tr,D/128),Se;let Ea=yi.get(Tr);return Ea===void 0?[]:(Se.every(bm=>bm.every(Am=>Am===0))&&(Ea===1?yi.delete(Tr):yi.set(Tr,Ea-1)),Se)});At=l(d.currentTime+Tt/d.sampleRate,d.sampleRate,()=>at.process(ft,xe,ye));for(let Se=0,Tr=0;Se<x.numberOfOutputs;Se+=1){for(let vo=0;vo<b[Se];vo+=1)es(rt,xe[Se],vo,Tr+vo,Tt);Tr+=b[Se]}}catch(ft){At=!1,H.dispatchEvent(new ErrorEvent("processorerror",{colno:ft.colno,filename:ft.filename,lineno:ft.lineno,message:ft.message}))}if(!At){for(let ft=0;ft<x.numberOfInputs;ft+=1){C[ft].disconnect(A[ft]);for(let Rt=0;Rt<x.channelCount;Rt+=1)A[Tt].disconnect(N,Rt,ft*x.channelCount+Rt)}if(g.parameterDescriptors!==void 0){let ft=g.parameterDescriptors.length;for(let Rt=0;Rt<ft;Rt+=1){let Se=y[Rt];Se.disconnect(N,0,I+Rt),Se.stop()}}N.disconnect(M),M.onaudioprocess=null,Ao?ot():Ai();break}}}};let Ao=!1,J=s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),bi=()=>M.connect(J).connect(d.destination),Ai=()=>{M.disconnect(J),J.disconnect()},Co=()=>{if(At){Ai(),x.numberOfOutputs>0&&M.connect(O);for(let z=0,rt=0;z<x.numberOfOutputs;z+=1){let zt=W[z];for(let Tt=0;Tt<b[z];Tt+=1)O.connect(zt,rt+Tt,Tt);rt+=b[z]}}Ao=!0},_o=()=>{At&&(bi(),ot()),Ao=!1};return bi(),p(H,Co,_o)};var bc=(o,t)=>{let e=o.createBiquadFilter();return ut(e,t),xt(e,t,"Q"),xt(e,t,"detune"),xt(e,t,"frequency"),xt(e,t,"gain"),dt(e,t,"type"),e};var sp=(o,t)=>(e,r)=>{let i=e.createChannelMerger(r.numberOfInputs);return o!==null&&o.name==="webkitAudioContext"&&t(e,i),ut(i,r),i};var ap=o=>{let t=o.numberOfOutputs;Object.defineProperty(o,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw wt()}}),Object.defineProperty(o,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw wt()}}),Object.defineProperty(o,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw wt()}})};var Vi=(o,t)=>{let e=o.createChannelSplitter(t.numberOfOutputs);return ut(e,t),ap(e),e};var cp=(o,t,e,r,i)=>(n,s)=>{if(n.createConstantSource===void 0)return e(n,s);let a=n.createConstantSource();return ut(a,s),xt(a,s,"offset"),t(r,()=>r(n))||Bi(a),t(i,()=>i(n))||Gi(a),o(n,a),a};var Re=(o,t)=>(o.connect=t.connect.bind(t),o.disconnect=t.disconnect.bind(t),o);var up=(o,t,e,r)=>(i,a)=>{var c=a,{offset:n}=c,s=Nr(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(R({},s),{gain:n})),p=u.getChannelData(0);p[0]=1,p[1]=1,l.buffer=u,l.loop=!0;let d={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(x){h.channelCount=x},get channelCountMode(){return h.channelCountMode},set channelCountMode(x){h.channelCountMode=x},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(x){h.channelInterpretation=x},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(x){l.onended=x},addEventListener(...x){return l.addEventListener(x[0],x[1],x[2])},dispatchEvent(...x){return l.dispatchEvent(x[0])},removeEventListener(...x){return l.removeEventListener(x[0],x[1],x[2])},start(x=0){l.start.call(l,x)},stop(x=0){l.stop.call(l,x)}},f=()=>l.connect(h),g=()=>l.disconnect(h);return o(i,l),r(Re(d,h),f,g)};var lp=(o,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",n=>()=>n.call(i),n=>s=>{if(s>2)throw o();return n.call(i,s)}),r.channelCountMode==="max"))throw o();return t(i,"channelCountMode",n=>()=>n.call(i),n=>s=>{if(s==="max")throw o();return n.call(i,s)}),i};var Ac=(o,t)=>{let e=o.createDelay(t.maxDelayTime);return ut(e,t),xt(e,t,"delayTime"),e};var hp=o=>(t,e)=>{let r=t.createDynamicsCompressor();if(ut(r,e),e.channelCount>2||e.channelCountMode==="max")throw o();return xt(r,e,"attack"),xt(r,e,"knee"),xt(r,e,"ratio"),xt(r,e,"release"),xt(r,e,"threshold"),r};var se=(o,t)=>{let e=o.createGain();return ut(e,t),xt(e,t,"gain"),e};var pp=o=>(t,e,r)=>{if(t.createIIRFilter===void 0)return o(t,e,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return ut(i,r),i};function qg(o,t){let e=t[0]*t[0]+t[1]*t[1];return[(o[0]*t[0]+o[1]*t[1])/e,(o[1]*t[0]-o[0]*t[1])/e]}function Wg(o,t){return[o[0]*t[0]-o[1]*t[1],o[0]*t[1]+o[1]*t[0]]}function dp(o,t){let e=[0,0];for(let r=o.length-1;r>=0;r-=1)e=Wg(e,t),e[0]+=o[r];return e}var mp=(o,t,e,r)=>(i,n,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=os(n,i.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),d=l instanceof Float64Array?l:new Float64Array(l),f=p.length,g=d.length,x=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(d[0]===0)throw t();if(p[0]!==1){for(let y=0;y<g;y+=1)d[y]/=p[0];for(let y=1;y<f;y+=1)p[y]/=p[0]}let b=e(i,h,s,s);b.channelCount=s,b.channelCountMode=a,b.channelInterpretation=c;let I=32,S=[],T=[],v=[];for(let y=0;y<s;y+=1){S.push(0);let N=new Float32Array(I),D=new Float32Array(I);N.fill(0),D.fill(0),T.push(N),v.push(D)}b.onaudioprocess=y=>{let N=y.inputBuffer,D=y.outputBuffer,M=N.numberOfChannels;for(let O=0;O<M;O+=1){let W=N.getChannelData(O),k=D.getChannelData(O);S[O]=is(p,f,d,g,x,T[O],v[O],S[O],I,W,k)}};let C=i.sampleRate/2;return Re({get bufferSize(){return h},get channelCount(){return b.channelCount},set channelCount(y){b.channelCount=y},get channelCountMode(){return b.channelCountMode},set channelCountMode(y){b.channelCountMode=y},get channelInterpretation(){return b.channelInterpretation},set channelInterpretation(y){b.channelInterpretation=y},get context(){return b.context},get inputs(){return[b]},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},addEventListener(...y){return b.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return b.dispatchEvent(y[0])},getFrequencyResponse(y,N,D){if(y.length!==N.length||N.length!==D.length)throw o();let M=y.length;for(let O=0;O<M;O+=1){let W=-Math.PI*(y[O]/C),k=[Math.cos(W),Math.sin(W)],P=dp(d,k),L=dp(p,k),q=qg(P,L);N[O]=Math.sqrt(q[0]*q[0]+q[1]*q[1]),D[O]=Math.atan2(q[1],q[0])}},removeEventListener(...y){return b.removeEventListener(y[0],y[1],y[2])}},b)};var fp=(o,t)=>o.createMediaElementSource(t.mediaElement);var gp=(o,t)=>{let e=o.createMediaStreamDestination();return ut(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var xp=(o,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((n,s)=>n.id<s.id?-1:n.id>s.id?1:0);let r=e.slice(0,1),i=o.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i};var yp=(o,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let i=new MediaStream([r]),n=e.createMediaStreamSource(i);if(r.kind!=="audio")throw o();if(t(e))throw new TypeError;return n};var bp=o=>o===null?null:o.hasOwnProperty("OfflineAudioContext")?o.OfflineAudioContext:o.hasOwnProperty("webkitOfflineAudioContext")?o.webkitOfflineAudioContext:null;var Ap=(o,t,e,r,i,n)=>(s,a)=>{let c=s.createOscillator();return ut(c,a),xt(c,a,"detune"),xt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):dt(c,a,"type"),t(e,()=>e(s))||Bi(c),t(r,()=>r(s))||n(c,s),t(i,()=>i(s))||Gi(c),o(s,c),c};var Cp=o=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?o(t,e):(ut(r,e),xt(r,e,"orientationX"),xt(r,e,"orientationY"),xt(r,e,"orientationZ"),xt(r,e,"positionX"),xt(r,e,"positionY"),xt(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 _p=(o,t,e,r,i,n,s,a,c,u)=>(l,D)=>{var M=D,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:g,orientationX:x,orientationY:b,orientationZ:I,panningModel:S,positionX:T,positionY:v,positionZ:C,refDistance:A,rolloffFactor:y}=M,N=Nr(M,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let O=l.createPanner();if(N.channelCount>2||N.channelCountMode==="max")throw s();ut(O,N);let W={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},k=e(l,Z(R({},W),{channelInterpretation:"speakers",numberOfInputs:6})),P=r(l,Z(R({},N),{gain:1})),L=r(l,Z(R({},W),{gain:1})),q=r(l,Z(R({},W),{gain:0})),H=r(l,Z(R({},W),{gain:0})),Q=r(l,Z(R({},W),{gain:0})),et=r(l,Z(R({},W),{gain:0})),at=r(l,Z(R({},W),{gain:0})),yt=i(l,256,6,1),Lt=n(l,Z(R({},W),{curve:new Float32Array([1,1]),oversample:"none"})),xe=[x,b,I],ye=[T,v,C],At=new Float32Array(1);yt.onaudioprocess=({inputBuffer:J})=>{let bi=[c(J,At,0),c(J,At,1),c(J,At,2)];bi.some((Co,_o)=>Co!==xe[_o])&&(O.setOrientation(...bi),xe=bi);let Ai=[c(J,At,3),c(J,At,4),c(J,At,5)];Ai.some((Co,_o)=>Co!==ye[_o])&&(O.setPosition(...Ai),ye=Ai)},Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(H.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(et.gain,"defaultValue",{get:()=>0}),Object.defineProperty(at.gain,"defaultValue",{get:()=>0});let ot={get bufferSize(){},get channelCount(){return O.channelCount},set channelCount(J){if(J>2)throw s();P.channelCount=J,O.channelCount=J},get channelCountMode(){return O.channelCountMode},set channelCountMode(J){if(J==="max")throw s();P.channelCountMode=J,O.channelCountMode=J},get channelInterpretation(){return O.channelInterpretation},set channelInterpretation(J){P.channelInterpretation=J,O.channelInterpretation=J},get coneInnerAngle(){return O.coneInnerAngle},set coneInnerAngle(J){O.coneInnerAngle=J},get coneOuterAngle(){return O.coneOuterAngle},set coneOuterAngle(J){O.coneOuterAngle=J},get coneOuterGain(){return O.coneOuterGain},set coneOuterGain(J){if(J<0||J>1)throw t();O.coneOuterGain=J},get context(){return O.context},get distanceModel(){return O.distanceModel},set distanceModel(J){O.distanceModel=J},get inputs(){return[P]},get maxDistance(){return O.maxDistance},set maxDistance(J){if(J<0)throw new RangeError;O.maxDistance=J},get numberOfInputs(){return O.numberOfInputs},get numberOfOutputs(){return O.numberOfOutputs},get orientationX(){return L.gain},get orientationY(){return q.gain},get orientationZ(){return H.gain},get panningModel(){return O.panningModel},set panningModel(J){O.panningModel=J},get positionX(){return Q.gain},get positionY(){return et.gain},get positionZ(){return at.gain},get refDistance(){return O.refDistance},set refDistance(J){if(J<0)throw new RangeError;O.refDistance=J},get rolloffFactor(){return O.rolloffFactor},set rolloffFactor(J){if(J<0)throw new RangeError;O.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!==ot.coneInnerAngle&&(ot.coneInnerAngle=h),p!==ot.coneOuterAngle&&(ot.coneOuterAngle=p),d!==ot.coneOuterGain&&(ot.coneOuterGain=d),f!==ot.distanceModel&&(ot.distanceModel=f),g!==ot.maxDistance&&(ot.maxDistance=g),x!==ot.orientationX.value&&(ot.orientationX.value=x),b!==ot.orientationY.value&&(ot.orientationY.value=b),I!==ot.orientationZ.value&&(ot.orientationZ.value=I),S!==ot.panningModel&&(ot.panningModel=S),T!==ot.positionX.value&&(ot.positionX.value=T),v!==ot.positionY.value&&(ot.positionY.value=v),C!==ot.positionZ.value&&(ot.positionZ.value=C),A!==ot.refDistance&&(ot.refDistance=A),y!==ot.rolloffFactor&&(ot.rolloffFactor=y),(xe[0]!==1||xe[1]!==0||xe[2]!==0)&&O.setOrientation(...xe),(ye[0]!==0||ye[1]!==0||ye[2]!==0)&&O.setPosition(...ye);let yi=()=>{P.connect(O),o(P,Lt,0,0),Lt.connect(L).connect(k,0,0),Lt.connect(q).connect(k,0,1),Lt.connect(H).connect(k,0,2),Lt.connect(Q).connect(k,0,3),Lt.connect(et).connect(k,0,4),Lt.connect(at).connect(k,0,5),k.connect(yt).connect(l.destination)},Ao=()=>{P.disconnect(O),a(P,Lt,0,0),Lt.disconnect(L),L.disconnect(k),Lt.disconnect(q),q.disconnect(k),Lt.disconnect(H),H.disconnect(k),Lt.disconnect(Q),Q.disconnect(k),Lt.disconnect(et),et.disconnect(k),Lt.disconnect(at),at.disconnect(k),k.disconnect(yt),yt.disconnect(l.destination)};return u(Re(ot,O),yi,Ao)};var vp=o=>(t,{disableNormalization:e,imag:r,real:i})=>{let n=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=t.createPeriodicWave(s,n,{disableNormalization:e});if(Array.from(r).length<2)throw o();return a};var qi=(o,t,e,r)=>o.createScriptProcessor(t,e,r);var Ip=(o,t)=>(e,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw t();if(e.createStereoPanner===void 0)return o(e,r);let n=e.createStereoPanner();return ut(n,r),xt(n,r,"pan"),Object.defineProperty(n,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw t()}}),n};var Sp=(o,t,e,r,i,n)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=Z(R({},u),{oversample:"none"}),h=(f,g,x,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385);for(let N=0;N<16385;N+=1){let D=N/16384*c;I[N]=Math.cos(D),S[N]=Math.sin(D)}let T=e(f,Z(R({},u),{gain:0})),v=r(f,Z(R({},l),{curve:I})),C=r(f,Z(R({},l),{curve:a})),A=e(f,Z(R({},u),{gain:0})),y=r(f,Z(R({},l),{curve:S}));return{connectGraph(){g.connect(T),g.connect(C.inputs===void 0?C:C.inputs[0]),g.connect(A),C.connect(x),x.connect(v.inputs===void 0?v:v.inputs[0]),x.connect(y.inputs===void 0?y:y.inputs[0]),v.connect(T.gain),y.connect(A.gain),T.connect(b,0,0),A.connect(b,0,1)},disconnectGraph(){g.disconnect(T),g.disconnect(C.inputs===void 0?C:C.inputs[0]),g.disconnect(A),C.disconnect(x),x.disconnect(v.inputs===void 0?v:v.inputs[0]),x.disconnect(y.inputs===void 0?y:y.inputs[0]),v.disconnect(T.gain),y.disconnect(A.gain),T.disconnect(b,0,0),A.disconnect(b,0,1)}}},p=(f,g,x,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385),T=new Float32Array(16385),v=new Float32Array(16385),C=Math.floor(16385/2);for(let q=0;q<16385;q+=1)if(q>C){let H=(q-C)/(16384-C)*c;I[q]=Math.cos(H),S[q]=Math.sin(H),T[q]=0,v[q]=1}else{let H=q/(16384-C)*c;I[q]=1,S[q]=0,T[q]=Math.cos(H),v[q]=Math.sin(H)}let A=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),y=e(f,Z(R({},u),{gain:0})),N=r(f,Z(R({},l),{curve:I})),D=e(f,Z(R({},u),{gain:0})),M=r(f,Z(R({},l),{curve:S})),O=r(f,Z(R({},l),{curve:a})),W=e(f,Z(R({},u),{gain:0})),k=r(f,Z(R({},l),{curve:T})),P=e(f,Z(R({},u),{gain:0})),L=r(f,Z(R({},l),{curve:v}));return{connectGraph(){g.connect(A),g.connect(O.inputs===void 0?O:O.inputs[0]),A.connect(y,0),A.connect(D,0),A.connect(W,1),A.connect(P,1),O.connect(x),x.connect(N.inputs===void 0?N:N.inputs[0]),x.connect(M.inputs===void 0?M:M.inputs[0]),x.connect(k.inputs===void 0?k:k.inputs[0]),x.connect(L.inputs===void 0?L:L.inputs[0]),N.connect(y.gain),M.connect(D.gain),k.connect(W.gain),L.connect(P.gain),y.connect(b,0,0),W.connect(b,0,0),D.connect(b,0,1),P.connect(b,0,1)},disconnectGraph(){g.disconnect(A),g.disconnect(O.inputs===void 0?O:O.inputs[0]),A.disconnect(y,0),A.disconnect(D,0),A.disconnect(W,1),A.disconnect(P,1),O.disconnect(x),x.disconnect(N.inputs===void 0?N:N.inputs[0]),x.disconnect(M.inputs===void 0?M:M.inputs[0]),x.disconnect(k.inputs===void 0?k:k.inputs[0]),x.disconnect(L.inputs===void 0?L:L.inputs[0]),N.disconnect(y.gain),M.disconnect(D.gain),k.disconnect(W.gain),L.disconnect(P.gain),y.disconnect(b,0,0),W.disconnect(b,0,0),D.disconnect(b,0,1),P.disconnect(b,0,1)}}},d=(f,g,x,b,I)=>{if(g===1)return h(f,x,b,I);if(g===2)return p(f,x,b,I);throw i()};return(f,S)=>{var T=S,{channelCount:g,channelCountMode:x,pan:b}=T,I=Nr(T,["channelCount","channelCountMode","pan"]);if(x==="max")throw i();let v=o(f,Z(R({},I),{channelCount:1,channelCountMode:x,numberOfInputs:2})),C=e(f,Z(R({},I),{channelCount:g,channelCountMode:x,gain:1})),A=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:b}),{connectGraph:y,disconnectGraph:N}=d(f,g,C,A,v);Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"maxValue",{get:()=>1}),Object.defineProperty(A.gain,"minValue",{get:()=>-1});let D={get bufferSize(){},get channelCount(){return C.channelCount},set channelCount(k){C.channelCount!==k&&(M&&N(),{connectGraph:y,disconnectGraph:N}=d(f,k,C,A,v),M&&y()),C.channelCount=k},get channelCountMode(){return C.channelCountMode},set channelCountMode(k){if(k==="clamped-max"||k==="max")throw i();C.channelCountMode=k},get channelInterpretation(){return C.channelInterpretation},set channelInterpretation(k){C.channelInterpretation=k},get context(){return C.context},get inputs(){return[C]},get numberOfInputs(){return C.numberOfInputs},get numberOfOutputs(){return C.numberOfOutputs},get pan(){return A.gain},addEventListener(...k){return C.addEventListener(k[0],k[1],k[2])},dispatchEvent(...k){return C.dispatchEvent(k[0])},removeEventListener(...k){return C.removeEventListener(k[0],k[1],k[2])}},M=!1,O=()=>{y(),M=!0},W=()=>{N(),M=!1};return n(Re(D,v),O,W)}};var wp=(o,t,e,r,i,n,s)=>(a,c)=>{let u=a.createWaveShaper();if(n!==null&&n.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=>x=>(g.call(u,x),p&&(r(x)&&h===null?h=o(a,u):!r(x)&&h!==null&&(h(),h=null)),x)),i(u,()=>{p=!0,r(u.curve)&&(h=o(a,u))},()=>{p=!1,h!==null&&(h(),h=null)})};var Tp=(o,t,e,r,i)=>(n,u)=>{var l=u,{curve:s,oversample:a}=l,c=Nr(l,["curve","oversample"]);let h=n.createWaveShaper(),p=n.createWaveShaper();ut(h,c),ut(p,c);let d=e(n,Z(R({},c),{gain:1})),f=e(n,Z(R({},c),{gain:-1})),g=e(n,Z(R({},c),{gain:1})),x=e(n,Z(R({},c),{gain:-1})),b=null,I=!1,S=null,T={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(A){d.channelCount=A,f.channelCount=A,h.channelCount=A,g.channelCount=A,p.channelCount=A,x.channelCount=A},get channelCountMode(){return h.channelCountMode},set channelCountMode(A){d.channelCountMode=A,f.channelCountMode=A,h.channelCountMode=A,g.channelCountMode=A,p.channelCountMode=A,x.channelCountMode=A},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(A){d.channelInterpretation=A,f.channelInterpretation=A,h.channelInterpretation=A,g.channelInterpretation=A,p.channelInterpretation=A,x.channelInterpretation=A},get context(){return h.context},get curve(){return S},set curve(A){if(A!==null&&A.length<2)throw t();if(A===null)h.curve=A,p.curve=A;else{let y=A.length,N=new Float32Array(y+2-y%2),D=new Float32Array(y+2-y%2);N[0]=A[0],D[0]=-A[y-1];let M=Math.ceil((y+1)/2),O=(y+1)/2-1;for(let W=1;W<M;W+=1){let k=W/M*O,P=Math.floor(k),L=Math.ceil(k);N[W]=P===L?A[P]:(1-(k-P))*A[P]+(1-(L-k))*A[L],D[W]=P===L?-A[y-1-P]:-((1-(k-P))*A[y-1-P])-(1-(L-k))*A[y-1-L]}N[M]=y%2===1?A[M-1]:(A[M-2]+A[M-1])/2,h.curve=N,p.curve=D}S=A,I&&(r(S)&&b===null?b=o(n,d):b!==null&&(b(),b=null))},get inputs(){return[d]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(A){h.oversample=A,p.oversample=A},addEventListener(...A){return d.addEventListener(A[0],A[1],A[2])},dispatchEvent(...A){return d.dispatchEvent(A[0])},removeEventListener(...A){return d.removeEventListener(A[0],A[1],A[2])}};s!==null&&(T.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==T.oversample&&(T.oversample=a);let v=()=>{d.connect(h).connect(g),d.connect(f).connect(p).connect(x).connect(g),I=!0,r(S)&&(b=o(n,d))},C=()=>{d.disconnect(h),h.disconnect(g),d.disconnect(f),f.disconnect(p),p.disconnect(x),x.disconnect(g),I=!1,b!==null&&(b(),b=null)};return i(Re(T,g),v,C)};var Zt=()=>new DOMException("","NotSupportedError");var Ug={numberOfChannels:1},Np=(o,t,e,r,i)=>class extends o{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}=R(R({},Ug),u),d=r(h,l,p);t(Ve,()=>Ve(d))||d.addEventListener("statechange",(()=>{let f=0,g=x=>{this._state==="running"&&(f>0?(d.removeEventListener("statechange",g),x.stopImmediatePropagation(),this._waitForThePromiseToSettle(x)):f+=1)};return g})()),super(d,h),this._length=l,this._nativeOfflineAudioContext=d,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,jr(this)}))}_waitForThePromiseToSettle(s){this._state===null?this._nativeOfflineAudioContext.dispatchEvent(s):setTimeout(()=>this._waitForThePromiseToSettle(s))}};var zg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Op=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},zg),u),p=e(l,h),d=n(l),f=d?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,d,p.detune,153600,-153600),this._frequency=t(this,d,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),ne(this)&&tr(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var Rp=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=null,a=null,c=null,u=(l,h)=>X(null,null,function*(){let p=e(l),d=pt(p,h);if(!d){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 n.set(h,p),d?(yield o(h,l.detune,p.detune),yield o(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=n.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Yg={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},Ep=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Yg),u),p=e(l,h),d=n(l),f=d?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,d,p.orientationX,Et,jt),this._orientationY=t(this,d,p.orientationY,Et,jt),this._orientationZ=t(this,d,p.orientationZ,Et,jt),this._positionX=t(this,d,p.positionX,Et,jt),this._positionY=t(this,d,p.positionY,Et,jt),this._positionZ=t(this,d,p.positionZ,Et,jt),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 Mp=(o,t,e,r,i,n,s,a,c,u)=>()=>{let l=new WeakMap,h=null,p=(d,f)=>X(null,null,function*(){let g=null,x=n(d),b={channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation},I=Z(R({},b),{coneInnerAngle:x.coneInnerAngle,coneOuterAngle:x.coneOuterAngle,coneOuterGain:x.coneOuterGain,distanceModel:x.distanceModel,maxDistance:x.maxDistance,panningModel:x.panningModel,refDistance:x.refDistance,rolloffFactor:x.rolloffFactor}),S=pt(x,f);if("bufferSize"in x)g=r(f,Z(R({},b),{gain:1}));else if(!S){let T=Z(R({},I),{orientationX:x.orientationX.value,orientationY:x.orientationY.value,orientationZ:x.orientationZ.value,positionX:x.positionX.value,positionY:x.positionY.value,positionZ:x.positionZ.value});x=i(f,T)}if(l.set(f,g===null?x:g),g!==null){if(h===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let M=new s(6,d.context.length,f.sampleRate),O=t(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});O.connect(M.destination),h=X(null,null,function*(){let W=yield Promise.all([d.orientationX,d.orientationY,d.orientationZ,d.positionX,d.positionY,d.positionZ].map((k,P)=>X(null,null,function*(){let L=e(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P===0?1:0});return yield a(M,k,L.offset),L})));for(let k=0;k<6;k+=1)W[k].connect(O,0,k),W[k].start(0);return u(M)})}let T=yield h,v=r(f,Z(R({},b),{gain:1}));yield c(d,f,v);let C=[];for(let M=0;M<T.numberOfChannels;M+=1)C.push(T.getChannelData(M));let A=[C[0][0],C[1][0],C[2][0]],y=[C[3][0],C[4][0],C[5][0]],N=r(f,Z(R({},b),{gain:1})),D=i(f,Z(R({},I),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:y[0],positionY:y[1],positionZ:y[2]}));v.connect(N).connect(D.inputs[0]),D.connect(g);for(let M=128;M<T.length;M+=128){let O=[C[0][M],C[1][M],C[2][M]],W=[C[3][M],C[4][M],C[5][M]];if(O.some((k,P)=>k!==A[P])||W.some((k,P)=>k!==y[P])){A=O,y=W;let k=M/f.sampleRate;N.gain.setValueAtTime(0,k),N=r(f,Z(R({},b),{gain:0})),D=i(f,Z(R({},I),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:y[0],positionY:y[1],positionZ:y[2]})),N.gain.setValueAtTime(1,k),v.connect(N).connect(D.inputs[0]),D.connect(g)}}return g}return S?(yield o(f,d.orientationX,x.orientationX),yield o(f,d.orientationY,x.orientationY),yield o(f,d.orientationZ,x.orientationZ),yield o(f,d.positionX,x.positionX),yield o(f,d.positionY,x.positionY),yield o(f,d.positionZ,x.positionZ)):(yield a(f,d.orientationX,x.orientationX),yield a(f,d.orientationY,x.orientationY),yield a(f,d.orientationZ,x.orientationZ),yield a(f,d.positionX,x.positionX),yield a(f,d.positionY,x.positionY),yield a(f,d.positionZ,x.positionZ)),Oe(x)?yield c(d,f,x.inputs[0]):yield c(d,f,x),x});return{render(d,f){let g=l.get(f);return g!==void 0?Promise.resolve(g):p(d,f)}}};var Hg={disableNormalization:!1},Dp=(o,t,e,r)=>class kp{constructor(n,s){let a=t(n),c=r(R(R({},Hg),s)),u=o(a,c);return e.add(u),u}static[Symbol.hasInstance](n){return n!==null&&typeof n=="object"&&Object.getPrototypeOf(n)===kp.prototype||e.has(n)}};var Lp=(o,t)=>(e,r,i)=>(o(r).replay(i),t(r,e,i));var jp=(o,t,e)=>(r,i,n)=>X(null,null,function*(){let s=o(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>X(null,[h],function*([u,l]){let d=yield t(u).render(u,i),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&d.connect(n,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var Pp=(o,t,e)=>(r,i,n)=>X(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>X(null,[u],function*([a,c]){let h=yield o(a).render(a,i);e(a)||h.connect(n,c)})))});var Fp=(o,t,e,r)=>i=>o(Ve,()=>Ve(i))?Promise.resolve(o(r,r)).then(n=>{if(!n){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(n=>{let s=t(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),n(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var Bp=o=>(t,e)=>{o.set(t,e)};var Gp=o=>(t,e)=>o.set(t,e);var Vp=(o,t,e,r,i,n,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),Ei(l)):t(n,()=>n(l))||a(l),o.add(l),l));var Qg={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},qp=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=i(a),l=R(R({},Qg),c),h=e(u,l),p=n(u),d=p?r():null;super(a,!1,h,d),this._pan=t(this,p,h.pan)}get pan(){return this._pan}};var Wp=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?yield o(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=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Up=o=>()=>{if(o===null)return!1;try{new o({length:1,sampleRate:44100})}catch(t){return!1}return!0};var zp=(o,t)=>()=>X(null,null,function*(){if(o===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),n=!1,s=!1;try{yield r.audioWorklet.addModule(i);let a=new o(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>n=!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 n&&!s});var Yp=(o,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=o(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{e.oncomplete=()=>{r.disconnect(),i(e.currentTime!==0)},e.startRendering()})};var Cc=()=>new DOMException("","UnknownError");var Zg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Hp=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Zg),u),p=e(l,h),f=n(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 Qp=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=o(s,u)}return r.set(s,a),Oe(a)?yield e(n,s,a.inputs[0]):yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Zp=()=>typeof window=="undefined"?null:window;var Xp=(o,t)=>e=>{e.copyFromChannel=(r,i,n=0)=>{let s=o(n),a=o(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,n=0)=>{let s=o(n),a=o(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 Jp=o=>t=>{t.copyFromChannel=(e=>(r,i,n=0)=>{let s=o(n),a=o(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,i,n=0)=>{let s=o(n),a=o(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var Kp=o=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),o(t,"buffer",i=>()=>{let n=i.call(t);return n===r?null:n},i=>n=>i.call(t,n===null?r:n))};var $p=(o,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw o()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw o()}});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 _c=(o,t,e)=>o.copyFromChannel===void 0?o.getChannelData(e)[0]:(o.copyFromChannel(t,e),t[0]);var vc=o=>{if(o===null)return!1;let t=o.length;return t%2!==0?o[Math.floor(t/2)]!==0:o[t/2-1]+o[t/2]!==0};var Wi=(o,t,e,r)=>{let i=o;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:n,set:s}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(o,t,{get:e(n),set:r(s)})};var td=o=>Z(R({},o),{outputChannelCount:o.outputChannelCount!==void 0?o.outputChannelCount:o.numberOfInputs===1&&o.numberOfOutputs===1?[o.channelCount]:Array.from({length:o.numberOfOutputs},()=>1)});var ed=o=>Z(R({},o),{channelCount:o.numberOfOutputs});var rd=o=>{let{imag:t,real:e}=o;return t===void 0?e===void 0?Z(R({},o),{imag:[0,0],real:[0,0]}):Z(R({},o),{imag:Array.from(e,()=>0),real:e}):e===void 0?Z(R({},o),{imag:t,real:Array.from(t,()=>0)}):Z(R({},o),{imag:t,real:e})};var Ic=(o,t,e)=>{try{o.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;Ic(o,t,e+1e-7)}};var id=o=>{let t=o.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var od=o=>{let t=o.createBufferSource(),e=o.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var nd=o=>{let t=o.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var ns=o=>{let t=o.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Sc=o=>{let t=o.createBuffer(1,1,44100),e=o.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var ss=o=>{let t=o.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var sd=o=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(o)}finally{t.close(),e.close()}};var ad=o=>{o.start=(t=>(e=0,r=0,i)=>{let n=o.buffer,s=n===null?r:Math.min(n.duration,r);n!==null&&s>n.duration-.5/o.context.sampleRate?t.call(o,e,0,0):t.call(o,e,s,i)})(o.start)};var wc=(o,t)=>{let e=t.createGain();o.connect(e);let r=(i=>()=>{i.call(o,e),o.removeEventListener("ended",r)})(o.disconnect);o.addEventListener("ended",r),Re(o,e),o.stop=(i=>{let n=!1;return(s=0)=>{if(n)try{i.call(o,s)}catch(a){e.gain.setValueAtTime(0,s)}else i.call(o,s),n=!0}})(o.stop)};var Kr=(o,t)=>e=>{let r={value:o};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(o,e):t.handleEvent.call(o,e)};var Xg=Ju(Ge),Jg=al(Ge),Kg=rh(kr),ud=new WeakMap,$g=yh(ud),Ee=Pl(new Map,new WeakMap),er=Zp(),ld=Hh(Ee,Ne),Tc=xh(Ht),Xt=jp(Ht,Tc,gr),tx=hl(ld,Ct,Xt),It=Ch(Oi),xr=bp(er),_t=jh(xr),hd=new WeakMap,pd=hh(Kr),Ui=Jh(er),Nc=Mh(Ui),Oc=Dh(er),dd=kh(er),Vo=$h(er),Pt=Nl(Ku(Hn),sl(Xg,Jg,Mi,Kg,Di,Ht,$g,$e,Ct,Ge,ne,gr,ki),Ee,Th(Po,Di,Ht,Ct,Xr,ne),Ne,Fi,Zt,$l(Mi,Po,Ht,Ct,Xr,It,ne,_t),nh(hd,Ht,Vt),pd,It,Nc,Oc,dd,_t,Vo),ex=ll(Pt,tx,Ne,ld,It,_t);var Rc=new WeakSet,cd=Qh(er),md=Hl(new Uint32Array(1)),Ec=Xp(md,Ne),Mc=Jp(md),Dc=pl(Rc,Ee,Zt,cd,xr,Up(cd),Ec,Mc);var as=cl(se),fd=Pp(Tc,Lr,gr),rr=ql(fd),zi=Xh(as,Ee,id,od,nd,ns,Sc,ss,ad,Kp(Wi),wc),ir=Lp(bh(Lr),fd),rx=fl(rr,zi,Ct,ir,Xt),qe=Ol($u(Qn),hd,jo,Rl,ic,oc,nc,sc,ac,Si,Eo,Ui,Ic),ix=ml(Pt,rx,qe,wt,zi,It,_t,Kr);var ox=vl(Pt,Il,Ne,wt,Kh(se,Wi),It,_t,Xt),nx=jl(rr,bc,Ct,ir,Xt),$r=Gp(ud),sx=Ll(Pt,qe,nx,Fi,bc,It,_t,$r),Fr=zh(Ge,Oc),ax=$p(wt,Fr),Br=sp(Ui,ax),cx=Bl(Br,Ct,Xt),ux=Fl(Pt,cx,Br,It,_t),lx=Vl(Vi,Ct,Xt),hx=Gl(Pt,lx,Vi,It,_t,ed),px=up(as,zi,se,Fr),Yi=cp(as,Ee,px,ns,ss),dx=Yl(rr,Yi,Ct,ir,Xt),mx=zl(Pt,qe,dx,Yi,It,_t,Kr),gd=lp(Zt,Wi),fx=Zl(gd,Ct,Xt),gx=Ql(Pt,fx,gd,It,_t,$r),xx=eh(rr,Ac,Ct,ir,Xt),yx=th(Pt,qe,xx,Ac,It,_t,$r),xd=hp(Zt),bx=ch(rr,xd,Ct,ir,Xt),Ax=ah(Pt,qe,bx,xd,Zt,It,_t,$r),Cx=fh(rr,se,Ct,ir,Xt),_x=mh(Pt,qe,Cx,se,It,_t),vx=mp(Fi,wt,qi,Zt),cs=Fp(Ee,se,qi,Yp(se,xr)),Ix=wh(zi,Ct,xr,Xt,cs),Sx=pp(vx),wx=Sh(Pt,Sx,Ix,It,_t,$r),Tx=Sl(qe,Br,Yi,qi,Zt,_c,_t,Wi),yd=new WeakMap,kc=Wh(ox,Tx,pd,_t,yd,Kr),bd=Ap(as,Ee,ns,Sc,ss,wc),Nx=Rp(rr,bd,Ct,ir,Xt),Ox=Op(Pt,qe,bd,Nx,It,_t,Kr),Ad=Ul(zi),Rx=Tp(Ad,wt,se,vc,Fr),us=wp(Ad,wt,Rx,vc,Fr,Ui,Wi),Ex=_p(Mi,wt,Br,se,qi,us,Zt,Di,_c,Fr),Cd=Cp(Ex),Mx=Mp(rr,Br,Yi,se,Cd,Ct,xr,ir,Xt,cs),Dx=Ep(Pt,qe,Cd,Mx,It,_t,$r),kx=vp(Ne),Lx=Dp(kx,It,new WeakSet,rd),jx=Sp(Br,Vi,se,us,Zt,Fr),_d=Ip(jx,Zt),Px=Wp(rr,_d,Ct,ir,Xt),Fx=qp(Pt,qe,_d,Px,It,_t),Bx=Qp(us,Ct,Xt),Gx=Hp(Pt,wt,us,Bx,It,_t,$r),vd=Ph(er),Lc=ph(er),Id=new WeakMap,Vx=_h(Id,xr),qx=vd?nl(Ee,Zt,lh(er),Lc,dh(Xu),It,Vx,_t,Vo,new WeakMap,new WeakMap,zp(Vo,xr),er):void 0,Wx=Lh(Nc,_t),Ux=Kl(Rc,Ee,Jl,uh,new WeakSet,It,Wx,Ri,Ve,Ec,Mc),Sd=kl(qx,ex,Dc,ix,sx,ux,hx,mx,gx,Ux,yx,Ax,_x,wx,kc,Ox,Dx,Lx,Fx,Gx),zx=Fh(Pt,fp,It,_t),Yx=Bh(Pt,gp,It,_t),Hx=Gh(Pt,xp,It,_t),Qx=yp(wt,_t),Zx=Vh(Pt,Qx,It),wd=_l(Sd,wt,Zt,Cc,zx,Yx,Hx,Zx,Ui);var jc=vh(yd),Xx=ul(jc),Td=Wl(Ne),Jx=ih(jc),Nd=sh(Ne),Od=new WeakMap,Kx=gh(Od,Vt),$x=np(Td,Ne,wt,Br,Vi,Yi,se,qi,Zt,Nd,Lc,Kx,Fr),ty=ep(wt,$x,se,Zt,Fr),ey=Dl(rr,Td,zi,Br,Vi,Yi,se,Jx,Nd,Lc,Ct,Vo,xr,ir,Xt,cs),ry=Ah(Id),iy=Bp(Od),Pc=vd?El(Xx,Pt,qe,ey,ty,Ht,ry,It,_t,Vo,td,iy,sd,Kr):void 0;var aq=qh(wt,Zt,Cc,kc,Ui);var Rd=Xl(Zt,xr),Ed=Vp(Rc,Ee,Tc,jc,cs,Ri,Ec,Mc),cq=Uh(Ee,wt,Rd,kc,Ed);var Md=Np(Sd,Ee,wt,Rd,Ed);var Dd=Nh(Oi,Nc),kd=Oh(Ni,Oc),Ld=Rh(jo,dd),jd=Eh(Oi,_t);function Ft(o){return o===void 0}function $(o){return o!==void 0}function Pd(o){return typeof o=="function"}function Jt(o){return typeof o=="number"}function We(o){return Object.prototype.toString.call(o)==="[object Object]"&&o.constructor===Object}function Fc(o){return typeof o=="boolean"}function Nt(o){return Array.isArray(o)}function te(o){return typeof o=="string"}function qo(o){return te(o)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(o)}function G(o,t){if(!o)throw new Error(t)}function Mt(o,t,e=1/0){if(!(t<=o&&o<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${o}`)}function ls(o){!o.isOffline&&o.state!=="running"&&ti('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Bd=!1,Fd=!1;function Bc(o){Bd=o}function Gd(o){Ft(o)&&Bd&&!Fd&&(Fd=!0,ti("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var Vd=console;function qd(...o){Vd.log(...o)}function ti(...o){Vd.warn(...o)}function Wd(o){return new wd(o)}function Ud(o,t,e){return new Md(o,t,e)}var ee=typeof self=="object"?self:null,zd=ee&&(ee.hasOwnProperty("AudioContext")||ee.hasOwnProperty("webkitAudioContext"));function Yd(o,t,e){return G($(Pc),"AudioWorkletNode only works in a secure context (https or localhost)"),new(o instanceof(ee==null?void 0:ee.BaseAudioContext)?ee==null?void 0:ee.AudioWorkletNode:Pc)(o,t,e)}function re(o,t,e,r){var i=arguments.length,n=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,t,e,r);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(n=(i<3?s(n):i>3?s(t,e,n):s(t,e))||n);return i>3&&n&&Object.defineProperty(t,e,n),n}function ht(o,t,e,r){function i(n){return n instanceof e?n:new e(function(s){s(n)})}return new(e||(e=Promise))(function(n,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?n(l.value):i(l.value).then(a,c)}u((r=r.apply(o,t||[])).next())})}var hs=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 v3.2.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
|
+
"use strict";var WebMusicScore=(()=>{var Fn=Object.defineProperty,_m=Object.defineProperties,vm=Object.getOwnPropertyDescriptor,Im=Object.getOwnPropertyDescriptors,Sm=Object.getOwnPropertyNames,Pn=Object.getOwnPropertySymbols;var Da=Object.prototype.hasOwnProperty,xu=Object.prototype.propertyIsEnumerable;var yu=Math.pow,Ea=(o,t,e)=>t in o?Fn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,R=(o,t)=>{for(var e in t||(t={}))Da.call(t,e)&&Ea(o,e,t[e]);if(Pn)for(var e of Pn(t))xu.call(t,e)&&Ea(o,e,t[e]);return o},Z=(o,t)=>_m(o,Im(t));var Rr=(o,t)=>{var e={};for(var r in o)Da.call(o,r)&&t.indexOf(r)<0&&(e[r]=o[r]);if(o!=null&&Pn)for(var r of Pn(o))t.indexOf(r)<0&&xu.call(o,r)&&(e[r]=o[r]);return e};var _i=(o,t)=>{for(var e in t)Fn(o,e,{get:t[e],enumerable:!0})},wm=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sm(t))!Da.call(o,i)&&i!==e&&Fn(o,i,{get:()=>t[i],enumerable:!(r=vm(t,i))||r.enumerable});return o};var Tm=o=>wm(Fn({},"__esModule",{value:!0}),o);var m=(o,t,e)=>Ea(o,typeof t!="symbol"?t+"":t,e);var X=(o,t,e)=>new Promise((r,i)=>{var n=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(n,s);a((e=e.apply(o,t)).next())});var ub={};_i(ub,{Audio:()=>tn,Core:()=>Ba,Pieces:()=>gu,Score:()=>fu,Theory:()=>Ja});var tn={};_i(tn,{getCurrentInstrument:()=>Ey,getInstrumentList:()=>My,playNote:()=>js,registerInstrument:()=>Dy,setInstrument:()=>pm,stop:()=>eu});var Ja={};_i(Ja,{AccidentalType:()=>Va,Chord:()=>Wa,DefaultGuitarNoteLabel:()=>Wf,DefaultHandedness:()=>fg,DefaultPitchNotation:()=>Vf,DefaultTuningName:()=>xg,GuitarNoteLabel:()=>Gn,GuitarNoteLabelList:()=>Uf,Handedness:()=>za,Interval:()=>No,KeySignature:()=>Fe,MaxNoteLength:()=>Hu,MinNoteLength:()=>Si,Mode:()=>Ga,Note:()=>V,NoteLength:()=>Gt,PitchNotation:()=>Er,PitchNotationList:()=>Gf,RhythmProps:()=>$t,Scale:()=>jr,ScaleFactory:()=>Yt,ScaleType:()=>Ke,SymbolSet:()=>Mr,TimeSignature:()=>dr,TuningNameList:()=>Oo,alterTempoSpeed:()=>Xa,getDefaultKeySignature:()=>Vn,getDefaultScale:()=>ag,getDefaultTempo:()=>zn,getDefaultTimeSignature:()=>Un,getPitchNotationName:()=>qf,getScale:()=>kr,getScaleFactory:()=>Uu,getScaleFactoryList:()=>ng,getTempoString:()=>Za,getTuningStrings:()=>Wn,validateGuitarNoteLabel:()=>zf,validateHandedness:()=>gg,validateIntervalQuality:()=>tg,validateNoteLength:()=>Qu,validatePitchNotation:()=>ju,validateScaleType:()=>qa,validateTuningName:()=>Ya});var Au=Object.defineProperty,Nm=(o,t,e)=>t in o?Au(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,hr=(o,t)=>{for(var e in t)Au(o,e,{get:t[e],enumerable:!0})},Je=(o,t,e)=>Nm(o,typeof t!="symbol"?t+"":t,e),_={};hr(_,{Arr:()=>Cu,Dom:()=>Su,Enum:()=>wu,Is:()=>Tu,Map:()=>Ou,Math:()=>_u,Obj:()=>Ru,Str:()=>Mu});var Cu={};hr(Cu,{arrayContains:()=>zm,chunckArray:()=>Ym,duplicate:()=>Bm,fillArray:()=>qm,getRangeArray:()=>Um,getSequenceArray:()=>Wm,isArray:()=>ja,mapRangeArray:()=>Iu,mapSequenceArray:()=>vu,removeDuplicates:()=>Gm,removeDuplicatesCmp:()=>Vm,toArray:()=>Fm});var _u={};hr(_u,{calcNormal:()=>Lm,clamp:()=>jm,interpolateCoord:()=>Dm,interpolateY:()=>km,isInteger:()=>we,linearToDecibels:()=>Om,mod:()=>Rm,romanize:()=>Mm,sum:()=>Pm,toOrdinalNumber:()=>Em});function we(o){return typeof o=="number"&&isFinite(o)&&o===Math.trunc(o)}function Om(o){if(isFinite(o))return o<=0?-1/0:20*Math.log10(o);throw new Error("linearToDecibel: Invalid linearVolume = "+o)}function Rm(o,t){return(o%t+t)%t}function Mm(o){if(!we(o)||o<0)throw new Error("romanize: Invalid n = "+o);for(var t=String(+o).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 Em(o){if(!we(o))throw new Error("toOrdinalNumber: Invalid n = "+o);let t=o.toString(),e=Number(t.charAt(t.length-1));return o===1||o>=20&&e===1?t+"st":o===2||o>=20&&e===2?t+"nd":o===3||o>=20&&e===3?t+"rd":t+"th"}function Dm(o,t,e,r,i){return{x:o+(e-o)*i,y:t+(r-t)*i}}function km(o,t,e,r,i){let n=(i-o)/(e-o);return t+(r-t)*n}function jm(o,t,e){return Math.min(Math.max(o,t),e)}function Lm(o,t,e,r){let i=e-o,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 Pm(o){return o.reduce((t,e)=>e+t,0)}function ja(o){return!!o&&Object.prototype.toString.call(o)==="[object Array]"}function Fm(o){return ja(o)?o:[o]}function Bm(o){return o===void 0?o:o.slice()}function Gm(o){return o.filter((t,e,r)=>r.indexOf(t)===e)}function Vm(o,t){return o.filter((e,r,i)=>r===i.findIndex(n=>t(e,n)))}function qm(o,t){if(!we(t)||t<0)throw new Error("fillArray: Invalid fillCount = "+t);return new Array(t).fill(o)}function vu(o,t){if(!we(o)||o<0)throw new Error("mapSequenceArray: Invalid len = "+o);let e=new Array(o);for(let r=0;r<o;r++)e[r]=t(r);return e}function Wm(o){return vu(o,t=>t)}function Iu(o,t,e){if(!we(o))throw new Error("mapRangeArray: Invalid start = "+t);if(!we(t))throw new Error("mapRangeArray: Invalid end = "+t);let r=Math.abs(t-o)+1,i=new Array(r);for(let n=0,s=o,a=Math.sign(t-o);n<r;s+=a,n++)i[n]=e(s);return i}function Um(o,t){return Iu(o,t,e=>e)}function zm(o,t){return o.indexOf(t)>=0}function Ym(o,t){if(!we(t)||t<1)throw new Error("chunckArray: Invalid chunckSize = "+t);let e=[];for(let r=0;r<o.length;r+=t)e.push(o.slice(r,r+t));return e}var Su={};hr(Su,{addClass:()=>Hm,appendTo:()=>ef,getButton:()=>sf,getCanvas:()=>af,getCanvasTextWidth:()=>hf,getDimension:()=>uf,getHeight:()=>$m,getOffset:()=>Xm,getPadding:()=>cf,getWidth:()=>Jm,hasClass:()=>La,removeClass:()=>Qm,removeFromParent:()=>rf,setHeight:()=>tf,setOffset:()=>Zm,setRect:()=>nf,setVisibility:()=>of,setWidth:()=>Km,styleLayoutChanged:()=>lf});var wu={};hr(wu,{getEnumValues:()=>Bn});function Bn(o){return Object.keys(o).filter(t=>Number.isNaN(Number(t))).map(t=>o[t])}var ka;(o=>{let t=Error;function e(y){t=y!=null?y:Error}o.setErrorClass=e;function r(y,N){throw new t("Assertion Error: "+y+(N?" "+N:""))}function i(y){return typeof y=="number"&&isFinite(y)&&y===Math.trunc(y)}function n(y){return typeof y=="number"}function s(y,N){y||r(N!=null?N:"Assertion failed!")}o.assert=s;function a(y,N,D="value"){if(!Bn(N).some(E=>E===y))throw new TypeError(`Invalid ${D} enum value: ${y}`)}o.assertEnum=a;function c(y){r(y!=null?y:"Interrupted!")}o.interrupt=c;function u(y,N){return i(y)||r(`Expected ${y} to be integer.`,N),y}o.int=u;function l(y,N,D){return y!==N&&r(`Expected ${y} to equal ${N}.`,D),y}o.eq=l;function h(y,N,D){return i(y)&&n(N)&&y===N||r(`Expected ${y} to be integer equal to ${N}.`,D),y}o.int_eq=h;function p(y,N,D){return i(y)&&n(N)&&y<N||r(`Expected ${y} to be integer less than ${N}.`,D),y}o.int_lt=p;function d(y,N,D){return i(y)&&n(N)&&y<=N||r(`Expected ${y} to be integer less than or equal to ${N}.`,D),y}o.int_lte=d;function f(y,N,D){return i(y)&&n(N)&&y>N||r(`Expected ${y} to be integer greater than ${N}.`,D),y}o.int_gt=f;function g(y,N,D){return i(y)&&n(N)&&y>=N||r(`Expected ${y} to be integer greater than or equal to ${N}.`,D),y}o.int_gte=g;function x(y,N,D,E){return i(y)&&n(N)&&n(D)&&y>=N&&y<=D||r(`Expected ${y} to be integer between ${N} and ${D}.`,E),y}o.int_between=x;function b(y,N){return i(y)&&y%2===1||r(`Expected ${y} to be odd number.`,N),y}o.odd=b;function I(y,N){return i(y)&&y%2===0||r(`Expected ${y} to be even number.`,N),y}o.even=I;function S(y,N,D){if(!N.some(E=>E===y)){let E=N.map(O=>String(O)).join(", ");r(`Expected ${y} to be in group [${E}].`,D)}return y}o.in_group=S;function T(y,N){return n(y)&&isFinite(y)||r(`Expected ${y} to be finite number.`,N),y}o.finite=T;function v(y,N,D){return i(N)&&N>=0&&N<y.length||r(`Expected ${N} to be array index in bounds [0..${y.length-1}].`,D),N}o.array_id=v;function C(y,N,D){return y[v(y,N,D)]}o.array_elem=C;function A(y,N){if(y===void 0)r("Required value is undefined.",N);else return y}o.require=A})(ka||(ka={}));var wo;(o=>{function t(){let p=document.createElement("div");p.style.width="1in",document.body.appendChild(p);let d=p.offsetWidth;return p.remove(),d||96}function e(){try{let p=document.createElement("div");p.style.visibility="hidden",p.style.width="100px",document.body.appendChild(p);let d=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),d-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 d=p.offsetHeight;return document.body.removeChild(p),d}function i(){if("ontouchstart"in window||"DocumentTouch"in window||"createTouch"in document&&"createTouchList"in document)return!0;var p=" -webkit- -moz- -o- -ms- ".split(" "),d=function(g){return window.matchMedia(g).matches},f=["(",p.join("touch-enabled),("),"heartz",")"].join("");return d(f)}function n(){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\\.]+)(.*)$/;o.DPI=t(),o.PxPerMm=o.DPI/25.4,o.ScrollbarWidth=e(),o.FontSize=r(),o.IsTouchDevice=i(),o.IsMobileDevice=n(),o.HostAddress=s();function u(p){return p/o.PxPerMm}o.pxToMm=u;function l(p){return p*o.PxPerMm}o.mmToPx=l;function h(p){if(typeof p=="number")return p;let d=NaN,f,g=p.toString().match(c);if(g&&g[1]){d=parseFloat(g[1]);let x=g[2]?g[2].toLowerCase():"undefined";f=a.test(x)?x:void 0,f||console.log("Unknown unit '"+x+"' => using 'px'.")}else d=parseFloat(p);switch(ka.finite(d,"value in function toPx"),f){case"mm":return l(d);case"cm":return l(d)*10;case"in":case"inch":return l(d)*25.4;case"em":return o.FontSize*d;default:case"px":return d}}o.toPx=h})(wo||(wo={}));function It(o){return o===void 0?void 0:wo.toPx(o)}function La(o,t){return t.length===0?!1:o.classList?o.classList.contains(t):!!o.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function Hm(o,t){t.length!==0&&(o.classList?o.classList.add(t):La(o,t)||(o.className+=" "+t))}function Qm(o,t){if(t.length!==0){if(o.classList)o.classList.remove(t);else if(La(o,t)){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");o.className=o.className.replace(e," ")}}}function Zm(o,t,e,r="px"){o.style.left=t+r,o.style.top=e+r}function Xm(o){let t=o.getBoundingClientRect(),e=document.documentElement;return{top:t.top+window.pageYOffset-e.clientTop,left:t.left+window.pageXOffset-e.clientLeft}}function Jm(o){if(o instanceof Window)return o.innerWidth;{let t=parseFloat(getComputedStyle(o,null).width.replace("px",""));return isNaN(t)?0:t}}function Km(o,t){o.style.width=t+"px"}function $m(o){if(o instanceof Window)return o.innerHeight;{let t=parseFloat(getComputedStyle(o,null).height.replace("px",""));return isNaN(t)?0:t}}function tf(o,t){o.style.height=t+"px"}function ef(o,t){t.appendChild(o)}function rf(o){o.remove()}function of(o,t){o.style.display=t?"block":"none"}function nf(o,t,e,r,i,n="px"){o.style.left=t+n,o.style.top=e+n,o.style.width=r+n,o.style.height=i+n}function sf(o){let t=typeof o=="string"?document.getElementById(o):o;return t instanceof HTMLButtonElement?t:void 0}function af(o){let t=typeof o=="string"?document.getElementById(o):o;return t instanceof HTMLCanvasElement?t:void 0}function cf(o){var s;if(!o)return{top:0,right:0,bottom:0,left:0};let t=It(o.paddingTop),e=It(o.paddingRight),r=It(o.paddingBottom),i=It(o.paddingLeft),n=((s=o.padding)!=null?s:"").toString().split(" ").filter(a=>a.length>0);switch(n.length){case 0:break;case 1:t!=null||(t=It(n[0])),e!=null||(e=It(n[0])),r!=null||(r=It(n[0])),i!=null||(i=It(n[0]));break;case 2:t!=null||(t=It(n[0])),e!=null||(e=It(n[1])),r!=null||(r=It(n[0])),i!=null||(i=It(n[1]));break;case 3:t!=null||(t=It(n[0])),e!=null||(e=It(n[1])),r!=null||(r=It(n[2])),i!=null||(i=It(n[1]));break;case 4:default:t!=null||(t=It(n[0])),e!=null||(e=It(n[1])),r!=null||(r=It(n[2])),i!=null||(i=It(n[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 uf(o){let t=It(o==null?void 0:o.left),e=It(o==null?void 0:o.right),r=It(o==null?void 0:o.top),i=It(o==null?void 0:o.bottom),n=It(o==null?void 0:o.width),s=It(o==null?void 0:o.height);return n===void 0&&t!==void 0&&e!==void 0&&(n=e-t),s===void 0&&r!==void 0&&i!==void 0&&(s=i-r),{left:t,top:r,width:n,height:s}}function lf(o,t){return!o&&!t?!1:!o||!t?!0:o.left!==t.left||o.top!==t.top||o.right!==t.right||o.bottom!==t.bottom||o.width!==t.width||o.height!==t.height}var Io;function hf(o,t){Io!=null||(Io=document.createElement("canvas"));let e=Io.getContext("2d");return e?(e.font=t,e.measureText(o).width):0}var Tu={};hr(Tu,{isArray:()=>Pa,isArrayOrUndefined:()=>ff,isBoolean:()=>yf,isBooleanOrUndefined:()=>bf,isEnumValue:()=>If,isEnumValueOrUndefined:()=>Sf,isFunction:()=>Af,isFunctionOrUndefined:()=>Cf,isInteger:()=>vi,isIntegerEq:()=>wf,isIntegerGt:()=>Tf,isIntegerGte:()=>Nf,isIntegerLt:()=>Of,isIntegerLte:()=>Rf,isNull:()=>df,isNumber:()=>_f,isNumberOrUndefined:()=>vf,isObject:()=>Nu,isObjectOrUndefined:()=>mf,isString:()=>gf,isStringOrUndefined:()=>xf,isUndefined:()=>pf});function pf(o){return o===void 0}function df(o){return o===null}function Nu(o){return typeof o=="object"&&o!==null&&!Pa(o)}function mf(o){return o===void 0||Nu(o)}function Pa(o){return!!o&&Object.prototype.toString.call(o)==="[object Array]"}function ff(o){return o===void 0||Pa(o)}function gf(o){return typeof o=="string"}function xf(o){return o===void 0||typeof o=="string"}function yf(o){return typeof o=="boolean"}function bf(o){return o===void 0||typeof o=="boolean"}function Af(o){return typeof o=="function"}function Cf(o){return o===void 0||typeof o=="function"}function _f(o){return typeof o=="number"}function vf(o){return o===void 0||typeof o=="number"}function If(o,t,e="value"){return Bn(t).some(r=>r===o)}function Sf(o,t,e="value"){return o===void 0||Bn(t).some(r=>r===o)}function vi(o){return typeof o=="number"&&isFinite(o)&&o===Math.trunc(o)}function wf(o,t){return vi(o)&&o===t}function Tf(o,t){return vi(o)&&o>t}function Nf(o,t){return vi(o)&&o>=t}function Of(o,t){return vi(o)&&o<t}function Rf(o,t){return vi(o)&&o<=t}var Ou={};hr(Ou,{getMapKeys:()=>Mf});function Mf(o){let t=[];return o.forEach((e,r)=>t.push(r)),t}var Ru={};hr(Ru,{isObject:()=>Ef});function Ef(o){return typeof o=="object"&&o!==null&&!ja(o)}var Mu={};hr(Mu,{chunkString:()=>jf,insertAt:()=>Lf,makeSentenceFromPascal:()=>Ff,removeAt:()=>Pf,repeatString:()=>kf,replaceAt:()=>Fa,toCharArray:()=>Df});function Df(o){return o.split("")}function kf(o,t){if(!we(t)||t<0)throw new Error("repeatStr: Invalid repeatCount = "+t);return new Array(t+1).join(o)}function jf(o,t){if(!we(t)||t<1)throw new Error("chunckString: Invalid chuckSize = "+t);let e=[];for(let r=0;r<o.length;r+=t)e.push(o.slice(r,r+t));return e}function Fa(o,t,e,r){if(!we(e)||e<0)throw new Error("replaceAt: Invalid removeCount = "+e);if(!we(t)||t<0||t+e>o.length)throw new Error("replaceAt: Invalid pos = "+t+", removeCount = "+e+", str.length = "+o.length);return o.substring(0,t)+r+o.substring(t+e)}function Lf(o,t,e){return Fa(o,t,0,e)}function Pf(o,t,e){return Fa(o,t,e,"")}function Ff(o){if(o==="")return"";let t=o.charAt(0),e="",r=()=>{t!==""&&(e===""?e+=t.charAt(0).toUpperCase()+t.substring(1):e+=" "+t,t="")},i=n=>n.toUpperCase()!==n.toLowerCase()&&n===n.toUpperCase();for(let n=1;n<o.length;n++){let s=o.charAt(n);i(s)&&r(),t+=s.toLowerCase()}return r(),e}var bu;(o=>{let t="ConsentCookie",e;(T=>{T.Accept="accept",T.Decline="decline"})(e||(e={}));let r,i,n=p(t);r=n==="accept"||n==="decline"?n:void 0;function s(T){i=new Date,i.setDate(i.getDate()+T)}o.setExpireDays=s;function a(){return r===void 0}o.isConsentPending=a;function c(){r="accept",h(t,r)}o.accept=c;function u(){r="decline",h(t,r)}o.decline=u;function l(){return document.cookie.split(";").map(v=>v.trim())}function h(T,v){let C=T+"="+v.toString()+";sameSite=Lax;";return i&&(C+="expires="+i.toUTCString()+";"),document.cookie=C,v}function p(T,v){let C=l().find(A=>A.startsWith(T+"="));return C===void 0?v:C.substring(T.length+1)}function d(T){document.cookie=T+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"}function f(T,v){return r==="accept"&&h(T,v),v}o.save=f;function g(T,v){return r==="accept"&&p(T,v)||v}o.read=g;function x(T,v){if(r==="accept"){let C=p(T);return C===void 0?v:parseInt(C)}else return v}o.readInt=x;function b(T,v){if(r==="accept"){let C=p(T);return C===void 0?v:/true|1/i.test(C)}else return v}o.readBool=b;function I(T){(r==="accept"||T===t)&&d(T)}o.erase=I;function S(){document.cookie.split(";").forEach(T=>I(T.trim().split("=")[0]))}o.eraseAll=S})(bu||(bu={}));var Eu=class So{constructor(t,e){Je(this,"x"),Je(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 So(this.x+t.x,this.y+t.y)}sub(t){return new So(this.x-t.x,this.y-t.y)}mul(t){return new So(this.x*t,this.y*t)}div(t){return new So(this.x/t,this.y/t)}},Du=class{constructor(o,t=1/0){Je(this,"cache"),Je(this,"next"),Je(this,"prev"),Je(this,"head"),Je(this,"tail"),Je(this,"capacity"),Je(this,"size"),Je(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=o,this.size=0,this.maxKeyLength=t}get(o){if(!(o.length>this.maxKeyLength)&&this.cache[o]!==void 0)return this.touch(o),this.cache[o]}set(o,t){if(!(o.length>this.maxKeyLength)){if(this.cache[o]!==void 0){this.cache[o]=t,this.touch(o);return}this.size>=this.capacity&&this.evict(),this.cache[o]=t,this.addToTail(o),this.size++}}touch(o){this.tail!==o&&(this.removeKey(o),this.addToTail(o))}evict(){if(this.head!==null){let o=this.head;this.removeKey(o),delete this.cache[o],this.size--}}removeKey(o){let t=this.prev[o],e=this.next[o];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[o],delete this.next[o]}addToTail(o){this.tail!==null?(this.next[this.tail]=o,this.prev[o]=this.tail):this.head=o,this.tail=o}};var Ba={};_i(Ba,{MusicError:()=>M,MusicErrorType:()=>gt,init:()=>Xr});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 Bf(o){return o===void 0?"":`[${gt[o]}] `}var M=class extends Error{constructor(...e){let[r,i]=e.length===1?[0,e[0]]:e;super(Bf(r)+i);m(this,"type");Object.setPrototypeOf(this,new.target.prototype),this.name="MusicError",this.type=r}};var ku=!1;function Xr(){ku||(ku=!0,console.log("%cWebMusicScore v3.2.0 (iife) initialized.","background: black; color: white; padding: 2px;"))}var Mr=(e=>(e[e.Ascii=0]="Ascii",e[e.Unicode=1]="Unicode",e))(Mr||{}),Er=(e=>(e[e.Scientific=0]="Scientific",e[e.Helmholtz=1]="Helmholtz",e))(Er||{}),Gf=_.Enum.getEnumValues(Er),Vf=0;function ju(o){if(_.Is.isEnumValue(o,Er))return o;throw new M(1,`Invalid pitchNotation: ${o}`)}function qf(o){return Er[ju(o)]}var Gn=(r=>(r.Default="Default",r.OmitOctave="Omit Octave",r.Interval="Interval",r))(Gn||{}),Wf="Default",Uf=_.Enum.getEnumValues(Gn);function zf(o){if(_.Is.isEnumValue(o,Gn))return o;throw new M(5,`Invalid guitarNoteLabel: ${o}`)}function Lu(o,t){return(o%t+t)%t}var Pu=12,Fu=7,Yf=new Map([[-2,"bb"],[-1,"b"],[0,""],[1,"#"],[2,"x"]]),Hf=new Map([[-2,"\u{1D12B}"],[-1,"\u266D"],[0,""],[1,"\u266F"],[2,"\u{1D12A}"]]),Bu=new Map([["",0],["bb",-2],["b",-1],["#",1],["x",2],["\u{1D12B}",-2],["\u266D",-1],["\u266F",1],["\u{1D12A}",2]]),To=["C","D","E","F","G","A","B"],Gu=[0,2,4,5,7,9,11],Vu=/^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/,st=class st{constructor(t,e,r){m(this,"diatonicClass");m(this,"accidental");m(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 M(2,`Invalid args: ${t}, ${e}, ${r}`)}get diatonicId(){return st.getDiatonicIdInOctave(this.diatonicClass,this.octave)}get chromaticId(){return st.getChromaticIdInOctave(Gu[this.diatonicClass]+this.accidental,this.octave)}get midiNumber(){return this.chromaticId}get chromaticClass(){return st.getChromaticClass(Gu[this.diatonicClass]+this.accidental)}get noteLetter(){return To[this.diatonicClass]}format(t,e){let{noteLetter:r,octave:i}=this,n=st.getAccidentalSymbol(this.accidental,e);return t===1?i>=3?r.toLowerCase()+n+"\u2032".repeat(i-3):r.toUpperCase()+n+"\u0375".repeat(2-i):r+n+i}formatOmitOctave(t){let e=To[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 M(2,`Invalid noteName: ${t}`);if(r.octave===void 0)throw new M(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),n=st.parseNote(i);if(!n)throw new M(2,`Invalid noteName: ${i}`);if(n.octave===void 0)throw new M(2,"Octave is required for note.");e=new st(n.noteLetter,n.accidental,n.octave),this.chromaticNoteCache.set(t,e)}return e}static getDiatonicClass(t){if(typeof t=="number")return Lu(t,7);if(typeof t=="string"&&t.length>0)return To.indexOf(st.validateNoteLetter(t[0]));throw new M(2,`Invalid arg: ${t}`)}static getOctaveFromDiatonicId(t){return Math.floor((t-Fu)/7)}static getDiatonicIdInOctave(t,e){return st.getDiatonicClass(t)+e*7+Fu}static getChromaticClass(t){return Lu(t,12)}static getOctaveFromChromaticId(t){return Math.floor((t-Pu)/12)}static getChromaticIdInOctave(t,e){return st.getChromaticClass(t)+e*12+Pu}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 Vu.test(t)}static parseNote(t){var c;let e=Vu.exec(t);if(!e)return;let r=st.validateNoteLetter(e[1]),i=e[2],n=st.validateAccidental((c=Bu.get(i))!=null?c:0),s=e[3],a=s?st.validateOctave(+s):void 0;return{noteLetter:r,accidental:n,octave:a}}static getScientificNoteName(t,e){let r=st.parseNote(t);if(!r)throw new M(2,`Invalid noteName: ${t}`);let{noteLetter:i,accidental:n,octave:s}=r;return i+st.getAccidentalSymbol(n,e)+(s!=null?s:"")}static getAccidentalSymbol(t,e){return e===1?Hf.get(t):Yf.get(t)}static getAccidental(t){let e=Bu.get(t);if(e===void 0)throw new M(2,`Invalid accidental: ${t}`);return e}static getNoteLetter(t){return To[st.getDiatonicClass(t)]}static findNextDiatonicIdAbove(t,e,r){let i=st.getDiatonicClass(t),n=st.getDiatonicClass(e),s=r?i<=n?1:0:i<n?1:0;return st.getDiatonicIdInOctave(i,st.getOctaveFromDiatonicId(e)+s)}static validateDiatonicId(t){if(_.Is.isInteger(t))return t;throw new M(2,`Invalid diatonicId: ${t}`)}static validateDiatonicClass(t){if(_.Is.isInteger(t)&&t>=0&&t<7)return t;throw new M(2,`Invalid diatonicClass: ${t}`)}static validateChromaticId(t){if(_.Is.isInteger(t))return t;throw new M(2,`Invalid chromaticId: ${t}`)}static validatechromaticClass(t){if(_.Is.isInteger(t)&&t>=0&&t<12)return t;throw new M(2,`Invalid chromaticClass: ${t}`)}static validateNoteLetter(t){if(To.some(e=>e===t))return t;throw new M(2,`Invalid note: ${t}`)}static validateOctave(t){if(_.Is.isInteger(t))return t;throw new M(2,`Invalid octave: ${t}`)}static validateAccidental(t){if(_.Is.isInteger(t)&&t>=-2&&t<=2)return t;throw new M(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}};m(st,"noteByNameCache",new Map),m(st,"chromaticNoteCache",new Map);var V=st;function Qf(o,t){let e=V.getChromaticClass(o)-new V(t,0).chromaticClass;for(;e>2;)e-=12;for(;e<-2;)e+=12;return V.validateAccidental(e)}var Zf=/^(bb?|b?|#?|x?)([0-9]*)$/;function Xf(o){var i,n;let t=Zf.exec(""+o);if(!t)throw new M(4,`Invalid degree: ${o}`);let e=(n=V.getAccidental((i=t[1])!=null?i:""))!=null?n:0,r=+t[2];if(!_.Is.isInteger(e)||e<-2||e>2||!_.Is.isInteger(r)||r<1)throw new M(4,`Invalid degree: ${o}`);return{deg:r,acc:e}}var Ga=(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))(Ga||{}),Va=(r=>(r[r.Natural=0]="Natural",r[r.Flats=1]="Flats",r[r.Sharps=2]="Sharps",r))(Va||{});function Vn(){return kr("C","Major")}var Dr=class Dr{constructor(t,e){this.tonic=t;this.mode=e;m(this,"naturalScaleNotes");m(this,"accidentalByDiatonicClass");m(this,"orderedAccidentedNotes");if(!_.Is.isEnumValue(e,Ga))throw new M(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=V.getDiatonicClass(t[0]),n=V.getNote(t+"0").chromaticId;for(let c=0;c<7;i++,n+=r[c],c++){let u=new V(V.getDiatonicClass(i),Qf(n,i));if(Math.abs(u.accidental)>=2)throw new M(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=Dr.OrderOfSharps.indexOf(c.noteLetter),h=Dr.OrderOfSharps.indexOf(u.noteLetter);if(l===-1||h===-1)throw new M(4,"Unexpected note in key signature.");return l-h}),a=this.naturalScaleNotes.filter(c=>c.accidental<0).sort((c,u)=>{let l=Dr.OrderOfFlats.indexOf(c.noteLetter),h=Dr.OrderOfFlats.indexOf(u.noteLetter);if(l===-1||h===-1)throw new M(4,"Unexpected note in key signature.");return l-h});if(s.length!==0&&a.length!==0)throw new M(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[V.getDiatonicClass(t)])!=null?e:0}getNumAccidentals(){return this.orderedAccidentedNotes.length}getOrderedAccidentalNotes(){return this.orderedAccidentedNotes}getNoteByDegree(t){let{deg:e,acc:r}=Xf(t);if(r===0)return this.naturalScaleNotes[(e-1)%7];{let i=this.naturalScaleNotes[(e-1)%7];return new V(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}};m(Dr,"OrderOfSharps","FCGDAEB"),m(Dr,"OrderOfFlats","BEADGCF");var Fe=Dr;var Jf=new Map([["Major","M"],["minor","m"],["Perfect","P"],["diminished","d"],["Augmented","A"],["doubly diminished","dd"],["Doubly Augmented","AA"]]),Kf={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 $f(o,t){for(;o<1;)o+=7,t+=12;for(;o>8;)o-=7,t-=12;let e=Kf[o];if(e)return e[t]}function tg(o){if(o==="Perfect"||o==="Major"||o==="minor"||o==="Augmented"||o==="diminished"||o==="Doubly Augmented"||o==="doubly diminished")return o;throw new M(1,`Invalid interval quality: ${o}`)}function eg(o){if(_.Is.isIntegerGte(o,1))return _.Math.toOrdinalNumber(o);throw new M(1,`Invalid interval quantity: ${o}`)}var qn=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidInterval"}},No=class o{constructor(t,e){this.note1=t;this.note2=e;m(this,"direction");m(this,"semitones");m(this,"quantity");m(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=$f(this.quantity,this.semitones);if(r)this.quality=r;else throw new qn("Unknown interval quality")}static get(t,e){try{return new o(t,e)}catch(r){if(r instanceof qn)return;throw r}}toString(){let t=this.direction==="Unison"?"":this.direction+" ",e=this.quality+" ",r=this.direction==="Unison"?"Unison":eg(this.quantity);return t+e+r}toAbbrString(){var i;let t=this.direction==="Descending"?"\u2193":"",e=(i=Jf.get(this.quality))!=null?i:"?",r=this.quantity;return t+e+r}};function rg(o){let t=V.getDiatonicClass("CCDDEFFGGAAB"[V.getChromaticClass(o)]),e=V.getOctaveFromChromaticId(o);return V.getDiatonicIdInOctave(t,e)}var ig=["Cb","C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#"],Ke=(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))(Ke||{});function og(o){switch(o){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 M(3,`Invalid scaleType: ${o}`)}}var jr=class extends Fe{constructor(e,r){super(e,og(r));this.tonic=e;this.scaleType=r;m(this,"scaleDegrees");m(this,"scaleNotes");m(this,"chromaticClassDegree");m(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 n=this.scaleNotes.findIndex(s=>s.chromaticClass===i);return n>=0?this.scaleDegrees[n]: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 V.getScientificNoteName(this.tonic,e)+" "+this.scaleType;default:return this.tonic+" "+this.scaleType}}getScaleNotes(e,r){if(!_.Is.isIntegerGte(r,1))throw new M(3,`Invalid numOctaves: ${r}`);let i=[];for(let s=1;s<=r;s++)i=[...i,...this.scaleNotes];i.push(this.scaleNotes[0]);let n=V.getNote(e).diatonicId;return i.map(s=>(n=V.findNextDiatonicIdAbove(s.diatonicId,n,!1),new V(n,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(_.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 V(e.diatonicClass,e.accidental,e.octave-1);if(e.chromaticId<r.chromaticId)throw new M(3,"Note is below rootNote.");let i=No.get(r,e);if(i===void 0)throw new M(3,"Interval is undefined.");return i}getPreferredChromaticNote(e){V.validateChromaticId(e);let r=this.preferredChromaticNoteCache.get(e);if(r)return r;let i=V.getOctaveFromChromaticId(e);if(r=this.scaleNotes.map(h=>h.noteLetter==="C"&&h.accidental<0?new V(h.diatonicClass,h.accidental,i+1):h.noteLetter==="B"&&h.accidental>0?new V(h.diatonicClass,h.accidental,i-1):new V(h.diatonicClass,h.accidental,i)).find(h=>V.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 d=Math.max(0,a);d<=c;d++)if(r=new V(d,p),e===r.chromaticId)return this.preferredChromaticNoteCache.set(e,r),r}return r=V.getChromaticNote(e),this.preferredChromaticNoteCache.set(e,r),r}},Yt=class{constructor(t){this.type=t;m(this,"tonicList",[]);m(this,"scaleMap",new Map);let e=[],r=[],i=[];if(ig.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 M(3,"Expected natural scale.");let n=(s,a)=>s.getNumAccidentals()-a.getNumAccidentals();this.tonicList=[...e.sort(n).map(s=>s.tonic),"- Sharps -",...r.sort(n).map(s=>s.tonic),"- Flats -",...i.sort(n).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 M(3,`Invalid scale: ${t} ${this.type}`)}hasScale(t){return this.scaleMap.get(t)!==void 0}},qu=[new Yt("Major"),new Yt("Natural Minor"),new Yt("Harmonic Minor"),"- Modes -",new Yt("Ionian"),new Yt("Dorian"),new Yt("Phrygian"),new Yt("Lydian"),new Yt("Mixolydian"),new Yt("Aeolian"),new Yt("Locrian"),"- Pentatonic -",new Yt("Major Pentatonic"),new Yt("Minor Pentatonic"),"- Blues -",new Yt("Major Hexatonic Blues"),new Yt("Minor Hexatonic Blues"),new Yt("Heptatonic Blues")];function ng(){return qu}var Wu=new Map;qu.forEach(o=>{o instanceof Yt&&Wu.set(o.getType(),o)});function Uu(o){let t=Wu.get(o);if(t)return t;throw new M(3,`Invalid scaleType: ${o}`)}function qa(o){if(_.Is.isEnumValue(o,Ke))return o;throw new M(3,`Invalid scaleType: ${o}`)}function kr(o,t){return Uu(t).getScale(o)}var sg=kr("C","Major");function ag(){return sg}var pr=(o,t)=>o.chromaticClass===t.chromaticClass,cg=["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"].map(o=>V.getNote(o+"0")),zu=new Map;function ug(o){let t=o.chromaticClass,e=zu.get(t);if(!e){if(e=cg.find(r=>pr(r,o)),!e)throw new M(1,`Invalid chord root note: ${o.formatOmitOctave(1)}`);zu.set(t,e)}return e}function lg(o,t){let e=o.formatOmitOctave(0);return kr(e,"Major").getNoteByDegree(t)}function hg(o){return _.Arr.removeDuplicatesCmp(o,pr)}var pg=[{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 dg(o,t){return o.degrees.every(e=>e!==t)?!0:o.degrees.length>=4&&t===5||o.degrees.length>=6&&t===9||o.degrees.length>=7&&t===11}var Ii=class extends Error{constructor(e){super(e);this.msg=e;this.name="InvalidChordException"}},Wa=class o{constructor(t,e,r,i){this.chordInfo=t;this.rootNote=r;m(this,"name");m(this,"notes");m(this,"omitNotes");m(this,"slashBassNote");this.name=t.name;let n=e.slice();!n.some(a=>pr(a,i))&&n.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=n.findIndex(h=>pr(h,u));if(l>=0)this.omitNotes[a]=!1,n.splice(l,1);else if(dg(t,c))this.omitNotes[a]=!0;else throw new Ii("Missing chord note!");pr(i,u)&&(i=u)}if(n.length>0)if(n.every(a=>pr(a,i)))this.slashBassNote=i;else throw new Ii("Got some extra notes that are not bass note!");else this.slashBassNote=pr(i,this.rootNote)?void 0:i;if(t.name==="5"&&this.slashBassNote)throw new Ii("Power chord no bass note allowed!")}static getChords(t){let e=[],r=V.sort(t),i=r[0],n=hg(r);for(let s=0;s<n.length;s++){let a=ug(n[s]);pg.forEach(c=>{try{let u=new o(c,n,a,i),l=e.findIndex(h=>h.replaceWith(u));l>=0?e[l]=u:e.push(u)}catch(u){if(!(u instanceof Ii))throw u}})}return e}replaceWith(t){if(t.notes.length<this.notes.length)return!1;if(t.slashBassNote&&this.slashBassNote&&!pr(t.slashBassNote,this.slashBassNote)||t.slashBassNote&&!this.slashBassNote||!t.slashBassNote&&this.slashBassNote)return!1;for(let e=0;e<this.notes.length;e++)if(!pr(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,n)=>this.getDegreeStr(n)+"("+(i?"-":this.getNoteStr(n))+")").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 V.replaceAccidentalSymbols(""+this.chordInfo.degrees[t],1)}getNoteStr(t){return this.notes[t].formatOmitOctave(1)}};var Ua={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 za=(e=>(e[e.RightHanded=0]="RightHanded",e[e.LeftHanded=1]="LeftHanded",e))(za||{}),fg=0;function gg(o){if(_.Is.isEnumValue(o,za))return o;throw new M(1,`Invalid handedness: ${o}`)}var Oo=Ua.list.map(o=>o.name),xg=Oo[0];function Ya(o){if(Oo.indexOf(o)<0)throw new M(1,`Invalid tuning name: ${o}`);return o}var Yu=new Du(100);function Wn(o){let t=Yu.get(o);if(!t){let e=Ua.list.find(r=>r.name===o);if(!e)throw new M(1,`Invalid tuningName: ${o}`);if(t=e.strings.slice().reverse().map(r=>V.getNote(r)),!_.Is.isIntegerEq(t.length,6))throw new M(0,`Tuning has ${t.length} strings.`);Yu.set(o,t)}return t}var Gt=(a=>(a[a.Whole=192]="Whole",a[a.Half=96]="Half",a[a.Quarter=48]="Quarter",a[a.Eighth=24]="Eighth",a[a.Sixteenth=12]="Sixteenth",a[a.ThirtySecond=6]="ThirtySecond",a[a.SixtyFourth=3]="SixtyFourth",a))(Gt||{}),Hu=192,Si=3,yg=new Map([[192,0],[96,0],[48,0],[24,1],[12,2],[6,3],[3,4]]),bg=new Map([[192,"\u{1D15D}"],[96,"\u{1D15E}"],[48,"\u{1D15F}"],[24,"\u{1D160}"],[12,"\u{1D161}"],[6,"\u{1D162}"],[3,"\u{1D163}"]]);function Qu(o){if(_.Is.isEnumValue(o,Gt))return o;throw new M(1,`Invalid noteLength: ${o}`)}var $t=class o{constructor(t,e,r){m(this,"noteLength");m(this,"dotted");m(this,"triplet");m(this,"ticks");m(this,"flagCount");var i;if(this.noteLength=Qu(t),this.dotted=e===!0,this.triplet=r===!0,this.ticks=this.noteLength,this.flagCount=(i=yg.get(this.noteLength))!=null?i:0,this.dotted&&this.triplet)throw new M(2,"Note cannot be both dotted and triplet!");if(this.dotted&&this.noteLength===Si)throw new M(2,"Shortest note cannot be dotted!");this.dotted&&(this.ticks+=this.noteLength/2),this.triplet&&(this.ticks=this.ticks*2/3)}static createFromNoteSize(t){return new o(Hu/t)}canDot(){return!this.dotted&&this.noteLength!==Si}hasStem(){return this.noteLength<192}toString(){return bg.get(this.noteLength)+(this.dotted?".":"")}};var dr=class{constructor(...t){m(this,"beatCount");m(this,"beatSize");m(this,"beatLength");m(this,"measureTicks");m(this,"beamGroupCount");m(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 M(5,`Invalid args: ${t}`);if(_.Is.isIntegerGte(this.beatCount,1)){if(!_.Is.isIntegerGte(this.beatSize,1))throw new M(5,`Invalid beatSize: ${this.beatSize}`)}else throw new M(5,`Invalid beatCount: ${this.beatCount}`);let e=$t.createFromNoteSize(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,!_.Is.isIntegerGte(this.beamGroupLength,1))throw new M(5,`Invalid beamGroupLength: ${this.beamGroupLength}`)}is(t,e){return this.beatCount===t&&this.beatSize===e}toString(){return this.beatCount+"/"+this.beatSize}},Ha;function Un(){return Ha||(Ha=new dr(4,4)),Ha}var Qa;function zn(){return Qa||(Qa={beatsPerMinute:120,options:{beatLength:48,dotted:!1}}),Qa}function Za(o){return new $t(o.options.beatLength,o.options.dotted).toString()+"="+o.beatsPerMinute}function Xa(o,t){return{beatsPerMinute:o.beatsPerMinute*t,options:{beatLength:o.options.beatLength,dotted:o.options.dotted}}}Xr();var Ro="15.1.22";var Ka=(o,t,e)=>({endTime:t,insertTime:e,type:"exponentialRampToValue",value:o});var $a=(o,t,e)=>({endTime:t,insertTime:e,type:"linearRampToValue",value:o});var wi=(o,t)=>({startTime:t,type:"setValue",value:o});var Mo=(o,t,e)=>({duration:e,startTime:t,type:"setValueCurve",values:o});var Yn=(o,t,{startTime:e,target:r,timeConstant:i})=>r+(t-r)*Math.exp((e-o)/i);var mr=o=>o.type==="exponentialRampToValue";var Jr=o=>o.type==="linearRampToValue";var Be=o=>mr(o)||Jr(o);var Ti=o=>o.type==="setValue";var Te=o=>o.type==="setValueCurve";var Ni=(o,t,e,r)=>{let i=o[t];return i===void 0?r:Be(i)||Ti(i)?i.value:Te(i)?i.values[i.values.length-1]:Yn(e,Ni(o,t-1,i.startTime,r),i)};var tc=(o,t,e,r,i)=>e===void 0?[r.insertTime,i]:Be(e)?[e.endTime,e.value]:Ti(e)?[e.startTime,e.value]:Te(e)?[e.startTime+e.duration,e.values[e.values.length-1]]:[e.startTime,Ni(o,t-1,e.startTime,i)];var Eo=o=>o.type==="cancelAndHold";var Do=o=>o.type==="cancelScheduledValues";var fr=o=>Eo(o)||Do(o)?o.cancelTime:mr(o)||Jr(o)?o.endTime:o.startTime;var ec=(o,t,e,{endTime:r,value:i})=>e===i?i:0<e&&0<i||e<0&&i<0?e*yu(i/e,(o-t)/(r-t)):0;var rc=(o,t,e,{endTime:r,value:i})=>e+(o-t)/(r-t)*(i-e);var Zu=(o,t)=>{let e=Math.floor(t),r=Math.ceil(t);return e===r?o[e]:(1-(t-e))*o[e]+(1-(r-t))*o[r]};var Xu=(o,{duration:t,startTime:e,values:r})=>{let i=(o-e)/t*(r.length-1);return Zu(r,i)};var ko=o=>o.type==="setTarget";var jo=class{constructor(t){this._automationEvents=[],this._currenTime=0,this._defaultValue=t}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(t){let e=fr(t);if(Eo(t)||Do(t)){let r=this._automationEvents.findIndex(n=>Do(t)&&Te(n)?n.startTime+n.duration>=e:fr(n)>=e),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),Eo(t)){let n=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Be(i)){if(n!==void 0&&ko(n))throw new Error("The internal list is malformed.");let s=n===void 0?i.insertTime:Te(n)?n.startTime+n.duration:fr(n),a=n===void 0?this._defaultValue:Te(n)?n.values[n.values.length-1]:n.value,c=mr(i)?ec(e,s,a,i):rc(e,s,a,i),u=mr(i)?Ka(c,e,this._currenTime):$a(c,e,this._currenTime);this._automationEvents.push(u)}if(n!==void 0&&ko(n)&&this._automationEvents.push(wi(this.getValue(e),e)),n!==void 0&&Te(n)&&n.startTime+n.duration>e){let s=e-n.startTime,a=(n.values.length-1)/n.duration,c=Math.max(2,1+Math.ceil(s*a)),u=s/(c-1)*a,l=n.values.slice(0,c);if(u<1)for(let h=1;h<c;h+=1){let p=u*h%1;l[h]=n.values[h-1]*(1-p)+n.values[h]*p}this._automationEvents[this._automationEvents.length-1]=Mo(l,n.startTime,s)}}}else{let r=this._automationEvents.findIndex(s=>fr(s)>e),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&Te(i)&&fr(i)+i.duration>e)return!1;let n=mr(t)?Ka(t.value,t.endTime,this._currenTime):Jr(t)?$a(t.value,e,this._currenTime):t;if(r===-1)this._automationEvents.push(n);else{if(Te(t)&&e+t.duration>fr(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,n)}}return!0}flush(t){let e=this._automationEvents.findIndex(r=>fr(r)>t);if(e>1){let r=this._automationEvents.slice(e-1),i=r[0];ko(i)&&r.unshift(wi(Ni(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=>fr(s)>t),r=this._automationEvents[e],i=(e===-1?this._automationEvents.length:e)-1,n=this._automationEvents[i];if(n!==void 0&&ko(n)&&(r===void 0||!Be(r)||r.insertTime>t))return Yn(t,Ni(this._automationEvents,i-1,n.startTime,this._defaultValue),n);if(n!==void 0&&Ti(n)&&(r===void 0||!Be(r)))return n.value;if(n!==void 0&&Te(n)&&(r===void 0||!Be(r)||n.startTime+n.duration>t))return t<n.startTime+n.duration?Xu(t,n):n.values[n.values.length-1];if(n!==void 0&&Be(n)&&(r===void 0||!Be(r)))return n.value;if(r!==void 0&&mr(r)){let[s,a]=tc(this._automationEvents,i,n,r,this._defaultValue);return ec(t,s,a,r)}if(r!==void 0&&Jr(r)){let[s,a]=tc(this._automationEvents,i,n,r,this._defaultValue);return rc(t,s,a,r)}return this._defaultValue}};var ic=o=>({cancelTime:o,type:"cancelAndHold"});var oc=o=>({cancelTime:o,type:"cancelScheduledValues"});var nc=(o,t)=>({endTime:t,type:"exponentialRampToValue",value:o});var sc=(o,t)=>({endTime:t,type:"linearRampToValue",value:o});var ac=(o,t,e)=>({startTime:t,target:o,timeConstant:e,type:"setTarget"});var Ju=()=>new DOMException("","AbortError");var Ku=o=>(t,e,[r,i,n],s)=>{o(t[i],[e,r,n],a=>a[0]===e&&a[1]===r,s)};var $u=o=>(t,e,r)=>{let i=[];for(let n=0;n<r.numberOfInputs;n+=1)i.push(new Set);o.set(t,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:e})};var tl=o=>(t,e)=>{o.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})};var $e=new WeakSet,Hn=new WeakMap,Oi=new WeakMap,Qn=new WeakMap,Lo=new WeakMap,Ri=new WeakMap,Zn=new WeakMap,Po=new WeakMap,Fo=new WeakMap,Bo=new WeakMap;var el={construct(){return el}},rl=o=>{try{let t=new Proxy(o,el);new t}catch(t){return!1}return!0};var il=/^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]*);?/,cc=(o,t)=>{let e=[],r=o.replace(/^[\s]+/,""),i=r.match(il);for(;i!==null;){let n=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(n,new URL(n,t).toString());e.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(il)}return[e.join(";"),r]};var ol=o=>{if(o!==void 0&&!Array.isArray(o))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},nl=o=>{if(!rl(o))throw new TypeError("The given value for processorCtor should be a constructor.");if(o.prototype===null||typeof o.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},sl=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>{let d=0;return(f,g,x={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 v=I.get(g);if(v!==void 0)return v}let S=n(f),T=S.audioWorklet===void 0?i(g).then(([v,C])=>{let[A,y]=cc(v,C),N=`${A};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${y}
|
|
3
|
+
})})(window,'_AWGS')`;return e(N)}).then(()=>{let v=p._AWGS.pop();if(v===void 0)throw new SyntaxError;r(S.currentTime,S.sampleRate,()=>v(class{},void 0,(C,A)=>{if(C.trim()==="")throw t();let y=Fo.get(S);if(y!==void 0){if(y.has(C))throw t();nl(A),ol(A.parameterDescriptors),y.set(C,A)}else nl(A),ol(A.parameterDescriptors),Fo.set(S,new Map([[C,A]]))},S.sampleRate,void 0,void 0))}):Promise.all([i(g),Promise.resolve(o(h,h))]).then(([[v,C],A])=>{let y=d+1;d=y;let[N,D]=cc(v,C),k=`${N};((AudioWorkletProcessor,registerProcessor)=>{${D}
|
|
4
|
+
})(${A?"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{${A?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${A?"":"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${y}',class extends AudioWorkletProcessor{process(){return !1}})`,P=new Blob([k],{type:"application/javascript; charset=utf-8"}),j=URL.createObjectURL(P);return S.audioWorklet.addModule(j,x).then(()=>{if(a(S))return S;let q=s(S);return q.audioWorklet.addModule(j,x).then(()=>q)}).then(q=>{if(c===null)throw new SyntaxError;try{new c(q,`__sac${y}`)}catch(H){throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(j))});return I===void 0?u.set(f,new Map([[g,T]])):I.set(g,T),T.then(()=>{let v=l.get(f);v===void 0?l.set(f,new Set([g])):v.add(g)}).finally(()=>{let v=u.get(f);v!==void 0&&v.delete(g)}),T}};var Vt=(o,t)=>{let e=o.get(t);if(e===void 0)throw new Error("A value with the given key could not be found.");return e};var Lr=(o,t)=>{let e=Array.from(o).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 o.delete(r),r};var Xn=(o,t,e,r)=>{let i=Vt(o,t),n=Lr(i,s=>s[0]===e&&s[1]===r);return i.size===0&&o.delete(t),n};var tr=o=>Vt(Zn,o);var Ge=o=>{if($e.has(o))throw new Error("The AudioNode is already stored.");$e.add(o),tr(o).forEach(t=>t(!0))};var Jn=o=>"port"in o;var er=o=>{if(!$e.has(o))throw new Error("The AudioNode is not stored.");$e.delete(o),tr(o).forEach(t=>t(!1))};var Go=(o,t)=>{!Jn(o)&&t.every(e=>e.size===0)&&er(o)};var al=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>{let d=new WeakMap;return(f,g,x,b,I)=>{let{activeInputs:S,passiveInputs:T}=n(g),{outputs:v}=n(f),C=a(f),A=y=>{let N=c(g),D=c(f);if(y){let E=Xn(T,f,x,b);o(S,f,E,!1),!I&&!h(f)&&e(D,N,x,b),p(g)&&Ge(g)}else{let E=r(S,f,x,b);t(T,b,E,!1),!I&&!h(f)&&i(D,N,x,b);let O=s(g);if(O===0)l(g)&&Go(g,S);else{let W=d.get(g);W!==void 0&&clearTimeout(W),d.set(g,setTimeout(()=>{l(g)&&Go(g,S)},O*1e3))}}};return u(v,[g,x,b],y=>y[0]===g&&y[1]===x&&y[2]===b,!0)?(C.add(A),l(f)?o(S,f,[x,b,A],!0):t(T,b,[f,x,A],!0),!0):!1}};var cl=o=>(t,e,[r,i,n],s)=>{let a=t.get(r);a===void 0?t.set(r,new Set([[i,e,n]])):o(a,[i,e,n],c=>c[0]===i&&c[1]===e,s)};var ul=o=>(t,e)=>{let r=o(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 ll=o=>(t,e)=>{o(t).add(e)};var Ag={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},hl=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=i(a),l=R(R({},Ag),c),h=r(u,l),p=n(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=(o,t)=>o.context===t;var pl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);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=o(s,u)}return r.set(s,a),yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Mi=o=>{try{o.copyToChannel(new Float32Array(1),0,-1)}catch(t){return!1}return!0};var Ne=()=>new DOMException("","IndexSizeError");var Ei=o=>{o.getChannelData=(t=>e=>{try{return t.call(o,e)}catch(r){throw r.code===12?Ne():r}})(o.getChannelData)};var Cg={numberOfChannels:1},dl=(o,t,e,r,i,n,s,a)=>{let c=null;return class ml{constructor(l){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");let{length:h,numberOfChannels:p,sampleRate:d}=R(R({},Cg),l);c===null&&(c=new i(1,1,44100));let f=r!==null&&t(n,n)?new r({length:h,numberOfChannels:p,sampleRate:d}):c.createBuffer(p,h,d);if(f.numberOfChannels===0)throw e();return typeof f.copyFromChannel!="function"?(s(f),Ei(f)):t(Mi,()=>Mi(f))||a(f),o.add(f),f}static[Symbol.hasInstance](l){return l!==null&&typeof l=="object"&&Object.getPrototypeOf(l)===ml.prototype||o.has(l)}}};var Lt=-34028234663852886e22,Et=-Lt;var ne=o=>$e.has(o);var _g={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},fl=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=R(R({},_g),l),d=i(h,p),f=s(h),g=f?t():null;super(u,!1,d,g),this._audioBufferSourceNodeRenderer=g,this._isBufferNullified=!1,this._isBufferSet=p.buffer!==null,this._nativeAudioBufferSourceNode=d,this._onended=null,this._playbackRate=e(this,f,d.playbackRate,Et,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),ne(this)&&er(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",p)}}stop(u=0){this._nativeAudioBufferSourceNode.stop(u),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=u)}};var gl=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=null,a=null,c=(u,l)=>X(null,null,function*(){let h=e(u),p=pt(h,l);if(!p){let d={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,d),s!==null&&h.start(...s),a!==null&&h.stop(a)}return n.set(l,h),p?yield o(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=n.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var xl=o=>"playbackRate"in o;var yl=o=>"frequency"in o&&"gain"in o;var bl=o=>"offset"in o;var Al=o=>!("frequency"in o)&&"gain"in o;var Cl=o=>"detune"in o&&"frequency"in o&&!("gain"in o);var _l=o=>"pan"in o;var Ht=o=>Vt(Hn,o);var Pr=o=>Vt(Qn,o);var Kn=(o,t)=>{let{activeInputs:e}=Ht(o);e.forEach(i=>i.forEach(([n])=>{t.includes(o)||Kn(n,[...t,o])}));let r=xl(o)?[o.playbackRate]:Jn(o)?Array.from(o.parameters.values()):yl(o)?[o.Q,o.detune,o.frequency,o.gain]:bl(o)?[o.offset]:Al(o)?[o.gain]:Cl(o)?[o.detune,o.frequency]:_l(o)?[o.pan]:[];for(let i of r){let n=Pr(i);n!==void 0&&n.activeInputs.forEach(([s])=>Kn(s,t))}ne(o)&&er(o)};var Fr=o=>{Kn(o.destination,[])};var $n=o=>o===void 0||typeof o=="number"||typeof o=="string"&&(o==="balanced"||o==="interactive"||o==="playback");var vl=(o,t,e,r,i,n,s,a,c)=>class extends o{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(!$n(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:d}=h;if(this._baseLatency=typeof h.baseLatency=="number"?h.baseLatency:p==="balanced"?512/d:p==="interactive"||p===void 0?256/d:p==="playback"?1024/d:Math.max(2,Math.min(128,Math.round(p*d/128)))*128/d,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 n(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 Il=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=s(h),d=i(h,l,p),f=p?t(a):null;super(u,!1,d,f),this._isNodeOfNativeOfflineAudioContext=p,this._nativeAudioDestinationNode=d}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 Sl=o=>{let t=new WeakMap,e=(r,i)=>X(null,null,function*(){let n=i.destination;return t.set(i,n),yield o(r,i,n),n});return{render(r,i){let n=t.get(i);return n!==void 0?Promise.resolve(n):e(r,i)}}};var wl=(o,t,e,r,i,n,s,a)=>(c,u)=>{let l=u.listener,h=()=>{let v=new Float32Array(1),C=t(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),A=s(u),y=!1,N=[0,0,-1,0,1,0],D=[0,0,0],E=()=>{if(y)return;y=!0;let P=r(u,256,9,0);P.onaudioprocess=({inputBuffer:j})=>{let q=[n(j,v,0),n(j,v,1),n(j,v,2),n(j,v,3),n(j,v,4),n(j,v,5)];q.some((Q,et)=>Q!==N[et])&&(l.setOrientation(...q),N=q);let H=[n(j,v,6),n(j,v,7),n(j,v,8)];H.some((Q,et)=>Q!==D[et])&&(l.setPosition(...H),D=H)},C.connect(P)},O=P=>j=>{j!==N[P]&&(N[P]=j,l.setOrientation(...N))},W=P=>j=>{j!==D[P]&&(D[P]=j,l.setPosition(...D))},k=(P,j,q)=>{let H=e(u,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:j});H.connect(C,0,P),H.start(),Object.defineProperty(H.offset,"defaultValue",{get(){return j}});let Q=o({context:c},A,H.offset,Et,Lt);return a(Q,"value",et=>()=>et.call(Q),et=>at=>{try{et.call(Q,at)}catch(yt){if(yt.code!==9)throw yt}E(),A&&q(at)}),Q.cancelAndHoldAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.cancelAndHoldAtTime),Q.cancelScheduledValues=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.cancelScheduledValues),Q.exponentialRampToValueAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.exponentialRampToValueAtTime),Q.linearRampToValueAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.linearRampToValueAtTime),Q.setTargetAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.setTargetAtTime),Q.setValueAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.setValueAtTime),Q.setValueCurveAtTime=(et=>A?()=>{throw i()}:(...at)=>{let yt=et.apply(Q,at);return E(),yt})(Q.setValueCurveAtTime),Q};return{forwardX:k(0,0,O(0)),forwardY:k(1,0,O(1)),forwardZ:k(2,-1,O(2)),positionX:k(6,0,W(0)),positionY:k(7,0,W(1)),positionZ:k(8,0,W(2)),upX:k(3,0,O(3)),upY:k(4,1,O(4)),upZ:k(5,0,O(5))}},{forwardX:p,forwardY:d,forwardZ:f,positionX:g,positionY:x,positionZ:b,upX:I,upY:S,upZ:T}=l.forwardX===void 0?h():l;return{get forwardX(){return p},get forwardY(){return d},get forwardZ(){return f},get positionX(){return g},get positionY(){return x},get positionZ(){return b},get upX(){return I},get upY(){return S},get upZ(){return T}}};var Kr=o=>"context"in o;var Br=o=>Kr(o[0]);var Ve=(o,t,e,r)=>{for(let i of o)if(e(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return o.add(t),!0};var uc=(o,t,[e,r],i)=>{Ve(o,[t,e,r],n=>n[0]===t&&n[1]===e,i)};var lc=(o,[t,e,r],i)=>{let n=o.get(t);n===void 0?o.set(t,new Set([[e,r]])):Ve(n,[e,r],s=>s[0]===e,i)};var Oe=o=>"inputs"in o;var Di=(o,t,e,r)=>{if(Oe(t)){let i=t.inputs[r];return o.connect(i,e,0),[i,e,0]}return o.connect(t,e,r),[t,e,r]};var hc=(o,t,e)=>{for(let r of o)if(r[0]===t&&r[1]===e)return o.delete(r),r;return null};var Tl=(o,t,e)=>Lr(o,r=>r[0]===t&&r[1]===e);var pc=(o,t)=>{if(!tr(o).delete(t))throw new Error("Missing the expected event listener.")};var dc=(o,t,e)=>{let r=Vt(o,t),i=Lr(r,n=>n[0]===e);return r.size===0&&o.delete(t),i};var ki=(o,t,e,r)=>{Oe(t)?o.disconnect(t.inputs[r],e,0):o.disconnect(t,e,r)};var Ct=o=>Vt(Oi,o);var $r=o=>Vt(Lo,o);var gr=o=>Po.has(o);var ji=o=>!$e.has(o);var mc=(o,t)=>new Promise(e=>{if(t!==null)e(!0);else{let r=o.createScriptProcessor(256,1,1),i=o.createGain(),n=o.createBuffer(1,2,44100),s=n.getChannelData(0);s[0]=1,s[1]=1;let a=o.createBufferSource();a.buffer=n,a.loop=!0,a.connect(r).connect(o.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(o.destination)},a.start()}});var ts=(o,t)=>{let e=new Map;for(let r of o)for(let i of r){let n=e.get(i);e.set(i,n===void 0?1:n+1)}e.forEach((r,i)=>t(i,r))};var ti=o=>"context"in o;var Nl=o=>{let t=new Map;o.connect=(e=>(r,i=0,n=0)=>{let s=ti(r)?e(r,i,n):e(r,i),a=t.get(r);return a===void 0?t.set(r,[{input:n,output:i}]):a.every(c=>c.input!==n||c.output!==i)&&a.push({input:n,output:i}),s})(o.connect.bind(o)),o.disconnect=(e=>(r,i,n)=>{if(e.apply(o),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!==n||n===void 0));a.length===0?t.delete(r):t.set(r,a)}}for(let[s,a]of t)a.forEach(c=>{ti(s)?o.connect(s,c.output,c.input):o.connect(s,c.output)})})(o.disconnect)};var vg=(o,t,e,r)=>{let{activeInputs:i,passiveInputs:n}=Pr(t),{outputs:s}=Ht(o),a=tr(o),c=u=>{let l=Ct(o),h=$r(t);if(u){let p=dc(n,o,e);uc(i,o,p,!1),!r&&!gr(o)&&l.connect(h,e)}else{let p=Tl(i,o,e);lc(n,p,!1),!r&&!gr(o)&&l.disconnect(h,e)}};return Ve(s,[t,e],u=>u[0]===t&&u[1]===e,!0)?(a.add(c),ne(o)?uc(i,o,[e,c],!0):lc(n,[o,e,c],!0),!0):!1},Ig=(o,t,e,r)=>{let{activeInputs:i,passiveInputs:n}=Ht(t),s=hc(i[r],o,e);return s===null?[Xn(n,o,e,r)[2],!1]:[s[2],!0]},Sg=(o,t,e)=>{let{activeInputs:r,passiveInputs:i}=Pr(t),n=hc(r,o,e);return n===null?[dc(i,o,e)[1],!1]:[n[2],!0]},fc=(o,t,e,r,i)=>{let[n,s]=Ig(o,e,r,i);if(n!==null&&(pc(o,n),s&&!t&&!gr(o)&&ki(Ct(o),Ct(e),r,i)),ne(e)){let{activeInputs:a}=Ht(e);Go(e,a)}},gc=(o,t,e,r)=>{let[i,n]=Sg(o,e,r);i!==null&&(pc(o,i),n&&!t&&!gr(o)&&Ct(o).disconnect($r(e),r))},wg=(o,t)=>{let e=Ht(o),r=[];for(let i of e.outputs)Br(i)?fc(o,t,...i):gc(o,t,...i),r.push(i[0]);return e.outputs.clear(),r},Tg=(o,t,e)=>{let r=Ht(o),i=[];for(let n of r.outputs)n[1]===e&&(Br(n)?fc(o,t,...n):gc(o,t,...n),i.push(n[0]),r.outputs.delete(n));return i},Ng=(o,t,e,r,i)=>{let n=Ht(o);return Array.from(n.outputs).filter(s=>s[0]===e&&(r===void 0||s[1]===r)&&(i===void 0||s[2]===i)).map(s=>(Br(s)?fc(o,t,...s):gc(o,t,...s),n.outputs.delete(s),s[0]))},Ol=(o,t,e,r,i,n,s,a,c,u,l,h,p,d,f,g)=>class extends u{constructor(b,I,S,T){super(S),this._context=b,this._nativeAudioNode=S;let v=l(b);h(v)&&e(mc,()=>mc(v,g))!==!0&&Nl(S),Oi.set(this,S),Zn.set(this,new Set),b.state!=="closed"&&I&&Ge(this),o(this,T,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 T=l(this._context),v=f(T);if(p(b)||d(b))throw n();if(Kr(b)){let y=Ct(b);try{let D=Di(this._nativeAudioNode,y,I,S),E=ji(this);(v||E)&&this._nativeAudioNode.disconnect(...D),this.context.state!=="closed"&&!E&&ji(b)&&Ge(b)}catch(D){throw D.code===12?n():D}if(t(this,b,I,S,v)){let D=c([this],b);ts(D,r(v))}return b}let C=$r(b);if(C.name==="playbackRate"&&C.maxValue===1024)throw s();try{this._nativeAudioNode.connect(C,I),(v||ji(this))&&this._nativeAudioNode.disconnect(C,I)}catch(y){throw y.code===12?n():y}if(vg(this,b,I,v)){let y=c([this],b);ts(y,r(v))}}disconnect(b,I,S){let T,v=l(this._context),C=f(v);if(b===void 0)T=wg(this,C);else if(typeof b=="number"){if(b<0||b>=this.numberOfOutputs)throw i();T=Tg(this,C,b)}else{if(I!==void 0&&(I<0||I>=this.numberOfOutputs)||Kr(b)&&S!==void 0&&(S<0||S>=b.numberOfInputs))throw i();if(T=Ng(this,C,b,I,S),T.length===0)throw n()}for(let A of T){let y=c([this],A);ts(y,a)}}};var Rl=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>(d,f,g,x=null,b=null)=>{let I=g.value,S=new jo(I),T=f?r(S):null,v={get defaultValue(){return I},get maxValue(){return x===null?g.maxValue:x},get minValue(){return b===null?g.minValue:b},get value(){return g.value},set value(C){g.value=C,v.setValueAtTime(C,d.context.currentTime)},cancelAndHoldAtTime(C){if(typeof g.cancelAndHoldAtTime=="function")T===null&&S.flush(d.context.currentTime),S.add(i(C)),g.cancelAndHoldAtTime(C);else{let A=Array.from(S).pop();T===null&&S.flush(d.context.currentTime),S.add(i(C));let y=Array.from(S).pop();g.cancelScheduledValues(C),A!==y&&y!==void 0&&(y.type==="exponentialRampToValue"?g.exponentialRampToValueAtTime(y.value,y.endTime):y.type==="linearRampToValue"?g.linearRampToValueAtTime(y.value,y.endTime):y.type==="setValue"?g.setValueAtTime(y.value,y.startTime):y.type==="setValueCurve"&&g.setValueCurveAtTime(y.values,y.startTime,y.duration))}return v},cancelScheduledValues(C){return T===null&&S.flush(d.context.currentTime),S.add(n(C)),g.cancelScheduledValues(C),v},exponentialRampToValueAtTime(C,A){if(C===0)throw new RangeError;if(!Number.isFinite(A)||A<0)throw new RangeError;let y=d.context.currentTime;return T===null&&S.flush(y),Array.from(S).length===0&&(S.add(u(I,y)),g.setValueAtTime(I,y)),S.add(s(C,A)),g.exponentialRampToValueAtTime(C,A),v},linearRampToValueAtTime(C,A){let y=d.context.currentTime;return T===null&&S.flush(y),Array.from(S).length===0&&(S.add(u(I,y)),g.setValueAtTime(I,y)),S.add(a(C,A)),g.linearRampToValueAtTime(C,A),v},setTargetAtTime(C,A,y){return T===null&&S.flush(d.context.currentTime),S.add(c(C,A,y)),g.setTargetAtTime(C,A,y),v},setValueAtTime(C,A){return T===null&&S.flush(d.context.currentTime),S.add(u(C,A)),g.setValueAtTime(C,A),v},setValueCurveAtTime(C,A,y){let N=C instanceof Float32Array?C:new Float32Array(C);if(h!==null&&h.name==="webkitAudioContext"){let D=A+y,E=d.context.sampleRate,O=Math.ceil(A*E),W=Math.floor(D*E),k=W-O,P=new Float32Array(k);for(let q=0;q<k;q+=1){let H=(N.length-1)/y*((O+q)/E-A),Q=Math.floor(H),et=Math.ceil(H);P[q]=Q===et?N[Q]:(1-(H-Q))*N[Q]+(1-(et-H))*N[et]}T===null&&S.flush(d.context.currentTime),S.add(l(P,A,y)),g.setValueCurveAtTime(P,A,y);let j=W/E;j<D&&p(v,P[P.length-1],j),p(v,N[N.length-1],D)}else T===null&&S.flush(d.context.currentTime),S.add(l(N,A,y)),g.setValueCurveAtTime(N,A,y);return v}};return e.set(v,g),t.set(v,d),o(v,T),v};var Ml=o=>({replay(t){for(let e of o)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:n}=e;t.setTargetAtTime(i,r,n)}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:n}=e;t.setValueCurveAtTime(n,i,r)}else throw new Error("Can't apply an unknown automation.")}});var Li=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 Og={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},El=(o,t,e,r,i,n,s,a,c,u,l,h,p,d)=>class extends t{constructor(g,x,b){var I;let S=a(g),T=c(S),v=l(R(R({},Og),b));p(v);let C=Fo.get(S),A=C==null?void 0:C.get(x),y=T||S.state!=="closed"?S:(I=s(S))!==null&&I!==void 0?I:S,N=i(y,T?null:g.baseLatency,u,x,A,v),D=T?r(x,v,A):null;super(g,!0,N,D);let E=[];N.parameters.forEach((W,k)=>{let P=e(this,T,W);E.push([k,P])}),this._nativeAudioWorkletNode=N,this._onprocessorerror=null,this._parameters=new Li(E),T&&o(S,this);let{activeInputs:O}=n(this);h(N,O)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(g){let x=typeof g=="function"?d(this,g):null;this._nativeAudioWorkletNode.onprocessorerror=x;let b=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=b!==null&&b===x?g:b}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Pi(o,t,e,r,i){if(typeof o.copyFromChannel=="function")t[e].byteLength===0&&(t[e]=new Float32Array(128)),o.copyFromChannel(t[e],r,i);else{let n=o.getChannelData(r);if(t[e].byteLength===0)t[e]=n.slice(i,i+128);else{let s=new Float32Array(n.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);t[e].set(s)}}}var es=(o,t,e,r,i)=>{typeof o.copyToChannel=="function"?t[e].byteLength!==0&&o.copyToChannel(t[e],r,i):t[e].byteLength!==0&&o.getChannelData(r).set(t[e],i)};var Fi=(o,t)=>{let e=[];for(let r=0;r<o;r+=1){let i=[],n=typeof t=="number"?t:t[r];for(let s=0;s<n;s+=1)i.push(new Float32Array(128));e.push(i)}return e};var Dl=(o,t)=>{let e=Vt(Bo,o),r=Ct(t);return Vt(e,r)};var Rg=(o,t,e,r,i,n,s)=>X(null,null,function*(){let a=t===null?Math.ceil(o.context.length/128)*128:t.length,c=r.channelCount*r.numberOfInputs,u=i.reduce((x,b)=>x+b,0),l=u===0?null:e.createBuffer(u,a,e.sampleRate);if(n===void 0)throw new Error("Missing the processor constructor.");let h=Ht(o),p=yield Dl(e,o),d=Fi(r.numberOfInputs,r.channelCount),f=Fi(r.numberOfOutputs,i),g=Array.from(o.parameters.keys()).reduce((x,b)=>Z(R({},x),{[b]:new Float32Array(128)}),{});for(let x=0;x<a;x+=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)Pi(t,d[b],I,I,x);n.parameterDescriptors!==void 0&&t!==null&&n.parameterDescriptors.forEach(({name:b},I)=>{Pi(t,g,b,c+I,x)});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=d.map((S,T)=>h.activeInputs[T].size===0?[]:S),I=s(x/e.sampleRate,e.sampleRate,()=>p.process(b,f,g));if(l!==null)for(let S=0,T=0;S<r.numberOfOutputs;S+=1){for(let v=0;v<i[S];v+=1)es(l,f[S],v,T+v,x);T+=i[S]}if(!I)break}catch(b){o.dispatchEvent(new ErrorEvent("processorerror",{colno:b.colno,filename:b.filename,lineno:b.lineno,message:b.message}));break}}return l}),kl=(o,t,e,r,i,n,s,a,c,u,l,h,p,d,f,g)=>(x,b,I)=>{let S=new WeakMap,T=null,v=(C,A)=>X(null,null,function*(){let y=l(C),N=null,D=pt(y,A),E=Array.isArray(b.outputChannelCount)?b.outputChannelCount:Array.from(b.outputChannelCount);if(h===null){let O=E.reduce((j,q)=>j+q,0),W=i(A,{channelCount:Math.max(1,O),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,O)}),k=[];for(let j=0;j<C.numberOfOutputs;j+=1)k.push(r(A,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:E[j]}));let P=s(A,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1});P.connect=t.bind(null,k),P.disconnect=c.bind(null,k),N=[W,k,P]}else D||(y=new h(A,x));if(S.set(A,N===null?y:N[2]),N!==null){if(T===null){if(I===void 0)throw new Error("Missing the processor constructor.");if(p===null)throw new Error("Missing the native OfflineAudioContext constructor.");let q=C.channelCount*C.numberOfInputs,H=I.parameterDescriptors===void 0?0:I.parameterDescriptors.length,Q=q+H;T=Rg(C,Q===0?null:yield X(null,null,function*(){let at=new p(Q,Math.ceil(C.context.length/128)*128,A.sampleRate),yt=[],jt=[];for(let At=0;At<b.numberOfInputs;At+=1)yt.push(s(at,{channelCount:b.channelCount,channelCountMode:b.channelCountMode,channelInterpretation:b.channelInterpretation,gain:1})),jt.push(i(at,{channelCount:b.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:b.channelCount}));let xe=yield Promise.all(Array.from(C.parameters.values()).map(At=>X(null,null,function*(){let ot=n(at,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:At.value});return yield d(at,At,ot.offset),ot}))),ye=r(at,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,q+H)});for(let At=0;At<b.numberOfInputs;At+=1){yt[At].connect(jt[At]);for(let ot=0;ot<b.channelCount;ot+=1)jt[At].connect(ye,ot,At*b.channelCount+ot)}for(let[At,ot]of xe.entries())ot.connect(ye,0,q+At),ot.start(0);return ye.connect(at.destination),yield Promise.all(yt.map(At=>f(C,at,At))),g(at)}),A,b,E,I,u)}let O=yield T,W=e(A,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[k,P,j]=N;O!==null&&(W.buffer=O,W.start(0)),W.connect(k);for(let q=0,H=0;q<C.numberOfOutputs;q+=1){let Q=P[q];for(let et=0;et<E[q];et+=1)k.connect(Q,H+et,et);H+=E[q]}return j}if(D)for(let[O,W]of C.parameters.entries())yield o(A,W,y.parameters.get(O));else for(let[O,W]of C.parameters.entries())yield d(A,W,y.parameters.get(O));return yield f(C,A,y),y});return{render(C,A){a(A,C);let y=S.get(A);return y!==void 0?Promise.resolve(y):v(C,A)}}};var jl=(o,t,e,r,i,n,s,a,c,u,l,h,p,d,f,g,x,b,I,S)=>class extends f{constructor(v,C){super(v,C),this._nativeContext=v,this._audioWorklet=o===void 0?void 0:{addModule:(A,y)=>o(this,A,y)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new t(this)}createBiquadFilter(){return new i(this)}createBuffer(v,C,A){return new e({length:C,numberOfChannels:v,sampleRate:A})}createBufferSource(){return new r(this)}createChannelMerger(v=6){return new n(this,{numberOfInputs:v})}createChannelSplitter(v=6){return new s(this,{numberOfOutputs:v})}createConstantSource(){return new a(this)}createConvolver(){return new c(this)}createDelay(v=1){return new l(this,{maxDelayTime:v})}createDynamicsCompressor(){return new h(this)}createGain(){return new p(this)}createIIRFilter(v,C){return new d(this,{feedback:C,feedforward:v})}createOscillator(){return new g(this)}createPanner(){return new x(this)}createPeriodicWave(v,C,A={disableNormalization:!1}){return new b(this,Z(R({},A),{imag:C,real:v}))}createStereoPanner(){return new I(this)}createWaveShaper(){return new S(this)}decodeAudioData(v,C,A){return u(this._nativeContext,v).then(y=>(typeof C=="function"&&C(y),y),y=>{throw typeof A=="function"&&A(y),y})}};var Mg={Q:1,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:350,gain:0,type:"lowpass"},Ll=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=R(R({},Mg),l),d=i(h,p),f=s(h),g=f?e():null;super(u,!1,d,g),this._Q=t(this,f,d.Q,Et,Lt),this._detune=t(this,f,d.detune,1200*Math.log2(Et),-1200*Math.log2(Et)),this._frequency=t(this,f,d.frequency,u.sampleRate/2,0),this._gain=t(this,f,d.gain,40*Math.log10(Et),Lt),this._nativeBiquadFilterNode=d,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 Pl=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?(yield o(c,a.Q,u.Q),yield o(c,a.detune,u.detune),yield o(c,a.frequency,u.frequency),yield o(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=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var Fl=(o,t)=>(e,r)=>{let i=t.get(e);if(i!==void 0)return i;let n=o.get(e);if(n!==void 0)return n;try{let s=r();return s instanceof Promise?(o.set(e,s),s.catch(()=>!1).then(a=>(o.delete(e),t.set(e,a),a))):(t.set(e,s),s)}catch(s){return t.set(e,!1),!1}};var Eg={channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6},Bl=(o,t,e,r,i)=>class extends o{constructor(s,a){let c=r(s),u=R(R({},Eg),a),l=e(c,u),h=i(c)?t():null;super(s,!1,l,h)}};var Gl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=o(s,u)}return r.set(s,a),yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Dg={channelCount:6,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:6},Vl=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=r(a),l=n(R(R({},Dg),c)),h=e(u,l),p=i(u)?t():null;super(a,!1,h,p)}};var ql=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=o(s,u)}return r.set(s,a),yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Wl=o=>(t,e,r)=>o(e,t,r);var Ul=o=>(t,e,r=0,i=0)=>{let n=t[r];if(n===void 0)throw o();return ti(e)?n.connect(e,0,i):n.connect(e,0)};var zl=o=>(t,e)=>{let r=o(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 kg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",offset:1},Yl=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},kg),u),p=r(l,h),d=n(l),f=d?e():null;super(c,!1,p,f),this._constantSourceNodeRenderer=f,this._nativeConstantSourceNode=p,this._offset=t(this,d,p.offset,Et,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),ne(this)&&er(this)};this._nativeConstantSourceNode.addEventListener("ended",u)}}stop(c=0){this._nativeConstantSourceNode.stop(c),this._constantSourceNodeRenderer!==null&&(this._constantSourceNodeRenderer.stop=c)}};var Hl=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=null,a=null,c=(u,l)=>X(null,null,function*(){let h=e(u),p=pt(h,l);if(!p){let d={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,offset:h.offset.value};h=t(l,d),s!==null&&h.start(s),a!==null&&h.stop(a)}return n.set(l,h),p?yield o(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=n.get(l);return h!==void 0?Promise.resolve(h):c(u,l)}}};var Ql=o=>t=>(o[0]=t,o[0]);var jg={buffer:null,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",disableNormalization:!1},Zl=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=r(a),l=R(R({},jg),c),h=e(u,l),d=i(u)?t():null;super(a,!1,h,d),this._isBufferNullified=!1,this._nativeConvolverNode=h,l.buffer!==null&&n(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,n(this,0)}else this._isBufferNullified=!1,n(this,this._nativeConvolverNode.buffer===null?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(a){this._nativeConvolverNode.normalize=a}};var Xl=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=o(s,u)}return r.set(s,a),Oe(a)?yield e(n,s,a.inputs[0]):yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Jl=(o,t)=>(e,r,i)=>{if(t===null)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new t(e,r,i)}catch(n){throw n.name==="SyntaxError"?o():n}};var Kl=()=>new DOMException("","DataCloneError");var xc=o=>{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(o,[o])}catch(n){}finally{i()}})};var $l=(o,t,e,r,i,n,s,a,c,u,l)=>(h,p)=>{let d=s(h)?h:n(h);if(i.has(p)){let f=e();return Promise.reject(f)}try{i.add(p)}catch(f){}return t(c,()=>c(d))?d.decodeAudioData(p).then(f=>(xc(p).catch(()=>{}),t(a,()=>a(f))||l(f),o.add(f),f)):new Promise((f,g)=>{let x=()=>X(null,null,function*(){try{yield xc(p)}catch(I){}}),b=I=>{g(I),x()};try{d.decodeAudioData(p,I=>{typeof I.copyFromChannel!="function"&&(u(I),Ei(I)),o.add(I),x().then(()=>f(I))},I=>{b(I===null?r():I)})}catch(I){b(I)}})};var th=(o,t,e,r,i,n,s,a)=>(c,u)=>{let l=t.get(c);if(l===void 0)throw new Error("Missing the expected cycle count.");let h=n(c.context),p=a(h);if(l===u){if(t.delete(c),!p&&s(c)){let d=r(c),{outputs:f}=e(c);for(let g of f)if(Br(g)){let x=r(g[0]);o(d,x,g[1],g[2])}else{let x=i(g[0]);d.connect(x,g[1])}}}else t.set(c,l-u)};var Lg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",delayTime:0,maxDelayTime:1},eh=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Lg),u),p=r(l,h),d=n(l),f=d?e(h.maxDelayTime):null;super(c,!1,p,f),this._delayTime=t(this,d,p.delayTime),s(this,h.maxDelayTime)}get delayTime(){return this._delayTime}};var rh=(o,t,e,r,i)=>n=>{let s=new WeakMap,a=(c,u)=>X(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:n};l=t(u,p)}return s.set(u,l),h?yield o(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 ih=o=>(t,e,r,i)=>o(t[i],n=>n[0]===e&&n[1]===r);var oh=o=>(t,e)=>{o(t).delete(e)};var nh=o=>"delayTime"in o;var sh=(o,t,e)=>function r(i,n){let s=Kr(n)?n:e(o,n);if(nh(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 rs=(o,t,e)=>{let r=t[e];if(r===void 0)throw o();return r},ah=o=>(t,e=void 0,r=void 0,i=0)=>e===void 0?t.forEach(n=>n.disconnect()):typeof e=="number"?rs(o,t,e).disconnect():ti(e)?r===void 0?t.forEach(n=>n.disconnect(e)):i===void 0?rs(o,t,r).disconnect(e,0):rs(o,t,r).disconnect(e,0,i):r===void 0?t.forEach(n=>n.disconnect(e)):rs(o,t,r).disconnect(e,0);var Pg={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},ch=(o,t,e,r,i,n,s,a)=>class extends o{constructor(u,l){let h=n(u),p=R(R({},Pg),l),d=r(h,p),f=s(h),g=f?e():null;super(u,!1,d,g),this._attack=t(this,f,d.attack),this._knee=t(this,f,d.knee),this._nativeDynamicsCompressorNode=d,this._ratio=t(this,f,d.ratio),this._release=t(this,f,d.release),this._threshold=t(this,f,d.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 uh=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?(yield o(c,a.attack,u.attack),yield o(c,a.knee,u.knee),yield o(c,a.ratio,u.ratio),yield o(c,a.release,u.release),yield o(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=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var lh=()=>new DOMException("","EncodingError");var hh=o=>t=>new Promise((e,r)=>{if(o===null){r(new SyntaxError);return}let i=o.document.head;if(i===null)r(new SyntaxError);else{let n=o.document.createElement("script"),s=new Blob([t],{type:"application/javascript"}),a=URL.createObjectURL(s),c=o.onerror,u=()=>{o.onerror=c,URL.revokeObjectURL(a)};o.onerror=(l,h,p,d,f)=>{if(h===a||h===o.location.href&&p===1&&d===1)return u(),r(f),!1;if(c!==null)return c(l,h,p,d,f)},n.onerror=()=>{u(),r(new SyntaxError)},n.onload=()=>{u(),e()},n.src=a,n.type="module",i.appendChild(n)}});var ph=o=>class{constructor(e){this._nativeEventTarget=e,this._listeners=new WeakMap}addEventListener(e,r,i){if(r!==null){let n=this._listeners.get(r);n===void 0&&(n=o(this,r),typeof r=="function"&&this._listeners.set(r,n)),this._nativeEventTarget.addEventListener(e,n,i)}}dispatchEvent(e){return this._nativeEventTarget.dispatchEvent(e)}removeEventListener(e,r,i){let n=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(e,n===void 0?null:n,i)}};var dh=o=>(t,e,r)=>{Object.defineProperties(o,{currentFrame:{configurable:!0,get(){return Math.round(t*e)}},currentTime:{configurable:!0,get(){return t}}});try{return r()}finally{o!==null&&(delete o.currentFrame,delete o.currentTime)}};var mh=o=>t=>X(null,null,function*(){try{let e=yield fetch(t);if(e.ok)return[yield e.text(),e.url]}catch(e){}throw o()});var Fg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},fh=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=i(a),l=R(R({},Fg),c),h=r(u,l),p=n(u),d=p?e():null;super(a,!1,h,d),this._gain=t(this,p,h.gain,Et,Lt)}get gain(){return this._gain}};var gh=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?yield o(c,a.gain,u.gain):yield r(c,a.gain,u.gain),yield i(a,c,u),u});return{render(a,c){let u=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var xh=(o,t)=>e=>t(o,e);var yh=o=>t=>{let e=o(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer};var bh=o=>t=>{var e;return(e=o.get(t))!==null&&e!==void 0?e:0};var Ah=o=>t=>{let e=o(t);if(e.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return e.renderer};var Ch=o=>t=>o.get(t);var wt=()=>new DOMException("","InvalidStateError");var _h=o=>t=>{let e=o.get(t);if(e===void 0)throw wt();return e};var vh=(o,t)=>e=>{let r=o.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),o.set(e,r),r};var Ih=o=>t=>{let e=o.get(t);if(e===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return e};var Bi=()=>new DOMException("","InvalidAccessError");var Sh=o=>{o.getFrequencyResponse=(t=>(e,r,i)=>{if(e.length!==r.length||r.length!==i.length)throw Bi();return t.call(o,e,r,i)})(o.getFrequencyResponse)};var Bg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},wh=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=r(a),l=i(u),h=R(R({},Bg),c),p=t(u,l?null:a.baseLatency,h),d=l?e(h.feedback,h.feedforward):null;super(a,!1,p,d),Sh(p),this._nativeIIRFilterNode=p,n(this,1)}getFrequencyResponse(a,c,u){return this._nativeIIRFilterNode.getFrequencyResponse(a,c,u)}};var is=(o,t,e,r,i,n,s,a,c,u,l)=>{let h=u.length,p=a;for(let d=0;d<h;d+=1){let f=e[0]*u[d];for(let g=1;g<i;g+=1){let x=p-g&c-1;f+=e[g]*n[x],f-=o[g]*s[x]}for(let g=i;g<r;g+=1)f+=e[g]*n[p-g&c-1];for(let g=i;g<t;g+=1)f-=o[g]*s[p-g&c-1];n[p]=u[d],s[p]=f,p=p+1&c-1,l[d]=f}return p};var Gg=(o,t,e,r)=>{let i=e instanceof Float64Array?e:new Float64Array(e),n=r instanceof Float64Array?r:new Float64Array(r),s=i.length,a=n.length,c=Math.min(s,a);if(i[0]!==1){for(let f=0;f<s;f+=1)n[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(o.numberOfChannels,o.length,o.sampleRate),d=o.numberOfChannels;for(let f=0;f<d;f+=1){let g=o.getChannelData(f),x=p.getChannelData(f);l.fill(0),h.fill(0),is(i,s,n,a,c,l,h,0,u,g,x)}return p},Th=(o,t,e,r,i)=>(n,s)=>{let a=new WeakMap,c=null,u=(l,h)=>X(null,null,function*(){let p=null,d=t(l),f=pt(d,h);if(h.createIIRFilter===void 0?p=o(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):f||(d=h.createIIRFilter(s,n)),a.set(h,p===null?d:p),p!==null){if(c===null){if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");let x=new e(l.context.destination.channelCount,l.context.length,h.sampleRate);c=X(null,null,function*(){yield r(l,x,x.destination);let b=yield i(x);return Gg(b,h,n,s)})}let g=yield c;return p.buffer=g,p.start(0),p}return yield r(l,h,d),d});return{render(l,h){let p=a.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Nh=(o,t,e,r,i,n)=>s=>(a,c)=>{let u=o.get(a);if(u===void 0){if(!s&&n(a)){let l=r(a),{outputs:h}=e(a);for(let p of h)if(Br(p)){let d=r(p[0]);t(l,d,p[1],p[2])}else{let d=i(p[0]);l.disconnect(d,p[1])}}o.set(a,c)}else o.set(a,u+c)};var Oh=(o,t)=>e=>{let r=o.get(e);return t(r)||t(e)};var Rh=(o,t)=>e=>o.has(e)||t(e);var Mh=(o,t)=>e=>o.has(e)||t(e);var Eh=(o,t)=>e=>{let r=o.get(e);return t(r)||t(e)};var Dh=o=>t=>o!==null&&t instanceof o;var kh=o=>t=>o!==null&&typeof o.AudioNode=="function"&&t instanceof o.AudioNode;var jh=o=>t=>o!==null&&typeof o.AudioParam=="function"&&t instanceof o.AudioParam;var Lh=(o,t)=>e=>o(e)||t(e);var Ph=o=>t=>o!==null&&t instanceof o;var Fh=o=>o!==null&&o.isSecureContext;var Bh=(o,t,e,r)=>class extends o{constructor(n,s){let a=e(n),c=t(a,s);if(r(a))throw TypeError();super(n,!0,c,null),this._nativeMediaElementAudioSourceNode=c}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}};var Vg={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers"},Gh=(o,t,e,r)=>class extends o{constructor(n,s){let a=e(n);if(r(a))throw new TypeError;let c=R(R({},Vg),s),u=t(a,c);super(n,!1,u,null),this._nativeMediaStreamAudioDestinationNode=u}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}};var Vh=(o,t,e,r)=>class extends o{constructor(n,s){let a=e(n),c=t(a,s);if(r(a))throw new TypeError;super(n,!0,c,null),this._nativeMediaStreamAudioSourceNode=c}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}};var qh=(o,t,e)=>class extends o{constructor(i,n){let s=e(i),a=t(s,n);super(i,!0,a,null)}};var Wh=(o,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(!$n(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 o()}):(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?o():s})}suspend(){return this._nativeAudioContext.suspend().catch(s=>{throw s===void 0?o():s})}};var Uh=(o,t,e,r,i,n)=>class extends e{constructor(a,c){super(a),this._nativeContext=a,Ri.set(this,a),r(a)&&i.set(a,new Set),this._destination=new o(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"?n(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=o=>{let t=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{let e=o.decodeAudioData(t.buffer,()=>{});return e===void 0?!1:(e.catch(()=>{}),!0)}catch(e){}return!1};var qg={numberOfChannels:1},zh=(o,t,e,r,i)=>class extends r{constructor(s){let{length:a,numberOfChannels:c,sampleRate:u}=R(R({},qg),s),l=e(c,a,u);o(qe,()=>qe(l))||l.addEventListener("statechange",(()=>{let h=0,p=d=>{this._state==="running"&&(h>0?(l.removeEventListener("statechange",p),d.stopImmediatePropagation(),this._waitForThePromiseToSettle(d)):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 Yh=(o,t)=>(e,r,i)=>{let n=new Set;return e.connect=(s=>(a,c=0,u=0)=>{let l=n.size===0;if(t(a))return s.call(e,a,c,u),o(n,[a,c,u],h=>h[0]===a&&h[1]===c&&h[2]===u,!0),l&&r(),a;s.call(e,a,c),o(n,[a,c],h=>h[0]===a&&h[1]===c,!0),l&&r()})(e.connect),e.disconnect=(s=>(a,c,u)=>{let l=n.size>0;if(a===void 0)s.apply(e),n.clear();else if(typeof a=="number"){s.call(e,a);for(let p of n)p[1]===a&&n.delete(p)}else{t(a)?s.call(e,a,c,u):s.call(e,a,c);for(let p of n)p[0]===a&&(c===void 0||p[1]===c)&&(u===void 0||p[2]===u)&&n.delete(p)}let h=n.size===0;l&&h&&i()})(e.disconnect),e};var dt=(o,t,e)=>{let r=t[e];r!==void 0&&r!==o[e]&&(o[e]=r)};var ut=(o,t)=>{dt(o,t,"channelCount"),dt(o,t,"channelCountMode"),dt(o,t,"channelInterpretation")};var yc=o=>typeof o.getFloatTimeDomainData=="function";var Hh=o=>{o.getFloatTimeDomainData=t=>{let e=new Uint8Array(t.length);o.getByteTimeDomainData(e);let r=Math.max(e.length,o.fftSize);for(let i=0;i<r;i+=1)t[i]=(e[i]-128)*.0078125;return t}};var Qh=(o,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"),o(yc,()=>yc(i))||Hh(i),i};var Zh=o=>o===null?null:o.hasOwnProperty("AudioBuffer")?o.AudioBuffer:null;var xt=(o,t,e)=>{let r=t[e];r!==void 0&&r!==o[e].value&&(o[e].value=r)};var Xh=o=>{o.start=(t=>{let e=!1;return(r=0,i=0,n)=>{if(e)throw wt();t.call(o,r,i,n),e=!0}})(o.start)};var Gi=o=>{o.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(o,e,r,i)})(o.start)};var Vi=o=>{o.stop=(t=>(e=0)=>{if(e<0)throw new RangeError("The parameter can't be negative.");t.call(o,e)})(o.stop)};var Jh=(o,t,e,r,i,n,s,a,c,u,l)=>(h,p)=>{let d=h.createBufferSource();return ut(d,p),xt(d,p,"playbackRate"),dt(d,p,"buffer"),dt(d,p,"loop"),dt(d,p,"loopEnd"),dt(d,p,"loopStart"),t(e,()=>e(h))||Xh(d),t(r,()=>r(h))||c(d),t(i,()=>i(h))||u(d,h),t(n,()=>n(h))||Gi(d),t(s,()=>s(h))||l(d,h),t(a,()=>a(h))||Vi(d),o(h,d),d};var Kh=o=>o===null?null:o.hasOwnProperty("AudioContext")?o.AudioContext:o.hasOwnProperty("webkitAudioContext")?o.webkitAudioContext:null;var $h=(o,t)=>(e,r,i)=>{let n=e.destination;if(n.channelCount!==r)try{n.channelCount=r}catch(a){}i&&n.channelCountMode!=="explicit"&&(n.channelCountMode="explicit"),n.maxChannelCount===0&&Object.defineProperty(n,"maxChannelCount",{value:r});let s=o(e,{channelCount:r,channelCountMode:n.channelCountMode,channelInterpretation:n.channelInterpretation,gain:1});return t(s,"channelCount",a=>()=>a.call(s),a=>c=>{a.call(s,c);try{n.channelCount=c}catch(u){if(c>n.maxChannelCount)throw u}}),t(s,"channelCountMode",a=>()=>a.call(s),a=>c=>{a.call(s,c),n.channelCountMode=c}),t(s,"channelInterpretation",a=>()=>a.call(s),a=>c=>{a.call(s,c),n.channelInterpretation=c}),Object.defineProperty(s,"maxChannelCount",{get:()=>n.maxChannelCount}),s.connect(n),s};var tp=o=>o===null?null:o.hasOwnProperty("AudioWorkletNode")?o.AudioWorkletNode:null;var ep=o=>{let{port1:t}=new MessageChannel;try{t.postMessage(o)}finally{t.close()}};var rp=(o,t,e,r,i)=>(n,s,a,c,u,l)=>{if(a!==null)try{let h=new a(n,c,l),p=new Map,d=null;if(Object.defineProperties(h,{channelCount:{get:()=>l.channelCount,set:()=>{throw o()}},channelCountMode:{get:()=>"explicit",set:()=>{throw o()}},onprocessorerror:{get:()=>d,set:f=>{typeof d=="function"&&h.removeEventListener("processorerror",d),d=typeof f=="function"?f:null,typeof d=="function"&&h.addEventListener("processorerror",d)}}}),h.addEventListener=(f=>(...g)=>{if(g[0]==="processorerror"){let x=typeof g[1]=="function"?g[1]:typeof g[1]=="object"&&g[1]!==null&&typeof g[1].handleEvent=="function"?g[1].handleEvent:null;if(x!==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"}}),x(I)):x(new ErrorEvent(g[0],R({},I)))},p.set(x,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 x=p.get(g[1]);x!==void 0&&(p.delete(g[1]),g[1]=x)}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(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return h.connect(f).connect(n.destination),i(h,()=>f.disconnect(),()=>f.connect(n.destination))}return h}catch(h){throw h.code===11?r():h}if(u===void 0)throw r();return ep(l),t(n,s,u,l)};var os=(o,t)=>o===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(o*t)))));var ip=o=>new Promise((t,e)=>{let{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:n})=>{r.close(),i.close(),t(n)},r.onmessageerror=({data:n})=>{r.close(),i.close(),e(n)},i.postMessage(o)});var op=(o,t)=>X(null,null,function*(){let e=yield ip(t);return new o(e)});var np=(o,t,e,r)=>{let i=Bo.get(o);i===void 0&&(i=new WeakMap,Bo.set(o,i));let n=op(e,r);return i.set(t,n),n};var sp=(o,t,e,r,i,n,s,a,c,u,l,h,p)=>(d,f,g,x)=>{if(x.numberOfInputs===0&&x.numberOfOutputs===0)throw c();let b=Array.isArray(x.outputChannelCount)?x.outputChannelCount:Array.from(x.outputChannelCount);if(b.some(z=>z<1))throw c();if(b.length!==x.numberOfOutputs)throw t();if(x.channelCountMode!=="explicit")throw c();let I=x.channelCount*x.numberOfInputs,S=b.reduce((z,rt)=>z+rt,0),T=g.parameterDescriptors===void 0?0:g.parameterDescriptors.length;if(I+T>6||S>6)throw c();let v=new MessageChannel,C=[],A=[];for(let z=0;z<x.numberOfInputs;z+=1)C.push(s(d,{channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation,gain:1})),A.push(i(d,{channelCount:x.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:x.channelCount}));let y=[];if(g.parameterDescriptors!==void 0)for(let{defaultValue:z,maxValue:rt,minValue:zt,name:Nt}of g.parameterDescriptors){let ft=n(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:x.parameterData[Nt]!==void 0?x.parameterData[Nt]:z===void 0?0:z});Object.defineProperties(ft.offset,{defaultValue:{get:()=>z===void 0?0:z},maxValue:{get:()=>rt===void 0?Et:rt},minValue:{get:()=>zt===void 0?Lt:zt}}),y.push(ft)}let N=r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,I+T)}),D=os(f,d.sampleRate),E=a(d,D,I+T,Math.max(1,S)),O=i(d,{channelCount:Math.max(1,S),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,S)}),W=[];for(let z=0;z<x.numberOfOutputs;z+=1)W.push(r(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:b[z]}));for(let z=0;z<x.numberOfInputs;z+=1){C[z].connect(A[z]);for(let rt=0;rt<x.channelCount;rt+=1)A[z].connect(N,rt,z*x.channelCount+rt)}let k=new Li(g.parameterDescriptors===void 0?[]:g.parameterDescriptors.map(({name:z},rt)=>{let zt=y[rt];return zt.connect(N,0,I+rt),zt.start(0),[z,zt.offset]}));N.connect(E);let P=x.channelInterpretation,j=null,q=x.numberOfOutputs===0?[E]:W,H={get bufferSize(){return D},get channelCount(){return x.channelCount},set channelCount(z){throw e()},get channelCountMode(){return x.channelCountMode},set channelCountMode(z){throw e()},get channelInterpretation(){return P},set channelInterpretation(z){for(let rt of C)rt.channelInterpretation=z;P=z},get context(){return E.context},get inputs(){return C},get numberOfInputs(){return x.numberOfInputs},get numberOfOutputs(){return x.numberOfOutputs},get onprocessorerror(){return j},set onprocessorerror(z){typeof j=="function"&&H.removeEventListener("processorerror",j),j=typeof z=="function"?z:null,typeof j=="function"&&H.addEventListener("processorerror",j)},get parameters(){return k},get port(){return v.port2},addEventListener(...z){return E.addEventListener(z[0],z[1],z[2])},connect:o.bind(null,q),disconnect:u.bind(null,q),dispatchEvent(...z){return E.dispatchEvent(z[0])},removeEventListener(...z){return E.removeEventListener(z[0],z[1],z[2])}},Q=new Map;v.port1.addEventListener=(z=>(...rt)=>{if(rt[0]==="message"){let zt=typeof rt[1]=="function"?rt[1]:typeof rt[1]=="object"&&rt[1]!==null&&typeof rt[1].handleEvent=="function"?rt[1].handleEvent:null;if(zt!==null){let Nt=Q.get(rt[1]);Nt!==void 0?rt[1]=Nt:(rt[1]=ft=>{l(d.currentTime,d.sampleRate,()=>zt(ft))},Q.set(zt,rt[1]))}}return z.call(v.port1,rt[0],rt[1],rt[2])})(v.port1.addEventListener),v.port1.removeEventListener=(z=>(...rt)=>{if(rt[0]==="message"){let zt=Q.get(rt[1]);zt!==void 0&&(Q.delete(rt[1]),rt[1]=zt)}return z.call(v.port1,rt[0],rt[1],rt[2])})(v.port1.removeEventListener);let et=null;Object.defineProperty(v.port1,"onmessage",{get:()=>et,set:z=>{typeof et=="function"&&v.port1.removeEventListener("message",et),et=typeof z=="function"?z:null,typeof et=="function"&&(v.port1.addEventListener("message",et),v.port1.start())}}),g.prototype.port=v.port1;let at=null;np(d,H,g,x).then(z=>at=z);let jt=Fi(x.numberOfInputs,x.channelCount),xe=Fi(x.numberOfOutputs,b),ye=g.parameterDescriptors===void 0?[]:g.parameterDescriptors.reduce((z,{name:rt})=>Z(R({},z),{[rt]:new Float32Array(128)}),{}),At=!0,ot=()=>{x.numberOfOutputs>0&&E.disconnect(O);for(let z=0,rt=0;z<x.numberOfOutputs;z+=1){let zt=W[z];for(let Nt=0;Nt<b[z];Nt+=1)O.disconnect(zt,rt+Nt,Nt);rt+=b[z]}},bi=new Map;E.onaudioprocess=({inputBuffer:z,outputBuffer:rt})=>{if(at!==null){let zt=h(H);for(let Nt=0;Nt<D;Nt+=128){for(let ft=0;ft<x.numberOfInputs;ft+=1)for(let Mt=0;Mt<x.channelCount;Mt+=1)Pi(z,jt[ft],Mt,Mt,Nt);g.parameterDescriptors!==void 0&&g.parameterDescriptors.forEach(({name:ft},Mt)=>{Pi(z,ye,ft,I+Mt,Nt)});for(let ft=0;ft<x.numberOfInputs;ft+=1)for(let Mt=0;Mt<b[ft];Mt+=1)xe[ft][Mt].byteLength===0&&(xe[ft][Mt]=new Float32Array(128));try{let ft=jt.map((Se,Or)=>{if(zt[Or].size>0)return bi.set(Or,D/128),Se;let Ma=bi.get(Or);return Ma===void 0?[]:(Se.every(Am=>Am.every(Cm=>Cm===0))&&(Ma===1?bi.delete(Or):bi.set(Or,Ma-1)),Se)});At=l(d.currentTime+Nt/d.sampleRate,d.sampleRate,()=>at.process(ft,xe,ye));for(let Se=0,Or=0;Se<x.numberOfOutputs;Se+=1){for(let vo=0;vo<b[Se];vo+=1)es(rt,xe[Se],vo,Or+vo,Nt);Or+=b[Se]}}catch(ft){At=!1,H.dispatchEvent(new ErrorEvent("processorerror",{colno:ft.colno,filename:ft.filename,lineno:ft.lineno,message:ft.message}))}if(!At){for(let ft=0;ft<x.numberOfInputs;ft+=1){C[ft].disconnect(A[ft]);for(let Mt=0;Mt<x.channelCount;Mt+=1)A[Nt].disconnect(N,Mt,ft*x.channelCount+Mt)}if(g.parameterDescriptors!==void 0){let ft=g.parameterDescriptors.length;for(let Mt=0;Mt<ft;Mt+=1){let Se=y[Mt];Se.disconnect(N,0,I+Mt),Se.stop()}}N.disconnect(E),E.onaudioprocess=null,Ao?ot():Ci();break}}}};let Ao=!1,J=s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Ai=()=>E.connect(J).connect(d.destination),Ci=()=>{E.disconnect(J),J.disconnect()},Co=()=>{if(At){Ci(),x.numberOfOutputs>0&&E.connect(O);for(let z=0,rt=0;z<x.numberOfOutputs;z+=1){let zt=W[z];for(let Nt=0;Nt<b[z];Nt+=1)O.connect(zt,rt+Nt,Nt);rt+=b[z]}}Ao=!0},_o=()=>{At&&(Ai(),ot()),Ao=!1};return Ai(),p(H,Co,_o)};var bc=(o,t)=>{let e=o.createBiquadFilter();return ut(e,t),xt(e,t,"Q"),xt(e,t,"detune"),xt(e,t,"frequency"),xt(e,t,"gain"),dt(e,t,"type"),e};var ap=(o,t)=>(e,r)=>{let i=e.createChannelMerger(r.numberOfInputs);return o!==null&&o.name==="webkitAudioContext"&&t(e,i),ut(i,r),i};var cp=o=>{let t=o.numberOfOutputs;Object.defineProperty(o,"channelCount",{get:()=>t,set:e=>{if(e!==t)throw wt()}}),Object.defineProperty(o,"channelCountMode",{get:()=>"explicit",set:e=>{if(e!=="explicit")throw wt()}}),Object.defineProperty(o,"channelInterpretation",{get:()=>"discrete",set:e=>{if(e!=="discrete")throw wt()}})};var qi=(o,t)=>{let e=o.createChannelSplitter(t.numberOfOutputs);return ut(e,t),cp(e),e};var up=(o,t,e,r,i)=>(n,s)=>{if(n.createConstantSource===void 0)return e(n,s);let a=n.createConstantSource();return ut(a,s),xt(a,s,"offset"),t(r,()=>r(n))||Gi(a),t(i,()=>i(n))||Vi(a),o(n,a),a};var Re=(o,t)=>(o.connect=t.connect.bind(t),o.disconnect=t.disconnect.bind(t),o);var lp=(o,t,e,r)=>(i,a)=>{var c=a,{offset:n}=c,s=Rr(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(R({},s),{gain:n})),p=u.getChannelData(0);p[0]=1,p[1]=1,l.buffer=u,l.loop=!0;let d={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(x){h.channelCount=x},get channelCountMode(){return h.channelCountMode},set channelCountMode(x){h.channelCountMode=x},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(x){h.channelInterpretation=x},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(x){l.onended=x},addEventListener(...x){return l.addEventListener(x[0],x[1],x[2])},dispatchEvent(...x){return l.dispatchEvent(x[0])},removeEventListener(...x){return l.removeEventListener(x[0],x[1],x[2])},start(x=0){l.start.call(l,x)},stop(x=0){l.stop.call(l,x)}},f=()=>l.connect(h),g=()=>l.disconnect(h);return o(i,l),r(Re(d,h),f,g)};var hp=(o,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",n=>()=>n.call(i),n=>s=>{if(s>2)throw o();return n.call(i,s)}),r.channelCountMode==="max"))throw o();return t(i,"channelCountMode",n=>()=>n.call(i),n=>s=>{if(s==="max")throw o();return n.call(i,s)}),i};var Ac=(o,t)=>{let e=o.createDelay(t.maxDelayTime);return ut(e,t),xt(e,t,"delayTime"),e};var pp=o=>(t,e)=>{let r=t.createDynamicsCompressor();if(ut(r,e),e.channelCount>2||e.channelCountMode==="max")throw o();return xt(r,e,"attack"),xt(r,e,"knee"),xt(r,e,"ratio"),xt(r,e,"release"),xt(r,e,"threshold"),r};var se=(o,t)=>{let e=o.createGain();return ut(e,t),xt(e,t,"gain"),e};var dp=o=>(t,e,r)=>{if(t.createIIRFilter===void 0)return o(t,e,r);let i=t.createIIRFilter(r.feedforward,r.feedback);return ut(i,r),i};function Wg(o,t){let e=t[0]*t[0]+t[1]*t[1];return[(o[0]*t[0]+o[1]*t[1])/e,(o[1]*t[0]-o[0]*t[1])/e]}function Ug(o,t){return[o[0]*t[0]-o[1]*t[1],o[0]*t[1]+o[1]*t[0]]}function mp(o,t){let e=[0,0];for(let r=o.length-1;r>=0;r-=1)e=Ug(e,t),e[0]+=o[r];return e}var fp=(o,t,e,r)=>(i,n,{channelCount:s,channelCountMode:a,channelInterpretation:c,feedback:u,feedforward:l})=>{let h=os(n,i.sampleRate),p=u instanceof Float64Array?u:new Float64Array(u),d=l instanceof Float64Array?l:new Float64Array(l),f=p.length,g=d.length,x=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(d[0]===0)throw t();if(p[0]!==1){for(let y=0;y<g;y+=1)d[y]/=p[0];for(let y=1;y<f;y+=1)p[y]/=p[0]}let b=e(i,h,s,s);b.channelCount=s,b.channelCountMode=a,b.channelInterpretation=c;let I=32,S=[],T=[],v=[];for(let y=0;y<s;y+=1){S.push(0);let N=new Float32Array(I),D=new Float32Array(I);N.fill(0),D.fill(0),T.push(N),v.push(D)}b.onaudioprocess=y=>{let N=y.inputBuffer,D=y.outputBuffer,E=N.numberOfChannels;for(let O=0;O<E;O+=1){let W=N.getChannelData(O),k=D.getChannelData(O);S[O]=is(p,f,d,g,x,T[O],v[O],S[O],I,W,k)}};let C=i.sampleRate/2;return Re({get bufferSize(){return h},get channelCount(){return b.channelCount},set channelCount(y){b.channelCount=y},get channelCountMode(){return b.channelCountMode},set channelCountMode(y){b.channelCountMode=y},get channelInterpretation(){return b.channelInterpretation},set channelInterpretation(y){b.channelInterpretation=y},get context(){return b.context},get inputs(){return[b]},get numberOfInputs(){return b.numberOfInputs},get numberOfOutputs(){return b.numberOfOutputs},addEventListener(...y){return b.addEventListener(y[0],y[1],y[2])},dispatchEvent(...y){return b.dispatchEvent(y[0])},getFrequencyResponse(y,N,D){if(y.length!==N.length||N.length!==D.length)throw o();let E=y.length;for(let O=0;O<E;O+=1){let W=-Math.PI*(y[O]/C),k=[Math.cos(W),Math.sin(W)],P=mp(d,k),j=mp(p,k),q=Wg(P,j);N[O]=Math.sqrt(q[0]*q[0]+q[1]*q[1]),D[O]=Math.atan2(q[1],q[0])}},removeEventListener(...y){return b.removeEventListener(y[0],y[1],y[2])}},b)};var gp=(o,t)=>o.createMediaElementSource(t.mediaElement);var xp=(o,t)=>{let e=o.createMediaStreamDestination();return ut(e,t),e.numberOfOutputs===1&&Object.defineProperty(e,"numberOfOutputs",{get:()=>0}),e};var yp=(o,{mediaStream:t})=>{let e=t.getAudioTracks();e.sort((n,s)=>n.id<s.id?-1:n.id>s.id?1:0);let r=e.slice(0,1),i=o.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:t}),i};var bp=(o,t)=>(e,{mediaStreamTrack:r})=>{if(typeof e.createMediaStreamTrackSource=="function")return e.createMediaStreamTrackSource(r);let i=new MediaStream([r]),n=e.createMediaStreamSource(i);if(r.kind!=="audio")throw o();if(t(e))throw new TypeError;return n};var Ap=o=>o===null?null:o.hasOwnProperty("OfflineAudioContext")?o.OfflineAudioContext:o.hasOwnProperty("webkitOfflineAudioContext")?o.webkitOfflineAudioContext:null;var Cp=(o,t,e,r,i,n)=>(s,a)=>{let c=s.createOscillator();return ut(c,a),xt(c,a,"detune"),xt(c,a,"frequency"),a.periodicWave!==void 0?c.setPeriodicWave(a.periodicWave):dt(c,a,"type"),t(e,()=>e(s))||Gi(c),t(r,()=>r(s))||n(c,s),t(i,()=>i(s))||Vi(c),o(s,c),c};var _p=o=>(t,e)=>{let r=t.createPanner();return r.orientationX===void 0?o(t,e):(ut(r,e),xt(r,e,"orientationX"),xt(r,e,"orientationY"),xt(r,e,"orientationZ"),xt(r,e,"positionX"),xt(r,e,"positionY"),xt(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 vp=(o,t,e,r,i,n,s,a,c,u)=>(l,D)=>{var E=D,{coneInnerAngle:h,coneOuterAngle:p,coneOuterGain:d,distanceModel:f,maxDistance:g,orientationX:x,orientationY:b,orientationZ:I,panningModel:S,positionX:T,positionY:v,positionZ:C,refDistance:A,rolloffFactor:y}=E,N=Rr(E,["coneInnerAngle","coneOuterAngle","coneOuterGain","distanceModel","maxDistance","orientationX","orientationY","orientationZ","panningModel","positionX","positionY","positionZ","refDistance","rolloffFactor"]);let O=l.createPanner();if(N.channelCount>2||N.channelCountMode==="max")throw s();ut(O,N);let W={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},k=e(l,Z(R({},W),{channelInterpretation:"speakers",numberOfInputs:6})),P=r(l,Z(R({},N),{gain:1})),j=r(l,Z(R({},W),{gain:1})),q=r(l,Z(R({},W),{gain:0})),H=r(l,Z(R({},W),{gain:0})),Q=r(l,Z(R({},W),{gain:0})),et=r(l,Z(R({},W),{gain:0})),at=r(l,Z(R({},W),{gain:0})),yt=i(l,256,6,1),jt=n(l,Z(R({},W),{curve:new Float32Array([1,1]),oversample:"none"})),xe=[x,b,I],ye=[T,v,C],At=new Float32Array(1);yt.onaudioprocess=({inputBuffer:J})=>{let Ai=[c(J,At,0),c(J,At,1),c(J,At,2)];Ai.some((Co,_o)=>Co!==xe[_o])&&(O.setOrientation(...Ai),xe=Ai);let Ci=[c(J,At,3),c(J,At,4),c(J,At,5)];Ci.some((Co,_o)=>Co!==ye[_o])&&(O.setPosition(...Ci),ye=Ci)},Object.defineProperty(q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(H.gain,"defaultValue",{get:()=>0}),Object.defineProperty(Q.gain,"defaultValue",{get:()=>0}),Object.defineProperty(et.gain,"defaultValue",{get:()=>0}),Object.defineProperty(at.gain,"defaultValue",{get:()=>0});let ot={get bufferSize(){},get channelCount(){return O.channelCount},set channelCount(J){if(J>2)throw s();P.channelCount=J,O.channelCount=J},get channelCountMode(){return O.channelCountMode},set channelCountMode(J){if(J==="max")throw s();P.channelCountMode=J,O.channelCountMode=J},get channelInterpretation(){return O.channelInterpretation},set channelInterpretation(J){P.channelInterpretation=J,O.channelInterpretation=J},get coneInnerAngle(){return O.coneInnerAngle},set coneInnerAngle(J){O.coneInnerAngle=J},get coneOuterAngle(){return O.coneOuterAngle},set coneOuterAngle(J){O.coneOuterAngle=J},get coneOuterGain(){return O.coneOuterGain},set coneOuterGain(J){if(J<0||J>1)throw t();O.coneOuterGain=J},get context(){return O.context},get distanceModel(){return O.distanceModel},set distanceModel(J){O.distanceModel=J},get inputs(){return[P]},get maxDistance(){return O.maxDistance},set maxDistance(J){if(J<0)throw new RangeError;O.maxDistance=J},get numberOfInputs(){return O.numberOfInputs},get numberOfOutputs(){return O.numberOfOutputs},get orientationX(){return j.gain},get orientationY(){return q.gain},get orientationZ(){return H.gain},get panningModel(){return O.panningModel},set panningModel(J){O.panningModel=J},get positionX(){return Q.gain},get positionY(){return et.gain},get positionZ(){return at.gain},get refDistance(){return O.refDistance},set refDistance(J){if(J<0)throw new RangeError;O.refDistance=J},get rolloffFactor(){return O.rolloffFactor},set rolloffFactor(J){if(J<0)throw new RangeError;O.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!==ot.coneInnerAngle&&(ot.coneInnerAngle=h),p!==ot.coneOuterAngle&&(ot.coneOuterAngle=p),d!==ot.coneOuterGain&&(ot.coneOuterGain=d),f!==ot.distanceModel&&(ot.distanceModel=f),g!==ot.maxDistance&&(ot.maxDistance=g),x!==ot.orientationX.value&&(ot.orientationX.value=x),b!==ot.orientationY.value&&(ot.orientationY.value=b),I!==ot.orientationZ.value&&(ot.orientationZ.value=I),S!==ot.panningModel&&(ot.panningModel=S),T!==ot.positionX.value&&(ot.positionX.value=T),v!==ot.positionY.value&&(ot.positionY.value=v),C!==ot.positionZ.value&&(ot.positionZ.value=C),A!==ot.refDistance&&(ot.refDistance=A),y!==ot.rolloffFactor&&(ot.rolloffFactor=y),(xe[0]!==1||xe[1]!==0||xe[2]!==0)&&O.setOrientation(...xe),(ye[0]!==0||ye[1]!==0||ye[2]!==0)&&O.setPosition(...ye);let bi=()=>{P.connect(O),o(P,jt,0,0),jt.connect(j).connect(k,0,0),jt.connect(q).connect(k,0,1),jt.connect(H).connect(k,0,2),jt.connect(Q).connect(k,0,3),jt.connect(et).connect(k,0,4),jt.connect(at).connect(k,0,5),k.connect(yt).connect(l.destination)},Ao=()=>{P.disconnect(O),a(P,jt,0,0),jt.disconnect(j),j.disconnect(k),jt.disconnect(q),q.disconnect(k),jt.disconnect(H),H.disconnect(k),jt.disconnect(Q),Q.disconnect(k),jt.disconnect(et),et.disconnect(k),jt.disconnect(at),at.disconnect(k),k.disconnect(yt),yt.disconnect(l.destination)};return u(Re(ot,O),bi,Ao)};var Ip=o=>(t,{disableNormalization:e,imag:r,real:i})=>{let n=r instanceof Float32Array?r:new Float32Array(r),s=i instanceof Float32Array?i:new Float32Array(i),a=t.createPeriodicWave(s,n,{disableNormalization:e});if(Array.from(r).length<2)throw o();return a};var Wi=(o,t,e,r)=>o.createScriptProcessor(t,e,r);var Sp=(o,t)=>(e,r)=>{let i=r.channelCountMode;if(i==="clamped-max")throw t();if(e.createStereoPanner===void 0)return o(e,r);let n=e.createStereoPanner();return ut(n,r),xt(n,r,"pan"),Object.defineProperty(n,"channelCountMode",{get:()=>i,set:s=>{if(s!==i)throw t()}}),n};var wp=(o,t,e,r,i,n)=>{let a=new Float32Array([1,1]),c=Math.PI/2,u={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},l=Z(R({},u),{oversample:"none"}),h=(f,g,x,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385);for(let N=0;N<16385;N+=1){let D=N/16384*c;I[N]=Math.cos(D),S[N]=Math.sin(D)}let T=e(f,Z(R({},u),{gain:0})),v=r(f,Z(R({},l),{curve:I})),C=r(f,Z(R({},l),{curve:a})),A=e(f,Z(R({},u),{gain:0})),y=r(f,Z(R({},l),{curve:S}));return{connectGraph(){g.connect(T),g.connect(C.inputs===void 0?C:C.inputs[0]),g.connect(A),C.connect(x),x.connect(v.inputs===void 0?v:v.inputs[0]),x.connect(y.inputs===void 0?y:y.inputs[0]),v.connect(T.gain),y.connect(A.gain),T.connect(b,0,0),A.connect(b,0,1)},disconnectGraph(){g.disconnect(T),g.disconnect(C.inputs===void 0?C:C.inputs[0]),g.disconnect(A),C.disconnect(x),x.disconnect(v.inputs===void 0?v:v.inputs[0]),x.disconnect(y.inputs===void 0?y:y.inputs[0]),v.disconnect(T.gain),y.disconnect(A.gain),T.disconnect(b,0,0),A.disconnect(b,0,1)}}},p=(f,g,x,b)=>{let I=new Float32Array(16385),S=new Float32Array(16385),T=new Float32Array(16385),v=new Float32Array(16385),C=Math.floor(16385/2);for(let q=0;q<16385;q+=1)if(q>C){let H=(q-C)/(16384-C)*c;I[q]=Math.cos(H),S[q]=Math.sin(H),T[q]=0,v[q]=1}else{let H=q/(16384-C)*c;I[q]=1,S[q]=0,T[q]=Math.cos(H),v[q]=Math.sin(H)}let A=t(f,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),y=e(f,Z(R({},u),{gain:0})),N=r(f,Z(R({},l),{curve:I})),D=e(f,Z(R({},u),{gain:0})),E=r(f,Z(R({},l),{curve:S})),O=r(f,Z(R({},l),{curve:a})),W=e(f,Z(R({},u),{gain:0})),k=r(f,Z(R({},l),{curve:T})),P=e(f,Z(R({},u),{gain:0})),j=r(f,Z(R({},l),{curve:v}));return{connectGraph(){g.connect(A),g.connect(O.inputs===void 0?O:O.inputs[0]),A.connect(y,0),A.connect(D,0),A.connect(W,1),A.connect(P,1),O.connect(x),x.connect(N.inputs===void 0?N:N.inputs[0]),x.connect(E.inputs===void 0?E:E.inputs[0]),x.connect(k.inputs===void 0?k:k.inputs[0]),x.connect(j.inputs===void 0?j:j.inputs[0]),N.connect(y.gain),E.connect(D.gain),k.connect(W.gain),j.connect(P.gain),y.connect(b,0,0),W.connect(b,0,0),D.connect(b,0,1),P.connect(b,0,1)},disconnectGraph(){g.disconnect(A),g.disconnect(O.inputs===void 0?O:O.inputs[0]),A.disconnect(y,0),A.disconnect(D,0),A.disconnect(W,1),A.disconnect(P,1),O.disconnect(x),x.disconnect(N.inputs===void 0?N:N.inputs[0]),x.disconnect(E.inputs===void 0?E:E.inputs[0]),x.disconnect(k.inputs===void 0?k:k.inputs[0]),x.disconnect(j.inputs===void 0?j:j.inputs[0]),N.disconnect(y.gain),E.disconnect(D.gain),k.disconnect(W.gain),j.disconnect(P.gain),y.disconnect(b,0,0),W.disconnect(b,0,0),D.disconnect(b,0,1),P.disconnect(b,0,1)}}},d=(f,g,x,b,I)=>{if(g===1)return h(f,x,b,I);if(g===2)return p(f,x,b,I);throw i()};return(f,S)=>{var T=S,{channelCount:g,channelCountMode:x,pan:b}=T,I=Rr(T,["channelCount","channelCountMode","pan"]);if(x==="max")throw i();let v=o(f,Z(R({},I),{channelCount:1,channelCountMode:x,numberOfInputs:2})),C=e(f,Z(R({},I),{channelCount:g,channelCountMode:x,gain:1})),A=e(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:b}),{connectGraph:y,disconnectGraph:N}=d(f,g,C,A,v);Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"maxValue",{get:()=>1}),Object.defineProperty(A.gain,"minValue",{get:()=>-1});let D={get bufferSize(){},get channelCount(){return C.channelCount},set channelCount(k){C.channelCount!==k&&(E&&N(),{connectGraph:y,disconnectGraph:N}=d(f,k,C,A,v),E&&y()),C.channelCount=k},get channelCountMode(){return C.channelCountMode},set channelCountMode(k){if(k==="clamped-max"||k==="max")throw i();C.channelCountMode=k},get channelInterpretation(){return C.channelInterpretation},set channelInterpretation(k){C.channelInterpretation=k},get context(){return C.context},get inputs(){return[C]},get numberOfInputs(){return C.numberOfInputs},get numberOfOutputs(){return C.numberOfOutputs},get pan(){return A.gain},addEventListener(...k){return C.addEventListener(k[0],k[1],k[2])},dispatchEvent(...k){return C.dispatchEvent(k[0])},removeEventListener(...k){return C.removeEventListener(k[0],k[1],k[2])}},E=!1,O=()=>{y(),E=!0},W=()=>{N(),E=!1};return n(Re(D,v),O,W)}};var Tp=(o,t,e,r,i,n,s)=>(a,c)=>{let u=a.createWaveShaper();if(n!==null&&n.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=>x=>(g.call(u,x),p&&(r(x)&&h===null?h=o(a,u):!r(x)&&h!==null&&(h(),h=null)),x)),i(u,()=>{p=!0,r(u.curve)&&(h=o(a,u))},()=>{p=!1,h!==null&&(h(),h=null)})};var Np=(o,t,e,r,i)=>(n,u)=>{var l=u,{curve:s,oversample:a}=l,c=Rr(l,["curve","oversample"]);let h=n.createWaveShaper(),p=n.createWaveShaper();ut(h,c),ut(p,c);let d=e(n,Z(R({},c),{gain:1})),f=e(n,Z(R({},c),{gain:-1})),g=e(n,Z(R({},c),{gain:1})),x=e(n,Z(R({},c),{gain:-1})),b=null,I=!1,S=null,T={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(A){d.channelCount=A,f.channelCount=A,h.channelCount=A,g.channelCount=A,p.channelCount=A,x.channelCount=A},get channelCountMode(){return h.channelCountMode},set channelCountMode(A){d.channelCountMode=A,f.channelCountMode=A,h.channelCountMode=A,g.channelCountMode=A,p.channelCountMode=A,x.channelCountMode=A},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(A){d.channelInterpretation=A,f.channelInterpretation=A,h.channelInterpretation=A,g.channelInterpretation=A,p.channelInterpretation=A,x.channelInterpretation=A},get context(){return h.context},get curve(){return S},set curve(A){if(A!==null&&A.length<2)throw t();if(A===null)h.curve=A,p.curve=A;else{let y=A.length,N=new Float32Array(y+2-y%2),D=new Float32Array(y+2-y%2);N[0]=A[0],D[0]=-A[y-1];let E=Math.ceil((y+1)/2),O=(y+1)/2-1;for(let W=1;W<E;W+=1){let k=W/E*O,P=Math.floor(k),j=Math.ceil(k);N[W]=P===j?A[P]:(1-(k-P))*A[P]+(1-(j-k))*A[j],D[W]=P===j?-A[y-1-P]:-((1-(k-P))*A[y-1-P])-(1-(j-k))*A[y-1-j]}N[E]=y%2===1?A[E-1]:(A[E-2]+A[E-1])/2,h.curve=N,p.curve=D}S=A,I&&(r(S)&&b===null?b=o(n,d):b!==null&&(b(),b=null))},get inputs(){return[d]},get numberOfInputs(){return h.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get oversample(){return h.oversample},set oversample(A){h.oversample=A,p.oversample=A},addEventListener(...A){return d.addEventListener(A[0],A[1],A[2])},dispatchEvent(...A){return d.dispatchEvent(A[0])},removeEventListener(...A){return d.removeEventListener(A[0],A[1],A[2])}};s!==null&&(T.curve=s instanceof Float32Array?s:new Float32Array(s)),a!==T.oversample&&(T.oversample=a);let v=()=>{d.connect(h).connect(g),d.connect(f).connect(p).connect(x).connect(g),I=!0,r(S)&&(b=o(n,d))},C=()=>{d.disconnect(h),h.disconnect(g),d.disconnect(f),f.disconnect(p),p.disconnect(x),x.disconnect(g),I=!1,b!==null&&(b(),b=null)};return i(Re(T,g),v,C)};var Zt=()=>new DOMException("","NotSupportedError");var zg={numberOfChannels:1},Op=(o,t,e,r,i)=>class extends o{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}=R(R({},zg),u),d=r(h,l,p);t(qe,()=>qe(d))||d.addEventListener("statechange",(()=>{let f=0,g=x=>{this._state==="running"&&(f>0?(d.removeEventListener("statechange",g),x.stopImmediatePropagation(),this._waitForThePromiseToSettle(x)):f+=1)};return g})()),super(d,h),this._length=l,this._nativeOfflineAudioContext=d,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 Yg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Rp=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Yg),u),p=e(l,h),d=n(l),f=d?r():null,g=c.sampleRate/2;super(c,!1,p,f),this._detune=t(this,d,p.detune,153600,-153600),this._frequency=t(this,d,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),ne(this)&&er(this)};this._nativeOscillatorNode.addEventListener("ended",u)}}stop(c=0){this._nativeOscillatorNode.stop(c),this._oscillatorNodeRenderer!==null&&(this._oscillatorNodeRenderer.stop=c)}};var Mp=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=null,a=null,c=null,u=(l,h)=>X(null,null,function*(){let p=e(l),d=pt(p,h);if(!d){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 n.set(h,p),d?(yield o(h,l.detune,p.detune),yield o(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=n.get(h);return p!==void 0?Promise.resolve(p):u(l,h)}}};var Hg={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},Ep=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Hg),u),p=e(l,h),d=n(l),f=d?r():null;super(c,!1,p,f),this._nativePannerNode=p,this._orientationX=t(this,d,p.orientationX,Et,Lt),this._orientationY=t(this,d,p.orientationY,Et,Lt),this._orientationZ=t(this,d,p.orientationZ,Et,Lt),this._positionX=t(this,d,p.positionX,Et,Lt),this._positionY=t(this,d,p.positionY,Et,Lt),this._positionZ=t(this,d,p.positionZ,Et,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 Dp=(o,t,e,r,i,n,s,a,c,u)=>()=>{let l=new WeakMap,h=null,p=(d,f)=>X(null,null,function*(){let g=null,x=n(d),b={channelCount:x.channelCount,channelCountMode:x.channelCountMode,channelInterpretation:x.channelInterpretation},I=Z(R({},b),{coneInnerAngle:x.coneInnerAngle,coneOuterAngle:x.coneOuterAngle,coneOuterGain:x.coneOuterGain,distanceModel:x.distanceModel,maxDistance:x.maxDistance,panningModel:x.panningModel,refDistance:x.refDistance,rolloffFactor:x.rolloffFactor}),S=pt(x,f);if("bufferSize"in x)g=r(f,Z(R({},b),{gain:1}));else if(!S){let T=Z(R({},I),{orientationX:x.orientationX.value,orientationY:x.orientationY.value,orientationZ:x.orientationZ.value,positionX:x.positionX.value,positionY:x.positionY.value,positionZ:x.positionZ.value});x=i(f,T)}if(l.set(f,g===null?x:g),g!==null){if(h===null){if(s===null)throw new Error("Missing the native OfflineAudioContext constructor.");let E=new s(6,d.context.length,f.sampleRate),O=t(E,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});O.connect(E.destination),h=X(null,null,function*(){let W=yield Promise.all([d.orientationX,d.orientationY,d.orientationZ,d.positionX,d.positionY,d.positionZ].map((k,P)=>X(null,null,function*(){let j=e(E,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:P===0?1:0});return yield a(E,k,j.offset),j})));for(let k=0;k<6;k+=1)W[k].connect(O,0,k),W[k].start(0);return u(E)})}let T=yield h,v=r(f,Z(R({},b),{gain:1}));yield c(d,f,v);let C=[];for(let E=0;E<T.numberOfChannels;E+=1)C.push(T.getChannelData(E));let A=[C[0][0],C[1][0],C[2][0]],y=[C[3][0],C[4][0],C[5][0]],N=r(f,Z(R({},b),{gain:1})),D=i(f,Z(R({},I),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:y[0],positionY:y[1],positionZ:y[2]}));v.connect(N).connect(D.inputs[0]),D.connect(g);for(let E=128;E<T.length;E+=128){let O=[C[0][E],C[1][E],C[2][E]],W=[C[3][E],C[4][E],C[5][E]];if(O.some((k,P)=>k!==A[P])||W.some((k,P)=>k!==y[P])){A=O,y=W;let k=E/f.sampleRate;N.gain.setValueAtTime(0,k),N=r(f,Z(R({},b),{gain:0})),D=i(f,Z(R({},I),{orientationX:A[0],orientationY:A[1],orientationZ:A[2],positionX:y[0],positionY:y[1],positionZ:y[2]})),N.gain.setValueAtTime(1,k),v.connect(N).connect(D.inputs[0]),D.connect(g)}}return g}return S?(yield o(f,d.orientationX,x.orientationX),yield o(f,d.orientationY,x.orientationY),yield o(f,d.orientationZ,x.orientationZ),yield o(f,d.positionX,x.positionX),yield o(f,d.positionY,x.positionY),yield o(f,d.positionZ,x.positionZ)):(yield a(f,d.orientationX,x.orientationX),yield a(f,d.orientationY,x.orientationY),yield a(f,d.orientationZ,x.orientationZ),yield a(f,d.positionX,x.positionX),yield a(f,d.positionY,x.positionY),yield a(f,d.positionZ,x.positionZ)),Oe(x)?yield c(d,f,x.inputs[0]):yield c(d,f,x),x});return{render(d,f){let g=l.get(f);return g!==void 0?Promise.resolve(g):p(d,f)}}};var Qg={disableNormalization:!1},kp=(o,t,e,r)=>class jp{constructor(n,s){let a=t(n),c=r(R(R({},Qg),s)),u=o(a,c);return e.add(u),u}static[Symbol.hasInstance](n){return n!==null&&typeof n=="object"&&Object.getPrototypeOf(n)===jp.prototype||e.has(n)}};var Lp=(o,t)=>(e,r,i)=>(o(r).replay(i),t(r,e,i));var Pp=(o,t,e)=>(r,i,n)=>X(null,null,function*(){let s=o(r);yield Promise.all(s.activeInputs.map((a,c)=>Array.from(a).map(h=>X(null,[h],function*([u,l]){let d=yield t(u).render(u,i),f=r.context.destination;!e(u)&&(r!==f||!e(r))&&d.connect(n,l,c)}))).reduce((a,c)=>[...a,...c],[]))});var Fp=(o,t,e)=>(r,i,n)=>X(null,null,function*(){let s=t(r);yield Promise.all(Array.from(s.activeInputs).map(u=>X(null,[u],function*([a,c]){let h=yield o(a).render(a,i);e(a)||h.connect(n,c)})))});var Bp=(o,t,e,r)=>i=>o(qe,()=>qe(i))?Promise.resolve(o(r,r)).then(n=>{if(!n){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(n=>{let s=t(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{s.disconnect(),n(a.renderedBuffer)},s.connect(i.destination),i.startRendering()});var Gp=o=>(t,e)=>{o.set(t,e)};var Vp=o=>(t,e)=>o.set(t,e);var qp=(o,t,e,r,i,n,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),Ei(l)):t(n,()=>n(l))||a(l),o.add(l),l));var Zg={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Wp=(o,t,e,r,i,n)=>class extends o{constructor(a,c){let u=i(a),l=R(R({},Zg),c),h=e(u,l),p=n(u),d=p?r():null;super(a,!1,h,d),this._pan=t(this,p,h.pan)}get pan(){return this._pan}};var Up=(o,t,e,r,i)=>()=>{let n=new WeakMap,s=(a,c)=>X(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 n.set(c,u),l?yield o(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=n.get(c);return u!==void 0?Promise.resolve(u):s(a,c)}}};var zp=o=>()=>{if(o===null)return!1;try{new o({length:1,sampleRate:44100})}catch(t){return!1}return!0};var Yp=(o,t)=>()=>X(null,null,function*(){if(o===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),n=!1,s=!1;try{yield r.audioWorklet.addModule(i);let a=new o(r,"a",{numberOfOutputs:0}),c=r.createOscillator();a.port.onmessage=()=>n=!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 n&&!s});var Hp=(o,t)=>()=>{if(t===null)return Promise.resolve(!1);let e=new t(1,1,44100),r=o(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{e.oncomplete=()=>{r.disconnect(),i(e.currentTime!==0)},e.startRendering()})};var Cc=()=>new DOMException("","UnknownError");var Xg={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},Qp=(o,t,e,r,i,n,s)=>class extends o{constructor(c,u){let l=i(c),h=R(R({},Xg),u),p=e(l,h),f=n(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 Zp=(o,t,e)=>()=>{let r=new WeakMap,i=(n,s)=>X(null,null,function*(){let a=t(n);if(!pt(a,s)){let u={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=o(s,u)}return r.set(s,a),Oe(a)?yield e(n,s,a.inputs[0]):yield e(n,s,a),a});return{render(n,s){let a=r.get(s);return a!==void 0?Promise.resolve(a):i(n,s)}}};var Xp=()=>typeof window=="undefined"?null:window;var Jp=(o,t)=>e=>{e.copyFromChannel=(r,i,n=0)=>{let s=o(n),a=o(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,n=0)=>{let s=o(n),a=o(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 Kp=o=>t=>{t.copyFromChannel=(e=>(r,i,n=0)=>{let s=o(n),a=o(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyFromChannel),t.copyToChannel=(e=>(r,i,n=0)=>{let s=o(n),a=o(i);if(s<t.length)return e.call(t,r,a,s)})(t.copyToChannel)};var $p=o=>(t,e)=>{let r=e.createBuffer(1,1,44100);t.buffer===null&&(t.buffer=r),o(t,"buffer",i=>()=>{let n=i.call(t);return n===r?null:n},i=>n=>i.call(t,n===null?r:n))};var td=(o,t)=>(e,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw o()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw o()}});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 _c=(o,t,e)=>o.copyFromChannel===void 0?o.getChannelData(e)[0]:(o.copyFromChannel(t,e),t[0]);var vc=o=>{if(o===null)return!1;let t=o.length;return t%2!==0?o[Math.floor(t/2)]!==0:o[t/2-1]+o[t/2]!==0};var Ui=(o,t,e,r)=>{let i=o;for(;!i.hasOwnProperty(t);)i=Object.getPrototypeOf(i);let{get:n,set:s}=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(o,t,{get:e(n),set:r(s)})};var ed=o=>Z(R({},o),{outputChannelCount:o.outputChannelCount!==void 0?o.outputChannelCount:o.numberOfInputs===1&&o.numberOfOutputs===1?[o.channelCount]:Array.from({length:o.numberOfOutputs},()=>1)});var rd=o=>Z(R({},o),{channelCount:o.numberOfOutputs});var id=o=>{let{imag:t,real:e}=o;return t===void 0?e===void 0?Z(R({},o),{imag:[0,0],real:[0,0]}):Z(R({},o),{imag:Array.from(e,()=>0),real:e}):e===void 0?Z(R({},o),{imag:t,real:Array.from(t,()=>0)}):Z(R({},o),{imag:t,real:e})};var Ic=(o,t,e)=>{try{o.setValueAtTime(t,e)}catch(r){if(r.code!==9)throw r;Ic(o,t,e+1e-7)}};var od=o=>{let t=o.createBufferSource();t.start();try{t.start()}catch(e){return!0}return!1};var nd=o=>{let t=o.createBufferSource(),e=o.createBuffer(1,1,44100);t.buffer=e;try{t.start(0,1)}catch(r){return!1}return!0};var sd=o=>{let t=o.createBufferSource();t.start();try{t.stop()}catch(e){return!1}return!0};var ns=o=>{let t=o.createOscillator();try{t.start(-1)}catch(e){return e instanceof RangeError}return!1};var Sc=o=>{let t=o.createBuffer(1,1,44100),e=o.createBufferSource();e.buffer=t,e.start(),e.stop();try{return e.stop(),!0}catch(r){return!1}};var ss=o=>{let t=o.createOscillator();try{t.stop(-1)}catch(e){return e instanceof RangeError}return!1};var ad=o=>{let{port1:t,port2:e}=new MessageChannel;try{t.postMessage(o)}finally{t.close(),e.close()}};var cd=o=>{o.start=(t=>(e=0,r=0,i)=>{let n=o.buffer,s=n===null?r:Math.min(n.duration,r);n!==null&&s>n.duration-.5/o.context.sampleRate?t.call(o,e,0,0):t.call(o,e,s,i)})(o.start)};var wc=(o,t)=>{let e=t.createGain();o.connect(e);let r=(i=>()=>{i.call(o,e),o.removeEventListener("ended",r)})(o.disconnect);o.addEventListener("ended",r),Re(o,e),o.stop=(i=>{let n=!1;return(s=0)=>{if(n)try{i.call(o,s)}catch(a){e.gain.setValueAtTime(0,s)}else i.call(o,s),n=!0}})(o.stop)};var ei=(o,t)=>e=>{let r={value:o};return Object.defineProperties(e,{currentTarget:r,target:r}),typeof t=="function"?t.call(o,e):t.handleEvent.call(o,e)};var Jg=Ku(Ve),Kg=cl(Ve),$g=ih(Lr),ld=new WeakMap,tx=bh(ld),Me=Fl(new Map,new WeakMap),rr=Xp(),hd=Qh(Me,Ne),Tc=yh(Ht),Xt=Pp(Ht,Tc,gr),ex=pl(hd,Ct,Xt),St=_h(Ri),xr=Ap(rr),_t=Ph(xr),pd=new WeakMap,dd=ph(ei),zi=Kh(rr),Nc=Dh(zi),Oc=kh(rr),md=jh(rr),Vo=tp(rr),Pt=Ol($u(Hn),al(Jg,Kg,Di,$g,ki,Ht,tx,tr,Ct,Ve,ne,gr,ji),Me,Nh(Po,ki,Ht,Ct,$r,ne),Ne,Bi,Zt,th(Di,Po,Ht,Ct,$r,St,ne,_t),sh(pd,Ht,Vt),dd,St,Nc,Oc,md,_t,Vo),rx=hl(Pt,ex,Ne,hd,St,_t);var Rc=new WeakSet,ud=Zh(rr),fd=Ql(new Uint32Array(1)),Mc=Jp(fd,Ne),Ec=Kp(fd),Dc=dl(Rc,Me,Zt,ud,xr,zp(ud),Mc,Ec);var as=ul(se),gd=Fp(Tc,Pr,gr),ir=Wl(gd),Yi=Jh(as,Me,od,nd,sd,ns,Sc,ss,cd,$p(Ui),wc),or=Lp(Ah(Pr),gd),ix=gl(ir,Yi,Ct,or,Xt),We=Rl(tl(Qn),pd,Lo,Ml,ic,oc,nc,sc,ac,wi,Mo,zi,Ic),ox=fl(Pt,ix,We,wt,Yi,St,_t,ei);var nx=Il(Pt,Sl,Ne,wt,$h(se,Ui),St,_t,Xt),sx=Pl(ir,bc,Ct,or,Xt),ri=Vp(ld),ax=Ll(Pt,We,sx,Bi,bc,St,_t,ri),Gr=Yh(Ve,Oc),cx=td(wt,Gr),Vr=ap(zi,cx),ux=Gl(Vr,Ct,Xt),lx=Bl(Pt,ux,Vr,St,_t),hx=ql(qi,Ct,Xt),px=Vl(Pt,hx,qi,St,_t,rd),dx=lp(as,Yi,se,Gr),Hi=up(as,Me,dx,ns,ss),mx=Hl(ir,Hi,Ct,or,Xt),fx=Yl(Pt,We,mx,Hi,St,_t,ei),xd=hp(Zt,Ui),gx=Xl(xd,Ct,Xt),xx=Zl(Pt,gx,xd,St,_t,ri),yx=rh(ir,Ac,Ct,or,Xt),bx=eh(Pt,We,yx,Ac,St,_t,ri),yd=pp(Zt),Ax=uh(ir,yd,Ct,or,Xt),Cx=ch(Pt,We,Ax,yd,Zt,St,_t,ri),_x=gh(ir,se,Ct,or,Xt),vx=fh(Pt,We,_x,se,St,_t),Ix=fp(Bi,wt,Wi,Zt),cs=Bp(Me,se,Wi,Hp(se,xr)),Sx=Th(Yi,Ct,xr,Xt,cs),wx=dp(Ix),Tx=wh(Pt,wx,Sx,St,_t,ri),Nx=wl(We,Vr,Hi,Wi,Zt,_c,_t,Ui),bd=new WeakMap,kc=Uh(nx,Nx,dd,_t,bd,ei),Ad=Cp(as,Me,ns,Sc,ss,wc),Ox=Mp(ir,Ad,Ct,or,Xt),Rx=Rp(Pt,We,Ad,Ox,St,_t,ei),Cd=zl(Yi),Mx=Np(Cd,wt,se,vc,Gr),us=Tp(Cd,wt,Mx,vc,Gr,zi,Ui),Ex=vp(Di,wt,Vr,se,Wi,us,Zt,ki,_c,Gr),_d=_p(Ex),Dx=Dp(ir,Vr,Hi,se,_d,Ct,xr,or,Xt,cs),kx=Ep(Pt,We,_d,Dx,St,_t,ri),jx=Ip(Ne),Lx=kp(jx,St,new WeakSet,id),Px=wp(Vr,qi,se,us,Zt,Gr),vd=Sp(Px,Zt),Fx=Up(ir,vd,Ct,or,Xt),Bx=Wp(Pt,We,vd,Fx,St,_t),Gx=Zp(us,Ct,Xt),Vx=Qp(Pt,wt,us,Gx,St,_t,ri),Id=Fh(rr),jc=dh(rr),Sd=new WeakMap,qx=vh(Sd,xr),Wx=Id?sl(Me,Zt,hh(rr),jc,mh(Ju),St,qx,_t,Vo,new WeakMap,new WeakMap,Yp(Vo,xr),rr):void 0,Ux=Lh(Nc,_t),zx=$l(Rc,Me,Kl,lh,new WeakSet,St,Ux,Mi,qe,Mc,Ec),wd=jl(Wx,rx,Dc,ox,ax,lx,px,fx,xx,zx,bx,Cx,vx,Tx,kc,Rx,kx,Lx,Bx,Vx),Yx=Bh(Pt,gp,St,_t),Hx=Gh(Pt,xp,St,_t),Qx=Vh(Pt,yp,St,_t),Zx=bp(wt,_t),Xx=qh(Pt,Zx,St),Td=vl(wd,wt,Zt,Cc,Yx,Hx,Qx,Xx,zi);var Lc=Ih(bd),Jx=ll(Lc),Nd=Ul(Ne),Kx=oh(Lc),Od=ah(Ne),Rd=new WeakMap,$x=xh(Rd,Vt),ty=sp(Nd,Ne,wt,Vr,qi,Hi,se,Wi,Zt,Od,jc,$x,Gr),ey=rp(wt,ty,se,Zt,Gr),ry=kl(ir,Nd,Yi,Vr,qi,Hi,se,Kx,Od,jc,Ct,Vo,xr,or,Xt,cs),iy=Ch(Sd),oy=Gp(Rd),Pc=Id?El(Jx,Pt,We,ry,ey,Ht,iy,St,_t,Vo,ed,oy,ad,ei):void 0;var uq=Wh(wt,Zt,Cc,kc,zi);var Md=Jl(Zt,xr),Ed=qp(Rc,Me,Tc,Lc,cs,Mi,Mc,Ec),lq=zh(Me,wt,Md,kc,Ed);var Dd=Op(wd,Me,wt,Md,Ed);var kd=Oh(Ri,Nc),jd=Rh(Oi,Oc),Ld=Mh(Lo,md),Pd=Eh(Ri,_t);function Ft(o){return o===void 0}function $(o){return o!==void 0}function Fd(o){return typeof o=="function"}function Jt(o){return typeof o=="number"}function Ue(o){return Object.prototype.toString.call(o)==="[object Object]"&&o.constructor===Object}function Fc(o){return typeof o=="boolean"}function Ot(o){return Array.isArray(o)}function te(o){return typeof o=="string"}function qo(o){return te(o)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(o)}function G(o,t){if(!o)throw new Error(t)}function Dt(o,t,e=1/0){if(!(t<=o&&o<=e))throw new RangeError(`Value must be within [${t}, ${e}], got: ${o}`)}function ls(o){!o.isOffline&&o.state!=="running"&&ii('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}var Gd=!1,Bd=!1;function Bc(o){Gd=o}function Vd(o){Ft(o)&&Gd&&!Bd&&(Bd=!0,ii("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"))}var qd=console;function Wd(...o){qd.log(...o)}function ii(...o){qd.warn(...o)}function Ud(o){return new Td(o)}function zd(o,t,e){return new Dd(o,t,e)}var ee=typeof self=="object"?self:null,Yd=ee&&(ee.hasOwnProperty("AudioContext")||ee.hasOwnProperty("webkitAudioContext"));function Hd(o,t,e){return G($(Pc),"AudioWorkletNode only works in a secure context (https or localhost)"),new(o instanceof(ee==null?void 0:ee.BaseAudioContext)?ee==null?void 0:ee.AudioWorkletNode:Pc)(o,t,e)}function re(o,t,e,r){var i=arguments.length,n=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,t,e,r);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(n=(i<3?s(n):i>3?s(t,e,n):s(t,e))||n);return i>3&&n&&Object.defineProperty(t,e,n),n}function ht(o,t,e,r){function i(n){return n instanceof e?n:new e(function(s){s(n)})}return new(e||(e=Promise))(function(n,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?n(l.value):i(l.value).then(a,c)}u((r=r.apply(o,t||[])).next())})}var hs=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 Ue(o){return Ld(o)}function or(o){return kd(o)}function Hi(o){return jd(o)}function Gr(o){return Dd(o)}function Hd(o){return o instanceof Dc}function sy(o,t){return o==="value"||Ue(t)||or(t)||Hd(t)}function Me(o,...t){if(!t.length)return o;let e=t.shift();if(We(o)&&We(e))for(let r in e)sy(r,e[r])?o[r]=e[r]:We(e[r])?(o[r]||Object.assign(o,{[r]:{}}),Me(o[r],e[r])):Object.assign(o,{[r]:e[r]});return Me(o,...t)}function Qd(o,t){return o.length===t.length&&o.every((e,r)=>t[r]===e)}function w(o,t,e=[],r){let i={},n=Array.from(t);if(We(n[0])&&r&&!Reflect.has(n[0],r)&&(Object.keys(n[0]).some(a=>Reflect.has(o,a))||(Me(i,{[r]:n[0]}),e.splice(e.indexOf(r),1),n.shift())),n.length===1&&We(n[0]))Me(i,n[0]);else for(let s=0;s<e.length;s++)$(n[s])&&(i[e[s]]=n[s]);return Me(o,i)}function Zd(o){return o.constructor.getDefaults()}function be(o,t){return Ft(o)?t:o}function ze(o,t){return t.forEach(e=>{Reflect.has(o,e)&&delete o[e]}),o}var Qt=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ee&&this.toString()===ee.TONE_DEBUG_CLASS)&&qd(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Qt.version=Ro;function yr(o,t){return o>t+1e-6}function Wo(o,t){return yr(o,t)||ae(o,t)}function ei(o,t){return o+1e-6<t}function ae(o,t){return Math.abs(o-t)<1e-6}function Gc(o,t,e){return Math.max(Math.min(o,e),t)}var qt=class o extends Qt{constructor(){super(),this.name="Timeline",this._timeline=[];let t=w(o.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(G(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];G(Wo(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(ae(this._timeline[e].time,t)){for(let r=e;r>=0&&ae(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&&Wo(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,n=i;if(i>0&&this._timeline[i-1][e]<=t)return i-1;for(;r<n;){let s=Math.floor(r+(n-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ae(a[e],t)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ae(l[e],t))s=u;else break}return s}else{if(ei(a[e],t)&&yr(c[e],t))return s;yr(a[e],t)?n=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),n=this._search(e);return i!==-1&&n!==-1?(this._timeline[i].time!==t&&(i+=1),this._timeline[n].time===e&&(n-=1),this._iterate(r,i,n)):i===-1&&this._iterate(r,0,n),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&&ae(this._timeline[r].time,t)){let i=r;for(let n=r;n>=0&&ae(this._timeline[n].time,t);n--)i=n;this._iterate(n=>{e(n)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Xd=[];function Vr(o){Xd.push(o)}function Jd(o){Xd.forEach(t=>t(o))}var Kd=[];function qr(o){Kd.push(o)}function $d(o){Kd.forEach(t=>t(o))}var Wr=class o extends Qt{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 n=this._events[i];for(let s=n.length-1;s>=0;s--)n[s]===e&&n.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,n=r.length;i<n;i++)r[i].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(o.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var Qi=class extends Wr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var ri=class o extends Qi{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new qt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=w(o.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=Wd({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new hs(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||(Jd(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 G(Gr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return G(Gr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return G(Gr(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){G(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){G(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){G(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){G(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return Yd(this.rawContext,t,e)}addAudioWorkletModule(t){return ht(this,void 0,void 0,function*(){G($(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 Gr(this._context)?this._context.resume():Promise.resolve()}close(){return ht(this,void 0,void 0,function*(){Gr(this._context)&&this.state!=="closed"&&!this._closeStarted&&(this._closeStarted=!0,yield this._context.close()),this._initialized&&$d(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 n=0;n<r.length;n++)r[n]=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 n=this.now();this._timeouts.add({callback:()=>{t(),i()},id:r,time:n+e})};return i(),r}};var ps=class extends Qi{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 B(o,t){Nt(t)?t.forEach(e=>B(o,e)):Object.defineProperty(o,t,{enumerable:!0,writable:!1})}function ii(o,t){Nt(t)?t.forEach(e=>ii(o,e)):Object.defineProperty(o,t,{writable:!0})}var tt=()=>{};var Dt=class o extends Qt{constructor(){super(),this.name="ToneAudioBuffer",this.onload=tt;let t=w(o.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,te(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:tt,onload:tt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Bt().sampleRate}set(t){return t instanceof o?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=o.load(t).then(r=>{this.set(r),this.onload(this)});o.downloads.push(e);try{yield e}finally{let r=o.downloads.indexOf(e);o.downloads.splice(r,1)}return this})}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){let e=Nt(t)&&t[0].length>0,r=e?t.length:1,i=e?t[0].length:t.length,n=Bt(),s=n.createBuffer(r,i,n.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(Jt(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let i=0;i<r;i++){let n=this.toArray(i);for(let s=0;s<n.length;s++)e[s]+=n[s]}e=e.map(i=>i/r),this.fromArray(e)}return this}toArray(t){if(Jt(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){G(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),i=Math.floor(e*this.sampleRate);G(r<i,"The start time must be less than the end time");let n=i-r,s=Bt().createBuffer(this.numberOfChannels,n,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,i),a);return new o(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 o().fromArray(t)}static fromUrl(t){return ht(this,void 0,void 0,function*(){return yield new o().load(t)})}static load(t){return ht(this,void 0,void 0,function*(){let e=o.baseUrl===""||o.baseUrl.endsWith("/")?o.baseUrl:o.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();o.downloads.length;)yield o.downloads[0]})}};Dt.baseUrl="";Dt.downloads=[];var Ye=class extends ri{constructor(){super({clockSource:"offline",context:Hi(arguments[0])?arguments[0]:Ud(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Hi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Hi(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 Dt(e)})}close(){return Promise.resolve()}};var tm=new ps,Zi=tm;function Bt(){return Zi===tm&&zd&&Vc(new ri),Zi}function Vc(o,t=!1){t&&Zi.dispose(),Gr(o)?Zi=new ri(o):Hi(o)?Zi=new Ye(o):Zi=o}if(ee&&!ee.TONE_SILENCE_LOGGING){let o="v";Ro==="dev"&&(o="");let t=` * Tone.js ${o}${Ro} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function Xi(o){return Math.pow(10,o/20)}function Ji(o){return 20*(Math.log(o)/Math.LN10)}function oi(o){return Math.pow(2,o/12)}var ds=440;function em(){return ds}function rm(o){ds=o}function He(o){return Math.round(qc(o))}function qc(o){return 69+12*Math.log2(o/ds)}function Uo(o){return ds*Math.pow(2,(o-69)/12)}var ms=class o extends Qt{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 o&&this.fromType(this._val),Ft(this._val))return this._noArg();if(te(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($(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 te(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 Ae=class o extends ms{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 o(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 n=1;n<9;n++){let s=Math.pow(2,n);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],i=new o(this.context,e[0]).toSeconds();return e.forEach(n=>{let s=new o(this.context,n).toSeconds();Math.abs(s-t)<Math.abs(i-t)&&(r=n,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 n=i.toString();return n.length>3&&(i=parseFloat(parseFloat(n).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 ce=class o extends Ae{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return em()}static set A4(t){rm(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:o.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let i=ay[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?i:o.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 o(this.context,this.valueOf()*oi(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return He(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/o.A4),r=Math.round(12*e)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),cy[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 Uo(t)}static ftom(t){return He(t)}},ay={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},cy=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var De=class extends Ae{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var Wt=class o extends Qt{constructor(){super();let t=w(o.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 Gd(t),new Ae(this.context,t).toSeconds()}toFrequency(t){return new ce(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=Zd(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 o?t[e]=r._getPartialProperties(t[e]):Nt(r)||Jt(r)||te(r)||Fc(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 o?this[e].set(t[e]):this[e]=t[e])}),this}};var nr=class extends qt{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 Mt(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 n=this._timeline[i];if(n.state===t)return n}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let n=this._timeline[i];if(n.state===t)return n}}};var nt=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,G($(t.param)&&(Ue(t.param)||t.param instanceof o),"param must be an AudioParam");!Ue(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 qt(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(Wt.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)&&Mt(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")?Xi(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?Ji(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),i=this._fromType(t);return G(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),n=this._initialValue;if(i===null)n=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"&&(n=this._exponentialApproach(i.time,a,i.value,i.constant,e))}else if(r===null)n=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"?n=this._linearInterpolate(i.time,s,r.time,r.value,e):n=this._exponentialInterpolate(i.time,s,r.time,r.value,e)}else n=i.value;return this._toType(n)}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 G(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=ae(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(e);return G(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);G(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let n=this.toSeconds(e);return this._assertRange(i),G(isFinite(i)&&isFinite(n),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:n,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",t,n,r),this._param.setTargetAtTime(i,n,r),this}setValueCurveAtTime(t,e,r,i=1){r=this.toSeconds(r),e=this.toSeconds(e);let n=this._fromType(t[0])*i;this.setValueAtTime(this._toType(n),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 G(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));G(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let i=this._events.get(e),n=this._events.getAfter(e);return i&&ae(i.time,e)?n?(this._param.cancelScheduledValues(n.time),this._events.cancel(n.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):n&&(this._param.cancelScheduledValues(n.time),this._events.cancel(n.time),n.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):n.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),n=i?i.time:e+2,s=(n-e)/10;for(let a=e;a<n;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){G(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,n){return r+(e-r)*Math.exp(-(n-t)/i)}_linearInterpolate(t,e,r,i,n){return e+(i-e)*((n-t)/(r-t))}_exponentialInterpolate(t,e,r,i,n){return e*Math.pow(i/e,(n-t)/(r-t))}};var j=class o extends Wt{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return $(this.input)?Ue(this.input)||this.input instanceof nt?1:this.input.numberOfInputs:0}get numberOfOutputs(){return $(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return $(t)&&(t instanceof o||or(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();G(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 Kt(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return ti("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return im(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 o?this.input.dispose():or(this.input)&&this.input.disconnect()),$(this.output)&&(this.output instanceof o?this.output.dispose():or(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function ke(...o){let t=o.shift();o.reduce((e,r)=>(e instanceof j?e.connect(r):or(e)&&Kt(e,r),r),t)}function Kt(o,t,e=0,r=0){for(G($(o),"Cannot connect from undefined node"),G($(t),"Cannot connect to undefined node"),(t instanceof j||or(t))&&G(t.numberOfInputs>0,"Cannot connect to node with no inputs"),G(o.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof j||t instanceof nt;)$(t.input)&&(t=t.input);for(;o instanceof j;)$(o.output)&&(o=o.output);Ue(t)?o.connect(t,e):o.connect(t,e,r)}function im(o,t,e=0,r=0){if($(t))for(;t instanceof j;)t=t.input;for(;!or(o);)$(o.output)&&(o=o.output);Ue(t)?o.disconnect(t,e):or(t)?o.disconnect(t,e,r):o.disconnect()}var Y=class o extends j{constructor(){let t=w(o.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 nt({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),B(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 Qe=class extends j{constructor(t){super(t),this.onended=tt,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Y({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let 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:tt})}_startGain(t,e=1){G(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){G(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!==tt&&(this.onended(this),this.onended=tt,!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"),G(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=tt,this}};var zo=class o extends Qe{constructor(){let t=w(o.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),Kt(this._source,this._gainNode),this.offset=new nt({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(Qe.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 K=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new zo({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 Ki(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 Ki(o,t,e,r){(t instanceof nt||Ue(t)||t instanceof K&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof K&&(t.overridden=!0)),Kt(o,t,e,r)}var fs=class o extends nt{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new qt(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(nt.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let i=this._fromType(t),n=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(n.time,n.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),n=this._events.previousEvent(i),s=this._getTicksUntilEvent(n,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),n=this._events.previousEvent(i),s=this._getTicksUntilEvent(n,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),n=Math.round(Math.max((e-i.time)*10,1)),s=(e-i.time)/n;for(let a=0;a<=n;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)),n=this._events.get(e);return n&&n.time===e&&n.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),n=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-n}_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 gs=class o extends K{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new fs({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(K.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 xs=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new nr,this._tickOffset=new qt,this._ticksAtTime=new qt,this._secondsAtTime=new qt,this.frequency=new gs({context:this.context,units:t.units,value:t.frequency}),B(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Wt.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),n={state:"paused",time:e};this._state.add(n);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!==n.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(n),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),n=i||e,s=i?i.seconds:0,a=null;return this._state.forEachBetween(n.time,t+this.sampleTime,c=>{let u=n.time,l=this._tickOffset.get(c.time);l&&l.time>=n.time&&(s=l.seconds,u=l.time),n.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),n=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),n=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(n)+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 n=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=ae(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<e;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(p){n=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(n)throw n;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var $i=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=tt,this._lastUpdate=0,this._state=new nr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new xs({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,B(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Wt.getDefaults(),{callback:tt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){ls(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}};Wr.mixin($i);var Le=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new Y({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,B(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 Wc=class o extends j{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="Destination",this.input=new Le({context:this.context}),this.output=new Y({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(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),ke(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}};Vr(o=>{o.destination=new Wc({context:o})});qr(o=>{o.destination.dispose()});var Uc=class extends j{constructor(){super(...arguments),this.name="Listener",this.positionX=new nt({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new nt({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new nt({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new nt({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new nt({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new nt({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new nt({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new nt({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new nt({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}};Vr(o=>{o.listener=new Uc({context:o})});qr(o=>{o.listener.dispose()});var to=class o extends Qt{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=w(o.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:tt,onload:tt,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return G(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=tt,i=tt){return te(e)?(this.baseUrl&&e.trim().substring(0,11).toLowerCase()==="data:audio/"&&(this.baseUrl=""),this._buffers.set(t.toString(),new Dt(this.baseUrl+e,r,i))):this._buffers.set(t.toString(),new Dt(e,r,i)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}};var Yo=class o extends ce{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 Uo(this.toMidi())}transpose(t){return new o(this.context,this.toMidi()+t)}};var Ce=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 zc=class extends Wt{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new qt,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}};Vr(o=>{o.draw=new zc({context:o})});qr(o=>{o.draw.dispose()});var ys=class extends Qt{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){G($(t.time),"Events must have a time property"),G($(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Yc(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}},Yc=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 bs=class extends Qt{constructor(t){super(),this.name="TimelineValue",this._timeline=new qt({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 ie=class o extends j{constructor(){super(w(o.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return Ki(this,t,e,r),this}};var he=class o extends ie{constructor(){let t=w(o.getDefaults(),arguments,["mapping","length"]);super(t),this.name="WaveShaper",this._shaper=this.context.createWaveShaper(),this.input=this._shaper,this.output=this._shaper,Nt(t.mapping)||t.mapping instanceof Float32Array?this.curve=Float32Array.from(t.mapping):Pd(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(K.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let i=0,n=e;i<n;i++){let s=i/(n-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));G(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var eo=class o extends ie{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new he({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ie.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 br=class o{constructor(t,e){this.id=o._eventId++,this._remainderTime=0;let r=Object.assign(o.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:tt,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}};br._eventId=0;var As=class o extends br{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(o.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({},br.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return ei(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Ce(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){ei(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 Ce(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);yr(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 Cs=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new bs(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new qt,this._repeatedEvents=new ys,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new $i({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),B(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(Wt.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 Ce(this.context,this._swingTicks*2/3).toSeconds()*i}Bc(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),Bc(!1)}schedule(t,e){let r=new br(this,{callback:t,time:new De(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,i=1/0){let n=new As(this,{callback:t,duration:new Ae(this.context,i).toTicks(),interval:new Ae(this.context,e).toTicks(),time:new De(this.context,r).toTicks()});return this._addEvent(n,this._repeatedEvents)}scheduleOnce(t,e){let r=new br(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 Ce(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){Nt(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new Ae(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Ae(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 Ce(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 Ce(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),n=e+i;this.emit("stop",n),this._clock.setTicksAtTime(t,n),this.emit("start",n,this._clock.getSecondsAtTime(n))}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,n=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/n,u=new Y(c),l=new eo(-1),h=new Y(c);i.chain(u,l,h),i=h,n=1/n,s=[u,l,h]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/n:e=0);let a=new Y(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(),ii(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};Wr.mixin(Cs);Vr(o=>{o.transport=new Cs({context:o})});qr(o=>{o.transport.dispose()});var mt=class extends j{constructor(t){super(t),this.input=void 0,this._state=new nr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=tt,this._syncedStop=tt,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Le({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,B(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(j.getDefaults(),{mute:!1,onstop:tt,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")G(yr(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 n=this._state.get(i);n&&(n.offset=this.toSeconds(be(e,0)),n.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 ls(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(yr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let i=e-this.toSeconds(r.time),n;r.duration&&(n=this.toSeconds(r.duration)-i),this._start(t,this.toSeconds(r.offset)+i,n)}}},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=tt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var sr=class o extends Qe{constructor(){let t=w(o.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,Kt(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new nt({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 Dt(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Qe.getDefaults(),{url:new Dt,loop:!1,loopEnd:0,loopStart:0,onload:tt,onerror:tt,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){G(this.buffer.loaded,"buffer is either not set or not loaded");let n=this.toSeconds(t);this._startGain(n,i),this.loop?e=be(e,this.loopStart):e=be(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;Wo(s,a)&&(s=(s-c)%u+c),ae(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,ei(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(n,s)),$(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(n+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 ni=class o extends mt{constructor(){let t=w(o.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(G(t in om,"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=om[this._type];this._source=new sr({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}},ro=44100*5,Hc=2,Ar={brown:null,pink:null,white:null},om={get brown(){if(!Ar.brown){let o=[];for(let t=0;t<Hc;t++){let e=new Float32Array(ro);o[t]=e;let r=0;for(let i=0;i<ro;i++){let n=Math.random()*2-1;e[i]=(r+.02*n)/1.02,r=e[i],e[i]*=3.5}}Ar.brown=new Dt().fromArray(o)}return Ar.brown},get pink(){if(!Ar.pink){let o=[];for(let t=0;t<Hc;t++){let e=new Float32Array(ro);o[t]=e;let r,i,n,s,a,c,u;r=i=n=s=a=c=u=0;for(let l=0;l<ro;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,i=.99332*i+h*.0750759,n=.969*n+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,e[l]=r+i+n+s+a+c+u+h*.5362,e[l]*=.11,u=h*.115926}}Ar.pink=new Dt().fromArray(o)}return Ar.pink},get white(){if(!Ar.white){let o=[];for(let t=0;t<Hc;t++){let e=new Float32Array(ro);o[t]=e;for(let r=0;r<ro;r++)e[r]=Math.random()*2-1}Ar.white=new Dt().fromArray(o)}return Ar.white}};function pe(o,t){return ht(this,void 0,void 0,function*(){let e=t/o.context.sampleRate,r=new Ye(1,e,o.context.sampleRate);return new o.constructor(Object.assign(o.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var Ho=class o extends Qe{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],Kt(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new nt({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new nt({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),B(this,["frequency","detune"])}static getDefaults(){return Object.assign(Qe.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 Ot=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),B(this,"frequency"),this.detune=new K({context:this.context,units:"cents",value:t.detune}),B(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 Ho({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 o._periodicWaveCache.find(e=>e.phase===this._phase&&Qd(e.partials,this._partials));{let t=o._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:n}=r;this._wave=n,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[i,n]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(i,n);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),o._periodicWaveCache.push({imag:n,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),o._periodicWaveCache.length>100&&o._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){Mt(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((n,s)=>i[s]=n),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(t,e){let i=2048,n=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[n,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?(n[c]=-l*Math.sin(e*c),s[c]=l*Math.cos(e*c)):(n[c]=0,s[c]=0)}return[n,s]}_inverseFFT(t,e,r){let i=0,n=t.length;for(let s=0;s<n;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,n=32;for(let s=0;s<n;s++)r=Math.max(this._inverseFFT(t,e,s/n*i),r);return Gc(-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 pe(this,t)})}dispose(){return super.dispose(),this._oscillator!==null&&this._oscillator.dispose(),this._wave=void 0,this.frequency.dispose(),this.detune.dispose(),this}};Ot._periodicWaveCache=[];var io=class extends ie{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new he({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 Ut=class o extends K{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Y({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(K.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var Qo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new io({context:this.context}),this._modulationNode=new Y({context:this.context}),this._carrier=new Ot({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 Ot({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ut({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),B(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ot.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 pe(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 oo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new Y({context:this.context,gain:0}),this._carrier=new Ot({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 K({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Ot({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ut({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Ut({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),B(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(Ot.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 pe(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 si=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new Y({context:this.context,gain:0}),this._thresh=new he({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new K({context:this.context,units:"audioRange",value:t.width}),this._triangle=new Ot({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),B(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 pe(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var Zo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),this.detune=new K({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,B(this,["frequency","detune"])}static getDefaults(){return Object.assign(Ot.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,n)=>i.detune.value=e+r*n)}}get count(){return this._oscillators.length}set count(t){if(Mt(t,1),this._oscillators.length!==t){this._forEach(e=>e.dispose()),this._oscillators=[];for(let e=0;e<t;e++){let r=new Ot({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):tt});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 pe(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var Xo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Ut({context:this.context,value:2}),this._pulse=new si({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new Ot({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),B(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 pe(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var nm={am:Qo,fat:Zo,fm:oo,oscillator:Ot,pulse:si,pwm:Xo},ai=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),this.detune=new K({context:this.context,units:"cents",value:t.detune}),B(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Ot.getDefaults(),oo.getDefaults(),Qo.getDefaults(),Zo.getDefaults(),si.getDefaults(),Xo.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=nm[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 nm[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")&&Jt(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")&&Jt(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"))&&te(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 pe(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function vs(o,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(n){Mt(n,o,t),e.set(this,n)}})}}function de(o,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(n){Mt(this.toSeconds(n),o,t),e.set(this,n)}})}}var Jo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["url","onload"]);super(t),this.name="Player",this._activeSources=new Set,this._buffer=new Dt({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:tt,onerror:tt,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=tt){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=be(e,this._loopStart):e=be(e,0);let i=this.toSeconds(e),n=r;r=be(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new sr({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);!this._loop&&!this._synced&&(this._state.cancel(t+s),this._state.setStateAtTime("stopped",t+s,{implicitEnd:!0})),this._activeSources.add(a),this._loop&&Ft(n)?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&&Mt(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&&Mt(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}};re([de(0)],Jo.prototype,"fadeIn",void 0);re([de(0)],Jo.prototype,"fadeOut",void 0);var Is=class extends ie{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new he({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 ue=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new K({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(te(t))return t;{let r;for(r in Ss)if(Ss[r][e]===t)return r;return t}}_setCurve(t,e,r){if(te(r)&&Reflect.has(Ss,r)){let i=Ss[r];We(i)?t!=="_decayCurve"&&(this[t]=i[e]):this[t]=i}else if(Nt(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),n=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(n&&this.sustain<1){let a=e*this.sustain,c=t+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,n+c):this._sig.exponentialApproachValueAtTime(a,c,n)}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):(G(Nt(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 Ki(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),n=i+this.toSeconds(this.release),s=n*.1,a=n+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}};re([de(0)],ue.prototype,"attack",void 0);re([de(0)],ue.prototype,"decay",void 0);re([vs(0,1)],ue.prototype,"sustain",void 0);re([de(0)],ue.prototype,"release",void 0);var Ss=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let i=[],n=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*n-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,d=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(d*(1-e))}function l(p){let d=new Array(p.length);for(let f=0;f<p.length;f++)d[f]=1-p[f];return d}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 _e=class o extends j{constructor(){let t=w(o.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 Le({context:this.context,volume:t.volume}),this.volume=this._volume.volume,B(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 n=i[e],s=this.context.transport.schedule(a=>{i[e]=a,r.apply(this,i)},n);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 n=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,n,i),this.triggerRelease(n+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var me=class o extends _e{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(_e.getDefaults(),{detune:0,onsilence:tt,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 ce?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let n=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,n,r)}else this.frequency.setValueAtTime(i,r);return this}};re([de(0)],me.prototype,"portamento",void 0);var no=class o extends ue{constructor(){super(w(o.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Y({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}};var ar=class o extends me{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new ai(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 no(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),B(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(me.getDefaults(),{envelope:Object.assign(ze(ue.getDefaults(),Object.keys(j.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(ze(ai.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 Ko=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new nt({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new nt({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new nt({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new nt({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){G(["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),n=this.context.createBiquadFilter();return n.type=this.type,n.Q.value=this.Q.value,n.frequency.value=this.frequency.value,n.gain.value=this.gain.value,n.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 Cr=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._filters=[],this._filters=[],this.Q=new K({context:this.context,units:"positive",value:t.Q}),this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),this.detune=new K({context:this.context,units:"cents",value:t.detune}),this.gain=new K({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,B(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){G(["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=Jt(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],i=r.indexOf(e);G(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(n=>n.disconnect()),this._filters=new Array(i);for(let n=0;n<i;n++){let s=new Ko({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[n]=s}this._internalChannels=this._filters,ke(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new Ko({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((n,s)=>r[s]*=n)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),ii(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var ws=class o extends ar{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,B(this,["oscillator","envelope"])}static getDefaults(){return Me(me.getDefaults(),ar.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 ce?t.toFrequency():t),n=i*this.octaves;return this.oscillator.frequency.setValueAtTime(n,r),this.oscillator.frequency.exponentialRampToValueAtTime(i,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};re([vs(0)],ws.prototype,"octaves",void 0);re([de(0)],ws.prototype,"pitchDecay",void 0);var sm=new Set;function ao(o){sm.add(o)}function Ts(o,t){let e=`registerProcessor("${o}", ${t})`;sm.add(e)}var hy=`
|
|
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(o){return Ld(o)}function nr(o){return jd(o)}function Qi(o){return Pd(o)}function qr(o){return kd(o)}function Qd(o){return o instanceof Dc}function ay(o,t){return o==="value"||ze(t)||nr(t)||Qd(t)}function Ee(o,...t){if(!t.length)return o;let e=t.shift();if(Ue(o)&&Ue(e))for(let r in e)ay(r,e[r])?o[r]=e[r]:Ue(e[r])?(o[r]||Object.assign(o,{[r]:{}}),Ee(o[r],e[r])):Object.assign(o,{[r]:e[r]});return Ee(o,...t)}function Zd(o,t){return o.length===t.length&&o.every((e,r)=>t[r]===e)}function w(o,t,e=[],r){let i={},n=Array.from(t);if(Ue(n[0])&&r&&!Reflect.has(n[0],r)&&(Object.keys(n[0]).some(a=>Reflect.has(o,a))||(Ee(i,{[r]:n[0]}),e.splice(e.indexOf(r),1),n.shift())),n.length===1&&Ue(n[0]))Ee(i,n[0]);else for(let s=0;s<e.length;s++)$(n[s])&&(i[e[s]]=n[s]);return Ee(o,i)}function Xd(o){return o.constructor.getDefaults()}function be(o,t){return Ft(o)?t:o}function Ye(o,t){return t.forEach(e=>{Reflect.has(o,e)&&delete o[e]}),o}var Qt=class{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||ee&&this.toString()===ee.TONE_DEBUG_CLASS)&&Wd(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}};Qt.version=Ro;function yr(o,t){return o>t+1e-6}function Wo(o,t){return yr(o,t)||ae(o,t)}function oi(o,t){return o+1e-6<t}function ae(o,t){return Math.abs(o-t)<1e-6}function Gc(o,t,e){return Math.max(Math.min(o,e),t)}var qt=class o extends Qt{constructor(){super(),this.name="Timeline",this._timeline=[];let t=w(o.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(G(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];G(Wo(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(ae(this._timeline[e].time,t)){for(let r=e;r>=0&&ae(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&&Wo(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,n=i;if(i>0&&this._timeline[i-1][e]<=t)return i-1;for(;r<n;){let s=Math.floor(r+(n-r)/2),a=this._timeline[s],c=this._timeline[s+1];if(ae(a[e],t)){for(let u=s;u<this._timeline.length;u++){let l=this._timeline[u];if(ae(l[e],t))s=u;else break}return s}else{if(oi(a[e],t)&&yr(c[e],t))return s;yr(a[e],t)?n=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),n=this._search(e);return i!==-1&&n!==-1?(this._timeline[i].time!==t&&(i+=1),this._timeline[n].time===e&&(n-=1),this._iterate(r,i,n)):i===-1&&this._iterate(r,0,n),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&&ae(this._timeline[r].time,t)){let i=r;for(let n=r;n>=0&&ae(this._timeline[n].time,t);n--)i=n;this._iterate(n=>{e(n)},i,r)}return this}dispose(){return super.dispose(),this._timeline=[],this}};var Jd=[];function Wr(o){Jd.push(o)}function Kd(o){Jd.forEach(t=>t(o))}var $d=[];function Ur(o){$d.push(o)}function tm(o){$d.forEach(t=>t(o))}var zr=class o extends Qt{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 n=this._events[i];for(let s=n.length-1;s>=0;s--)n[s]===e&&n.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,n=r.length;i<n;i++)r[i].apply(this,e)}return this}static mixin(t){["on","once","off","emit"].forEach(e=>{let r=Object.getOwnPropertyDescriptor(o.prototype,e);Object.defineProperty(t.prototype,e,r)})}dispose(){return super.dispose(),this._events=void 0,this}};var Zi=class extends zr{constructor(){super(...arguments),this.isOffline=!1}toJSON(){return{}}};var ni=class o extends Zi{constructor(){var t,e;super(),this.name="Context",this._constants=new Map,this._timeouts=new qt,this._timeoutIds=0,this._initialized=!1,this._closeStarted=!1,this.isOffline=!1,this._workletPromise=null;let r=w(o.getDefaults(),arguments,["context"]);r.context?(this._context=r.context,this._latencyHint=((t=arguments[0])===null||t===void 0?void 0:t.latencyHint)||""):(this._context=Ud({latencyHint:r.latencyHint}),this._latencyHint=r.latencyHint),this._ticker=new hs(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||(Kd(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 G(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return G(qr(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return G(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){G(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){G(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){G(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){G(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return Hd(this.rawContext,t,e)}addAudioWorkletModule(t){return ht(this,void 0,void 0,function*(){G($(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&&tm(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 n=0;n<r.length;n++)r[n]=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 n=this.now();this._timeouts.add({callback:()=>{t(),i()},id:r,time:n+e})};return i(),r}};var ps=class extends Zi{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 B(o,t){Ot(t)?t.forEach(e=>B(o,e)):Object.defineProperty(o,t,{enumerable:!0,writable:!1})}function si(o,t){Ot(t)?t.forEach(e=>si(o,e)):Object.defineProperty(o,t,{writable:!0})}var tt=()=>{};var kt=class o extends Qt{constructor(){super(),this.name="ToneAudioBuffer",this.onload=tt;let t=w(o.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,te(t.url)?this.load(t.url).catch(t.onerror):t.url&&this.set(t.url)}static getDefaults(){return{onerror:tt,onload:tt,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Bt().sampleRate}set(t){return t instanceof o?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=o.load(t).then(r=>{this.set(r),this.onload(this)});o.downloads.push(e);try{yield e}finally{let r=o.downloads.indexOf(e);o.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,n=Bt(),s=n.createBuffer(r,i,n.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(Jt(t))this.fromArray(this.toArray(t));else{let e=new Float32Array(this.length),r=this.numberOfChannels;for(let i=0;i<r;i++){let n=this.toArray(i);for(let s=0;s<n.length;s++)e[s]+=n[s]}e=e.map(i=>i/r),this.fromArray(e)}return this}toArray(t){if(Jt(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){G(this.loaded,"Buffer is not loaded");let r=Math.floor(t*this.sampleRate),i=Math.floor(e*this.sampleRate);G(r<i,"The start time must be less than the end time");let n=i-r,s=Bt().createBuffer(this.numberOfChannels,n,this.sampleRate);for(let a=0;a<this.numberOfChannels;a++)s.copyToChannel(this.getChannelData(a).subarray(r,i),a);return new o(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 o().fromArray(t)}static fromUrl(t){return ht(this,void 0,void 0,function*(){return yield new o().load(t)})}static load(t){return ht(this,void 0,void 0,function*(){let e=o.baseUrl===""||o.baseUrl.endsWith("/")?o.baseUrl:o.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();o.downloads.length;)yield o.downloads[0]})}};kt.baseUrl="";kt.downloads=[];var He=class extends ni{constructor(){super({clockSource:"offline",context:Qi(arguments[0])?arguments[0]:zd(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:Qi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this.isOffline=!0,this._duration=Qi(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 em=new ps,Xi=em;function Bt(){return Xi===em&&Yd&&Vc(new ni),Xi}function Vc(o,t=!1){t&&Xi.dispose(),qr(o)?Xi=new ni(o):Qi(o)?Xi=new He(o):Xi=o}if(ee&&!ee.TONE_SILENCE_LOGGING){let o="v";Ro==="dev"&&(o="");let t=` * Tone.js ${o}${Ro} * `;console.log(`%c${t}`,"background: #000; color: #fff")}function Ji(o){return Math.pow(10,o/20)}function Ki(o){return 20*(Math.log(o)/Math.LN10)}function ai(o){return Math.pow(2,o/12)}var ds=440;function rm(){return ds}function im(o){ds=o}function Qe(o){return Math.round(qc(o))}function qc(o){return 69+12*Math.log2(o/ds)}function Uo(o){return ds*Math.pow(2,(o-69)/12)}var ms=class o extends Qt{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 o&&this.fromType(this._val),Ft(this._val))return this._noArg();if(te(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 te(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 Ae=class o extends ms{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 o(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 n=1;n<9;n++){let s=Math.pow(2,n);e.push(s+"n."),e.push(s+"n"),e.push(s+"t")}e.push("0");let r=e[0],i=new o(this.context,e[0]).toSeconds();return e.forEach(n=>{let s=new o(this.context,n).toSeconds();Math.abs(s-t)<Math.abs(i-t)&&(r=n,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 n=i.toString();return n.length>3&&(i=parseFloat(parseFloat(n).toFixed(3))),[r,e,i].join(":")}toTicks(){let t=this._beatsToUnits(1);return this.valueOf()/t*this._getPPQ()}toSeconds(){return this.valueOf()}toMidi(){return Qe(this.toFrequency())}_now(){return this.context.now()}};var ce=class o extends Ae{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return rm()}static set A4(t){im(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return this.defaultUnits==="midi"?t:o.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i,method(t,e){let i=cy[t.toLowerCase()]+(parseInt(e,10)+1)*12;return this.defaultUnits==="midi"?i:o.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 o(this.context,this.valueOf()*ai(t))}harmonize(t){return t.map(e=>this.transpose(e))}toMidi(){return Qe(this.valueOf())}toNote(){let t=this.toFrequency(),e=Math.log2(t/o.A4),r=Math.round(12*e)+57,i=Math.floor(r/12);return i<0&&(r+=-12*i),uy[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 Uo(t)}static ftom(t){return Qe(t)}},cy={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},uy=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];var De=class extends Ae{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}};var Wt=class o extends Qt{constructor(){super();let t=w(o.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 Vd(t),new Ae(this.context,t).toSeconds()}toFrequency(t){return new ce(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=Xd(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 o?t[e]=r._getPartialProperties(t[e]):Ot(r)||Jt(r)||te(r)||Fc(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 o?this[e].set(t[e]):this[e]=t[e])}),this}};var sr=class extends qt{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 Dt(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 n=this._timeline[i];if(n.state===t)return n}}getNextState(t,e){let r=this._search(e);if(r!==-1)for(let i=r;i<this._timeline.length;i++){let n=this._timeline[i];if(n.state===t)return n}}};var nt=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments,["param","units","convert"]);for(super(t),this.name="Param",this.overridden=!1,this._minOutput=1e-7,G($(t.param)&&(ze(t.param)||t.param instanceof o),"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 qt(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(Wt.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)&&Dt(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")?Ji(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&this.units==="decibels"?Ki(t):t}setValueAtTime(t,e){let r=this.toSeconds(e),i=this._fromType(t);return G(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),n=this._initialValue;if(i===null)n=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"&&(n=this._exponentialApproach(i.time,a,i.value,i.constant,e))}else if(r===null)n=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"?n=this._linearInterpolate(i.time,s,r.time,r.value,e):n=this._exponentialInterpolate(i.time,s,r.time,r.value,e)}else n=i.value;return this._toType(n)}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 G(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=ae(r,0)?this._minOutput:r,this._assertRange(r);let i=this.toSeconds(e);return G(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);G(isFinite(r)&&r>0,"timeConstant must be a number greater than 0");let n=this.toSeconds(e);return this._assertRange(i),G(isFinite(i)&&isFinite(n),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:r,time:n,type:"setTargetAtTime",value:i}),this.log(this.units,"setTargetAtTime",t,n,r),this._param.setTargetAtTime(i,n,r),this}setValueCurveAtTime(t,e,r,i=1){r=this.toSeconds(r),e=this.toSeconds(e);let n=this._fromType(t[0])*i;this.setValueAtTime(this._toType(n),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 G(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));G(isFinite(e),`Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(t)}`),this.log(this.units,"cancelAndHoldAtTime",e,"value="+r);let i=this._events.get(e),n=this._events.getAfter(e);return i&&ae(i.time,e)?n?(this._param.cancelScheduledValues(n.time),this._events.cancel(n.time)):(this._param.cancelAndHoldAtTime(e),this._events.cancel(e+this.sampleTime)):n&&(this._param.cancelScheduledValues(n.time),this._events.cancel(n.time),n.type==="linearRampToValueAtTime"?this.linearRampToValueAtTime(this._toType(r),e):n.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),n=i?i.time:e+2,s=(n-e)/10;for(let a=e;a<n;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){G(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,n){return r+(e-r)*Math.exp(-(n-t)/i)}_linearInterpolate(t,e,r,i,n){return e+(i-e)*((n-t)/(r-t))}_exponentialInterpolate(t,e,r,i,n){return e*Math.pow(i/e,(n-t)/(r-t))}};var L=class o extends Wt{constructor(){super(...arguments),this._internalChannels=[]}get numberOfInputs(){return $(this.input)?ze(this.input)||this.input instanceof nt?1:this.input.numberOfInputs:0}get numberOfOutputs(){return $(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return $(t)&&(t instanceof o||nr(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();G(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 Kt(this,t,e,r),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return ii("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,r=0){return om(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 o?this.input.dispose():nr(this.input)&&this.input.disconnect()),$(this.output)&&(this.output instanceof o?this.output.dispose():nr(this.output)&&this.output.disconnect()),this._internalChannels=[],this}};function ke(...o){let t=o.shift();o.reduce((e,r)=>(e instanceof L?e.connect(r):nr(e)&&Kt(e,r),r),t)}function Kt(o,t,e=0,r=0){for(G($(o),"Cannot connect from undefined node"),G($(t),"Cannot connect to undefined node"),(t instanceof L||nr(t))&&G(t.numberOfInputs>0,"Cannot connect to node with no inputs"),G(o.numberOfOutputs>0,"Cannot connect from node with no outputs");t instanceof L||t instanceof nt;)$(t.input)&&(t=t.input);for(;o instanceof L;)$(o.output)&&(o=o.output);ze(t)?o.connect(t,e):o.connect(t,e,r)}function om(o,t,e=0,r=0){if($(t))for(;t instanceof L;)t=t.input;for(;!nr(o);)$(o.output)&&(o=o.output);ze(t)?o.disconnect(t,e):nr(t)?o.disconnect(t,e,r):o.disconnect()}var Y=class o extends L{constructor(){let t=w(o.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 nt({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),B(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 Ze=class extends L{constructor(t){super(t),this.onended=tt,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new Y({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(e){let 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:tt})}_startGain(t,e=1){G(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){G(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!==tt&&(this.onended(this),this.onended=tt,!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"),G(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=tt,this}};var zo=class o extends Ze{constructor(){let t=w(o.getDefaults(),arguments,["offset"]);super(t),this.name="ToneConstantSource",this._source=this.context.createConstantSource(),Kt(this._source,this._gainNode),this.offset=new nt({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 K=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["value","units"]);super(t),this.name="Signal",this.override=!0,this.output=this._constantSource=new zo({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 $i(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 $i(o,t,e,r){(t instanceof nt||ze(t)||t instanceof K&&t.override)&&(t.cancelScheduledValues(0),t.setValueAtTime(0,0),t instanceof K&&(t.overridden=!0)),Kt(o,t,e,r)}var fs=class o extends nt{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="TickParam",this._events=new qt(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(nt.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,r){e=this.toSeconds(e),this.setRampPoint(e);let i=this._fromType(t),n=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(n.time,n.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),n=this._events.previousEvent(i),s=this._getTicksUntilEvent(n,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),n=this._events.previousEvent(i),s=this._getTicksUntilEvent(n,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),n=Math.round(Math.max((e-i.time)*10,1)),s=(e-i.time)/n;for(let a=0;a<=n;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)),n=this._events.get(e);return n&&n.time===e&&n.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),n=this.getTicksAtTime(r);return this.getTicksAtTime(r+i)-n}_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 gs=class o extends K{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="TickSignal",this.input=this._param=new fs({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(K.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 xs=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments,["frequency"]);super(t),this.name="TickSource",this._state=new sr,this._tickOffset=new qt,this._ticksAtTime=new qt,this._secondsAtTime=new qt,this.frequency=new gs({context:this.context,units:t.units,value:t.frequency}),B(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},Wt.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),n={state:"paused",time:e};this._state.add(n);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!==n.time&&(c={state:u.state,time:u.time,ticks:a})),s=u}),this._state.remove(n),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),n=i||e,s=i?i.seconds:0,a=null;return this._state.forEachBetween(n.time,t+this.sampleTime,c=>{let u=n.time,l=this._tickOffset.get(c.time);l&&l.time>=n.time&&(s=l.seconds,u=l.time),n.state==="started"&&c.state!=="started"&&(s+=c.time-u,c.time!==r.time&&(a={state:c.state,time:c.time,seconds:s})),n=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),n=Math.max(r.time,i.time),s=this.frequency.getTicksAtTime(n)+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 n=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=ae(l,1)?0:l;let h=this.frequency.getTimeOfTick(a+l);for(;h<e;){try{r(h,Math.round(this.getTicksAtTime(h)))}catch(p){n=p;break}h+=this.frequency.getDurationOfTicks(1,h)}}if(n)throw n;return this}dispose(){return super.dispose(),this._state.dispose(),this._tickOffset.dispose(),this._ticksAtTime.dispose(),this._secondsAtTime.dispose(),this.frequency.dispose(),this}};var to=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments,["callback","frequency"]);super(t),this.name="Clock",this.callback=tt,this._lastUpdate=0,this._state=new sr("stopped"),this._boundLoop=this._loop.bind(this),this.callback=t.callback,this._tickSource=new xs({context:this.context,frequency:t.frequency,units:t.units}),this._lastUpdate=0,this.frequency=this._tickSource.frequency,B(this,"frequency"),this._state.setStateAtTime("stopped",0),this.context.on("tick",this._boundLoop)}static getDefaults(){return Object.assign(Wt.getDefaults(),{callback:tt,frequency:1,units:"hertz"})}get state(){return this._state.getValueAtTime(this.now())}start(t,e){ls(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(to);var je=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["volume"]);super(t),this.name="Volume",this.input=this.output=new Y({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,B(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 Wc=class o extends L{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="Destination",this.input=new je({context:this.context}),this.output=new Y({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(o=>{o.destination=new Wc({context:o})});Ur(o=>{o.destination.dispose()});var Uc=class extends L{constructor(){super(...arguments),this.name="Listener",this.positionX=new nt({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new nt({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new nt({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new nt({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new nt({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new nt({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new nt({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new nt({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new nt({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(o=>{o.listener=new Uc({context:o})});Ur(o=>{o.listener.dispose()});var eo=class o extends Qt{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;let t=w(o.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:tt,onload:tt,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return G(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=tt,i=tt){return te(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 Yo=class o extends ce{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return Qe(super._frequencyToUnits(t))}_ticksToUnits(t){return Qe(super._ticksToUnits(t))}_beatsToUnits(t){return Qe(super._beatsToUnits(t))}_secondsToUnits(t){return Qe(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return Uo(this.toMidi())}transpose(t){return new o(this.context,this.toMidi()+t)}};var Ce=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 zc=class extends Wt{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new qt,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(o=>{o.draw=new zc({context:o})});Ur(o=>{o.draw.dispose()});var ys=class extends Qt{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){G($(t.time),"Events must have a time property"),G($(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new Yc(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}},Yc=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 bs=class extends Qt{constructor(t){super(),this.name="TimelineValue",this._timeline=new qt({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 ie=class o extends L{constructor(){super(w(o.getDefaults(),arguments,["context"]))}connect(t,e=0,r=0){return $i(this,t,e,r),this}};var he=class o extends ie{constructor(){let t=w(o.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):Fd(t.mapping)&&this.setMap(t.mapping,t.length)}static getDefaults(){return Object.assign(K.getDefaults(),{length:1024})}setMap(t,e=1024){let r=new Float32Array(e);for(let i=0,n=e;i<n;i++){let s=i/(n-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));G(e,"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}};var ro=class o extends ie{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="Pow",this._exponentScaler=this.input=this.output=new he({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(ie.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 br=class o{constructor(t,e){this.id=o._eventId++,this._remainderTime=0;let r=Object.assign(o.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:tt,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}};br._eventId=0;var As=class o extends br{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(o.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({},br.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvent(){return oi(this._nextTick,this.floatTime+this.duration)?this.transport.scheduleOnce(this.invoke.bind(this),new Ce(this.context,this._nextTick).toSeconds()):-1}_createEvents(t){oi(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 Ce(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);yr(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 Cs=class o extends Wt{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="Transport",this._loop=new bs(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new qt,this._repeatedEvents=new ys,this._syncedSignals=[],this._swingAmount=0,this._ppq=t.ppq,this._clock=new to({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),B(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(Wt.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 Ce(this.context,this._swingTicks*2/3).toSeconds()*i}Bc(!0),this._timeline.forEachAtTime(e,r=>r.invoke(t)),Bc(!1)}schedule(t,e){let r=new br(this,{callback:t,time:new De(this.context,e).toTicks()});return this._addEvent(r,this._timeline)}scheduleRepeat(t,e,r,i=1/0){let n=new As(this,{callback:t,duration:new Ae(this.context,i).toTicks(),interval:new Ae(this.context,e).toTicks(),time:new De(this.context,r).toTicks()});return this._addEvent(n,this._repeatedEvents)}scheduleOnce(t,e){let r=new br(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 Ce(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 Ae(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new Ae(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 Ce(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 Ce(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),n=e+i;this.emit("stop",n),this._clock.setTicksAtTime(t,n),this.emit("start",n,this._clock.getSecondsAtTime(n))}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,n=1/(60/i.getValueAtTime(r)/this.PPQ),s=[];if(t.units==="time"){let c=.015625/n,u=new Y(c),l=new ro(-1),h=new Y(c);i.chain(u,l,h),i=h,n=1/n,s=[u,l,h]}e||(t.getValueAtTime(r)!==0?e=t.getValueAtTime(r)/n:e=0);let a=new Y(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(),si(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}};zr.mixin(Cs);Wr(o=>{o.transport=new Cs({context:o})});Ur(o=>{o.transport.dispose()});var mt=class extends L{constructor(t){super(t),this.input=void 0,this._state=new sr("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=tt,this._syncedStop=tt,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,B(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(L.getDefaults(),{mute:!1,onstop:tt,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")G(yr(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 n=this._state.get(i);n&&(n.offset=this.toSeconds(be(e,0)),n.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 ls(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(yr(e,0)){let r=this._state.get(e);if(r&&r.state==="started"&&r.time!==e){let i=e-this.toSeconds(r.time),n;r.duration&&(n=this.toSeconds(r.duration)-i),this._start(t,this.toSeconds(r.offset)+i,n)}}},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=tt,this.unsync(),this._volume.dispose(),this._state.dispose(),this}};var ar=class o extends Ze{constructor(){let t=w(o.getDefaults(),arguments,["url","onload"]);super(t),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1,Kt(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new nt({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:tt,onerror:tt,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){G(this.buffer.loaded,"buffer is either not set or not loaded");let n=this.toSeconds(t);this._startGain(n,i),this.loop?e=be(e,this.loopStart):e=be(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;Wo(s,a)&&(s=(s-c)%u+c),ae(s,this.buffer.duration)&&(s=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,oi(s,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(n,s)),$(r)){let a=this.toSeconds(r);a=Math.max(a,0),this.stop(n+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 ci=class o extends mt{constructor(){let t=w(o.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(G(t in nm,"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=nm[this._type];this._source=new ar({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}},io=44100*5,Hc=2,Ar={brown:null,pink:null,white:null},nm={get brown(){if(!Ar.brown){let o=[];for(let t=0;t<Hc;t++){let e=new Float32Array(io);o[t]=e;let r=0;for(let i=0;i<io;i++){let n=Math.random()*2-1;e[i]=(r+.02*n)/1.02,r=e[i],e[i]*=3.5}}Ar.brown=new kt().fromArray(o)}return Ar.brown},get pink(){if(!Ar.pink){let o=[];for(let t=0;t<Hc;t++){let e=new Float32Array(io);o[t]=e;let r,i,n,s,a,c,u;r=i=n=s=a=c=u=0;for(let l=0;l<io;l++){let h=Math.random()*2-1;r=.99886*r+h*.0555179,i=.99332*i+h*.0750759,n=.969*n+h*.153852,s=.8665*s+h*.3104856,a=.55*a+h*.5329522,c=-.7616*c-h*.016898,e[l]=r+i+n+s+a+c+u+h*.5362,e[l]*=.11,u=h*.115926}}Ar.pink=new kt().fromArray(o)}return Ar.pink},get white(){if(!Ar.white){let o=[];for(let t=0;t<Hc;t++){let e=new Float32Array(io);o[t]=e;for(let r=0;r<io;r++)e[r]=Math.random()*2-1}Ar.white=new kt().fromArray(o)}return Ar.white}};function pe(o,t){return ht(this,void 0,void 0,function*(){let e=t/o.context.sampleRate,r=new He(1,e,o.context.sampleRate);return new o.constructor(Object.assign(o.get(),{frequency:2/e,detune:0,context:r})).toDestination().start(0),(yield r.render()).getChannelData(0)})}var Ho=class o extends Ze{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator],Kt(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new nt({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new nt({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),B(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 o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="Oscillator",this._oscillator=null,this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),B(this,"frequency"),this.detune=new K({context:this.context,units:"cents",value:t.detune}),B(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 Ho({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 o._periodicWaveCache.find(e=>e.phase===this._phase&&Zd(e.partials,this._partials));{let t=o._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:n}=r;this._wave=n,this._partials=i,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave)}else{let[i,n]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(i,n);this._wave=s,this._oscillator!==null&&this._oscillator.setPeriodicWave(this._wave),o._periodicWaveCache.push({imag:n,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:i,type:this._type,wave:this._wave}),o._periodicWaveCache.length>100&&o._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){Dt(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((n,s)=>i[s]=n),this._partials=Array.from(i),this.type=this._type}}_getRealImaginary(t,e){let i=2048,n=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[n,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?(n[c]=-l*Math.sin(e*c),s[c]=l*Math.cos(e*c)):(n[c]=0,s[c]=0)}return[n,s]}_inverseFFT(t,e,r){let i=0,n=t.length;for(let s=0;s<n;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,n=32;for(let s=0;s<n;s++)r=Math.max(this._inverseFFT(t,e,s/n*i),r);return Gc(-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 pe(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 oo=class extends ie{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new he({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 Ut=class o extends K{constructor(){let t=w(o.getDefaults(),arguments,["value"]);super(t),this.name="Multiply",this.override=!1,this._mult=this.input=this.output=new Y({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(K.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}};var Qo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="AMOscillator",this._modulationScale=new oo({context:this.context}),this._modulationNode=new Y({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 Ut({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),B(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 pe(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 no=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","modulationType"]);super(t),this.name="FMOscillator",this._modulationNode=new Y({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 K({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new Rt({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new Ut({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new Ut({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),B(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 pe(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 ui=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","width"]);super(t),this.name="PulseOscillator",this._widthGate=new Y({context:this.context,gain:0}),this._thresh=new he({context:this.context,mapping:e=>e<=0?-1:1}),this.width=new K({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),B(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 pe(this,t)})}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}};var Zo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","spread"]);super(t),this.name="FatOscillator",this._oscillators=[],this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),this.detune=new K({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,B(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,n)=>i.detune.value=e+r*n)}}get count(){return this._oscillators.length}set count(t){if(Dt(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):tt});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 pe(this,t)})}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}};var Xo=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","modulationFrequency"]);super(t),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new Ut({context:this.context,value:2}),this._pulse=new ui({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),B(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 pe(this,t)})}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}};var sm={am:Qo,fat:Zo,fm:no,oscillator:Rt,pulse:ui,pwm:Xo},li=class o extends mt{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="OmniOscillator",this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),this.detune=new K({context:this.context,units:"cents",value:t.detune}),B(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(Rt.getDefaults(),no.getDefaults(),Qo.getDefaults(),Zo.getDefaults(),ui.getDefaults(),Xo.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=sm[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 sm[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")&&Jt(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")&&Jt(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"))&&te(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 pe(this,t)})}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}};function vs(o,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(n){Dt(n,o,t),e.set(this,n)}})}}function de(o,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(n){Dt(this.toSeconds(n),o,t),e.set(this,n)}})}}var Jo=class o extends mt{constructor(){let t=w(o.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:tt,onerror:tt,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=tt){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=be(e,this._loopStart):e=be(e,0);let i=this.toSeconds(e),n=r;r=be(r,Math.max(this._buffer.duration-i,0));let s=this.toSeconds(r);s=s/this._playbackRate,t=this.toSeconds(t);let a=new ar({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(n)?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&&Dt(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&&Dt(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}};re([de(0)],Jo.prototype,"fadeIn",void 0);re([de(0)],Jo.prototype,"fadeOut",void 0);var Is=class extends ie{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new he({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 ue=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["attack","decay","sustain","release"]);super(t),this.name="Envelope",this._sig=new K({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(te(t))return t;{let r;for(r in Ss)if(Ss[r][e]===t)return r;return t}}_setCurve(t,e,r){if(te(r)&&Reflect.has(Ss,r)){let i=Ss[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),n=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(n&&this.sustain<1){let a=e*this.sustain,c=t+i;this.log("decay",c),this._decayCurve==="linear"?this._sig.linearRampToValueAtTime(a,n+c):this._sig.exponentialApproachValueAtTime(a,c,n)}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):(G(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 $i(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),n=i+this.toSeconds(this.release),s=n*.1,a=n+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}};re([de(0)],ue.prototype,"attack",void 0);re([de(0)],ue.prototype,"decay",void 0);re([vs(0,1)],ue.prototype,"sustain",void 0);re([de(0)],ue.prototype,"release",void 0);var Ss=(()=>{let t,e,r=[];for(t=0;t<128;t++)r[t]=Math.sin(t/127*(Math.PI/2));let i=[],n=6.4;for(t=0;t<127;t++){e=t/127;let p=Math.sin(e*(Math.PI*2)*n-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,d=Math.cos(p*Math.PI*2*e);u[t]=Math.abs(d*(1-e))}function l(p){let d=new Array(p.length);for(let f=0;f<p.length;f++)d[f]=1-p[f];return d}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 _e=class o extends L{constructor(){let t=w(o.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,B(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 n=i[e],s=this.context.transport.schedule(a=>{i[e]=a,r.apply(this,i)},n);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 n=this.toSeconds(r),s=this.toSeconds(e);return this.triggerAttack(t,n,i),this.triggerRelease(n+s),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}};var me=class o extends _e{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(_e.getDefaults(),{detune:0,onsilence:tt,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 ce?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(r)>.05){let n=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(i,n,r)}else this.frequency.setValueAtTime(i,r);return this}};re([de(0)],me.prototype,"portamento",void 0);var so=class o extends ue{constructor(){super(w(o.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new Y({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}};var cr=class o extends me{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="Synth",this.oscillator=new li(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new so(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),B(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(me.getDefaults(),{envelope:Object.assign(Ye(ue.getDefaults(),Object.keys(L.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Ye(li.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 Ko=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type"]);super(t),this.name="BiquadFilter",this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new nt({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new nt({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new nt({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new nt({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){G(["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),n=this.context.createBiquadFilter();return n.type=this.type,n.Q.value=this.Q.value,n.frequency.value=this.frequency.value,n.gain.value=this.gain.value,n.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 Cr=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["frequency","type","rolloff"]);super(t),this.name="Filter",this.input=new Y({context:this.context}),this.output=new Y({context:this.context}),this._filters=[],this._filters=[],this.Q=new K({context:this.context,units:"positive",value:t.Q}),this.frequency=new K({context:this.context,units:"frequency",value:t.frequency}),this.detune=new K({context:this.context,units:"cents",value:t.detune}),this.gain=new K({context:this.context,units:"decibels",convert:!1,value:t.gain}),this._type=t.type,this.rolloff=t.rolloff,B(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){G(["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=Jt(t)?t:parseInt(t,10),r=[-12,-24,-48,-96],i=r.indexOf(e);G(i!==-1,`rolloff can only be ${r.join(", ")}`),i+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(n=>n.disconnect()),this._filters=new Array(i);for(let n=0;n<i;n++){let s=new Ko({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[n]=s}this._internalChannels=this._filters,ke(this.input,...this._internalChannels,this.output)}getFrequencyResponse(t=128){let e=new Ko({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((n,s)=>r[s]*=n)}),e.dispose(),r}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),si(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}};var ws=class o extends cr{constructor(){let t=w(o.getDefaults(),arguments);super(t),this.name="MembraneSynth",this.portamento=0,this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,B(this,["oscillator","envelope"])}static getDefaults(){return Ee(me.getDefaults(),cr.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 ce?t.toFrequency():t),n=i*this.octaves;return this.oscillator.frequency.setValueAtTime(n,r),this.oscillator.frequency.exponentialRampToValueAtTime(i,r+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}};re([vs(0)],ws.prototype,"octaves",void 0);re([de(0)],ws.prototype,"pitchDecay",void 0);var am=new Set;function co(o){am.add(o)}function Ts(o,t){let e=`registerProcessor("${o}", ${t})`;am.add(e)}var py=`
|
|
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
|
-
`;
|
|
49
|
+
`;co(py);var dy=`
|
|
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
|
-
`;
|
|
116
|
+
`;co(dy);var my=`
|
|
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
|
-
`;
|
|
160
|
+
`;co(my);var cm="feedback-comb-filter",fy=`
|
|
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
|
-
`;Ts(
|
|
190
|
+
`;Ts(cm,fy);var Ns=class o extends _e{constructor(){let t=w(o.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),G(!Jt(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(_e.getDefaults(),{maxPolyphony:32,options:{},voice:cr})}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 G(t instanceof me,"Voice must extend Monophonic class"),t.connect(this.output),this._voices.push(t),t}else ii("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 n=new Yo(this.context,i).toMidi(),s=this._getNextAvailableVoice();s&&(s.triggerAttack(i,e,r),this._activeVoices.push({midi:n,voice:s,released:!1}),this.log("triggerAttack",i,e))})}_triggerRelease(t,e){t.forEach(r=>{let i=new Yo(this.context,r).toMidi(),n=this._activeVoices.find(({midi:s,released:a})=>s===i&&!a);n&&(n.voice.triggerRelease(e),n.released=!0,this.log("triggerRelease",r,e))})}_scheduleEvent(t,e,r,i){G(!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 n=this.toSeconds(r);if(this.triggerAttack(t,n,i),Ot(e)){G(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);G(c>0,"The duration must be greater than 0"),this.triggerRelease(t[s],n+c)}}else{let s=this.toSeconds(e);G(s>0,"The duration must be greater than 0"),this.triggerRelease(t,n+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=Ye(t,["onsilence","context"]);return this.options=Ee(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 Os=class o extends _e{constructor(){let t=w(o.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(G(qo(r)||Jt(i)&&isFinite(i),`url key is neither a note or midi pitch: ${r}`),qo(r)){let n=new ce(this.context,r).toMidi();e[n]=t.urls[r]}else Jt(i)&&isFinite(i)&&(e[i]=t.urls[i])}),this._buffers=new eo({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(_e.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:tt,onerror:tt,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 n=qc(new ce(this.context,i).toFrequency()),s=Math.round(n),a=n-s,c=this._findClosest(s),u=s-c,l=this._buffers.get(u),h=ai(c+a),p=new ar({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 d=this._activeSources.get(s),f=d.indexOf(p);f!==-1&&d.splice(f,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(r=>{let i=new ce(this.context,r).toMidi();if(this._activeSources.has(i)&&this._activeSources.get(i).length){let n=this._activeSources.get(i);e=this.toSeconds(e),n.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 n=this.toSeconds(r);return this.triggerAttack(t,n,i),Ot(e)?(G(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,n+this.toSeconds(c))})):this.triggerRelease(t,n+this.toSeconds(e)),this}add(t,e,r){if(G(qo(t)||isFinite(t),`note must be a pitch or midi: ${t}`),qo(t)){let i=new ce(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}};re([de(0)],Os.prototype,"attack",void 0);re([de(0)],Os.prototype,"release",void 0);var uo=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["fade"]);super(t),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Is({context:this.context}),this.a=new Y({context:this.context,gain:0}),this.b=new Y({context:this.context,gain:0}),this.output=new Y({context:this.context}),this._internalChannels=[this.a,this.b],this.fade=new K({context:this.context,units:"normalRange",value:t.fade}),B(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),this._panner.channelCount=1,this._panner.channelCountMode="explicit",Kt(this._split,this.a.gain,0),Kt(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(L.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 fe=class extends L{constructor(t){super(t),this.name="Effect",this._dryWet=new uo({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new Y({context:this.context}),this.effectReturn=new Y({context:this.context}),this.input=new Y({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],B(this,"wet")}static getDefaults(){return Object.assign(L.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 $o=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["pan"]);super(t),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner,this.pan=new nt({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),this._panner.channelCount=t.channelCount,this._panner.channelCountMode="explicit",B(this,"pan")}static getDefaults(){return Object.assign(L.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}};var lm="bit-crusher",_y=`
|
|
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
|
-
`;Ts(um,Cy);var Ur=class o extends j{constructor(){let t=w(o.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 RJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var FJ=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var Ms=class o extends fe{constructor(){let t=w(o.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Mt(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Mt(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(fe.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Mt(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Mt(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 ni({context:e}),i=new ni({context:e}),n=new Ur({context:e});r.connect(n,0,0),i.connect(n,0,1);let s=new Y({context:e}).toDestination();n.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(tt),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var uo=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new Y({context:this.context}),o._allSolos.has(this.context)||o._allSolos.set(this.context,new Set),o._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(),o._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){o._soloed.has(this.context)||o._soloed.set(this.context,new Set),o._soloed.get(this.context).add(this)}_removeSolo(){o._soloed.has(this.context)&&o._soloed.get(this.context).delete(this)}_isSoloed(){return o._soloed.has(this.context)&&o._soloed.get(this.context).has(this)}_noSolos(){return!o._soloed.has(this.context)||o._soloed.has(this.context)&&o._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(),o._allSolos.get(this.context).delete(this),this._removeSolo(),this}};uo._allSolos=new Map;uo._soloed=new Map;var Ds=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new $o({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Le({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,B(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 Kc=class o extends j{constructor(){let t=w(o.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new uo({solo:t.solo,context:this.context}),this._panVol=this.output=new Ds({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),B(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 o.buses.has(t)||o.buses.set(t,new Y({context:this.context})),o.buses.get(t)}send(t,e=0){let r=this._getBus(t),i=new Y({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}};Kc.buses=new Map;var wrt=Bt().transport;var Trt=Bt().destination,Nrt=Bt().destination;var Ort=Bt().listener;var Rrt=Bt().draw;var Ert=Bt();var $c=class{constructor(){m(this,"audioSource");try{let t=new Ms({decay:3,wet:.4}).toDestination(),e=new Cr(800,"lowpass").connect(t);this.audioSource=new Ns(ar,{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=_.Math.linearToDecibels(r)),this.audioSource.triggerAttackRelease(t,e!=null?e:"2n"))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},tu=new $c;Hr();function Oy(o){return typeof o=="string"?o:(typeof o=="number"&&(o=V.getChromaticNote(o)),o.format(0,0))}var ks=[tu],lo=tu;function Ry(){return ks.map(o=>o.getName())}function Ey(){return lo.getName()}function My(o){ks.some(t=>t.getName()===o.getName())||(ks.push(o),hm(o.getName()))}function hm(o){if(o===lo.getName())return;lo.stop();let t=ks.find(e=>e.getName()===o);t&&(lo=t)}function Ls(o,t,e){lo.playNote(Oy(o),t,e)}function eu(){lo.stop()}var mu={};Ci(mu,{Annotation:()=>ci,Arpeggio:()=>zr,Clef:()=>vr,Connective:()=>Ir,DivRect:()=>F,DocumentBuilder:()=>wr,Fermata:()=>rn,Label:()=>ho,MAccidental:()=>nn,MArpeggio:()=>cn,MBarLineLeft:()=>Cn,MBarLineRight:()=>An,MBeamGroup:()=>pn,MConnective:()=>wn,MDocument:()=>Yr,MEnding:()=>vn,MExtensionLine:()=>Sn,MFermata:()=>In,MHeader:()=>Mn,MImage:()=>on,MMeasure:()=>Nn,MNoteGroup:()=>mn,MPlaybackButtons:()=>du,MPlayer:()=>jn,MRenderer:()=>pu,MRest:()=>un,MRhythmColumn:()=>xn,MScoreRow:()=>En,MSignature:()=>an,MSpecialText:()=>yn,MStaff:()=>On,MStaffBeamGroup:()=>dn,MStaffNoteGroup:()=>fn,MStaffRest:()=>ln,MStaffTabBarLine:()=>_n,MTab:()=>Rn,MTabNoteGroup:()=>gn,MText:()=>sn,MusicInterface:()=>bt,Navigation:()=>Ie,NoteAnchor:()=>ve,PlayState:()=>js,ScoreEvent:()=>Dn,ScoreObjectEvent:()=>li,ScoreStaffPosEvent:()=>ui,StaffPreset:()=>_r,Stem:()=>je,TieType:()=>cr,VerticalPosition:()=>en,getStringNumbers:()=>ru,getVoiceIds:()=>oe});var F=class o{constructor(...t){m(this,"left");m(this,"centerX");m(this,"right");m(this,"top");m(this,"centerY");m(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 E(1,`Invalid DivRect args: ${t}`)}static create(t,e,r,i){return new o(t,t+r,e,e+i)}static createCentered(t,e,r,i){return new o(t-r/2,t+r/2,e-i/2,e+i/2)}static createSections(t,e,r,i){return new o(-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 o(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=_.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=_.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 _r=(s=>(s[s.Treble=1]="Treble",s[s.Bass=2]="Bass",s[s.Grand=3]="Grand",s[s.GuitarTreble=4]="GuitarTreble",s[s.GuitarTab=8]="GuitarTab",s[s.GuitarCombined=12]="GuitarCombined",s))(_r||{}),vr=(e=>(e.G="G",e.F="F",e))(vr||{});function oe(){return[0,1,2,3]}function ru(){return[1,2,3,4,5,6]}var je=(r=>(r[r.Auto=0]="Auto",r[r.Up=1]="Up",r[r.Down=2]="Down",r))(je||{}),zr=(e=>(e[e.Up=0]="Up",e[e.Down=1]="Down",e))(zr||{}),cr=(e=>(e[e.Stub=-1]="Stub",e[e.ToMeasureEnd=-2]="ToMeasureEnd",e))(cr||{}),ve=(n=>(n[n.Auto=0]="Auto",n[n.Above=1]="Above",n[n.Center=2]="Center",n[n.Below=3]="Below",n[n.StemTip=4]="StemTip",n))(ve||{}),Ir=(r=>(r[r.Tie=0]="Tie",r[r.Slur=1]="Slur",r[r.Slide=2]="Slide",r))(Ir||{}),en=(i=>(i[i.Above=0]="Above",i[i.Below=1]="Below",i[i.Both=2]="Both",i[i.Auto=3]="Auto",i))(en||{}),js=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(js||{}),rn=(e=>(e[e.AtNote=0]="AtNote",e[e.AtMeasureEnd=1]="AtMeasureEnd",e))(rn||{}),Ie=(h=>(h[h.DC_al_Fine=0]="DC_al_Fine",h[h.DC_al_Coda=1]="DC_al_Coda",h[h.DS_al_Fine=2]="DS_al_Fine",h[h.DS_al_Coda=3]="DS_al_Coda",h[h.Coda=4]="Coda",h[h.toCoda=5]="toCoda",h[h.Segno=6]="Segno",h[h.Fine=7]="Fine",h[h.StartRepeat=8]="StartRepeat",h[h.EndRepeat=9]="EndRepeat",h[h.Ending=10]="Ending",h))(Ie||{}),ci=(e=>(e[e.Dynamics=0]="Dynamics",e[e.Tempo=1]="Tempo",e))(ci||{}),ho=(e=>(e[e.Note=0]="Note",e[e.Chord=1]="Chord",e))(ho||{});var Ps=class{constructor(t){m(this,"head");m(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;m(this,"anchoredLayoutObjects",[]);m(this,"link");m(this,"rect",new F);m(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 Fs={DrawDebugRects:!1,DisableBeams:!1},ct={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 pm="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 dm="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 Dy="#55cc55",ky="#55cc55",Ly="#44aa44",iu=new Map([[0,{src:pm}],[1,{src:dm}]]);function jy(o,t){return!o&&!t?!0:!o||!t?!1:o.scoreRow===t.scoreRow&&o.diatonicId===t.diatonicId}function Py(o,t){return!o&&!t?!0:!o||!t?!1:o.length===t.length&&o.every((e,r)=>e===t[r])}var Bs=class{constructor(t){this.mi=t;m(this,"devicePixelRatio");m(this,"fontSize");m(this,"unitSize");m(this,"lineWidth");m(this,"beamThickness");m(this,"scoreEventListener");m(this,"canvas");m(this,"ctx");m(this,"mdoc");m(this,"cursorRect");m(this,"mousePos");m(this,"curStaffPos");m(this,"curObjects");m(this,"hilightedStaffPos");m(this,"hilightedObj");m(this,"usingTouch",!1);m(this,"onClickFn");m(this,"onMouseMoveFn");m(this,"onMouseLeaveFn");m(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=wo.FontSize*ct.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this.lineWidth=this.unitSize*.2,this.beamThickness=this.unitSize*.8,iu.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 E(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(iu).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(t){var e;return(e=iu.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 Eu(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!jy(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:i,diatonicId:n}=this.curStaffPos;this.scoreEventListener(new ui("leave",this.getMusicInterface(),i.getMusicInterface(),n))}if(r&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:n}=t;this.scoreEventListener(new ui("enter",this.getMusicInterface(),i.getMusicInterface(),n))}if(e&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:n}=t;this.scoreEventListener(new ui("click",this.getMusicInterface(),i.getMusicInterface(),n))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!Py(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new li("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new li("enter",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new li("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),n=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(n||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),n=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(n||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,n=r.height+1;t.width=i,t.height=n,t.style.width=i/this.devicePixelRatio+"px",t.style.height=n/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:n,diatonicId:s}=r,a=n.getStaff(s);a&&(t.fillStyle=Dy,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=ky,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,Ly,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 n=r.measureText(t);return r.font=i,n.width}else return _.Dom.getCanvasTextWidth(t,e)}drawDebugRect(t){if(!Fs.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 n=this.getCanvasContext();n&&(i!==void 0&&(n.fillStyle=i),n.beginPath(),n.arc(t,e,r,0,2*Math.PI),n.fill())}drawLine(t,e,r,i,n,s){let a=this.getCanvasContext();a&&(a.strokeStyle=n!=null?n:"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,n,s,a,c){let u=this.getCanvasContext();if(u){let l=t+(r-t)*n,h=e+(i-e)*n,p=t+(r-t)*s,d=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,d),u.stroke()}}drawLedgerLines(t,e,r){let{unitSize:i}=this,n=i*ct.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-n/2,a,r+n/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-n/2,a,r+n/2,a)}}}};var Gs=class{constructor(t){this.measure=t;m(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===V.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 Vs=class extends it{constructor(e,r,i,n,s){super(e);this.image=r;this.anchorX=i;this.anchorY=n;this.imageScale=s;m(this,"mi");this.mi=new on(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:i,image:n,imageScale:s}=this,{unitSize:a}=e;try{let c=n.naturalWidth*s*a,u=n.naturalHeight*s*a;this.rect=F.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new F}}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(n){}}};var hi=class extends it{constructor(e,r,i,n="black"){super(e);this.diatonicId=r;this.accidental=i;this.color=n;m(this,"mi");this.mi=new nn(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=F.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=F.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=F.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=F.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=F.createSections(r*1,r*1,r*1,r*1);break;default:throw new E(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:n}=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=n,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=n,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=n*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=n,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=n*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=n,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 Fy=.5,lt=class extends it{constructor(e,r,i,n){var a,c,u,l,h,p;super(e);this.anchorX=i;this.anchorY=n;m(this,"text");m(this,"scale");m(this,"color");m(this,"bold");m(this,"italic");m(this,"boxed");m(this,"padding");m(this,"bgcolor");m(this,"font","");m(this,"textLines");m(this,"lineWidths",[]);m(this,"lineHeight",0);m(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?Fy: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 F,this.mi=new sn(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:n,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=F.createSections(l*i,l*(1-i),h*n,h*(1-n))}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:n,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,d=-s*(l?.25:.175),f=n*e.unitSize,g=(i.left+f)*(1-c)+(i.right-f)*c,x=(i.top+f)*(1-u)+(i.bottom-f)*u;switch(this.textLines.forEach((b,I)=>{let S=g-a[I]*c,T=x-p*u+s*(I+1)+d;r.fillText(b,S,T)}),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,T=(i.bottom-i.top)/2;r.beginPath(),r.ellipse(b,I,S,T,0,0,2*Math.PI),r.stroke();break}}};var qs=class extends it{constructor(e,r){super(e);this.measure=e;this.staff=r;m(this,"clefImage");m(this,"eightBelowClef");m(this,"measureNumber");m(this,"ksNeutralizeAccidentals",[]);m(this,"ksNewAccidentals",[]);m(this,"beatCountText");m(this,"beatSizeText");m(this,"tempoText");m(this,"mi");this.mi=new an(this)}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let i=e.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new Vs(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(),n=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],n&&!Pe.equals(s,n)&&n.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new hi(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new hi(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 n=r.beatSize.toString();this.beatSizeText=new lt(this,{text:n,scale:1.4},0,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=Za(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 V.findNextDiatonicIdAbove(e.diatonicId,i,!1);throw new E(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 n=this.ksNeutralizeAccidentals[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.ksNewAccidentals.length;i++){let n=this.ksNewAccidentals[i].pick(e,r);if(n.length>0)return[this,...n]}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,n=r,s=0;if(this.rect=new F,this.clefImage&&(s+=n,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+=n,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+=n,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+n,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+n,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+=n}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 Ws=class extends it{constructor(e,r,i){super(e);this.col=e;this.line=r;this.arpeggioDir=i;m(this,"topArrowHeight",0);m(this,"bottomArrowHeight",0);m(this,"cycleHeight",0);m(this,"numCycles",0);m(this,"color","black");m(this,"mi");this.mi=new cn(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===0?r:0,this.bottomArrowHeight=this.arpeggioDir===1?r:0;let i=this.line.getTopLineY(),n=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((n-i)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new F(-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:n,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=n.top+s;c<this.numCycles;c++,u+=this.cycleHeight)r.moveTo(n.centerX,u),r.quadraticCurveTo(n.left,u+this.cycleHeight/4,n.centerX,u+this.cycleHeight/2),r.quadraticCurveTo(n.right,u+this.cycleHeight*3/4,n.centerX,u+this.cycleHeight);r.stroke(),s>0&&(r.beginPath(),r.moveTo(n.centerX,n.top),r.lineTo(n.right,n.top+s),r.lineTo(n.left,n.top+s),r.fill()),a>0&&(r.beginPath(),r.moveTo(n.centerX,n.bottom),r.lineTo(n.left,n.bottom-a),r.lineTo(n.right,n.bottom-a),r.fill())}};function By(o){return typeof o=="number"?V.getChromaticNote(o).diatonicId:typeof o=="string"?V.getNote(o).diatonicId:o instanceof V?o.diatonicId:void 0}var Us=class extends it{constructor(e,r){super(e);this.staff=e;this.rest=r;m(this,"restRect",new F);m(this,"dotRect");m(this,"mi");e.addObject(this),this.mi=new ln(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.restRect.offsetInPlace(e,r),(i=this.dotRect)==null||i.offsetInPlace(e,r),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRect&&this.rect.expandInPlace(this.dotRect)}},pi=class extends it{constructor(e,r,i,n){var c,u;super(e);this.col=e;this.voiceId=r;m(this,"ownStemDir");m(this,"ownDiatonicId");m(this,"color");m(this,"hide");m(this,"rhythmProps");m(this,"beamGroup");m(this,"staffObjects",[]);m(this,"mi");let s=By(n==null?void 0:n.staffPos);if(s!==void 0){let l=this.row.hasStaff,h=this.row.getStaff(s);if(l&&!h)throw new E(6,"Rest staffPos is out of staff boundaries!")}this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,s),this.ownStemDir=this.measure.updateOwnStemDir(this);let a=this.row.getStaff(this.ownDiatonicId);a&&a.isSpace(this.ownDiatonicId)&&(this.ownDiatonicId+=this.ownDiatonicId>=a.middleLineDiatonicId?1:-1),this.color=(c=n==null?void 0:n.color)!=null?c:"black",this.hide=(u=n==null?void 0:n.hide)!=null?u:!1,this.rhythmProps=new $t(i,n==null?void 0:n.dotted,n==null?void 0:n.triplet),this.mi=new un(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 dotted(){return this.rhythmProps.dotted}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}get triplet(){return this.rhythmProps.triplet}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 n=this.staffObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}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,n=this.stemDir===1?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().centerY-n);return{staff:r,x:i,y:n,stemHeight:s}})}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof Us&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case 192:return 1;case 96:return-1;case 48:return-1;case 24:return-1;case 12:return-1;case 6:return-3;case 3:return-3;default:throw new E(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:n}=this,{noteLength:s,dotted:a,flagCount:c}=this.rhythmProps,u=0,l=0,h=0,p=0;if(s===192)u=i,l=i,h=0,p=i;else if(s===96)u=i,l=i,h=i,p=0;else if(s===48)u=i*1,l=i*1,h=i*3.2,p=i*3;else{let d=1-c%2;u=i*(1+c*.25),l=i*(1+c*.125),h=i*(.5+c-d),p=i*(1+c+d)}this.row.getStaves().forEach(d=>{if(!d.containsDiatonicId(n)||!d.containsVoiceId(this.voiceId))return;let f=new Us(d,this);if(f.restRect=new F(-u,0,l,-h,0,p),a){let g=ct.DotSize*i,x=l+(ct.RestDotSpace+ct.DotSize/2)*i,b=this.getRestDotVerticalDisplacement(s)*i;f.dotRect=F.createCentered(x,b,g,g)}f.offset(0,d.getDiatonicIdY(n)),this.staffObjects.push(f)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;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:n}=e,{color:s}=this,{noteLength:a,flagCount:c}=this.rhythmProps;r.strokeStyle=r.fillStyle=s,r.lineWidth=n,this.staffObjects.forEach(u=>{let{dotRect:l,restRect:h}=u,p=h.centerX,d=h.centerY;if(a===192)r.fillRect(p-i,d,i*2,i);else if(a===96)r.fillRect(p-i,d-i,i*2,i);else if(a===48)r.beginPath(),r.moveTo(p-i*.6,d-i*3.2),r.lineTo(p+i*.7,d-i*1.5),r.quadraticCurveTo(p-i*.8,d-i*.5,p+i*1,d+i*1.5),r.lineTo(p-i*1,d-i*.75),r.quadraticCurveTo(p+i*.2,d-i*1.5,p-i*.6,d-i*3.2),r.moveTo(p+i*1,d+i*1.5),r.quadraticCurveTo(p-i*.8,d+i*1,p-i*.2,d+i*2.8),r.bezierCurveTo(p-i*1.8,d+i*1.5,p-i*.6,d-i*.2,p+i*.9,d+i*1.5),r.fill(),r.stroke();else if(c>0){let f=1-c%2,g=b=>p+(-b*.25+.5)*i,x=b=>d+(b+f)*i;r.beginPath(),r.moveTo(g(1+c),x(1+c)),r.lineTo(g(-.5-c),x(-.5-c)),r.stroke();for(let b=0;b<c;b++){let I=c-b*2;r.beginPath(),r.moveTo(g(I-2.5),x(I-2.5)),r.quadraticCurveTo(g(I-.5)+i*.25,x(I-1.5),g(I-1.5)-i*1.5,x(I-1.5)),r.stroke(),r.beginPath(),r.arc(g(I-2)-i*1.5,x(I-2),i*.5,0,Math.PI*2),r.fill()}}l&&e.fillCircle(l.centerX,l.centerY,l.width/2)})}};var Gy=(o,t)=>{let e=ct.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=o/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),o/r*e}},hn=class{constructor(t,e,r,i,n){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=i;this.y=n;m(this,"topBeamsHeight",0);m(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new F(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},ou=class extends it{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;m(this,"tripletNumber");m(this,"tripletNumberOffsetY",0);m(this,"points",[]);m(this,"mi");e.addObject(this),this.mi=new dn(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.points.forEach(n=>n.offset(e,0)),(i=this.tripletNumber)==null||i.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().copy():this.tripletNumber&&(this.rect=this.tripletNumber.getRect().copy()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tripletNumber&&this.rect.expandInPlace(this.tripletNumber.getRect())}},di=class o extends it{constructor(e,r){super(e[0].measure);this.symbols=e;m(this,"mi");m(this,"type");m(this,"staffObjects",[]);if(this.mi=new pn(this),e.every(i=>i.measure===e[0].measure)){if(e.length<2)throw new E(6,"Beam group need minimum 2 symbols, but "+e.length+" given.")}else throw new E(6,"All beam group symbols are not in same measure.");if(r){if(!e.every(n=>n.triplet))throw new E(6,"Not every symbol's triplet property is true.");let i=e.length<3||e.some(n=>!(n instanceof St))||e.some(n=>n.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&&(i=!1),e.some(n=>n.rhythmProps.noteLength>=48)&&(i=!0),this.type=i?2:1,St.setTripletBeamCounts(this)}else this.type=0;if(e.every(i=>i.getBeamGroup()===void 0))e.forEach(i=>i.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new E(6,"Cannot add beam group because some symbol already has one.")}static createBeam(e){e.length>1&&new o(e,!1)}static createTriplet(e){if(!e.every(n=>n.triplet))return!1;let r=96,i=e.map(n=>n.rhythmProps.noteLength);if(e.length==2){if(i[0]<=r&&i[1]===i[0]/2&&i[0]/2>=Ii||i[1]<=r&&i[0]===i[1]/2&&i[1]/2>=Ii)return new o(e,!0),!0}else if(e.length===3&&i[0]<=r&&i.every(n=>n===i[0]))return new o(e,!0),!0;return!1}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 n=this.staffObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}getType(){return this.type}isTriplet(){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:n}=e,{stemDir:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var W,k;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}),d=a.map(P=>{var L;return(L=P[u])==null?void 0:L.stemHeight}),f=r[0],g=l[0],x=h[0],b=p[0],I=r[r.length-1],S=l[l.length-1],T=h[h.length-1],v=p[h.length-1];if(g===void 0||x===void 0||b===void 0||S===void 0||T===void 0||v===void 0)return;let C=(W=d[0])!=null?W:0,A=(k=d[d.length-1])!=null?k:0;if(this.type!==2){let P=C<A?Math.sqrt(A-C):0,L=A<C?Math.sqrt(C-A):0;s===1&&(P*=-1,L*=-1),P!==0&&(x+=P,h[0]+=P),L!==0&&(T+=L,h[h.length-1]+=L)}let y=n*2*(s===1?-1:1),N=(T+x)/2,D=Gy(S-g,T-x)/2;x=N-D,T=N+D;let M=0;h.forEach((P,L)=>{let q=l[L];if(q!==void 0&&P!==void 0){let H=_.Math.interpolateY(g,x,S,T,q),Q=P-H;s===1&&Q<0?M=Math.min(M,Q):s===2&&Q>0&&(M=Math.max(M,Q))}}),x+=M,T+=M,h=h.map(P=>P===void 0?void 0:P+M);let O=new ou(c,this);if(this.type===2){let P=n/(S-g),L=_.Math.interpolateCoord(g,x+y,S,T+y,-P),q=_.Math.interpolateCoord(g,x+y,S,T+y,1+P);O.points.push(new hn(b,this,f,L.x,L.y)),O.points.push(new hn(v,this,I,q.x,q.y)),O.tripletNumberOffsetY=0}else if(this.type===0||this.type===1){M*=.5;let{beamThickness:P}=e,L=q=>{let H=r[q];if(H instanceof St){let Q=H instanceof St?Math.max(H.getLeftBeamCount(),H.getRightBeamCount()):0;return ct.BeamSeparation*n*(this.stemDir===1?Q-1:0)}else return 0};r.forEach((q,H)=>{let Q=p[H],et=l[H],at=h[H];if(Q&&et!==void 0&&at!==void 0){let yt=new hn(Q,this,q,et,at);yt.topBeamsHeight=P/2+(s===2?L(H):0),yt.bottomBeamsHeight=P/2+(s===1?L(H):0),O.points.push(yt)}}),O.tripletNumberOffsetY=y}this.isTriplet()&&(O.tripletNumber=new lt(this,"3",.5,.5),O.tripletNumber.layout(e),O.tripletNumber.offset((g+S)/2,(x+T)/2+O.tripletNumberOffsetY)),O.points.length>=2&&this.staffObjects.push(O)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;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(n=>{n.symbol instanceof St&&(n!==r&&n!==i&&(n.y=_.Math.interpolateY(r.x,r.y,i.x,i.y,n.x)),n.symbol.setStemTipY(n.staff,n.y))}),e.tripletNumber){let n=(r.y+i.y)/2+e.tripletNumberOffsetY;e.tripletNumber.offset(0,-e.tripletNumber.getRect().centerY+n)}})}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r,beamThickness:i,lineWidth:n}=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.tripletNumber?a.tripletNumber.getRect().width/(u.x-c.x)*1.2:0,h=_.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5-l/2),p=_.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5+l/2),d=this.stemDir===1?r:-r;e.drawLine(c.x,c.y,h.x,h.y,s,n),e.drawLine(p.x,p.y,u.x,u.y,s,n),e.drawLine(c.x,c.y,c.x,c.y+d,s,n),e.drawLine(u.x,u.y,u.x,u.y+d,s,n)}}else if(this.type===0||this.type===1){let c=ct.BeamSeparation*r*(this.stemDir===1?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 d=h.symbol.getRightBeamCount(),f=p.symbol.getLeftBeamCount(),g=h.x,x=h.y,b=p.x,I=p.y;for(let S=0;S<Math.max(d,f);S++)S<d&&S<f?e.drawLine(g,x,b,I,s,i):d>f?e.drawPartialLine(g,x,b,I,0,.25,s,i):f>d&&e.drawPartialLine(g,x,b,I,.75,1,s,i),x+=c,I+=c}}a.tripletNumber&&a.tripletNumber.draw(e)})}};function Vy(o,t){let e=_.Arr.isArray(t)?t:t!==void 0?[t]:[],r=o.map((i,n)=>({note:i,string:e[n]}));return r=_.Arr.removeDuplicatesCmp(r,(i,n)=>V.equals(i.note,n.note)).sort((i,n)=>V.compareFunc(i.note,n.note)),{notes:r.map(i=>i.note),strings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}function qy(o){return o===!0||o===0?0:o===1?1:void 0}var zs=class extends it{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;m(this,"noteHeadRects",[]);m(this,"dotRects",[]);m(this,"accidentals",[]);m(this,"stemTip");m(this,"stemBase");m(this,"flagRects",[]);m(this,"prevTopNoteY",0);m(this,"prevBottomNoteY",0);m(this,"mi");this.mi=new fn(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[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,n;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),(n=this.stemBase)==null||n.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},nu=class extends it{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;m(this,"fretNumbers",[]);m(this,"mi");e.addObject(this),this.mi=new gn(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 o extends it{constructor(e,r,i,n,s){var c,u,l;super(e);this.col=e;this.voiceId=r;this.notes=i;m(this,"minDiatonicId");m(this,"maxDiatonicId");m(this,"ownDiatonicId");m(this,"ownStemDir");m(this,"ownString");m(this,"color");m(this,"staccato");m(this,"diamond");m(this,"arpeggio");m(this,"rhythmProps");m(this,"startConnnectives",[]);m(this,"runningConnectives",[]);m(this,"leftBeamCount",0);m(this,"rightBeamCount",0);m(this,"beamGroup");m(this,"staffObjects",[]);m(this,"tabObjects",[]);m(this,"mi");if(!_.Is.isIntegerGte(i.length,1))throw new E(6,"Cannot create note group object because notes array is empty.");let a=Vy(i,s==null?void 0:s.string);this.notes=a.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,s==null?void 0:s.stem),this.ownString=this.measure.updateOwnString(this,a.strings),this.color=(c=s==null?void 0:s.color)!=null?c:"black",this.staccato=(u=s==null?void 0:s.staccato)!=null?u:!1,this.diamond=(l=s==null?void 0:s.diamond)!=null?l:!1,this.arpeggio=qy(s==null?void 0:s.arpeggio),this.rhythmProps=new $t(n,s==null?void 0:s.dotted,s==null?void 0:s.triplet),this.mi=new mn(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}get triplet(){return this.rhythmProps.triplet}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof ur||e.containsDiatonicId(this.ownDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective===0)throw new E(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective===1)throw new E(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 n=this.staffObjects[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.tabObjects.length;i++){let n=this.tabObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,i,n,s){if(r instanceof kt){let a=r;if(i<0||i>=this.notes.length)throw new E(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(v=>v.staff===a);if(!c||i<0||i>=c.noteHeadRects.length){let v=this.getRect();return{x:v.centerX,y:v.bottom}}let u=c.noteHeadRects[i],l=c.stemTip,h=this.stemDir,p=l!==void 0,d=p?h===1?"right":"left":void 0,f=u.height/2,g=u.centerX,x=u.centerY,b=u.left-f,I=u.right+f,S=u.top-f,T=u.bottom+f;switch(n===0?n=3:n===4&&!p&&(n=h===1?1:3),n){case 2:return s==="left"?{x:I,y:x}:{x:b,y:x};case 1:return!p||h===2?{x:g,y:S}:{x:s==="left"&&d==="right"?I:s==="right"&&d==="left"?b:g,y:S};case 3:return!p||h===1?{x:g,y:T}:{x:s==="left"&&d==="right"?I:s==="right"&&d==="left"?b:g,y:T};case 4:return{x:g,y:l.centerY+(h===1?-f:f)};default:throw new E(6,"Invalid noteAnchor: "+n)}}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,d=.9;if(e.connective===2){let f=e.noteGroups[0].getFretNumber(c,0),g=e.noteGroups[1].getFretNumber(c,0),x=f===void 0||g===void 0||f<=g;s==="left"?p=x?l.centerY+l.bottomh*d:l.centerY-l.toph*d:p=x?l.centerY-l.toph*d:l.centerY+l.bottomh*d}else p=l.centerY+l.bottomh*d;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(n=>n instanceof o),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 n=i.getVoiceSymbols(this.voiceId).filter(s=>s instanceof o);if(n.length>0)return n[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===1).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,n=(l=(u=e.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir===1?e.getRect().top:e.getRect().bottom,s=this.stemDir===1?Math.abs(e.noteHeadRects[0].centerY-n):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].centerY-n);return{staff:r,x:i,y:n,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{noteLength:i,flagCount:n}=this.rhythmProps;if(i>=192)return 0;{let s=this.hasBeamCount()?ct.BeamSeparation:ct.FlagSeparation;return(ct.StemHeight+Math.max(0,n-1)*s)*r}}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 zs&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(i=>i.connective===0).map(i=>{let n=i.noteGroups,s=n.indexOf(this);if(s<0)return 0;if(i.span===-1||i.span===-2)return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=n[s-1];return a&&a.notes.some(c=>V.equals(c,e))?0:(n=n.slice(s),s=n.findIndex(c=>c.notes.every(u=>!V.equals(u,e))),s>=0&&(n=n.slice(0,s)),_.Math.sum(n.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:n,stemDir:s}=this,{dotted:a,flagCount:c}=this.rhythmProps,u=ct.DotSize*i,l=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadWidth)*i,h=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadHeight)*i;this.staffObjects.length=0,n.getStaves().forEach(p=>{if(!p.containsDiatonicId(this.ownDiatonicId)||!p.containsVoiceId(this.voiceId))return;let d=new zs(p,this),f=p,g=p;this.notes.forEach((C,A)=>{var P;let y=A===0,N=A===this.notes.length-1,D=(P=p.getActualStaff(C.diatonicId))!=null?P:p,M=this.col.getNoteHeadDisplacement(this,C)*l,O=D.getDiatonicIdY(C.diatonicId),W=D.isLine(C.diatonicId);y&&s===1&&(f=D),N&&s===1&&(g=D),y&&s===2&&(g=D),N&&s===2&&(f=D);let k=d.noteHeadRects[A]=F.createCentered(M,O,l,h);if(D.addObject(k),r.needAccidental(C)){let L=d.accidentals[A]=new hi(this,C.diatonicId,C.accidental,this.color);L&&(L.layout(e),L.offset(-k.leftw-i*ct.NoteAccSpace-L.getRect().rightw,O)),D.addObject(L)}if(a){let L=k.right+ct.NoteDotSpace*i+u/2,q=O+this.getDotVerticalDisplacement(p,C.diatonicId,s)*i,H=F.createCentered(L,q,u,u);d.dotRects.push(H),D.addObject(H)}if(this.staccato){if(s===1&&y){let L=M,q=O+i*(W?3:2),H=F.createCentered(L,q,u,u);d.dotRects.push(H),f.addObject(H)}else if(s===2&&N){let L=M,q=O-i*(W?3:2),H=F.createCentered(L,q,u,u);d.dotRects.push(H),f.addObject(H)}}});let x=d.noteHeadRects[0].centerY,b=d.noteHeadRects[d.noteHeadRects.length-1].centerY,I=s===1?l/2:-l/2,S=this.getStemHeight(e),T=s===1?b-S:x+S,v=s===1?x:b;if(this.rhythmProps.hasStem()&&(d.stemTip=new F(I,I,T,T),d.stemBase=new F(I,I,v,v),g.addObject(d.stemTip),f.addObject(d.stemBase)),!this.hasBeamCount()){let C=c===0?0:ct.FlagWidth*i,A=c===0?0:ct.FlagHeight*i;for(let y=0;y<c;y++){let N=y*i*ct.FlagSeparation,D=d.flagRects[y]=s===1?new F(I,I+C,T+N,T+A+N):new F(I,I+C,T-A-N,T-N);g.addObject(D)}}this.staffObjects.push(d)}),this.tabObjects.length=0,n.getTabs().forEach(p=>{if(!p.containsVoiceId(this.voiceId))return;let d=new nu(p,this);this.notes.forEach((f,g)=>{var x,b;if(this.ownString[g]!==void 0){let I=this.ownString[g]-1,S=f.chromaticId-p.getTuningStrings()[I].chromaticId,T=S<0?"red":"black",v=new lt(this,{text:String(S),color:T,bgcolor:"white"},.5,.5);d.fretNumbers.push(v),v.layout(e);let C=this.col.getNoteHeadDisplacement(this,f)*l,A=(b=(x=this.staffObjects[0])==null?void 0:x.stemBase)==null?void 0:b.centerX,y=A!=null?A:C,N=p.getStringY(I);v.offset(y,N)}}),d.fretNumbers.length>0&&this.tabObjects.push(d)})}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 F;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(n=>n.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:n,stemDir:s}=this,{noteLength:a}=this.rhythmProps;this.staffObjects.forEach(c=>{c.accidentals.forEach(u=>u.draw(e)),r.strokeStyle=r.fillStyle=n,r.lineWidth=i,c.noteHeadRects.forEach(u=>{let l=a>=96;this.diamond?l?(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.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.ellipse(u.centerX,u.centerY,u.leftw,u.toph,-.3,0,Math.PI*2),l?r.stroke():r.fill())}),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,d=s===1?u.top:u.bottom,f=s===1?u.bottom:u.top;r.beginPath(),r.moveTo(l,d),r.bezierCurveTo(l,d*.75+f*.25,l+p*1.5,d*.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=(n,s)=>n.rhythmProps.noteLength===s.rhythmProps.noteLength*2&&n.rhythmProps.dotted&&!s.rhythmProps.dotted&&n.rhythmProps.flagCount>0&&s.rhythmProps.flagCount>0;for(let n=0;n<e.length;n++){let s=e[n],a=e[n-1],c=e[n+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 n=0;n<e.length;n++){let s=e[n],a=e[n-1],c=e[n+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 setTripletBeamCounts(e){let r=e.getType(),i=e.getSymbols();if(r===1)i.forEach((n,s)=>{n instanceof o&&(n.leftBeamCount=s===0?0:n.rhythmProps.flagCount,n.rightBeamCount=s===i.length-1?0:n.rhythmProps.flagCount)});else if(r===2)i.forEach(n=>{n instanceof o&&(n.leftBeamCount=n.rightBeamCount=0)});else throw new E(6,"Cannot set triplet beam count because triplet beam group type is invalid.")}getDotVerticalDisplacement(e,r,i){return e.isLine(r)?i===1?-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 n=e.notes[i],s=r.notes[i];if(n.diatonicId!==s.diatonicId||n.accidental!==s.accidental)return!1}return!0}};var Wy=(o,t)=>{let e=V.compareFunc(o.note,t.note);return e===0&&(e=o.noteGroup.stemDir===t.noteGroup.stemDir?0:o.noteGroup.stemDir===1?1:-1),e},Sr=class extends it{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;m(this,"voiceSymbol",[]);m(this,"minDiatonicId");m(this,"maxDiatonicId");m(this,"staffMinDiatonicId",new Map);m(this,"staffMaxDiatonicId",new Map);m(this,"arpeggioDir");m(this,"arpeggios",[]);m(this,"noteHeadDisplacements",[]);m(this,"playerProps");m(this,"needLayout",!0);m(this,"shapeRects",[]);m(this,"mi");this.playerProps=new po(this),this.mi=new xn(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 E(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(n=>r.push(n)))}),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 n=this.voiceSymbol[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.arpeggios.length;i++){let n=this.arpeggios[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:0}setVoiceSymbol(e,r){su(e),this.voiceSymbol[e]=r,r instanceof pi?!r.hide&&r.noteLength>=96&&(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.noteLength)),r=ct.NoteHeadWidth;switch(e){case 192:return r*5;case 96:return r*3;case 48: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(Wy),!(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],n=this.noteHeadDisplacements[e+1];if(i.displacement!==void 0)continue;let s=i.noteGroup.stemDir===2?-1:1;r&&i.note.diatonicId-r.note.diatonicId<=1?i.displacement=r.displacement===0?s:0:n&&n.note.diatonicId-i.note.diatonicId<=1&&(i.displacement=n.displacement===0?s:0)}}}getNoteHeadDisplacement(e,r){let i=this.noteHeadDisplacements.find(n=>n.noteGroup===e&&V.equals(n.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,n,s,a){if(n<=0)return;e.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,n),!0):!1)||e.push({note:i,ticks:n,staccato:s,slur:a})}return oe().forEach(i=>{let n=this.getVoiceSymbol(i);if(n instanceof St){let s=n.getPlaySlur();n.notes.forEach(a=>{let c=n.getPlayTicks(a),u=n.staccato;r(a,c,u,s)})}}),e.sort((i,n)=>V.compareFunc(i.note,n.note)),this.hasArpeggio()&&this.getArpeggioDir()===1&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new F;let{row:i}=this,{unitSize:n}=e,s=this.getMinWidth()*n/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 Ws(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(d=>{d.visibleInStaff(l)&&(d instanceof St?(h=h===void 0?d.minDiatonicId:Math.min(h,d.minDiatonicId),p=p===void 0?d.maxDiatonicId:Math.max(p,d.maxDiatonicId)):d instanceof pi&&(h=h===void 0?d.ownDiatonicId:Math.min(h,d.ownDiatonicId),p=p===void 0?d.ownDiatonicId:Math.max(p,d.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),n=this.staffMaxDiatonicId.get(r);i!==void 0&&e.drawLedgerLines(r,i,this.getRect().centerX),n!==void 0&&e.drawLedgerLines(r,n,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(e)}),this.arpeggios.forEach(r=>r.draw(e))}};var lr=class lr extends it{constructor(e,r){super(e);this.text=r;m(this,"components",[]);m(this,"mi");switch(this.text){case lr.Coda:this.components=[new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new lt(this," Coda",0,1)];break;case lr.toCoda:this.components=[new lt(this,"toCoda ",1,1),new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case lr.Segno:this.components=[new lt(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new yn(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 lr.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 F(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case lr.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 F(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))}};m(lr,"toCoda","\u{1D10C} toCoda"),m(lr,"Coda","Coda \u{1D10C}"),m(lr,"Segno","\u{1D10B}");var Ze=lr;function bn(o){switch(o){case 1:return"D.C. al Coda";case 0:return"D.C. al Fine";case 3:return"D.S. al Coda";case 2:return"D.S. al Fine";case 7:return"Fine";case 6:return Ze.Segno;case 4:return Ze.Coda;case 5:return Ze.toCoda;default:return Ie[o]}}function au(o){return["ppp","pp","p","mp","m","mf","f","ff","fff","cresc.","decresc.","dim."].indexOf(o)>=0}function Ys(o){return["ppp","pp","p","mp","m","mf","f","ff","fff"].indexOf(o)>=0}function cu(o){return["accel.","rit.","a tempo"].indexOf(o)>=0}function Uy(o){switch(o){case"bottom":return .8;case"middle":return .5}}function zy(o){return au(o)?2:cu(o)?1:0}var mi=class extends Ps{constructor(e,r,i,n,s,a){super(e);m(this,"length");m(this,"visible");m(this,"lineStyle");m(this,"linePos");m(this,"startColumn");m(this,"context");if(this.length=i,this.visible=n,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=e instanceof lt?zy(e.getText()):0,e instanceof lt)e.updateAnchorY(Uy(a));else throw new E(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 n=[9,10];for(let s=0;s<n.length;s++)if(i.hasNavigation(n[s]))return"section-break"}}if(r===1){let i=e.getAnchoredLayoutObjects();for(let n=0;n<i.length;n++){let s=i[n].getTextContent();if(s&&cu(s))return s}}else if(r===2){let i=e.getAnchoredLayoutObjects();for(let n=0;n<i.length;n++){let s=i[n].getTextContent();if(s&&au(s))return s}}}getExtensionRangeInfo(){let{startColumn:e,length:r,context:i}=this,n=[e];if(r<=0)return{startColumn:e,endColumn:e,columnRange:n,extensionBreakText:void 0};let s=r,a=e;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:e,endColumn:a,columnRange:n,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:e,endColumn:a,columnRange:n,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:e,endColumn:a,columnRange:n,extensionBreakText:void 0};a=c,n.push(a)}}};var Yy=2,Hy=2,Qy=.5,Zy=.5;function Xy(o,t){let e=new $t(t.options.beatLength,t.options.dotted).ticks,r=t.beatsPerMinute*e;return 60*o/r}function mo(o){switch(o){case"fff":return .9;case"ff":return .8;case"f":return .7;case"mf":return .6;default:case"m":return .5;case"mp":return .4;case"p":return .3;case"pp":return .2;case"ppp":return .1}}function uu(){return mo("m")}function Jy(o){return o*1.25}var Ky=.5,po=class{constructor(t){this.col=t;m(this,"speed");m(this,"volume");this.speed=1,this.volume=uu()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=uu()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=_.Math.clamp(this.getSpeed(),.1,10);return Xa(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 fi)return this.measure.getMeasureTicks()/2;{let r=oe().map(i=>t.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:_.Math.sum(r)/r.length}}},Hs=class o{constructor(){m(this,"playTimer");m(this,"playPos");m(this,"playState",2);m(this,"doc");m(this,"cursorPositionChangeListener");m(this,"playStateChnageListener");m(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,n=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=o.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation(8)&&(r=e),e.hasNavigation(6)&&(i=e),s&&e.hasNavigation(5))for(;e&&!e.hasNavigation(4);)e=e.getNextMeasure();else if(n&&e.hasNavigation(7))e=void 0;else if(e.hasNavigation(1))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation(0))n=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation(3))s=!0,e=i;else if(e.hasNavigation(2))n=!0,e=i;else if(e.hasNavigation(9)){let u=e.getPassCount(),l=e.getEndRepeatPlayCount()-1,h=((a=e.getNextMeasure())==null?void 0:a.hasNavigation(10))===!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=uu(),r=new Map,i=new Map,n=(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 Sr))return;a.getAnchoredLayoutObjects().forEach(p=>{var f;let d=(f=p.getTextContent())!=null?f:"";if(d==="a tempo")t=1;else if(Ys(d))e=mo(d);else if(p.musicObj.getLink()instanceof mi){let g=p.musicObj.getLink(),{columnRange:x,extensionBreakText:b}=g.getExtensionRangeInfo(),I=_.Math.sum(x.map(S=>S.getTicksToNextColumn()));switch(d){case"accel.":{let S=t,T=S*Yy,v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),n(C,S+(T-S)*v/I)});break}case"rit.":{let S=t,T=S/Hy,v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),n(C,S+(T-S)*v/I)});break}case"cresc.":{let S=e,T=S+Qy;b&&Ys(b)&&mo(b)>S&&(T=mo(b));let v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(T-S)*v/I)});break}case"decresc.":case"dim.":{let S=e,T=S-Zy;b&&Ys(b)&&mo(b)<S&&(T=mo(b));let v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(T-S)*v/I)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(t=_.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(e=_.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 n=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!n||n.hasNavigation(8))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=Xy(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),i=t.getPlayerProps().getFermataHoldTicks(),n;t instanceof fi?n=e(i,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?6*c:0,l=e(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(e(24,r)/2,l/2));let h=Jy(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=Ky),u>0){let p=e(u,r);window.setTimeout(()=>Ls(a.note,l,h),p*1e3)}else Ls(a.note,l,h)}}),n=e(t.getTicksToNextColumn()+i,r)),this.playTimer=window.setTimeout(()=>this.playStep(),n*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,n=e.row.getRect().bottom;return new F(r,r,i,n)}};var lu=class extends it{constructor(e){super(e);this.line=e;m(this,"lineRects",[]);m(this,"dotRects",[]);m(this,"mi");e.addObject(this),this.mi=new _n(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)}},Qs=class extends it{constructor(e){super(e);this.measure=e;m(this,"staffTabObjects",[]);m(this,"barLineType",0)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let n=this.staffTabObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,lineWidth:i}=e,{measure:n,barLineType:s}=this,{row:a}=n,c=i,u=.7*r,l=.7*r,h=ct.DotSize*r,p=h/2;a.getNotationLines().forEach(d=>{let f=new lu(d),g,x,b,I,S=(v,C)=>{f.lineRects.push(new F(v,v+C/2,v+C,b,0,I))},T=v=>{for(let C=-1;C<=1;C+=2){let A=g+C*x;f.dotRects.push(new F(v-p,v,v+p,A-p,A,A+p))}};switch(d instanceof kt?(g=d.getMiddleLineY(),x=d.getDiatonicSpacing()):(g=(d.getBottomLineY()+d.getTopLineY())/2,x=(d.getBottomLineY()-d.getTopLineY())/6),b=d.getTopLineY(),I=d.getBottomLineY(),s){case 0:f.setRect(new F(0,0,0,b,0,I));break;case 1:f.setRect(new F(-c,0,0,b,0,I)),S(-c,c);break;case 2:f.setRect(new F(-c-l-c,0,0,b,0,I)),S(-c-l-c,c),S(-c,c);break;case 3:f.setRect(new F(-u-l-c,0,0,b,0,I)),S(-c-l-u,c),S(-u,u);break;case 4:f.setRect(new F(0,0,u+l+c+l+h,b,0,I)),S(0,u),S(u+l,c),T(u+l+c+l+p);break;case 5:f.setRect(new F(-u-l-c-l-h,0,0,b,0,I)),S(-c-l-u,c),S(-u,u),T(-c-l-u-l-p);break;case 6:f.setRect(new F(-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),T(-u/2-l-c-l-p),T(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 F}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(n=>r.fillRect(n.left,n.top,n.width,n.height)),i.dotRects.forEach(n=>e.fillCircle(n.centerX,n.centerY,n.width/2))}))}},fo=class extends Qs{constructor(e){super(e);m(this,"mi");this.mi=new Cn(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation(8)?r&&r.row===e.row&&r.hasNavigation(9)?0:4:0}},fi=class extends Qs{constructor(e){super(e);m(this,"playerProps");m(this,"mi");this.playerProps=new po(this),this.mi=new An(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation(9)?r&&r.row===e.row&&r.hasNavigation(8)?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation(8)?2:r&&r.hasNavigation(8)?0:1}};var gi=class extends it{constructor(e,r){super(e);this.measure=e;this.passages=r;m(this,"endingText");m(this,"shapeRects",[]);m(this,"mi");if(this.mi=new vn(this),_.Is.isIntegerGte(r.length,1)){if(!this.passages.every(n=>_.Is.isIntegerGte(n,1)))throw new E(6,"Invalid passages: "+this.passages)}else throw new E(6,"Passages is empty.");this.passages.sort((n,s)=>n-s);let i=this.passages.map(n=>n+".").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(10))===!0||e.hasNavigation(9)||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 F,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:i}=this;this.endingText.layout(e);let n=this.endingText.getRect(),s=i.getColumnsContentRect(),a=n.height;this.rect=new F(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new F(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new F(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new F(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:n}=this;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle="black",r.lineWidth=i,r.beginPath(),r.moveTo(n.left,n.bottom),r.lineTo(n.left,n.top),r.lineTo(n.right,n.top),this.isSingleMeasureEnding()&&r.lineTo(n.right,n.bottom),r.stroke(),this.endingText.draw(e)}};var go=class extends it{constructor(e,r){super(e);this.pos=r;m(this,"color","black");m(this,"mi");this.mi=new In(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,n=r*3;this.rect=new F(-i/2,i/2,-n,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i,unitSize:n}=e,s=this.pos===1,a=(s?n:-n)*.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 d=p/6;e.fillCircle((c+u)/2,h-d,Math.abs(d))}};var xo=class extends it{constructor(e,r,i,n){super(e);this.measure=e;this.extension=r;this.leftObj=i;this.rightObj=n;m(this,"mi");r.addTail(this),this.mi=new Sn(this)}get row(){return this.measure.row}getMusicInterface(){return this.mi}getLineLeft(){return this.leftObj instanceof fo?this.leftObj.getRect().centerX:this.leftObj.getRect().right}getLineRight(){if(this.rightObj instanceof Sr){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(),n=this.getLineRight(),s=r;this.rect=new F(i,n,-s/2,s/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new F}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 n=this.extension.getTails();if(n.length>0&&this===n[n.length-1]){let s=i.centerY>this.measure.row.getRect().centerY?-e.unitSize:e.unitSize;e.drawLine(i.right,i.centerY,i.right,i.centerY+s,"black",e.lineWidth)}}};var xi=class extends it{constructor(e,r,i,n,s,...a){super(i);this.connectiveProps=e;this.line=r;this.measure=i;m(this,"lx",0);m(this,"ly",0);m(this,"rx",0);m(this,"ry",0);m(this,"cp1x",0);m(this,"cp1y",0);m(this,"cp2x",0);m(this,"cp2y",0);m(this,"arcHeight",0);m(this,"leftNoteGroup");m(this,"leftNoteId");m(this,"rightNoteGroup");m(this,"rightNoteId");m(this,"tieType");m(this,"mi");this.leftNoteGroup=n,this.leftNoteId=s,a[0]instanceof St&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):_.Is.isEnumValue(a[0],cr)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new wn(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:n,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:p}=l,{row:d}=i,f=d.getPrevRow(),g=d.getNextRow(),x=d.getConnectivesContentRect(),b,I;b=s.getConnectiveAnchorPoint(l,n,a,h,"left"),c!==void 0&&u!==void 0?I=c.getConnectiveAnchorPoint(l,n,u,h,"right"):I=this.tieType===-2?{x:i.getColumnsContentRect().right,y:b.y}:{x:b.x+r*ct.StubTieLength,y:b.y};let S,T,v,C;if(c===void 0)S=b.x,T=b.y,v=I.x,C=I.y;else if(s.row===d&&c.row===d)S=b.x,T=b.y,v=I.x,C=I.y;else if(s.row===f&&c.row===d){let O=f.getConnectivesContentRect().right-b.x,W=I.x-x.left;S=x.left,T=b.y+(I.y-b.y)*O/(O+W),v=I.x,C=I.y}else if(s.row===d&&c.row===g){let M=g.getConnectivesContentRect(),O=x.right-b.x,W=I.x-M.left;S=b.x,T=b.y,v=x.right,C=b.y+(I.y-b.y)*O/(O+W)}else throw new E(6,"Cannot layout connective object because no valid left and right note groups.");let y=(p==="up"?-1:1)*r*Math.log2(v-S)/3;this.lx=S,this.ly=T,this.rx=v,this.ry=C,this.arcHeight=this.connectiveProps.connective===2?0:y;let{nx:N,ny:D}=_.Math.calcNormal(S,T,v,C);this.cp1x=S*.7+v*.3+N*this.arcHeight,this.cp1y=T*.7+C*.3+D*this.arcHeight,this.cp2x=S*.3+v*.7+N*this.arcHeight,this.cp2y=T*.3+C*.7+D*this.arcHeight,this.rect=new F(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:n}=e;e.drawDebugRect(i);let s=n*1.5,a=n*.25;r.strokeStyle=r.fillStyle="black",r.lineWidth=n,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 yo=class{constructor(t,e,r,i){this.connective=t;this.span=e;this.noteAnchor=r;m(this,"noteGroups");m(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span===-1||this.span===-2?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(){let t=this.noteGroups[0].stemDir,e=this.noteGroups[0].rhythmProps.hasStem;if(this.noteAnchor===4)this.arcDir=t===1?"up":"down";else if(this.noteAnchor===0)this.arcDir=t===1||!e?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor=2:this.connective===2?this.noteAnchor=2:this.arcDir==="up"?this.noteAnchor=1:this.noteAnchor=3;else if(this.noteAnchor===2){let{row:r}=this.noteGroups[0].measure,i=this.noteGroups[0].ownDiatonicId,n=r.getStaff(i);this.arcDir=!n||i<n.middleLineDiatonicId?"down":"up"}else this.noteAnchor===1?this.arcDir="up":this.noteAnchor===3&&(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===0){if(e===-1||e===-2){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],n=this.noteGroups[r+1];i.notes.forEach((s,a)=>{let c=n.notes.findIndex(u=>V.equals(u,s));c>=0&&this.createObjConnective(i,a,n,c)})}}else if(t===1){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===2&&this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],n=this.noteGroups[r+1];this.createObjConnective(i,0,n,0)}}createObjConnectiveWithTieType(t,e,r){t.row.getNotationLines().filter(i=>t.enableConnective(i)).forEach(i=>{i instanceof kt?new xi(this,i,t.measure,t,e,r):t.getFretNumberString(e)!==void 0&&new xi(this,i,t.measure,t,e,r)})}createObjConnective(t,e,r,i){let n=(s,a,c,u,l)=>{s.row.getNotationLines().filter(h=>a.enableConnective(h)&&u.enableConnective(h)).forEach(h=>{if(h instanceof kt)new xi(this,h,s,a,c,u,l);else{let p=a.getFretNumberString(c),d=u.getFretNumberString(l);p!==void 0&&d!==void 0&&(p===d||this.connective===1)&&new xi(this,h,s,a,c,u,l)}})};if(t.measure===r.measure)n(t.measure,t,e,r,i);else if(t.measure.getNextMeasure()===r.measure)n(t.measure,t,e,r,i),n(r.measure,t,e,r,i);else throw new E(6,"Cannot create connective because it is jumping measures.")}};function su(o){if(oe().indexOf(o)<0)throw new E(6,"Invalid voiceId: "+o);return o}var Tn=class Tn extends it{constructor(e){super(e);this.row=e;m(this,"prevMeasure");m(this,"nextMeasure");m(this,"keySignature",Vn());m(this,"timeSignature",Un());m(this,"tempo",zn());m(this,"alterKeySignature");m(this,"alterTimeSignature");m(this,"alterTempo");m(this,"signatures",[]);m(this,"tabStringNotes",[]);m(this,"barLineLeft");m(this,"columns",[]);m(this,"barLineRight");m(this,"connectives",[]);m(this,"beamGroups",[]);m(this,"tabStringNotesWidth",0);m(this,"measureId");m(this,"needLayout",!0);m(this,"leftSolidAreaWidth",0);m(this,"minColumnsAreaWidth",0);m(this,"rightSolidAreaWidth",0);m(this,"useDiatonicId",[]);m(this,"useStemDir",[]);m(this,"useString",[]);m(this,"voiceSymbols",[]);m(this,"lastAddedRhythmColumn");m(this,"lastAddedRhythmSymbol");m(this,"addExtensionToMusicObjects",[]);m(this,"layoutObjects",[]);m(this,"postMeasureBreakWidth",0);m(this,"passCount",0);m(this,"needBeamsUpdate",!0);m(this,"navigationSet",new Set);m(this,"isEndSong",!1);m(this,"isEndSection",!1);m(this,"endRepeatPlayCount",2);m(this,"endRepeatPlayCountText");m(this,"staticObjectsCache",new Map);m(this,"mi");this.mi=new Nn(this),this.prevMeasure=e.doc.getLastMeasure(),this.prevMeasure&&(this.prevMeasure.nextMeasure=this),this.barLineLeft=new fo(this),this.barLineRight=new fi(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 n=this.getPrevMeasure();n&&n.useDiatonicId[e]!==void 0&&(this.useDiatonicId[e]=n.useDiatonicId[e])}let i=this.useDiatonicId[e];return i===void 0&&(this.row.hasStaff?i=this.row.getTopStaff().middleLineDiatonicId:i=V.getNote("C4").diatonicId),this.useDiatonicId[e]=V.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:0);let n=this.useStemDir[i];if(n===0||n===void 0){let c=this.row.getStaff(e.ownDiatonicId);return c?e.ownDiatonicId>c.middleLineDiatonicId?2:1:1}else return n}updateOwnString(e,r){var n,s;let{voiceId:i}=e;return r!==void 0?this.useString[i]=r:this.useString[i]===void 0&&(this.useString[i]=(s=(n=this.getPrevMeasure())==null?void 0:n.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 n=this.signatures[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.tabStringNotes.length;i++){let n=this.tabStringNotes[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.columns.length;i++){let n=this.columns[i].pick(e,r);if(n.length>0)return[this,...n]}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 n=this.connectives[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.beamGroups.length;i++){let n=this.beamGroups[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.layoutObjects.length;i++){let n=this.layoutObjects[i].musicObj.pick(e,r);if(n.length>0)return[this,...n]}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 Pe)this.alterKeySignature=e[0];else if(e[0]instanceof Dr)this.alterKeySignature=e[0];else try{let i=""+e[0],n=qa(""+e[1]);this.alterKeySignature=Mr(i,n)}catch(i){throw new E(6,"Cannot set key signature because invalid args: "+e)}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:Vn(),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 dr?e:new dr(e),this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:Un(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r,i){var s;(s=this.getPrevMeasure())==null||s.endSection();let n=r!==void 0?{beatLength:r,dotted:i}:void 0;this.alterTempo={beatsPerMinute:e,options:n},this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:zn(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,n;this.alterTempo.options?(i=this.alterTempo.options.beatLength,n=(e=this.alterTempo.options.dotted)!=null?e:!1):this.alterTimeSignature?(i=this.alterTimeSignature.beatLength,n=!1):(i=this.tempo.options.beatLength,n=this.tempo.options.dotted),this.tempo={beatsPerMinute:r,options:{beatLength:i,dotted:n}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,i,n){this.layoutObjects.push(new Zs(e,r,i,n)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(e,r,i){let n=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")n[a]&&i(n[a],c);else if(typeof a=="string"&&a.length>0){let l=n.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];(_.Is.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(d=>{switch(h.verticalPosition){case 0:s(d,0,p);break;case 1:s(d,1,p);break;case 2:s(d,0,p),s(d,1,p);break;case 3:s(d,r,p);break}})}}}};e===void 0?n.length>=2&&n[0]instanceof kt&&n[0].staffConfig.clef==="G"&&n[0].isGrand()&&n[1]instanceof kt&&n[1].staffConfig.clef==="F"&&n[1].isGrand()?s(r===1?1:0,r):s(0,r):_.Is.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let i=r===1?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new E(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(n,s)=>{this.addLayoutObject(new go(i,s),n,0,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof go&&r.anchor===e)}addNavigation(e,r,...i){let n;switch(r){case 10:if(this.navigationSet.has(r))throw new E(6,"Cannot add ending beasure measure already has one.");let s=this,a=i;n={createObj:()=>new gi(s,a),layoutGroupId:3,defaultVerticalPos:0};break;case 1:case 0:case 3:case 2:{let c=this.barLineRight,u=bn(r);n={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0},this.addNavigation(e,9),this.endSong();break}case 7:{let c=this.barLineRight,u=bn(r);n={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0};break}case 6:case 4:{let c=this.barLineLeft,u=bn(r);n={createObj:()=>new Ze(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case 5:{let c=this.barLineRight,u=bn(r);n={createObj:()=>new Ze(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case 9:if(i.length===0)this.endRepeatPlayCount=2;else if(_.Is.isIntegerGte(i[0],2))this.endRepeatPlayCount=i[0];else throw new E(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}n&&this.forEachStaffGroup(e,n.defaultVerticalPos,(s,a)=>{this.addLayoutObject(n.createObj(),s,n.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,i){let n=this.lastAddedRhythmColumn;if(n){if(i.length===0)throw new E(6,"Cannot add annotation because annotation text is empty.")}else throw new E(6,"Cannot add annotation because anchor is undefined.");let s={text:i},a,c;switch(r){case 0:a=5,c=0,s.italic=!0;break;case 1:a=4,c=0,s.italic=!0;break}this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(n,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(e,r,i){let n=this.lastAddedRhythmColumn;if(n){if(i.length===0)throw new E(6,"Cannot add label because label text is empty.")}else throw new E(6,"Cannot add label because anchor is undefined.");let s={text:i},a,c;switch(r){case 0:a=1,c=1;break;case 1:a=6,c=0;break}this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(n,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 E(6,"Connective can be added to note group only.");if(e===0){let n=_.Is.isInteger(r[0])||_.Is.isEnumValue(r[0],cr)?r[0]:2,s=_.Is.isEnumValue(r[1],ve)?r[1]:0;i.startConnective(new yo(0,n,s,i))}else if(e===1){let n=_.Is.isInteger(r[0])?r[0]:2,s=_.Is.isEnumValue(r[1],ve)?r[1]:0;i.startConnective(new yo(1,n,s,i))}else if(e===2){let n=_.Is.isEnumValue(r[0],ve)?r[0]:0;i.startConnective(new yo(2,2,n,i))}}addExtension(e,r){if(this.addExtensionToMusicObjects.forEach(i=>{let n=i.getParent();if(i instanceof lt&&n instanceof Sr){let s="dashed",a="bottom",c=new mi(i,n,e,r,s,a);i.setLink(c)}else throw new E(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new E(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 gi)}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),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=i,this.lastAddedRhythmSymbol=r}addNoteGroup(e,r,i,n){let s=r.map(c=>typeof c=="string"?V.getNote(c):c),a=this.getRhythmColumn(e);this.addRhythmSymbol(e,new St(a,e,s,i,n))}addRest(e,r,i){let n=this.getRhythmColumn(e);this.addRhythmSymbol(e,new pi(n,e,r,i))}getRhythmColumn(e){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let n=this.columns[i],s=n.getVoiceSymbol(e);s&&(r=n.positionTicks+s.rhythmProps.ticks)}for(let i=0;i<=this.columns.length;i++){let n=this.columns[i];if(n&&n.positionTicks===r)return n;if(!n||n.positionTicks>r){let s=new Sr(this,r);return this.columns.splice(i,0,s),s}}throw new E(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(i=>{oe().forEach(n=>{let s=i.getVoiceSymbol(n);s&&(e===void 0||e===n)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new F(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(n=>n.getStaticObjects(e).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(e,r));let i=this.layoutObjects.filter(n=>n.line===e&&n.isPositionResolved()).map(n=>n.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:n,verticalPos:s,line:a}=e;if(r.getLink()instanceof mi){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 d=p===l.measure?u.getHead():p.getBarLineLeft(),f=p===h.measure?h:p.getBarLineRight(),g=p.row.getNotationLines(),x=(c=g.find(b=>b.name!==""&&b.name===a.name))!=null?c:g[a.id];x&&p.addLayoutObject(new xo(p,u,d,f),x,n,s)}}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createBeams(){!this.needBeamsUpdate||!this.row.hasStaff||(this.beamGroups.forEach(e=>e.detach()),this.beamGroups.length=0,oe().forEach(e=>{let r=this.getVoiceSymbols(e);if(!(r.length<=2)){for(let i=0;i<r.length;){let n=r.slice(i,i+2),s=r.slice(i,i+3);n.length===2&&di.createTriplet(n)?i+=2:s.length===3&&di.createTriplet(s)?i+=3:i++}if(!Fs.DisableBeams){let i=[],n=0,s=0;this.isUpBeat()&&(n=s=Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()));let a=this.getTimeSignature();r.forEach(c=>{for(i.push(c),s+=c.rhythmProps.ticks,n===0&&s===a.beamGroupLength&&Tn.setupBeamGroup(i);s>=a.beamGroupLength;)i=[],n=s=s-a.beamGroupLength})}}}),this.needBeamsUpdate=!1,this.requestLayout())}static setupBeamGroup(e){let r=e.map(n=>{var s;return n instanceof St&&((s=n.getBeamGroup())==null?void 0:s.isTriplet())!==!0?n:void 0});St.setBeamCounts(r);let i=[];r.forEach(n=>{n&&n.hasBeamCount()?i.push(n):(di.createBeam(i),i=[])}),di.createBeam(i)}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return su(e),this.voiceSymbols[e]===void 0&&(this.voiceSymbols[e]=[]),this.voiceSymbols[e]}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):oe().forEach(c=>{this.getConsumedTicks(c)>0&&this.completeRests(c)});return}let r=this.getMeasureTicks(),i=this.getConsumedTicks(e),n=r-i,s=[],a=_.Enum.getEnumValues(Gt);for(;n>0;)a.forEach(c=>{let u=new $t(c,!1);if(u.canDot()){let l=new $t(c,!0);for(;l.ticks<=n;)s.push(l),n-=l.ticks}for(;u.ticks<=n;)s.push(u),n-=u.ticks});s.reverse().forEach(c=>this.addRest(e,c.noteLength,{dotted:c.dotted}))}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var d;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?ct.PostMeasureBreakWidth*r:0;let i=this===this.row.getFirstMeasure(),n=((d=this.getPrevMeasure())==null?void 0:d.hasPostMeasureBreak())===!0;this.tabStringNotesWidth=i&&this.row.hasTab?r*4:0;let s=i||n,a=i&&!this.row.isFirstRow(),c=i||n||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;s||a||c||u||l?this.signatures=this.row.getStaves().map((f,g)=>{let x=this.signatures.find(I=>I.staff===f),b=x!=null?x:new qs(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 x=f.getTuningStrings()[g].format(1,1),b=new lt(this,{text:x,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 Gs(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,Tn.MinFlexContentWidth*r)}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new F,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 n=Math.max(0,...this.signatures.map(p=>p.getRect().width));i=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.tabStringNotesWidth+n-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=_.Math.sum(this.columns.map(p=>p.getRect().width)),l=c/u,h=s;this.columns.forEach(p=>{i=p.getRect();let d=h+i.leftw*l;p.offset(d-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 go).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(),n=a=>e.drawLine(r,a,i,a),{row:s}=this;s.getNotationLines().forEach(a=>{if(a instanceof kt)for(let c=a.bottomLineDiatonicId;c<=a.topLineDiatonicId;c+=2)n(a.getDiatonicIdY(c));else if(a instanceof ur)for(let c=0;c<6;c++)n(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))}};m(Tn,"MinFlexContentWidth",10);var bo=Tn;var $y=[1,6],tb=[2,3,4,5,6];function eb(o){for(;o;){if(o instanceof bo)return o;o=o.getParent()}throw new E(6,"Parent measure is required but not found!")}var Xs=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},Zs=class{constructor(t,e,r,i){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=i;m(this,"anchor");m(this,"measure");m(this,"row");m(this,"layoutGroup");m(this,"positionResolved",!0);this.measure=eb(this.musicObj),this.row=this.measure.row;let n=this.musicObj.getParent();if(!n)throw new E(6,"Parent music object is required as an anchor.");this.anchor=n,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:n}=this,s=n.getTopLineY(),a=n.getBottomLineY(),c=t.unitSize*2,u=i===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,l=r.getStaticObjects(n),h=e.getShapeRects();return l.forEach(p=>{let d=p.getShapeRects();h.forEach(f=>{d.forEach(g=>{F.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 Ze)return this.musicObj.getText()}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}getRect(){return this.musicObj.getRect()}},Js=class{constructor(t){this.layoutGroupId=t;m(this,"layoutObjectTable",[]);m(this,"rowAlign");m(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=tb.indexOf(t)>=0,this.widensColumn=$y.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 Ks=class extends it{constructor(e){super(e);m(this,"objects",[]);m(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 Js(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(n=>!n.isPositionResolved());let i;r.forEach(n=>{let s=n.resolveClosestToStaffY(e);i=n.verticalPos===1?Math.max(s,i!=null?i:s):Math.min(s,i!=null?i:s)}),r.forEach(n=>this.setObjectY(n,i))}layoutLayoutGroup(e,r,i){let n=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());n.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof gi||a instanceof xo?a.layoutFitToMeasure(e):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(e,n):n.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=n.filter(l=>c.some(h=>h===l.musicObj));this.alignObjectsY(e,u)}else this.alignObjectsY(e,[s])})}},kt=class extends Ks{constructor(e,r,i){super(e);this.row=e;this.staffConfig=r;this.id=i;m(this,"clefImageAsset");m(this,"clefLineDiatonicId");m(this,"topLineDiatonicId");m(this,"middleLineDiatonicId");m(this,"bottomLineDiatonicId");m(this,"minDiatonicId");m(this,"maxDiatonicId");m(this,"joinedGrandStaff");m(this,"topLineY",0);m(this,"bottomLineY",0);m(this,"mi");let n=(s,a)=>V.getNote(s).diatonicId-(a?7:0);r.clef==="G"?(this.clefImageAsset=0,this.clefLineDiatonicId=n("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2):(this.clefImageAsset=1,this.clefLineDiatonicId=n("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2),this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(n(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(n(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new On(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 V.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 E(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 E(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*ct.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new F(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){}},ur=class extends Ks{constructor(e,r,i){super(e);this.row=e;this.tabConfig=r;this.id=i;m(this,"top",0);m(this,"bottom",0);m(this,"tuningName");m(this,"tuningStrings");m(this,"mi");_.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(n=>V.getNote(n)).reverse()):typeof r.tuning=="string"?(this.tuningName=Ya(r.tuning),this.tuningStrings=Wn(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=Wn(this.tuningName)),this.mi=new Rn(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*ct.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new F(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 $s=class extends it{constructor(e,r,i){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=i;m(this,"nextRow");m(this,"minWidth",0);m(this,"notationLines");m(this,"staves");m(this,"tabs");m(this,"measures",[]);m(this,"needLayout",!0);m(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(n=>n instanceof kt),this.tabs=this.notationLines.filter(n=>n instanceof ur),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new En(this)}getMusicInterface(){return this.mi}createNotationLines(){let e=this.scoreConfig.map((r,i)=>r.type==="staff"?new kt(this,r,i):new ur(this,r,i));for(let r=0;r<e.length-1;r++){let i=e[r],n=e[r+1];i instanceof kt&&i.isGrand()&&i.staffConfig.clef==="G"&&n instanceof kt&&n.isGrand()&&n.staffConfig.clef==="F"&&(i.joinGrandStaff(n),n.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 E(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new E(6,"Bottom staff is required!")}getStaff(e){V.validateDiatonicId(e);for(let r=0;r<this.notationLines.length;r++){let i=this.notationLines[r];if(i instanceof kt&&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 n=this.measures[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.notationLines.length;i++){let n=this.notationLines[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:e.left;return new F(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],n=i instanceof kt?i.getDiatonicIdAt(e):void 0;if(n!==void 0)return n}}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 F(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 n=i,s=0;this.measures.forEach(u=>{n-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=n/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=Math.min(0,...this.measures.map(s=>s.getRect().top)),n=Math.max(0,...this.measures.map(s=>s.getRect().bottom));this.rect=new F(e,r,i,n)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutPositionLines(e){let{unitSize:r}=e;for(let i=1;i<this.notationLines.length;i++){let n=this.notationLines[i-1],s=this.notationLines[i];if(n instanceof kt&&n.isGrand()&&n.staffConfig.clef==="G"&&s instanceof kt&&s.isGrand()&&s.staffConfig.clef==="F"){let a=r*6;s.offset(0,n.getBottomLineY()-s.getTopLineY()+a)}else{let a=r*3;s.offset(0,n.calcBottom()-s.calcTop()+a)}}this.measures.forEach(i=>{i.requestRectUpdate(),i.getBarLineLeft().requestRectUpdate(),i.getBarLineRight().requestRectUpdate(),i.getColumns().forEach(n=>{n.requestRectUpdate(),oe().forEach(s=>{var a;return(a=n.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 ur)){let i=this.getFirstMeasure().getStaffLineLeft(),n=Math.min(...this.notationLines.map(a=>a.getTopLineY())),s=Math.max(...this.notationLines.map(a=>a.getBottomLineY()));e.drawLine(i,n,i,s)}this.measures.forEach(i=>i.draw(e)),this.notationLines.forEach(i=>i.draw(e)),r.restore()}}};var ta=class extends it{constructor(e,r,i,n){super(e);this.title=r;this.composer=i;this.arranger=n;m(this,"titleText");m(this,"composerText");m(this,"arrangerText");m(this,"mi");this.mi=new Mn(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 F(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 ea=class extends it{constructor(){super(void 0);m(this,"needLayout",!0);m(this,"renderer");m(this,"rows",[]);m(this,"measures",[]);m(this,"measuresPerRow",1/0);m(this,"curScoreConfig",[{type:"staff",clef:"G"}]);m(this,"header");m(this,"newRowRequested",!1);m(this,"allConnectiveProps",[]);m(this,"staffGroups",new Map);m(this,"mi");this.mi=new Yr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(_.Is.isEnumValue(e,_r))switch(e){default:case 1:this.curScoreConfig=[{type:"staff",clef:"G"}];break;case 2:this.curScoreConfig=[{type:"staff",clef:"F"}];break;case 3:this.curScoreConfig=[{type:"staff",clef:"G",isGrand:!0},{type:"staff",clef:"F",isGrand:!0}];break;case 4:this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case 8:this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case 12:this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else _.Is.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0;r<this.curScoreConfig.length-1;r++){let i=this.curScoreConfig[r],n=this.curScoreConfig[r+1];i.type==="staff"&&n.type==="staff"?i.clef==="G"&&i.isGrand&&n.clef==="F"&&n.isGrand?(i.minNote="C4",n.maxNote="B3",i.isOctaveDown=n.isOctaveDown=!1):i.isGrand=n.isGrand=!1:i.type==="staff"?i.isGrand=!1:n.type==="staff"&&(n.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 ta(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 $s(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]}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 bo(e);return this.measures.push(r),e.addMeasure(r),this.requestLayout(),r}addStaffGroup(e,r,i){this.staffGroups.set(e,new Xs(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(n=>n.createBeams()),this.forEachMeasure(n=>n.createExtensions()),this.allConnectiveProps.forEach(n=>n.removeConnectives()),this.allConnectiveProps.forEach(n=>n.createConnectives()),this.rows.forEach(n=>n.resetLayoutGroups(e)),this.rows.forEach(n=>n.layout(e));let i=Math.max(ct.DocumentMinWidth*r,...this.rows.map(n=>1.4*n.getMinWidth()));this.rows.forEach(n=>n.layoutWidth(e,i)),this.rows.forEach(n=>n.layoutLayoutGroups(e)),this.rows.forEach(n=>n.layoutPositionLines(e)),this.rows.forEach(n=>n.layoutPadding(e)),this.rect=new F,this.header&&(this.header.layoutWidth(e,i),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(n=>{n.offset(-this.rect.left,this.rect.bottom+r*2-n.getRect().top),this.rect.expandInPlace(n.getRect())}),this.rows.forEach(n=>n.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 n=this.rows[i];if(!n.hasStaff||!n.getRect().contains(e,r))continue;let s=n.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:n,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 n=this.rows[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}};function U(o,t,e){if(!o)throw new E(6,`Invalid arg: ${t} = ${e}`)}function hu(o){if(typeof o!="string")return!1;{let t=V.parseNote(o);return t!==void 0&&t.octave!==void 0}}function ra(o){return _.Is.isNumber(o)&&oe().indexOf(o)>=0}function fm(o){return _.Is.isNumber(o)&&ru().indexOf(o)>=0}function gm(o){U(_.Is.isObject(o),"staffConfig",o),U(o.type==="staff","staffConfig.type",o.type),U(_.Is.isEnumValue(o.clef,vr),"staffConfig.clef",o.clef),U(_.Is.isBooleanOrUndefined(o.isOctaveDown),"staffConfig.isOctaveDown",o.isOctaveDown),U(_.Is.isUndefined(o.minNote)||hu(o.minNote),"staffConfig.minNote",o.minNote),U(_.Is.isUndefined(o.maxNote)||hu(o.maxNote),"staffConfig.maxNote",o.maxNote),U(_.Is.isUndefined(o.voiceIds)||_.Is.isArray(o.voiceIds)&&o.voiceIds.every(t=>_.Is.isNumber(t)),"staffConfig.voiceIds",o.voiceIds),U(_.Is.isBooleanOrUndefined(o.isGrand),"staffConfig.isGrand",o.isGrand)}function xm(o){U(_.Is.isObject(o),"tabConfig",o),U(o.type==="tab","tabConfig.type",o.type),typeof o.tuning=="string"?U(Oo.includes(o.tuning),"tabConfig.tuning",o.tuning):_.Is.isArray(o.tuning)&&U(o.tuning.length===6&&o.tuning.every(t=>hu(t)),"tabConfig.tuning",o.tuning),U(_.Is.isUndefined(o.voiceIds)||_.Is.isArray(o.voiceIds)&&o.voiceIds.every(t=>_.Is.isNumber(t)),"tabConfig.voiceIds",o.voiceIds)}function ym(o){U(_.Is.isObject(o),"noteOptions",o),U(_.Is.isBooleanOrUndefined(o.dotted),"noteOptions.dotted",o.dotted),U(_.Is.isEnumValueOrUndefined(o.stem,je),"noteOptions.stem",o.stem),U(_.Is.isStringOrUndefined(o.color),"noteOptions.color",o.color),U(_.Is.isBooleanOrUndefined(o.arpeggio)||_.Is.isEnumValue(o.arpeggio,zr),"noteOptions.arpeggio",o.arpeggio),U(_.Is.isBooleanOrUndefined(o.staccato),"noteOptions.staccato",o.staccato),U(_.Is.isBooleanOrUndefined(o.diamond),"noteOptions.diamond",o.diamond),U(_.Is.isBooleanOrUndefined(o.triplet),"noteOptions.triplet",o.triplet),U(_.Is.isUndefined(o.string)||fm(o.string)||_.Is.isArray(o.string)&&o.string.length>0&&o.string.every(t=>fm(t)),"noteOptions.string",o.string)}function rb(o){U(_.Is.isObject(o),"restOptions",o),U(_.Is.isBooleanOrUndefined(o.dotted),"restOptions.dotted",o.dotted),U(_.Is.isStringOrUndefined(o.staffPos)||_.Is.isInteger(o.staffPos)||o.staffPos instanceof V,"restOptions.staffPos",o.staffPos),U(_.Is.isStringOrUndefined(o.color),"restOptions.color",o.color),U(_.Is.isBooleanOrUndefined(o.hide),"restOptions.hide",o.hide),U(_.Is.isBooleanOrUndefined(o.triplet),"restOptions.triplet",o.triplet)}function ia(o){U(_.Is.isStringOrUndefined(o)||_.Is.isIntegerGte(o,0)||_.Is.isArray(o)&&o.every(t=>_.Is.isString(t)||_.Is.isIntegerGte(t,0)),"staffTabOrGroup",o)}var wr=class{constructor(){m(this,"doc");this.doc=new ea}setScoreConfiguration(t){return _.Is.isEnumValue(t,_r)||(_.Is.isObject(t)&&t.type==="staff"?gm(t):_.Is.isObject(t)&&t.type==="tab"?xm(t):_.Is.isArray(t)?(U(t.length>0,"config",t),t.forEach(e=>{_.Is.isObject(e)&&e.type==="staff"?gm(e):_.Is.isObject(e)&&e.type==="tab"?xm(e):U(!1,"config",t)})):U(!1,"config",t)),this.doc.setScoreConfiguration(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 U(_.Is.isStringOrUndefined(t),"title",t),U(_.Is.isStringOrUndefined(e),"composer",e),U(_.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return U(_.Is.isIntegerGte(t,1)||t===1/0,"measuresPerRow",t),this.doc.setMeasuresPerRow(t),this}addMeasure(){return this.doc.addMeasure(),this}setKeySignature(...t){return U(t[0]instanceof Dr||t[0]instanceof Pe||_.Is.isString(t[0])&&_.Is.isEnumValue(t[1],Je),"keySignature",t),this.getMeasure().setKeySignature(...t),this}setTimeSignature(t){return U(t instanceof dr||_.Is.isString(t),"timeSignature",t),this.getMeasure().setTimeSignature(t),this}setTempo(t,e,r){return U(_.Is.isIntegerGte(t,1),"beatsPerMinute",t),e===void 0?U(_.Is.isUndefined(r),"dotted",r):(U(_.Is.isEnumValue(e,Gt),"beatLength",e),U(_.Is.isBooleanOrUndefined(r),"dotted",r)),this.getMeasure().setTempo(t,e,r),this}addNote(t,e,r,i){return U(ra(t),"voiceId",t),U(e instanceof V||_.Is.isString(e),"note",e),U(_.Is.isEnumValue(r,Gt),"noteLength",r),i!==void 0&&ym(i),this.getMeasure().addNoteGroup(t,[e],r,i),this}addChord(t,e,r,i){return U(ra(t),"voiceId",t),U(_.Is.isArray(e)&&e.length>=1&&e.every(n=>n instanceof V||_.Is.isString(n)),"notes",e),U(_.Is.isEnumValue(r,Gt),"noteLength",r),i!==void 0&&ym(i),this.getMeasure().addNoteGroup(t,e,r,i),this}addRest(t,e,r){return U(ra(t),"voiceId",t),U(_.Is.isEnumValue(e,Gt),"restLength",e),r!==void 0&&rb(r),this.getMeasure().addRest(t,e,r),this}addFermataInternal(t,e){return ia(t),U(_.Is.isEnumValue(e,rn),"fermata",e),this.getMeasure().addFermata(t,e),this}addFermata(t=0){return this.addFermataInternal(void 0,t)}addFermataTo(t,e=0){return this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return ia(t),U(_.Is.isEnumValue(e,Ie),"navigation",e),e===9&&r.length>0?U(_.Is.isIntegerGte(r[0],1),"playCount",r[0]):e===10&&r.length>0&&U(r.every(i=>_.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)}addLabelInternal(t,e,r){return ia(t),U(_.Is.isEnumValue(e,ho),"label",e),U(_.Is.isString(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)}addAnnotationInternal(t,e,r){return ia(t),U(_.Is.isEnumValue(e,ci),"annotation",e),U(_.Is.isString(r),"text",r),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(t,e){return this.addAnnotationInternal(void 0,t,e)}addAnnotationTo(t,e,r){return this.addAnnotationInternal(t,e,r)}addConnective(t,...e){if(U(_.Is.isEnumValue(t,Ir),"connective",t),t===0){U(_.Is.isUndefined(e[0])||_.Is.isInteger(e[0])||_.Is.isEnumValue(e[0],cr),"tieSpan",e[0]),U(_.Is.isEnumValueOrUndefined(e[1],ve),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t===1){U(_.Is.isUndefined(e[0])||_.Is.isInteger(e[0]),"slurSpan",e[0]),U(_.Is.isEnumValueOrUndefined(e[1],ve),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t===2){U(_.Is.isEnumValueOrUndefined(e[0],ve),"noteAnchor",e[0]);let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t,e){return U(_.Is.isIntegerGte(t,0)||t===1/0||_.Is.isEnumValue(t,Gt),"extendionLength",t),U(_.Is.isBooleanOrUndefined(e),"extensionVisible",e),this.getMeasure().addExtension(t,e!=null?e:!0),this}addStaffGroup(t,e,r=3){return U(_.Is.isString(t)&&t.length>0,"groupName",t),U(_.Is.isString(e)&&e.length>0||_.Is.isIntegerGte(e,0)||_.Is.isArray(e)&&e.every(i=>_.Is.isString(i)&&i.length>0||_.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",e),U(_.Is.isEnumValue(r,en),"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 U(_.Is.isUndefined(t)||ra(t),"voiceId",t),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){U(_.Is.isString(e),"bottomNote",e),U(_.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),n=t.getScaleNotes(e,r);for(let s=0;s<n.length;s++){s%i.beatCount===0&&s>0&&this.addMeasure();let a=n[s];this.addNote(0,a,i.beatLength),this.addLabel(0,a.formatOmitOctave(1))}return this}};var Dn=class{constructor(t){this.type=t}},ui=class extends Dn{constructor(e,r,i,n){super(e);this.renderer=r;this.scoreRow=i;this.diatonicId=n}},li=class extends Dn{constructor(e,r,i){super(e);this.renderer=r;this.objects=i;if(arguments.length===0)throw new E(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 ge(o,t,e){if(!o)throw new E(6,`Invalid arg: ${t} = ${e}`)}function kn(o,t){if(o==null)throw new TypeError(t);return o}function ib(o){return _.Is.isNumber(o)&&oe().indexOf(o)>=0}var bt=class{constructor(t){this.name=t}getParent(){var t;return(t=this.getMusicObject().getParent())==null?void 0:t.getMusicInterface()}},oa=class oa extends bt{constructor(e){super(oa.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};m(oa,"Name","Accidental");var nn=oa,na=class na extends bt{constructor(e){super(na.Name);this.obj=e}getMusicObject(){return this.obj}};m(na,"Name","Connective");var wn=na,sa=class sa extends bt{constructor(e){super(sa.Name);this.obj=e}getMusicObject(){return this.obj}};m(sa,"Name","Arpeggio");var cn=sa,aa=class aa extends bt{constructor(e){super(aa.Name);this.obj=e}getMusicObject(){return this.obj}};m(aa,"Name","BeamGroup");var pn=aa,ca=class ca extends bt{constructor(e){super(ca.Name);this.obj=e}getMusicObject(){return this.obj}};m(ca,"Name","StaffBeamGroup");var dn=ca,ua=class ua extends bt{constructor(e){super(ua.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.getTitle()}getComposer(){return this.obj.getComposer()}getArranger(){return this.obj.getArranger()}play(e){return ge(_.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),new jn(this,e).play()}};m(ua,"Name","Document");var Yr=ua,la=class la extends bt{constructor(e){super(la.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return ge(_.Is.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};m(la,"Name","Ending");var vn=la,ha=class ha extends bt{constructor(e){super(ha.Name);this.obj=e}getMusicObject(){return this.obj}};m(ha,"Name","Fermata");var In=ha,pa=class pa extends bt{constructor(e){super(pa.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};m(pa,"Name","Header");var Mn=pa,da=class da extends bt{constructor(e){super(da.Name);this.obj=e}getMusicObject(){return this.obj}};m(da,"Name","Image");var on=da,ma=class ma extends bt{constructor(e){super(ma.Name);this.obj=e}getMusicObject(){return this.obj}getMeasureNumber(){return this.obj.getMeasureNumber()}getRhythmColumns(){return this.obj.getColumns().map(e=>e.getMusicInterface())}};m(ma,"Name","Measure");var Nn=ma,fa=class fa extends bt{constructor(e){super(fa.Name);this.obj=e}getMusicObject(){return this.obj}};m(fa,"Name","BarLineRight");var An=fa,ga=class ga extends bt{constructor(e){super(ga.Name);this.obj=e}getMusicObject(){return this.obj}};m(ga,"Name","BarLineLeft");var Cn=ga,xa=class xa extends bt{constructor(e){super(xa.Name);this.obj=e}getMusicObject(){return this.obj}};m(xa,"Name","StaffTabBarLine");var _n=xa,ya=class ya extends bt{constructor(e){super(ya.Name);this.obj=e}getMusicObject(){return this.obj}getNotes(){return this.obj.notes}getRhythmProps(){return this.obj.rhythmProps}};m(ya,"Name","NoteGroup");var mn=ya,ba=class ba extends bt{constructor(e){super(ba.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}};m(ba,"Name","StaffNoteGroup");var fn=ba,Aa=class Aa extends bt{constructor(e){super(Aa.Name);this.obj=e}getMusicObject(){return this.obj}getNoteGroup(){return this.obj.noteGroup.getMusicInterface()}};m(Aa,"Name","TabNoteGroup");var gn=Aa,Ca=class Ca extends bt{constructor(e){super(Ca.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmProps(){return this.obj.rhythmProps}};m(Ca,"Name","Rest");var un=Ca,_a=class _a extends bt{constructor(e){super(_a.Name);this.obj=e}getMusicObject(){return this.obj}getRest(){return this.obj.rest.getMusicInterface()}};m(_a,"Name","StaffRest");var ln=_a,va=class va extends bt{constructor(e){super(va.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return ge(ib(e),"voiceId",e),(r=this.obj.getVoiceSymbol(e))==null?void 0:r.getMusicInterface()}};m(va,"Name","RhythmColumn");var xn=va,Ia=class Ia extends bt{constructor(e){super(Ia.Name);this.obj=e}getMusicObject(){return this.obj}getMeasures(){return this.obj.getMeasures().map(e=>e.getMusicInterface())}};m(Ia,"Name","ScoreRow");var En=Ia,Sa=class Sa extends bt{constructor(e){super(Sa.Name);this.obj=e}getMusicObject(){return this.obj}};m(Sa,"Name","Staff");var On=Sa,wa=class wa extends bt{constructor(e){super(wa.Name);this.obj=e}getMusicObject(){return this.obj}};m(wa,"Name","Tab");var Rn=wa,Ta=class Ta extends bt{constructor(e){super(Ta.Name);this.obj=e}getMusicObject(){return this.obj}};m(Ta,"Name","Signature");var an=Ta,Na=class Na extends bt{constructor(e){super(Na.Name);this.obj=e}getMusicObject(){return this.obj}};m(Na,"Name","SpecialText");var yn=Na,Oa=class Oa extends bt{constructor(e){super(Oa.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};m(Oa,"Name","Text");var sn=Oa,Ra=class Ra extends bt{constructor(e){super(Ra.Name);this.obj=e}getMusicObject(){return this.obj}};m(Ra,"Name","ExtensionLine");var Sn=Ra,Ln=class Ln{constructor(t,e){m(this,"player");ge(t instanceof Yr,"doc",t),ge(_.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new Hs,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()),eu()}play(){return Ln.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),Ln.currentlyPlaying.delete(this),this}};m(Ln,"currentlyPlaying",new Set);var jn=Ln,pu=class{constructor(){m(this,"renderer");this.renderer=new Bs(this)}setDocument(t){return ge(_.Is.isUndefined(t)||t instanceof Yr,"doc",t),this.renderer.setDocument(t),this}setCanvas(t){return t=kn(_.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){ge(_.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)}}},le=class le{constructor(){m(this,"playButton");m(this,"stopButton");m(this,"playStopButton");m(this,"pauseButton");m(this,"onPlay");m(this,"onStop");m(this,"onPlayStop");m(this,"onPause");m(this,"playLabel","Play");m(this,"stopLabel","Stop");m(this,"pauseLabel","Pause");m(this,"playState",2);m(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 ge(_.Is.isUndefined(t)||t instanceof Yr,"doc",t),this.onStop(),t?this.player=new jn(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 ge(_.Is.isStringOrUndefined(e),"btnLabel",e),le.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=kn(_.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",le.removeOnClickListeners(this.playButton,"all"),le.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return ge(_.Is.isStringOrUndefined(e),"btnLabel",e),le.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=kn(_.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",le.removeOnClickListeners(this.stopButton,"all"),le.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return ge(_.Is.isStringOrUndefined(e),"playLabel",e),ge(_.Is.isStringOrUndefined(r),"stopLabel",r),le.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=kn(_.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",le.removeOnClickListeners(this.playStopButton,"all"),le.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return ge(_.Is.isStringOrUndefined(e),"btnLabel",e),le.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=kn(_.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",le.removeOnClickListeners(this.pauseButton,"all"),le.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(t){let r=this.savedOnClickListeners.get(t)||[],i=[];r.forEach(n=>{e===n||e==="all"?t.removeEventListener("click",n):i.push(n)}),this.savedOnClickListeners.set(t,i)}}static addOnClickListener(t,e){ge(_.Is.isFunction(e),"onClick",e),t.addEventListener("click",e);let r=this.savedOnClickListeners.get(t)||[];this.savedOnClickListeners.set(t,[...r,e])}};m(le,"savedOnClickListeners",new Map);var du=le;Hr();var fu={};Ci(fu,{createAndanteByDiabelli:()=>sb,createFrereJacques:()=>ob,createGreensleeves:()=>nb});function ob(){return new wr().setScoreConfiguration(4).setHeader("Frere Jacques").addMeasure().setKeySignature("G","Major").setTimeSignature("4/4").addNote(0,"G3",48).addNote(0,"A3",48).addNote(0,"B3",48).addNote(0,"G3",48).addMeasure().addNote(0,"G3",48).addNote(0,"A3",48).addNote(0,"B3",48).addNote(0,"G3",48).addMeasure().addNote(0,"B3",48).addNote(0,"C4",48).addNote(0,"D4",96).endRow().addMeasure().addNote(0,"B3",48).addNote(0,"C4",48).addNote(0,"D4",96).addMeasure().addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(0,"C4",24).addNote(0,"B3",48).addNote(0,"G3",48).endRow().addMeasure().addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(0,"C4",24).addNote(0,"B3",48).addNote(0,"G3",48).addMeasure().addNote(0,"G3",48).addNote(0,"D3",48).addNote(0,"G3",96).addMeasure().addNote(0,"G3",48).addNote(0,"D3",48).addNote(0,"G3",96).getDocument()}function nb(){return new wr().setScoreConfiguration(4).setHeader("Greensleeves").addMeasure().setKeySignature("C","Major").setTimeSignature("6/8").setTempo(140).addNote(0,"A3",24).addMeasure().addNavigation(8).addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"D4",24).addNote(0,"E4",24,{dotted:!0}).addNote(0,"F4",12).addNote(0,"E4",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"A2",24).addNote(1,"E3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"A3",24).addNote(0,"A3",24,{dotted:!0}).addLabel(1,"F").addNote(0,"G#3",12).addNote(0,"A3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"F2",24).addNote(1,"A2",48).addMeasure().addNote(0,"B3",48,{stem:1}).addLabel(1,"E").addNote(0,"G#3",24).addNote(0,"E3",48).addNote(0,"A3",24).addNote(1,"E2",24,{stem:2}).addNote(1,"B2",48).addNote(1,"E2",24).addNote(1,"B2",48).endRow().addMeasure().addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"D4",24).addNote(0,"E4",24,{dotted:!0}).addNote(0,"F4",12).addNote(0,"E4",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"A2",24).addNote(1,"E3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",24,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"B3",12).addNote(0,"A3",24).addNote(0,"G#3",24,{dotted:!0}).addLabel(1,"E").addNote(0,"F#3",12).addNote(0,"G#3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"A3",48,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"A3",48,{dotted:!0}).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",24).addNote(1,"C4",24).addNote(1,"A2",48,{dotted:!0}).endRow().addMeasure().addChord(0,["C3","E3","G3","C4","G4"],48,{dotted:!0,arpeggio:0,stem:1}).addLabel(1,"C").addNote(0,"G4",24,{dotted:!0}).addNote(0,"F#4",12).addNote(0,"E4",24).addRest(1,48,{dotted:!0,hide:!0}).addNote(1,"C3",24,{stem:2}).addNote(1,"G3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"A3",24).addNote(0,"A3",24,{dotted:!0}).addLabel(1,"F").addNote(0,"G#3",12).addNote(0,"A3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"F2",24).addNote(1,"A2",48).addMeasure().addNote(0,"B3",48,{stem:1}).addLabel(1,"E").addNote(0,"G#3",24).addNote(0,"E3",48,{dotted:!0}).addNote(1,"E2",24,{stem:2}).addNote(1,"B2",48).addNote(1,"E2",24).addNote(1,"B2",24).addNote(1,"E3",24).endRow().addMeasure().addNote(0,"G4",48,{dotted:!0,stem:1}).addLabel(1,"C").addNote(0,"G4",24,{dotted:!0}).addNote(0,"F#4",12).addNote(0,"E4",24).addNote(1,"C3",24,{stem:2}).addNote(1,"G3",24).addNote(1,"C4",24).addNote(1,"C3",24).addNote(1,"G3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",24,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"B3",12).addNote(0,"A3",24).addNote(0,"G#3",24,{dotted:!0}).addLabel(1,"E").addNote(0,"F#3",12).addNote(0,"G#3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNavigation(10,1).addNavigation(9).addNote(0,"A3",48,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"A3",48).addNote(0,"A3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",24).addNote(1,"C4",24).addNote(1,"A2",48,{dotted:!0}).addMeasure().addNavigation(10,2).addNote(0,"A3",48,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"A3",48,{dotted:!0}).addFermata().addNote(1,"A2",24,{stem:2}).addNote(1,"E3",24).addNote(1,"C4",24).addNote(1,"A2",48,{dotted:!0}).getDocument()}function sb(){return new wr().setScoreConfiguration(4).setHeader("Andante","A. Diabelli").addMeasure().setKeySignature("D","Major").setTimeSignature("3/4").setTempo(80).addRest(0,24,{staffPos:"G4"}).addAnnotation(0,"p").addNote(0,"F#4",24,{stem:1}).addNote(0,"G4",24).addConnective(1,2,3).addNote(0,"F#4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(1,"D3",96,{dotted:!0,stem:2}).addMeasure().addNote(0,"C#4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"G4",48).addNote(1,"A2",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"f").addNote(0,"A3",24).addNote(0,"G#3",24).addConnective(1,2,3).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",24).addNote(1,"A2",96,{dotted:!0}).endRow().addMeasure().addNote(0,"D4",24,{string:3}).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"G4",24).addNote(0,"A4",48).addNote(1,"D3",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"G4"}).addAnnotation(0,"p").addNote(0,"F#4",24).addNote(0,"G4",24).addConnective(1,2,3).addNote(0,"F#4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(1,"D3",96,{dotted:!0}).addMeasure().addNote(0,"C#4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"G4",48).addNote(1,"A2",96,{dotted:!0}).endRow().addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"f").addNote(0,"A3",24).addNote(0,"G#3",24).addConnective(1,2,3).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",24).addNote(1,"A2",96,{dotted:!0}).addMeasure().addNote(0,"D4",48).addRest(1,48,{staffPos:"D3"}).addNote(0,"D3",48).addNote(1,"D3",48).addRest(1,48,{staffPos:"B3"}).addNavigation(9).addMeasure().addRest(0,24,{staffPos:"D4"}).addAnnotation(0,"f").addNote(0,"D4",24).addNote(0,"E4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"C#4",24).addNote(0,"B3",24).addNote(1,"E2",96,{dotted:!0}).endRow().addMeasure().addNote(0,"C#4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"E4",48).addNote(1,"A2",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"p").addNote(0,"E3",24).addNote(0,"D#3",24).addConnective(1,2,3).addNote(0,"E3",24).addNote(0,"F#3",24).addNote(0,"G#3",24).addNote(1,"E2",96,{dotted:!0}).addMeasure().addNote(0,"A3",24).addConnective(1,2,3).addNote(0,"G#3",24).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",48).addNote(1,"A2",96,{dotted:!0}).endRow().addMeasure().addRest(0,24,{staffPos:"G4"}).addAnnotation(0,"f").addNote(0,"G4",24).addNote(0,"A4",24).addConnective(1,2,3).addNote(0,"G4",24).addNote(0,"F#4",24).addNote(0,"E4",24).addNote(1,"A2",96,{dotted:!0}).addMeasure().addNote(0,"D4",24).addNote(0,"C#4",24).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",48).addNote(1,"D3",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"ff").addNote(0,"A3",24).addNote(0,"G#3",24).addConnective(1,2,3).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",24).addNote(1,"A2",96,{dotted:!0}).addMeasure().addNote(0,"D4",48).addRest(1,48,{staffPos:"D3"}).addNote(0,"D3",48).addNote(1,"D3",48).addRest(1,48,{staffPos:"B3"}).endSong().getDocument()}return wm(ab);})();
|
|
209
|
+
`;Ts(lm,_y);var Yr=class o extends L{constructor(){let t=w(o.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 EJ=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100];var GJ=[1687/25e3,1601/25e3,2053/25e3,2251/25e3];var Es=class o extends fe{constructor(){let t=w(o.getDefaults(),arguments,["decay"]);super(t),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();let e=this.toSeconds(t.decay);Dt(e,.001),this._decay=e;let r=this.toSeconds(t.preDelay);Dt(r,0),this._preDelay=r,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(fe.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){t=this.toSeconds(t),Dt(t,.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){t=this.toSeconds(t),Dt(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 ci({context:e}),i=new ci({context:e}),n=new Yr({context:e});r.connect(n,0,0),i.connect(n,0,1);let s=new Y({context:e}).toDestination();n.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(tt),yield t,this._convolver.buffer=(yield a).get(),this})}dispose(){return super.dispose(),this._convolver.disconnect(),this}};var lo=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["solo"]);super(t),this.name="Solo",this.input=this.output=new Y({context:this.context}),o._allSolos.has(this.context)||o._allSolos.set(this.context,new Set),o._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(),o._allSolos.get(this.context).forEach(e=>e._updateSolo())}get muted(){return this.input.gain.value===0}_addSolo(){o._soloed.has(this.context)||o._soloed.set(this.context,new Set),o._soloed.get(this.context).add(this)}_removeSolo(){o._soloed.has(this.context)&&o._soloed.get(this.context).delete(this)}_isSoloed(){return o._soloed.has(this.context)&&o._soloed.get(this.context).has(this)}_noSolos(){return!o._soloed.has(this.context)||o._soloed.has(this.context)&&o._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(),o._allSolos.get(this.context).delete(this),this._removeSolo(),this}};lo._allSolos=new Map;lo._soloed=new Map;var Ds=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["pan","volume"]);super(t),this.name="PanVol",this._panner=this.input=new $o({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,B(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 Kc=class o extends L{constructor(){let t=w(o.getDefaults(),arguments,["volume","pan"]);super(t),this.name="Channel",this._solo=this.input=new lo({solo:t.solo,context:this.context}),this._panVol=this.output=new Ds({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),B(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 o.buses.has(t)||o.buses.set(t,new Y({context:this.context})),o.buses.get(t)}send(t,e=0){let r=this._getBus(t),i=new Y({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}};Kc.buses=new Map;var Nrt=Bt().transport;var Ort=Bt().destination,Rrt=Bt().destination;var Mrt=Bt().listener;var Ert=Bt().draw;var Drt=Bt();var $c=class{constructor(){m(this,"audioSource");try{let t=new Es({decay:3,wet:.4}).toDestination(),e=new Cr(800,"lowpass").connect(t);this.audioSource=new Ns(cr,{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=_.Math.linearToDecibels(r)),this.audioSource.triggerAttackRelease(t,e!=null?e:"2n"))}catch(i){}}stop(){try{this.audioSource&&this.audioSource.releaseAll()}catch(t){}}},tu=new $c;Xr();function Ry(o){return typeof o=="string"?o:(typeof o=="number"&&(o=V.getChromaticNote(o)),o.format(0,0))}var ks=[tu],ho=tu;function My(){return ks.map(o=>o.getName())}function Ey(){return ho.getName()}function Dy(o){ks.some(t=>t.getName()===o.getName())||(ks.push(o),pm(o.getName()))}function pm(o){if(o===ho.getName())return;ho.stop();let t=ks.find(e=>e.getName()===o);t&&(ho=t)}function js(o,t,e){ho.playNote(Ry(o),t,e)}function eu(){ho.stop()}var fu={};_i(fu,{Annotation:()=>hi,Arpeggio:()=>Hr,Clef:()=>vr,Connective:()=>Ir,DivRect:()=>F,DocumentBuilder:()=>Nr,Fermata:()=>rn,Label:()=>po,MAccidental:()=>nn,MArpeggio:()=>cn,MBarLineLeft:()=>Cn,MBarLineRight:()=>An,MBeamGroup:()=>pn,MConnective:()=>wn,MDocument:()=>Zr,MEnding:()=>vn,MExtensionLine:()=>Sn,MFermata:()=>In,MHeader:()=>En,MImage:()=>on,MMeasure:()=>Nn,MNoteGroup:()=>mn,MPlaybackButtons:()=>du,MPlayer:()=>Ln,MRenderer:()=>pu,MRest:()=>un,MRhythmColumn:()=>xn,MScoreRow:()=>Mn,MSignature:()=>an,MSpecialText:()=>yn,MStaff:()=>On,MStaffBeamGroup:()=>dn,MStaffNoteGroup:()=>fn,MStaffRest:()=>ln,MStaffTabBarLine:()=>_n,MTab:()=>Rn,MTabNoteGroup:()=>gn,MText:()=>sn,MusicInterface:()=>bt,Navigation:()=>Ie,NoteAnchor:()=>ve,PlayState:()=>Ls,ScoreEvent:()=>Dn,ScoreObjectEvent:()=>di,ScoreStaffPosEvent:()=>pi,StaffPreset:()=>_r,Stem:()=>Le,TieType:()=>ur,VerticalPosition:()=>en,getStringNumbers:()=>ru,getVoiceIds:()=>oe});var F=class o{constructor(...t){m(this,"left");m(this,"centerX");m(this,"right");m(this,"top");m(this,"centerY");m(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 M(1,`Invalid DivRect args: ${t}`)}static create(t,e,r,i){return new o(t,t+r,e,e+i)}static createCentered(t,e,r,i){return new o(t-r/2,t+r/2,e-i/2,e+i/2)}static createSections(t,e,r,i){return new o(-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 o(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=_.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=_.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 _r=(s=>(s[s.Treble=1]="Treble",s[s.Bass=2]="Bass",s[s.Grand=3]="Grand",s[s.GuitarTreble=4]="GuitarTreble",s[s.GuitarTab=8]="GuitarTab",s[s.GuitarCombined=12]="GuitarCombined",s))(_r||{}),vr=(e=>(e.G="G",e.F="F",e))(vr||{});function oe(){return[0,1,2,3]}function ru(){return[1,2,3,4,5,6]}var Le=(r=>(r[r.Auto=0]="Auto",r[r.Up=1]="Up",r[r.Down=2]="Down",r))(Le||{}),Hr=(e=>(e[e.Up=0]="Up",e[e.Down=1]="Down",e))(Hr||{}),ur=(e=>(e[e.Stub=-1]="Stub",e[e.ToMeasureEnd=-2]="ToMeasureEnd",e))(ur||{}),ve=(n=>(n[n.Auto=0]="Auto",n[n.Above=1]="Above",n[n.Center=2]="Center",n[n.Below=3]="Below",n[n.StemTip=4]="StemTip",n))(ve||{}),Ir=(r=>(r[r.Tie=0]="Tie",r[r.Slur=1]="Slur",r[r.Slide=2]="Slide",r))(Ir||{}),en=(i=>(i[i.Above=0]="Above",i[i.Below=1]="Below",i[i.Both=2]="Both",i[i.Auto=3]="Auto",i))(en||{}),Ls=(r=>(r[r.Playing=0]="Playing",r[r.Paused=1]="Paused",r[r.Stopped=2]="Stopped",r))(Ls||{}),rn=(e=>(e[e.AtNote=0]="AtNote",e[e.AtMeasureEnd=1]="AtMeasureEnd",e))(rn||{}),Ie=(h=>(h[h.DC_al_Fine=0]="DC_al_Fine",h[h.DC_al_Coda=1]="DC_al_Coda",h[h.DS_al_Fine=2]="DS_al_Fine",h[h.DS_al_Coda=3]="DS_al_Coda",h[h.Coda=4]="Coda",h[h.toCoda=5]="toCoda",h[h.Segno=6]="Segno",h[h.Fine=7]="Fine",h[h.StartRepeat=8]="StartRepeat",h[h.EndRepeat=9]="EndRepeat",h[h.Ending=10]="Ending",h))(Ie||{}),hi=(e=>(e[e.Dynamics=0]="Dynamics",e[e.Tempo=1]="Tempo",e))(hi||{}),po=(e=>(e[e.Note=0]="Note",e[e.Chord=1]="Chord",e))(po||{});var Ps=class{constructor(t){m(this,"head");m(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;m(this,"anchoredLayoutObjects",[]);m(this,"link");m(this,"rect",new F);m(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 Fs={DrawDebugRects:!1,DisableBeams:!1},ct={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 dm="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 mm="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 ky="#55cc55",jy="#55cc55",Ly="#44aa44",iu=new Map([[0,{src:dm}],[1,{src:mm}]]);function Py(o,t){return!o&&!t?!0:!o||!t?!1:o.scoreRow===t.scoreRow&&o.diatonicId===t.diatonicId}function Fy(o,t){return!o&&!t?!0:!o||!t?!1:o.length===t.length&&o.every((e,r)=>e===t[r])}var Bs=class{constructor(t){this.mi=t;m(this,"devicePixelRatio");m(this,"fontSize");m(this,"unitSize");m(this,"lineWidth");m(this,"beamThickness");m(this,"scoreEventListener");m(this,"canvas");m(this,"ctx");m(this,"mdoc");m(this,"cursorRect");m(this,"mousePos");m(this,"curStaffPos");m(this,"curObjects");m(this,"hilightedStaffPos");m(this,"hilightedObj");m(this,"usingTouch",!1);m(this,"onClickFn");m(this,"onMouseMoveFn");m(this,"onMouseLeaveFn");m(this,"onTouchEndFn");this.devicePixelRatio=window.devicePixelRatio,this.fontSize=wo.FontSize*ct.DocumentScale*this.devicePixelRatio,this.unitSize=this.fontSize*.3,this.lineWidth=this.unitSize*.2,this.beamThickness=this.unitSize*.8,iu.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 M(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(iu).every(r=>r[1].finished===!0)&&this.onLoad()}getImageAsset(t){var e;return(e=iu.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 Eu(t.offsetX,t.offsetY)}updateCurStaffPos(t,e){let r=!Py(t,this.curStaffPos);if(r&&this.curStaffPos&&this.scoreEventListener){let{scoreRow:i,diatonicId:n}=this.curStaffPos;this.scoreEventListener(new pi("leave",this.getMusicInterface(),i.getMusicInterface(),n))}if(r&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:n}=t;this.scoreEventListener(new pi("enter",this.getMusicInterface(),i.getMusicInterface(),n))}if(e&&t&&this.scoreEventListener){let{scoreRow:i,diatonicId:n}=t;this.scoreEventListener(new pi("click",this.getMusicInterface(),i.getMusicInterface(),n))}return this.curStaffPos=t,r}updateCurObjects(t,e){let r=!Fy(t,this.curObjects);return r&&this.curObjects&&this.curObjects.length>0&&this.scoreEventListener&&this.scoreEventListener(new di("leave",this.getMusicInterface(),this.curObjects.map(i=>i.getMusicInterface()))),r&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new di("enter",this.getMusicInterface(),t.map(i=>i.getMusicInterface()))),e&&t&&t.length>0&&this.scoreEventListener&&this.scoreEventListener(new di("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),n=this.updateCurStaffPos(i,!0),s=this.updateCurObjects(r,!0);(n||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),n=this.updateCurStaffPos(i,!1),s=this.updateCurObjects(r,!1);(n||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,n=r.height+1;t.width=i,t.height=n,t.style.width=i/this.devicePixelRatio+"px",t.style.height=n/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:n,diatonicId:s}=r,a=n.getStaff(s);a&&(t.fillStyle=ky,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=jy,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,Ly,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 n=r.measureText(t);return r.font=i,n.width}else return _.Dom.getCanvasTextWidth(t,e)}drawDebugRect(t){if(!Fs.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 n=this.getCanvasContext();n&&(i!==void 0&&(n.fillStyle=i),n.beginPath(),n.arc(t,e,r,0,2*Math.PI),n.fill())}drawLine(t,e,r,i,n,s){let a=this.getCanvasContext();a&&(a.strokeStyle=n!=null?n:"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,n,s,a,c){let u=this.getCanvasContext();if(u){let l=t+(r-t)*n,h=e+(i-e)*n,p=t+(r-t)*s,d=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,d),u.stroke()}}drawLedgerLines(t,e,r){let{unitSize:i}=this,n=i*ct.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-n/2,a,r+n/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-n/2,a,r+n/2,a)}}}};var Gs=class{constructor(t){this.measure=t;m(this,"accidentalByDiatonicId",[])}getAccidentalFromKeySignature(t){let r=this.measure.getKeySignature().getOrderedAccidentalNotes().find(i=>i.diatonicClass===V.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 Vs=class extends it{constructor(e,r,i,n,s){super(e);this.image=r;this.anchorX=i;this.anchorY=n;this.imageScale=s;m(this,"mi");this.mi=new on(this)}getMusicInterface(){return this.mi}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){let{anchorX:r,anchorY:i,image:n,imageScale:s}=this,{unitSize:a}=e;try{let c=n.naturalWidth*s*a,u=n.naturalHeight*s*a;this.rect=F.createSections(c*r,c*(1-r),u*i,u*(1-i))}catch(c){this.rect=new F}}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(n){}}};var mi=class extends it{constructor(e,r,i,n="black"){super(e);this.diatonicId=r;this.accidental=i;this.color=n;m(this,"mi");this.mi=new nn(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=F.createSections(r*1.25,r*1.25,r*4,r*1.2);break;case-1:this.rect=F.createSections(r*.75,r*.75,r*4,r*1.2);break;case 0:this.rect=F.createSections(r*.75,r*.75,r*2.2,r*2.2);break;case 1:this.rect=F.createSections(r*.75,r*.75,r*2,r*2);break;case 2:this.rect=F.createSections(r*1,r*1,r*1,r*1);break;default:throw new M(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:n}=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=n,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=n,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=n*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=n,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=n*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=n,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 By=.5,lt=class extends it{constructor(e,r,i,n){var a,c,u,l,h,p;super(e);this.anchorX=i;this.anchorY=n;m(this,"text");m(this,"scale");m(this,"color");m(this,"bold");m(this,"italic");m(this,"boxed");m(this,"padding");m(this,"bgcolor");m(this,"font","");m(this,"textLines");m(this,"lineWidths",[]);m(this,"lineHeight",0);m(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?By: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 F,this.mi=new sn(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:n,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=F.createSections(l*i,l*(1-i),h*n,h*(1-n))}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:n,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,d=-s*(l?.25:.175),f=n*e.unitSize,g=(i.left+f)*(1-c)+(i.right-f)*c,x=(i.top+f)*(1-u)+(i.bottom-f)*u;switch(this.textLines.forEach((b,I)=>{let S=g-a[I]*c,T=x-p*u+s*(I+1)+d;r.fillText(b,S,T)}),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,T=(i.bottom-i.top)/2;r.beginPath(),r.ellipse(b,I,S,T,0,0,2*Math.PI),r.stroke();break}}};var qs=class extends it{constructor(e,r){super(e);this.measure=e;this.staff=r;m(this,"clefImage");m(this,"eightBelowClef");m(this,"measureNumber");m(this,"ksNeutralizeAccidentals",[]);m(this,"ksNewAccidentals",[]);m(this,"beatCountText");m(this,"beatSizeText");m(this,"tempoText");m(this,"mi");this.mi=new an(this)}getMusicInterface(){return this.mi}updateClefImage(e,r){if(r){let i=e.getImageAsset(this.staff.clefImageAsset);this.clefImage=i?new Vs(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(),n=i?i.getKeySignature():void 0,s=r.getKeySignature();this.ksNeutralizeAccidentals=[],this.ksNewAccidentals=[],n&&!Fe.equals(s,n)&&n.getOrderedAccidentalNotes().forEach(a=>{this.ksNeutralizeAccidentals.push(new mi(this,this.getAccidentalDiatonicId(a),0))}),s.getOrderedAccidentalNotes().forEach(a=>{this.ksNewAccidentals.push(new mi(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 n=r.beatSize.toString();this.beatSizeText=new lt(this,{text:n,scale:1.4},0,.5)}else this.beatCountText=this.beatSizeText=void 0}updateTempo(e){if(e){let r=Za(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 V.findNextDiatonicIdAbove(e.diatonicId,i,!1);throw new M(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 n=this.ksNeutralizeAccidentals[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.ksNewAccidentals.length;i++){let n=this.ksNewAccidentals[i].pick(e,r);if(n.length>0)return[this,...n]}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,n=r,s=0;if(this.rect=new F,this.clefImage&&(s+=n,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+=n,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+=n,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+n,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+n,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+=n}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 Ws=class extends it{constructor(e,r,i){super(e);this.col=e;this.line=r;this.arpeggioDir=i;m(this,"topArrowHeight",0);m(this,"bottomArrowHeight",0);m(this,"cycleHeight",0);m(this,"numCycles",0);m(this,"color","black");m(this,"mi");this.mi=new cn(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===0?r:0,this.bottomArrowHeight=this.arpeggioDir===1?r:0;let i=this.line.getTopLineY(),n=this.line.getBottomLineY();this.cycleHeight=r*2,this.numCycles=Math.ceil((n-i)/this.cycleHeight)+2;let s=r*2,a=this.numCycles*this.cycleHeight;this.rect=new F(-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:n,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=n.top+s;c<this.numCycles;c++,u+=this.cycleHeight)r.moveTo(n.centerX,u),r.quadraticCurveTo(n.left,u+this.cycleHeight/4,n.centerX,u+this.cycleHeight/2),r.quadraticCurveTo(n.right,u+this.cycleHeight*3/4,n.centerX,u+this.cycleHeight);r.stroke(),s>0&&(r.beginPath(),r.moveTo(n.centerX,n.top),r.lineTo(n.right,n.top+s),r.lineTo(n.left,n.top+s),r.fill()),a>0&&(r.beginPath(),r.moveTo(n.centerX,n.bottom),r.lineTo(n.left,n.bottom-a),r.lineTo(n.right,n.bottom-a),r.fill())}};function Gy(o){return typeof o=="number"?V.getChromaticNote(o).diatonicId:typeof o=="string"?V.getNote(o).diatonicId:o instanceof V?o.diatonicId:void 0}var Us=class extends it{constructor(e,r){super(e);this.staff=e;this.rest=r;m(this,"restRect",new F);m(this,"dotRect");m(this,"mi");e.addObject(this),this.mi=new ln(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.restRect.offsetInPlace(e,r),(i=this.dotRect)==null||i.offsetInPlace(e,r),this.requestRectUpdate(),this.rest.requestRectUpdate()}updateRect(){this.rect=this.restRect.copy(),this.dotRect&&this.rect.expandInPlace(this.dotRect)}},Sr=class extends it{constructor(e,r,i,n){var c,u;super(e);this.col=e;this.voiceId=r;m(this,"ownStemDir");m(this,"ownDiatonicId");m(this,"color");m(this,"hide");m(this,"rhythmProps");m(this,"beamGroup");m(this,"staffObjects",[]);m(this,"mi");let s=Gy(n==null?void 0:n.staffPos);if(s!==void 0){let l=this.row.hasStaff,h=this.row.getStaff(s);if(l&&!h)throw new M(6,"Rest staffPos is out of staff boundaries!")}this.ownDiatonicId=this.measure.updateOwnDiatonicId(r,s),this.ownStemDir=this.measure.updateOwnStemDir(this);let a=this.row.getStaff(this.ownDiatonicId);a&&a.isSpace(this.ownDiatonicId)&&(this.ownDiatonicId+=this.ownDiatonicId>=a.middleLineDiatonicId?1:-1),this.color=(c=n==null?void 0:n.color)!=null?c:"black",this.hide=(u=n==null?void 0:n.hide)!=null?u:!1,this.rhythmProps=new $t(i,n==null?void 0:n.dotted,n==null?void 0:n.triplet),this.mi=new un(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 dotted(){return this.rhythmProps.dotted}get stemDir(){return this.beamGroup?this.beamGroup.stemDir:this.ownStemDir}get triplet(){return this.rhythmProps.triplet}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 n=this.staffObjects[i].pick(e,r);if(n.length>0)return[this,...n]}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,n=this.stemDir===1?e.getRect().top:e.getRect().bottom,s=Math.abs(e.getRect().centerY-n);return{staff:r,x:i,y:n,stemHeight:s}})}isEmpty(){return this.staffObjects.length===0}visibleInStaff(e){return e.containsVoiceId(this.voiceId)&&this.staffObjects.some(r=>r instanceof Us&&r.staff===e)}getRestDotVerticalDisplacement(e){switch(e){case 192:return 1;case 96:return-1;case 48:return-1;case 24:return-1;case 12:return-1;case 6:return-3;case 3:return-3;default:throw new M(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:n}=this,{noteLength:s,dotted:a,flagCount:c}=this.rhythmProps,u=0,l=0,h=0,p=0;if(s===192)u=i,l=i,h=0,p=i;else if(s===96)u=i,l=i,h=i,p=0;else if(s===48)u=i*1,l=i*1,h=i*3.2,p=i*3;else{let d=1-c%2;u=i*(1+c*.25),l=i*(1+c*.125),h=i*(.5+c-d),p=i*(1+c+d)}this.row.getStaves().forEach(d=>{if(!d.containsDiatonicId(n)||!d.containsVoiceId(this.voiceId))return;let f=new Us(d,this);if(f.restRect=new F(-u,0,l,-h,0,p),a){let g=ct.DotSize*i,x=l+(ct.RestDotSpace+ct.DotSize/2)*i,b=this.getRestDotVerticalDisplacement(s)*i;f.dotRect=F.createCentered(x,b,g,g)}f.offset(0,d.getDiatonicIdY(n)),this.staffObjects.push(f)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;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:n}=e,{color:s}=this,{noteLength:a,flagCount:c}=this.rhythmProps;r.strokeStyle=r.fillStyle=s,r.lineWidth=n,this.staffObjects.forEach(u=>{let{dotRect:l,restRect:h}=u,p=h.centerX,d=h.centerY;if(a===192)r.fillRect(p-i,d,i*2,i);else if(a===96)r.fillRect(p-i,d-i,i*2,i);else if(a===48)r.beginPath(),r.moveTo(p-i*.6,d-i*3.2),r.lineTo(p+i*.7,d-i*1.5),r.quadraticCurveTo(p-i*.8,d-i*.5,p+i*1,d+i*1.5),r.lineTo(p-i*1,d-i*.75),r.quadraticCurveTo(p+i*.2,d-i*1.5,p-i*.6,d-i*3.2),r.moveTo(p+i*1,d+i*1.5),r.quadraticCurveTo(p-i*.8,d+i*1,p-i*.2,d+i*2.8),r.bezierCurveTo(p-i*1.8,d+i*1.5,p-i*.6,d-i*.2,p+i*.9,d+i*1.5),r.fill(),r.stroke();else if(c>0){let f=1-c%2,g=b=>p+(-b*.25+.5)*i,x=b=>d+(b+f)*i;r.beginPath(),r.moveTo(g(1+c),x(1+c)),r.lineTo(g(-.5-c),x(-.5-c)),r.stroke();for(let b=0;b<c;b++){let I=c-b*2;r.beginPath(),r.moveTo(g(I-2.5),x(I-2.5)),r.quadraticCurveTo(g(I-.5)+i*.25,x(I-1.5),g(I-1.5)-i*1.5,x(I-1.5)),r.stroke(),r.beginPath(),r.arc(g(I-2)-i*1.5,x(I-2),i*.5,0,Math.PI*2),r.fill()}}l&&e.fillCircle(l.centerX,l.centerY,l.width/2)})}};var Vy=(o,t)=>{let e=ct.BeamAngleFactor;if(!Number.isFinite(e)||e===0)return t;{let r=o/t/e;return r=Math.sign(r)*Math.sqrt(Math.abs(r)),o/r*e}},hn=class{constructor(t,e,r,i,n){this.staff=t;this.beamGroup=e;this.symbol=r;this.x=i;this.y=n;m(this,"topBeamsHeight",0);m(this,"bottomBeamsHeight",0);t.addObject(this)}offset(t,e){this.x+=t,this.y+=e,this.beamGroup.requestRectUpdate()}getRect(){return new F(this.x,this.x,this.x,this.y-this.topBeamsHeight,this.y,this.y+this.bottomBeamsHeight)}},ou=class extends it{constructor(e,r){super(e);this.staff=e;this.beamGroup=r;m(this,"tripletNumber");m(this,"tripletNumberOffsetY",0);m(this,"points",[]);m(this,"mi");e.addObject(this),this.mi=new dn(this)}getMusicInterface(){return this.mi}pick(e,r){return this.getRect().contains(e,r)?[this]:[]}offset(e,r){var i;this.points.forEach(n=>n.offset(e,0)),(i=this.tripletNumber)==null||i.offset(e,r),this.requestRectUpdate(),this.beamGroup.requestRectUpdate()}updateRect(){this.points.length>0?this.rect=this.points[0].getRect().copy():this.tripletNumber&&(this.rect=this.tripletNumber.getRect().copy()),this.points.forEach(e=>this.rect.expandInPlace(e.getRect())),this.tripletNumber&&this.rect.expandInPlace(this.tripletNumber.getRect())}},fi=class o extends it{constructor(e,r){super(e[0].measure);this.symbols=e;m(this,"mi");m(this,"type");m(this,"staffObjects",[]);if(this.mi=new pn(this),e.every(i=>i.measure===e[0].measure)){if(e.length<2)throw new M(6,"Beam group need minimum 2 symbols, but "+e.length+" given.")}else throw new M(6,"All beam group symbols are not in same measure.");if(r){if(!e.every(n=>n.triplet))throw new M(6,"Not every symbol's triplet property is true.");let i=e.length<3||e.some(n=>!(n instanceof vt))||e.some(n=>n.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&&(i=!1),e.some(n=>n.rhythmProps.noteLength>=48)&&(i=!0),this.type=i?2:1,vt.setTripletBeamCounts(this)}else this.type=0;if(e.every(i=>i.getBeamGroup()===void 0))e.forEach(i=>i.setBeamGroup(this)),e[0].measure.addBeamGroup(this);else throw new M(6,"Cannot add beam group because some symbol already has one.")}static createBeam(e){e.length>1&&new o(e,!1)}static createTriplet(e){let r=96,i=e.map(n=>n.rhythmProps.noteLength);if(e.length==2){if(i[0]<=r&&i[1]===i[0]/2&&i[0]/2>=Si||i[1]<=r&&i[0]===i[1]/2&&i[1]/2>=Si)return new o(e,!0),!0}else if(e.length===3&&i[0]<=r&&i.every(n=>n===i[0]))return new o(e,!0),!0;return!1}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 n=this.staffObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}getType(){return this.type}isTriplet(){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:n}=e,{stemDir:s}=this,a=r.map(c=>c.getBeamCoords());a[0].map(c=>c==null?void 0:c.staff).forEach((c,u)=>{var W,k;if(!c)return;let l=a.map(P=>{var j;return(j=P[u])==null?void 0:j.x}),h=a.map(P=>{var j;return(j=P[u])==null?void 0:j.y}),p=a.map(P=>{var j;return(j=P[u])==null?void 0:j.staff}),d=a.map(P=>{var j;return(j=P[u])==null?void 0:j.stemHeight}),f=r[0],g=l[0],x=h[0],b=p[0],I=r[r.length-1],S=l[l.length-1],T=h[h.length-1],v=p[h.length-1];if(g===void 0||x===void 0||b===void 0||S===void 0||T===void 0||v===void 0)return;let C=(W=d[0])!=null?W:0,A=(k=d[d.length-1])!=null?k:0;if(this.type!==2){let P=C<A?Math.sqrt(A-C):0,j=A<C?Math.sqrt(C-A):0;s===1&&(P*=-1,j*=-1),P!==0&&(x+=P,h[0]+=P),j!==0&&(T+=j,h[h.length-1]+=j)}let y=n*2*(s===1?-1:1),N=(T+x)/2,D=Vy(S-g,T-x)/2;x=N-D,T=N+D;let E=0;h.forEach((P,j)=>{let q=l[j];if(q!==void 0&&P!==void 0){let H=_.Math.interpolateY(g,x,S,T,q),Q=P-H;s===1&&Q<0?E=Math.min(E,Q):s===2&&Q>0&&(E=Math.max(E,Q))}}),x+=E,T+=E,h=h.map(P=>P===void 0?void 0:P+E);let O=new ou(c,this);if(this.type===2){let P=n/(S-g),j=_.Math.interpolateCoord(g,x+y,S,T+y,-P),q=_.Math.interpolateCoord(g,x+y,S,T+y,1+P);O.points.push(new hn(b,this,f,j.x,j.y)),O.points.push(new hn(v,this,I,q.x,q.y)),O.tripletNumberOffsetY=0}else if(this.type===0||this.type===1){E*=.5;let{beamThickness:P}=e,j=q=>{let H=r[q];if(H instanceof vt){let Q=H instanceof vt?Math.max(H.getLeftBeamCount(),H.getRightBeamCount()):0;return ct.BeamSeparation*n*(this.stemDir===1?Q-1:0)}else return 0};r.forEach((q,H)=>{let Q=p[H],et=l[H],at=h[H];if(Q&&et!==void 0&&at!==void 0){let yt=new hn(Q,this,q,et,at);yt.topBeamsHeight=P/2+(s===2?j(H):0),yt.bottomBeamsHeight=P/2+(s===1?j(H):0),O.points.push(yt)}}),O.tripletNumberOffsetY=y}this.isTriplet()&&(O.tripletNumber=new lt(this,"3",.5,.5),O.tripletNumber.layout(e),O.tripletNumber.offset((g+S)/2,(x+T)/2+O.tripletNumberOffsetY)),O.points.length>=2&&this.staffObjects.push(O)})}updateRect(){if(this.staffObjects.length===0)this.rect=new F;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(n=>{n.symbol instanceof vt&&(n!==r&&n!==i&&(n.y=_.Math.interpolateY(r.x,r.y,i.x,i.y,n.x)),n.symbol.setStemTipY(n.staff,n.y))}),e.tripletNumber){let n=(r.y+i.y)/2+e.tripletNumberOffsetY;e.tripletNumber.offset(0,-e.tripletNumber.getRect().centerY+n)}})}offset(e,r){this.staffObjects.forEach(i=>i.offset(e,0)),this.requestRectUpdate()}draw(e){let{unitSize:r,beamThickness:i,lineWidth:n}=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.tripletNumber?a.tripletNumber.getRect().width/(u.x-c.x)*1.2:0,h=_.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5-l/2),p=_.Math.interpolateCoord(c.x,c.y,u.x,u.y,.5+l/2),d=this.stemDir===1?r:-r;e.drawLine(c.x,c.y,h.x,h.y,s,n),e.drawLine(p.x,p.y,u.x,u.y,s,n),e.drawLine(c.x,c.y,c.x,c.y+d,s,n),e.drawLine(u.x,u.y,u.x,u.y+d,s,n)}}else if(this.type===0||this.type===1){let c=ct.BeamSeparation*r*(this.stemDir===1?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 d=h.symbol.getRightBeamCount(),f=p.symbol.getLeftBeamCount(),g=h.x,x=h.y,b=p.x,I=p.y;for(let S=0;S<Math.max(d,f);S++)S<d&&S<f?e.drawLine(g,x,b,I,s,i):d>f?e.drawPartialLine(g,x,b,I,0,.25,s,i):f>d&&e.drawPartialLine(g,x,b,I,.75,1,s,i),x+=c,I+=c}}a.tripletNumber&&a.tripletNumber.draw(e)})}};function Wy(o,t){let e=_.Arr.isArray(t)?t:t!==void 0?[t]:[],r=o.map((i,n)=>({note:i,string:e[n]}));return r=_.Arr.removeDuplicatesCmp(r,(i,n)=>V.equals(i.note,n.note)).sort((i,n)=>V.compareFunc(i.note,n.note)),{notes:r.map(i=>i.note),strings:r.every(i=>i.string===void 0)?void 0:r.map(i=>i.string)}}function Uy(o){return o===!0||o===0?0:o===1?1:void 0}var zs=class extends it{constructor(e,r){super(e);this.staff=e;this.noteGroup=r;m(this,"noteHeadRects",[]);m(this,"dotRects",[]);m(this,"accidentals",[]);m(this,"stemTip");m(this,"stemBase");m(this,"flagRects",[]);m(this,"prevTopNoteY",0);m(this,"prevBottomNoteY",0);m(this,"mi");this.mi=new fn(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 n=this.accidentals[i].pick(e,r);if(n.length>0)return[this,...n]}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,n;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),(n=this.stemBase)==null||n.offsetInPlace(e,r),this.flagRects.forEach(s=>s.offsetInPlace(e,r)),this.requestRectUpdate(),this.noteGroup.requestRectUpdate()}},nu=class extends it{constructor(e,r){super(e);this.tab=e;this.noteGroup=r;m(this,"fretNumbers",[]);m(this,"mi");e.addObject(this),this.mi=new gn(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 o extends it{constructor(e,r,i,n,s){var c,u,l;super(e);this.col=e;this.voiceId=r;this.notes=i;m(this,"minDiatonicId");m(this,"maxDiatonicId");m(this,"ownDiatonicId");m(this,"ownStemDir");m(this,"ownString");m(this,"color");m(this,"staccato");m(this,"diamond");m(this,"arpeggio");m(this,"rhythmProps");m(this,"startConnnectives",[]);m(this,"runningConnectives",[]);m(this,"leftBeamCount",0);m(this,"rightBeamCount",0);m(this,"beamGroup");m(this,"staffObjects",[]);m(this,"tabObjects",[]);m(this,"mi");if(!_.Is.isIntegerGte(i.length,1))throw new M(6,"Cannot create note group object because notes array is empty.");let a=Wy(i,s==null?void 0:s.string);this.notes=a.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,s==null?void 0:s.stem),this.ownString=this.measure.updateOwnString(this,a.strings),this.color=(c=s==null?void 0:s.color)!=null?c:"black",this.staccato=(u=s==null?void 0:s.staccato)!=null?u:!1,this.diamond=(l=s==null?void 0:s.diamond)!=null?l:!1,this.arpeggio=Uy(s==null?void 0:s.arpeggio),this.rhythmProps=new $t(n,s==null?void 0:s.dotted,s==null?void 0:s.triplet),this.mi=new mn(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}get triplet(){return this.rhythmProps.triplet}enableConnective(e){return e.containsVoiceId(this.voiceId)&&(e instanceof Pe||e.containsDiatonicId(this.ownDiatonicId))}startConnective(e){if(!this.row.hasStaff&&e.connective===0)throw new M(6,"Ties not implemented for guitar tabs alone, staff is required!");if(!this.row.hasStaff&&e.connective===1)throw new M(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 n=this.staffObjects[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.tabObjects.length;i++){let n=this.tabObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[]}getTopNote(){return this.notes[this.notes.length-1]}getBottomNote(){return this.notes[0]}getConnectiveAnchorPoint(e,r,i,n,s){if(r instanceof Tt){let a=r;if(i<0||i>=this.notes.length)throw new M(6,"Invalid noteIndex: "+i);let c=this.staffObjects.find(v=>v.staff===a);if(!c||i<0||i>=c.noteHeadRects.length){let v=this.getRect();return{x:v.centerX,y:v.bottom}}let u=c.noteHeadRects[i],l=c.stemTip,h=this.stemDir,p=l!==void 0,d=p?h===1?"right":"left":void 0,f=u.height/2,g=u.centerX,x=u.centerY,b=u.left-f,I=u.right+f,S=u.top-f,T=u.bottom+f;switch(n===0?n=3:n===4&&!p&&(n=h===1?1:3),n){case 2:return s==="left"?{x:I,y:x}:{x:b,y:x};case 1:return!p||h===2?{x:g,y:S}:{x:s==="left"&&d==="right"?I:s==="right"&&d==="left"?b:g,y:S};case 3:return!p||h===1?{x:g,y:T}:{x:s==="left"&&d==="right"?I:s==="right"&&d==="left"?b:g,y:T};case 4:return{x:g,y:l.centerY+(h===1?-f:f)};default:throw new M(6,"Invalid noteAnchor: "+n)}}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,d=.9;if(e.connective===2){let f=e.noteGroups[0].getFretNumber(c,0),g=e.noteGroups[1].getFretNumber(c,0),x=f===void 0||g===void 0||f<=g;s==="left"?p=x?l.centerY+l.bottomh*d:l.centerY-l.toph*d:p=x?l.centerY-l.toph*d:l.centerY+l.bottomh*d}else p=l.centerY+l.bottomh*d;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(n=>n instanceof o),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 n=i.getVoiceSymbols(this.voiceId).filter(s=>s instanceof o);if(n.length>0)return n[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===1).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,n=(l=(u=e.stemTip)==null?void 0:u.centerY)!=null?l:this.stemDir===1?e.getRect().top:e.getRect().bottom,s=this.stemDir===1?Math.abs(e.noteHeadRects[0].centerY-n):Math.abs(e.noteHeadRects[e.noteHeadRects.length-1].centerY-n);return{staff:r,x:i,y:n,stemHeight:s}})}getStemHeight(e){let{unitSize:r}=e,{noteLength:i,flagCount:n}=this.rhythmProps;if(i>=192)return 0;{let s=this.hasBeamCount()?ct.BeamSeparation:ct.FlagSeparation;return(ct.StemHeight+Math.max(0,n-1)*s)*r}}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 zs&&r.staff===e)}getPlayTicks(e){let r=this.runningConnectives.filter(i=>i.connective===0).map(i=>{let n=i.noteGroups,s=n.indexOf(this);if(s<0)return 0;if(i.span===-1||i.span===-2)return Math.max(this.rhythmProps.ticks,this.measure.getMeasureTicks()-this.col.positionTicks);let a=n[s-1];return a&&a.notes.some(c=>V.equals(c,e))?0:(n=n.slice(s),s=n.findIndex(c=>c.notes.every(u=>!V.equals(u,e))),s>=0&&(n=n.slice(0,s)),_.Math.sum(n.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:n,stemDir:s}=this,{dotted:a,flagCount:c}=this.rhythmProps,u=ct.DotSize*i,l=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadWidth)*i,h=(this.diamond?ct.DiamondNoteHeadSize:ct.NoteHeadHeight)*i;this.staffObjects.length=0,n.getStaves().forEach(p=>{if(!p.containsDiatonicId(this.ownDiatonicId)||!p.containsVoiceId(this.voiceId))return;let d=new zs(p,this),f=p,g=p;this.notes.forEach((C,A)=>{var P;let y=A===0,N=A===this.notes.length-1,D=(P=p.getActualStaff(C.diatonicId))!=null?P:p,E=this.col.getNoteHeadDisplacement(this,C)*l,O=D.getDiatonicIdY(C.diatonicId),W=D.isLine(C.diatonicId);y&&s===1&&(f=D),N&&s===1&&(g=D),y&&s===2&&(g=D),N&&s===2&&(f=D);let k=d.noteHeadRects[A]=F.createCentered(E,O,l,h);if(D.addObject(k),r.needAccidental(C)){let j=d.accidentals[A]=new mi(this,C.diatonicId,C.accidental,this.color);j&&(j.layout(e),j.offset(-k.leftw-i*ct.NoteAccSpace-j.getRect().rightw,O)),D.addObject(j)}if(a){let j=k.right+ct.NoteDotSpace*i+u/2,q=O+this.getDotVerticalDisplacement(p,C.diatonicId,s)*i,H=F.createCentered(j,q,u,u);d.dotRects.push(H),D.addObject(H)}if(this.staccato){if(s===1&&y){let j=E,q=O+i*(W?3:2),H=F.createCentered(j,q,u,u);d.dotRects.push(H),f.addObject(H)}else if(s===2&&N){let j=E,q=O-i*(W?3:2),H=F.createCentered(j,q,u,u);d.dotRects.push(H),f.addObject(H)}}});let x=d.noteHeadRects[0].centerY,b=d.noteHeadRects[d.noteHeadRects.length-1].centerY,I=s===1?l/2:-l/2,S=this.getStemHeight(e),T=s===1?b-S:x+S,v=s===1?x:b;if(this.rhythmProps.hasStem()&&(d.stemTip=new F(I,I,T,T),d.stemBase=new F(I,I,v,v),g.addObject(d.stemTip),f.addObject(d.stemBase)),!this.hasBeamCount()){let C=c===0?0:ct.FlagWidth*i,A=c===0?0:ct.FlagHeight*i;for(let y=0;y<c;y++){let N=y*i*ct.FlagSeparation,D=d.flagRects[y]=s===1?new F(I,I+C,T+N,T+A+N):new F(I,I+C,T-A-N,T-N);g.addObject(D)}}this.staffObjects.push(d)}),this.tabObjects.length=0,n.getTabs().forEach(p=>{if(!p.containsVoiceId(this.voiceId))return;let d=new nu(p,this);this.notes.forEach((f,g)=>{var x,b;if(this.ownString[g]!==void 0){let I=this.ownString[g]-1,S=f.chromaticId-p.getTuningStrings()[I].chromaticId,T=S<0?"red":"black",v=new lt(this,{text:String(S),color:T,bgcolor:"white"},.5,.5);d.fretNumbers.push(v),v.layout(e);let C=this.col.getNoteHeadDisplacement(this,f)*l,A=(b=(x=this.staffObjects[0])==null?void 0:x.stemBase)==null?void 0:b.centerX,y=A!=null?A:C,N=p.getStringY(I);v.offset(y,N)}}),d.fretNumbers.length>0&&this.tabObjects.push(d)})}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 F;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(n=>n.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:n,stemDir:s}=this,{noteLength:a}=this.rhythmProps;this.staffObjects.forEach(c=>{c.accidentals.forEach(u=>u.draw(e)),r.strokeStyle=r.fillStyle=n,r.lineWidth=i,c.noteHeadRects.forEach(u=>{let l=a>=96;this.diamond?l?(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.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.ellipse(u.centerX,u.centerY,u.leftw,u.toph,-.3,0,Math.PI*2),l?r.stroke():r.fill())}),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,d=s===1?u.top:u.bottom,f=s===1?u.bottom:u.top;r.beginPath(),r.moveTo(l,d),r.bezierCurveTo(l,d*.75+f*.25,l+p*1.5,d*.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=(n,s)=>n.rhythmProps.noteLength===s.rhythmProps.noteLength*2&&n.rhythmProps.dotted&&!s.rhythmProps.dotted&&n.rhythmProps.flagCount>0&&s.rhythmProps.flagCount>0;for(let n=0;n<e.length;n++){let s=e[n],a=e[n-1],c=e[n+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 n=0;n<e.length;n++){let s=e[n],a=e[n-1],c=e[n+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 setTripletBeamCounts(e){let r=e.getType(),i=e.getSymbols();if(r===1)i.forEach((n,s)=>{n instanceof o&&(n.leftBeamCount=s===0?0:n.rhythmProps.flagCount,n.rightBeamCount=s===i.length-1?0:n.rhythmProps.flagCount)});else if(r===2)i.forEach(n=>{n instanceof o&&(n.leftBeamCount=n.rightBeamCount=0)});else throw new M(6,"Cannot set triplet beam count because triplet beam group type is invalid.")}getDotVerticalDisplacement(e,r,i){return e.isLine(r)?i===1?-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 n=e.notes[i],s=r.notes[i];if(n.diatonicId!==s.diatonicId||n.accidental!==s.accidental)return!1}return!0}};var zy=(o,t)=>{let e=V.compareFunc(o.note,t.note);return e===0&&(e=o.noteGroup.stemDir===t.noteGroup.stemDir?0:o.noteGroup.stemDir===1?1:-1),e},wr=class extends it{constructor(e,r){super(e);this.measure=e;this.positionTicks=r;m(this,"voiceSymbol",[]);m(this,"minDiatonicId");m(this,"maxDiatonicId");m(this,"staffMinDiatonicId",new Map);m(this,"staffMaxDiatonicId",new Map);m(this,"arpeggioDir");m(this,"arpeggios",[]);m(this,"noteHeadDisplacements",[]);m(this,"playerProps");m(this,"needLayout",!0);m(this,"shapeRects",[]);m(this,"mi");this.playerProps=new mo(this),this.mi=new xn(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 M(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(n=>r.push(n)))}),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 n=this.voiceSymbol[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.arpeggios.length;i++){let n=this.arpeggios[i].pick(e,r);if(n.length>0)return[this,...n]}return[]}hasArpeggio(){return this.arpeggioDir!==void 0}getArpeggioDir(){var e;return(e=this.arpeggioDir)!=null?e:0}setVoiceSymbol(e,r){su(e),this.voiceSymbol[e]=r,r instanceof Sr?!r.hide&&r.noteLength>=96&&(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.noteLength)),r=ct.NoteHeadWidth;switch(e){case 192:return r*5;case 96:return r*3;case 48: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(zy),!(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],n=this.noteHeadDisplacements[e+1];if(i.displacement!==void 0)continue;let s=i.noteGroup.stemDir===2?-1:1;r&&i.note.diatonicId-r.note.diatonicId<=1?i.displacement=r.displacement===0?s:0:n&&n.note.diatonicId-i.note.diatonicId<=1&&(i.displacement=n.displacement===0?s:0)}}}getNoteHeadDisplacement(e,r){let i=this.noteHeadDisplacements.find(n=>n.noteGroup===e&&V.equals(n.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,n,s,a){if(n<=0)return;e.some(u=>i.diatonicId===u.note.diatonicId&&i.accidental===u.note.accidental?(u.ticks=Math.max(u.ticks,n),!0):!1)||e.push({note:i,ticks:n,staccato:s,slur:a})}return oe().forEach(i=>{let n=this.getVoiceSymbol(i);if(n instanceof vt){let s=n.getPlaySlur();n.notes.forEach(a=>{let c=n.getPlayTicks(a),u=n.staccato;r(a,c,u,s)})}}),e.sort((i,n)=>V.compareFunc(i.note,n.note)),this.hasArpeggio()&&this.getArpeggioDir()===1&&e.reverse(),e}requestLayout(){this.needLayout||(this.needLayout=!0,this.measure.requestLayout())}layout(e,r){if(!this.needLayout)return;this.requestRectUpdate(),this.rect=new F;let{row:i}=this,{unitSize:n}=e,s=this.getMinWidth()*n/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 Ws(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(d=>{d.visibleInStaff(l)&&(d instanceof vt?(h=h===void 0?d.minDiatonicId:Math.min(h,d.minDiatonicId),p=p===void 0?d.maxDiatonicId:Math.max(p,d.maxDiatonicId)):d instanceof Sr&&(h=h===void 0?d.ownDiatonicId:Math.min(h,d.ownDiatonicId),p=p===void 0?d.ownDiatonicId:Math.max(p,d.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),n=this.staffMaxDiatonicId.get(r);i!==void 0&&e.drawLedgerLines(r,i,this.getRect().centerX),n!==void 0&&e.drawLedgerLines(r,n,this.getRect().centerX)}),this.voiceSymbol.forEach(r=>{r&&r.draw(e)}),this.arpeggios.forEach(r=>r.draw(e))}};var lr=class lr extends it{constructor(e,r){super(e);this.text=r;m(this,"components",[]);m(this,"mi");switch(this.text){case lr.Coda:this.components=[new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3),new lt(this," Coda",0,1)];break;case lr.toCoda:this.components=[new lt(this,"toCoda ",1,1),new lt(this,{text:"\u{1D10C}",scale:1.7},.5,.3)];break;case lr.Segno:this.components=[new lt(this,{text:"\u{1D10B}",scale:1.1},.5,1)];break;default:this.components=[];break}this.mi=new yn(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 lr.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 F(r.getRect().left,r.getRect().centerX,i.getRect().right,i.getRect().top,i.getRect().centerY,i.getRect().bottom);break}case lr.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 F(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))}};m(lr,"toCoda","\u{1D10C} toCoda"),m(lr,"Coda","Coda \u{1D10C}"),m(lr,"Segno","\u{1D10B}");var Xe=lr;function bn(o){switch(o){case 1:return"D.C. al Coda";case 0:return"D.C. al Fine";case 3:return"D.S. al Coda";case 2:return"D.S. al Fine";case 7:return"Fine";case 6:return Xe.Segno;case 4:return Xe.Coda;case 5:return Xe.toCoda;default:return Ie[o]}}function au(o){return["ppp","pp","p","mp","m","mf","f","ff","fff","cresc.","decresc.","dim."].indexOf(o)>=0}function Ys(o){return["ppp","pp","p","mp","m","mf","f","ff","fff"].indexOf(o)>=0}function cu(o){return["accel.","rit.","a tempo"].indexOf(o)>=0}function Yy(o){switch(o){case"bottom":return .8;case"middle":return .5}}function Hy(o){return au(o)?2:cu(o)?1:0}var gi=class extends Ps{constructor(e,r,i,n,s,a){super(e);m(this,"length");m(this,"visible");m(this,"lineStyle");m(this,"linePos");m(this,"startColumn");m(this,"context");if(this.length=i,this.visible=n,this.lineStyle=s,this.linePos=a,this.startColumn=r,this.context=e instanceof lt?Hy(e.getText()):0,e instanceof lt)e.updateAnchorY(Yy(a));else throw new M(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 n=[9,10];for(let s=0;s<n.length;s++)if(i.hasNavigation(n[s]))return"section-break"}}if(r===1){let i=e.getAnchoredLayoutObjects();for(let n=0;n<i.length;n++){let s=i[n].getTextContent();if(s&&cu(s))return s}}else if(r===2){let i=e.getAnchoredLayoutObjects();for(let n=0;n<i.length;n++){let s=i[n].getTextContent();if(s&&au(s))return s}}}getExtensionRangeInfo(){let{startColumn:e,length:r,context:i}=this,n=[e];if(r<=0)return{startColumn:e,endColumn:e,columnRange:n,extensionBreakText:void 0};let s=r,a=e;for(;;){let c=a.getNextColumn();if(!c)return{startColumn:e,endColumn:a,columnRange:n,extensionBreakText:void 0};let u=this.getSpanBreakText(c,i);if(u!==void 0)return{startColumn:e,endColumn:a,columnRange:n,extensionBreakText:u};if(s-=a.getTicksToNextColumn(),s<=0)return{startColumn:e,endColumn:a,columnRange:n,extensionBreakText:void 0};a=c,n.push(a)}}};var Qy=2,Zy=2,Xy=.5,Jy=.5;function Ky(o,t){let e=new $t(t.options.beatLength,t.options.dotted).ticks,r=t.beatsPerMinute*e;return 60*o/r}function fo(o){switch(o){case"fff":return .9;case"ff":return .8;case"f":return .7;case"mf":return .6;default:case"m":return .5;case"mp":return .4;case"p":return .3;case"pp":return .2;case"ppp":return .1}}function uu(){return fo("m")}function $y(o){return o*1.25}var tb=.5,mo=class{constructor(t){this.col=t;m(this,"speed");m(this,"volume");this.speed=1,this.volume=uu()}get measure(){return this.col.measure}reset(){this.speed=1,this.volume=uu()}setSpeed(t){this.speed=t}getSpeed(){return this.speed}getTempo(){let t=_.Math.clamp(this.getSpeed(),.1,10);return Xa(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=oe().map(i=>t.getVoiceSymbol(i)).filter(i=>!!i).map(i=>i.rhythmProps.ticks);return r.length===0?0:_.Math.sum(r)/r.length}}},Hs=class o{constructor(){m(this,"playTimer");m(this,"playPos");m(this,"playState",2);m(this,"doc");m(this,"cursorPositionChangeListener");m(this,"playStateChnageListener");m(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,n=!1,s=!1;for(;e;){if(e.incPassCount(),e.getEnding()){let u=e.getPassCount();e=o.getMeasureByEndingPassage(e,u)}if(e)if(t.push(e),e.hasNavigation(8)&&(r=e),e.hasNavigation(6)&&(i=e),s&&e.hasNavigation(5))for(;e&&!e.hasNavigation(4);)e=e.getNextMeasure();else if(n&&e.hasNavigation(7))e=void 0;else if(e.hasNavigation(1))s=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation(0))n=!0,e=this.doc.getFirstMeasure();else if(e.hasNavigation(3))s=!0,e=i;else if(e.hasNavigation(2))n=!0,e=i;else if(e.hasNavigation(9)){let u=e.getPassCount(),l=e.getEndRepeatPlayCount()-1,h=((a=e.getNextMeasure())==null?void 0:a.hasNavigation(10))===!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=uu(),r=new Map,i=new Map,n=(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 f;let d=(f=p.getTextContent())!=null?f:"";if(d==="a tempo")t=1;else if(Ys(d))e=fo(d);else if(p.musicObj.getLink()instanceof gi){let g=p.musicObj.getLink(),{columnRange:x,extensionBreakText:b}=g.getExtensionRangeInfo(),I=_.Math.sum(x.map(S=>S.getTicksToNextColumn()));switch(d){case"accel.":{let S=t,T=S*Qy,v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),n(C,S+(T-S)*v/I)});break}case"rit.":{let S=t,T=S/Zy,v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),n(C,S+(T-S)*v/I)});break}case"cresc.":{let S=e,T=S+Xy;b&&Ys(b)&&fo(b)>S&&(T=fo(b));let v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(T-S)*v/I)});break}case"decresc.":case"dim.":{let S=e,T=S-Jy;b&&Ys(b)&&fo(b)<S&&(T=fo(b));let v=0;x.forEach(C=>{v+=C.getTicksToNextColumn(),s(C,S+(T-S)*v/I)});break}}}});let c=(l=r.get(a))!=null?l:[];c.length>0&&(t=_.Math.sum(c)/c.length);let u=(h=i.get(a))!=null?h:[];u.length>0&&(e=_.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 n=r==null?void 0:r.getNextMeasure();if(!r||r.hasEndSong()||r.hasEndSection()||!n||n.hasNavigation(8))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=Ky(s,a);return Math.max(0,c)},r=t.getPlayerProps().getTempo(),i=t.getPlayerProps().getFermataHoldTicks(),n;t instanceof Tr?n=e(i,r):(t.getPlayerNotes().forEach((a,c)=>{let u=t.hasArpeggio()?6*c:0,l=e(a.ticks+i-u,r);if(l>0){a.staccato&&(l=Math.min(e(24,r)/2,l/2));let h=$y(t.getPlayerProps().getVolume());if(a.slur==="slurred"&&(h*=tb),u>0){let p=e(u,r);window.setTimeout(()=>js(a.note,l,h),p*1e3)}else js(a.note,l,h)}}),n=e(t.getTicksToNextColumn()+i,r)),this.playTimer=window.setTimeout(()=>this.playStep(),n*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,n=e.row.getRect().bottom;return new F(r,r,i,n)}};var lu=class extends it{constructor(e,r){super(r);this.barLine=e;this.line=r;m(this,"lineRects",[]);m(this,"dotRects",[]);m(this,"mi");r.addObject(this),this.mi=new _n(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)}},Qs=class extends it{constructor(e){super(e);this.measure=e;m(this,"staffTabObjects",[]);m(this,"barLineType",0)}pick(e,r){if(!this.getRect().contains(e,r))return[];for(let i=0;i<this.staffTabObjects.length;i++){let n=this.staffTabObjects[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}layout(e){this.requestRectUpdate(),this.staffTabObjects.length=0,this.barLineType=this.solveBarLineType();let{unitSize:r,lineWidth:i}=e,{measure:n,barLineType:s}=this,{row:a}=n,c=i,u=.7*r,l=.7*r,h=ct.DotSize*r,p=h/2;a.getNotationLines().forEach(d=>{let f=new lu(this,d),g,x,b,I,S=(v,C)=>{f.lineRects.push(new F(v,v+C/2,v+C,b,0,I))},T=v=>{for(let C=-1;C<=1;C+=2){let A=g+C*x;f.dotRects.push(new F(v-p,v,v+p,A-p,A,A+p))}};switch(d instanceof Tt?(g=d.getMiddleLineY(),x=d.getDiatonicSpacing()):(g=(d.getBottomLineY()+d.getTopLineY())/2,x=(d.getBottomLineY()-d.getTopLineY())/6),b=d.getTopLineY(),I=d.getBottomLineY(),s){case 0:f.setRect(new F(0,0,0,b,0,I));break;case 1:f.setRect(new F(-c,0,0,b,0,I)),S(-c,c);break;case 2:f.setRect(new F(-c-l-c,0,0,b,0,I)),S(-c-l-c,c),S(-c,c);break;case 3:f.setRect(new F(-u-l-c,0,0,b,0,I)),S(-c-l-u,c),S(-u,u);break;case 4:f.setRect(new F(0,0,u+l+c+l+h,b,0,I)),S(0,u),S(u+l,c),T(u+l+c+l+p);break;case 5:f.setRect(new F(-u-l-c-l-h,0,0,b,0,I)),S(-c-l-u,c),S(-u,u),T(-c-l-u-l-p);break;case 6:f.setRect(new F(-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),T(-u/2-l-c-l-p),T(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 F}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(n=>r.fillRect(n.left,n.top,n.width,n.height)),i.dotRects.forEach(n=>e.fillCircle(n.centerX,n.centerY,n.width/2))}))}},Qr=class extends Qs{constructor(e){super(e);m(this,"mi");this.mi=new Cn(this)}getMusicInterface(){return this.mi}solveBarLineType(){let e=this.measure,r=e.getPrevMeasure();return e.hasNavigation(8)?r&&r.row===e.row&&r.hasNavigation(9)?0:4:0}},Tr=class extends Qs{constructor(e){super(e);m(this,"playerProps");m(this,"mi");this.playerProps=new mo(this),this.mi=new An(this)}getMusicInterface(){return this.mi}getPlayerProps(){return this.playerProps}solveBarLineType(){let e=this.measure,r=e.getNextMeasure();return e.hasNavigation(9)?r&&r.row===e.row&&r.hasNavigation(8)?6:5:!e.doc.hasSingleMeasure()&&(e.hasEndSong()||!e.getNextMeasure())?3:e.hasEndSection()||e===e.row.getLastMeasure()&&r&&r.row===e.row.getNextRow()&&r.hasNavigation(8)?2:r&&r.hasNavigation(8)?0:1}};var xi=class extends it{constructor(e,r){super(e);this.measure=e;this.passages=r;m(this,"endingText");m(this,"shapeRects",[]);m(this,"mi");if(this.mi=new vn(this),_.Is.isIntegerGte(r.length,1)){if(!this.passages.every(n=>_.Is.isIntegerGte(n,1)))throw new M(6,"Invalid passages: "+this.passages)}else throw new M(6,"Passages is empty.");this.passages.sort((n,s)=>n-s);let i=this.passages.map(n=>n+".").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(10))===!0||e.hasNavigation(9)||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 F,this.shapeRects=[this.rect.copy()]}layoutFitToMeasure(e){let{unitSize:r}=e,{measure:i}=this;this.endingText.layout(e);let n=this.endingText.getRect(),s=i.getColumnsContentRect(),a=n.height;this.rect=new F(s.left+r,s.right-r,-a,0),this.endingText.offset(this.rect.left+r/2,this.rect.bottom),this.shapeRects=[new F(this.rect.left,this.rect.left+1,this.rect.top,this.rect.bottom),new F(this.rect.left,this.rect.right,this.rect.top,this.rect.top+1),new F(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:n}=this;e.drawDebugRect(this.rect),r.strokeStyle=r.fillStyle="black",r.lineWidth=i,r.beginPath(),r.moveTo(n.left,n.bottom),r.lineTo(n.left,n.top),r.lineTo(n.right,n.top),this.isSingleMeasureEnding()&&r.lineTo(n.right,n.bottom),r.stroke(),this.endingText.draw(e)}};var go=class extends it{constructor(e,r){super(e);this.pos=r;m(this,"color","black");m(this,"mi");this.mi=new In(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,n=r*3;this.rect=new F(-i/2,i/2,-n,0)}offset(e,r){this.rect.offsetInPlace(e,r)}draw(e){let r=e.getCanvasContext();if(!r)return;let{lineWidth:i,unitSize:n}=e,s=this.pos===1,a=(s?n:-n)*.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 d=p/6;e.fillCircle((c+u)/2,h-d,Math.abs(d))}};var xo=class extends it{constructor(e,r,i,n,s){super(e);this.measure=e;this.line=r;this.extension=i;this.leftObj=n;this.rightObj=s;m(this,"mi");i.addTail(this),this.mi=new Sn(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(),n=this.getLineRight(),s=r;this.rect=new F(i,n,-s/2,s/2)}pick(e,r){return this.rect.contains(e,r)?[this]:[]}layout(e){this.rect=new F}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 n=this.extension.getTails();if(n.length>0&&this===n[n.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 yi=class extends it{constructor(e,r,i,n,s,...a){super(i);this.connectiveProps=e;this.line=r;this.measure=i;m(this,"lx",0);m(this,"ly",0);m(this,"rx",0);m(this,"ry",0);m(this,"cp1x",0);m(this,"cp1y",0);m(this,"cp2x",0);m(this,"cp2y",0);m(this,"arcHeight",0);m(this,"leftNoteGroup");m(this,"leftNoteId");m(this,"rightNoteGroup");m(this,"rightNoteId");m(this,"tieType");m(this,"mi");this.leftNoteGroup=n,this.leftNoteId=s,a[0]instanceof vt&&typeof a[1]=="number"?(this.rightNoteGroup=a[0],this.rightNoteId=a[1],this.tieType=void 0):_.Is.isEnumValue(a[0],ur)&&(this.rightNoteGroup=void 0,this.rightNoteId=void 0,this.tieType=a[0]),this.measure.addConnectiveObject(this),this.mi=new wn(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:n,leftNoteGroup:s,leftNoteId:a,rightNoteGroup:c,rightNoteId:u,connectiveProps:l}=this,{noteAnchor:h,arcDir:p}=l,{row:d}=i,f=d.getPrevRow(),g=d.getNextRow(),x=d.getConnectivesContentRect(),b,I;b=s.getConnectiveAnchorPoint(l,n,a,h,"left"),c!==void 0&&u!==void 0?I=c.getConnectiveAnchorPoint(l,n,u,h,"right"):I=this.tieType===-2?{x:i.getColumnsContentRect().right,y:b.y}:{x:b.x+r*ct.StubTieLength,y:b.y};let S,T,v,C;if(c===void 0)S=b.x,T=b.y,v=I.x,C=I.y;else if(s.row===d&&c.row===d)S=b.x,T=b.y,v=I.x,C=I.y;else if(s.row===f&&c.row===d){let O=f.getConnectivesContentRect().right-b.x,W=I.x-x.left;S=x.left,T=b.y+(I.y-b.y)*O/(O+W),v=I.x,C=I.y}else if(s.row===d&&c.row===g){let E=g.getConnectivesContentRect(),O=x.right-b.x,W=I.x-E.left;S=b.x,T=b.y,v=x.right,C=b.y+(I.y-b.y)*O/(O+W)}else throw new M(6,"Cannot layout connective object because no valid left and right note groups.");let y=(p==="up"?-1:1)*r*Math.log2(v-S)/3;this.lx=S,this.ly=T,this.rx=v,this.ry=C,this.arcHeight=this.connectiveProps.connective===2?0:y;let{nx:N,ny:D}=_.Math.calcNormal(S,T,v,C);this.cp1x=S*.7+v*.3+N*this.arcHeight,this.cp1y=T*.7+C*.3+D*this.arcHeight,this.cp2x=S*.3+v*.7+N*this.arcHeight,this.cp2y=T*.3+C*.7+D*this.arcHeight,this.rect=new F(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:n}=e;e.drawDebugRect(i);let s=n*1.5,a=n*.25;r.strokeStyle=r.fillStyle="black",r.lineWidth=n,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 yo=class{constructor(t,e,r,i){this.connective=t;this.span=e;this.noteAnchor=r;m(this,"noteGroups");m(this,"arcDir","down");this.noteGroups=[i]}getStartNoteGroup(){return this.noteGroups[0]}startsWith(t){return this.noteGroups[0]===t}addNoteGroup(t){return this.span===-1||this.span===-2?!1:this.span>this.noteGroups.length?(this.noteGroups.push(t),!0):!1}computeParams(){let t=this.noteGroups[0].stemDir,e=this.noteGroups[0].rhythmProps.hasStem;if(this.noteAnchor===4)this.arcDir=t===1?"up":"down";else if(this.noteAnchor===0)this.arcDir=t===1||!e?"down":"up",this.noteGroups[0].notes.length>1?this.noteAnchor=2:this.connective===2?this.noteAnchor=2:this.arcDir==="up"?this.noteAnchor=1:this.noteAnchor=3;else if(this.noteAnchor===2){let{row:r}=this.noteGroups[0].measure,i=this.noteGroups[0].ownDiatonicId,n=r.getStaff(i);this.arcDir=!n||i<n.middleLineDiatonicId?"down":"up"}else this.noteAnchor===1?this.arcDir="up":this.noteAnchor===3&&(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===0){if(e===-1||e===-2){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],n=this.noteGroups[r+1];i.notes.forEach((s,a)=>{let c=n.notes.findIndex(u=>V.equals(u,s));c>=0&&this.createObjConnective(i,a,n,c)})}}else if(t===1){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===2&&this.noteGroups.length>=2)for(let r=0;r<this.noteGroups.length-1;r++){let i=this.noteGroups[r],n=this.noteGroups[r+1];this.createObjConnective(i,0,n,0)}}createObjConnectiveWithTieType(t,e,r){t.row.getNotationLines().filter(i=>t.enableConnective(i)).forEach(i=>{i instanceof Tt?new yi(this,i,t.measure,t,e,r):t.getFretNumberString(e)!==void 0&&new yi(this,i,t.measure,t,e,r)})}createObjConnective(t,e,r,i){let n=(s,a,c,u,l)=>{s.row.getNotationLines().filter(h=>a.enableConnective(h)&&u.enableConnective(h)).forEach(h=>{if(h instanceof Tt)new yi(this,h,s,a,c,u,l);else{let p=a.getFretNumberString(c),d=u.getFretNumberString(l);p!==void 0&&d!==void 0&&(p===d||this.connective===1)&&new yi(this,h,s,a,c,u,l)}})};if(t.measure===r.measure)n(t.measure,t,e,r,i);else if(t.measure.getNextMeasure()===r.measure)n(t.measure,t,e,r,i),n(r.measure,t,e,r,i);else throw new M(6,"Cannot create connective because it is jumping measures.")}};function su(o){if(oe().indexOf(o)<0)throw new M(6,"Invalid voiceId: "+o);return o}var Tn=class Tn extends it{constructor(e){super(e);this.row=e;m(this,"prevMeasure");m(this,"nextMeasure");m(this,"keySignature",Vn());m(this,"timeSignature",Un());m(this,"tempo",zn());m(this,"alterKeySignature");m(this,"alterTimeSignature");m(this,"alterTempo");m(this,"signatures",[]);m(this,"tabStringNotes",[]);m(this,"barLineLeft");m(this,"columns",[]);m(this,"barLineRight");m(this,"connectives",[]);m(this,"beamGroups",[]);m(this,"tabStringNotesWidth",0);m(this,"measureId");m(this,"needLayout",!0);m(this,"leftSolidAreaWidth",0);m(this,"minColumnsAreaWidth",0);m(this,"rightSolidAreaWidth",0);m(this,"useDiatonicId",[]);m(this,"useStemDir",[]);m(this,"useString",[]);m(this,"voiceSymbols",[]);m(this,"lastAddedRhythmColumn");m(this,"lastAddedRhythmSymbol");m(this,"addExtensionToMusicObjects",[]);m(this,"layoutObjects",[]);m(this,"postMeasureBreakWidth",0);m(this,"passCount",0);m(this,"needBeamsUpdate",!0);m(this,"navigationSet",new Set);m(this,"isEndSong",!1);m(this,"isEndSection",!1);m(this,"endRepeatPlayCount",2);m(this,"endRepeatPlayCountText");m(this,"staticObjectsCache",new Map);m(this,"mi");this.mi=new Nn(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 n=this.getPrevMeasure();n&&n.useDiatonicId[e]!==void 0&&(this.useDiatonicId[e]=n.useDiatonicId[e])}let i=this.useDiatonicId[e];return i===void 0&&(this.row.hasStaff?i=this.row.getTopStaff().middleLineDiatonicId:i=V.getNote("C4").diatonicId),this.useDiatonicId[e]=V.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:0);let n=this.useStemDir[i];if(n===0||n===void 0){let c=this.row.getStaff(e.ownDiatonicId);return c?e.ownDiatonicId>c.middleLineDiatonicId?2:1:1}else return n}updateOwnString(e,r){var n,s;let{voiceId:i}=e;return r!==void 0?this.useString[i]=r:this.useString[i]===void 0&&(this.useString[i]=(s=(n=this.getPrevMeasure())==null?void 0:n.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 n=this.signatures[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.tabStringNotes.length;i++){let n=this.tabStringNotes[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.columns.length;i++){let n=this.columns[i].pick(e,r);if(n.length>0)return[this,...n]}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 n=this.connectives[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.beamGroups.length;i++){let n=this.beamGroups[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.layoutObjects.length;i++){let n=this.layoutObjects[i].musicObj.pick(e,r);if(n.length>0)return[this,...n]}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 try{let i=""+e[0],n=qa(""+e[1]);this.alterKeySignature=kr(i,n)}catch(i){throw new M(6,"Cannot set key signature because invalid args: "+e)}this.updateKeySignature()}updateKeySignature(){this.keySignature=this.prevMeasure?this.prevMeasure.keySignature:Vn(),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 dr?e:new dr(e),this.updateTimeSignature()}updateTimeSignature(){this.timeSignature=this.prevMeasure?this.prevMeasure.timeSignature:Un(),this.alterTimeSignature&&(this.timeSignature=this.alterTimeSignature),this.nextMeasure&&this.nextMeasure.updateTimeSignature(),this.requestLayout()}getTempo(){return this.tempo}setTempo(e,r,i){var s;(s=this.getPrevMeasure())==null||s.endSection();let n=r!==void 0?{beatLength:r,dotted:i}:void 0;this.alterTempo={beatsPerMinute:e,options:n},this.updateTempo()}updateTempo(){var e;if(this.tempo=this.prevMeasure?this.prevMeasure.tempo:zn(),this.alterTempo){let r=this.alterTempo.beatsPerMinute,i,n;this.alterTempo.options?(i=this.alterTempo.options.beatLength,n=(e=this.alterTempo.options.dotted)!=null?e:!1):this.alterTimeSignature?(i=this.alterTimeSignature.beatLength,n=!1):(i=this.tempo.options.beatLength,n=this.tempo.options.dotted),this.tempo={beatsPerMinute:r,options:{beatLength:i,dotted:n}}}this.nextMeasure&&this.nextMeasure.updateTempo(),this.requestLayout()}hasPostMeasureBreak(){return this.isEndSong&&this!==this.row.getLastMeasure()}getPostMeasureBreakWidth(){return this.postMeasureBreakWidth}addLayoutObject(e,r,i,n){this.layoutObjects.push(new Zs(e,r,i,n)),this.requestLayout(),this.requestRectUpdate()}forEachStaffGroup(e,r,i){let n=this.row.getNotationLines(),s=(a,c,u=[])=>{if(typeof a=="number")n[a]&&i(n[a],c);else if(typeof a=="string"&&a.length>0){let l=n.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];(_.Is.isArray(h.staffsTabsAndGroups)?h.staffsTabsAndGroups:[h.staffsTabsAndGroups]).forEach(d=>{switch(h.verticalPosition){case 0:s(d,0,p);break;case 1:s(d,1,p);break;case 2:s(d,0,p),s(d,1,p);break;case 3:s(d,r,p);break}})}}}};e===void 0?n.length>=2&&n[0]instanceof Tt&&n[0].staffConfig.clef==="G"&&n[0].isGrand()&&n[1]instanceof Tt&&n[1].staffConfig.clef==="F"&&n[1].isGrand()?s(r===1?1:0,r):s(0,r):_.Is.isArray(e)?e.forEach(a=>s(a,r)):s(e,r)}addFermata(e,r){let i=r===1?this.barLineRight:this.lastAddedRhythmColumn;if(!i)throw new M(6,"Cannot add Fermata because anchor is undefined.");this.forEachStaffGroup(e,0,(n,s)=>{this.addLayoutObject(new go(i,s),n,0,s)}),this.disableExtension(),this.requestLayout()}hasFermata(e){return this.layoutObjects.some(r=>r.musicObj instanceof go&&r.anchor===e)}addNavigation(e,r,...i){let n;switch(r){case 10:if(this.navigationSet.has(r))throw new M(6,"Cannot add ending beasure measure already has one.");let s=this,a=i;n={createObj:()=>new xi(s,a),layoutGroupId:3,defaultVerticalPos:0};break;case 1:case 0:case 3:case 2:{let c=this.barLineRight,u=bn(r);n={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0},this.addNavigation(e,9),this.endSong();break}case 7:{let c=this.barLineRight,u=bn(r);n={createObj:()=>new lt(c,u,1,1),layoutGroupId:2,defaultVerticalPos:0};break}case 6:case 4:{let c=this.barLineLeft,u=bn(r);n={createObj:()=>new Xe(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case 5:{let c=this.barLineRight,u=bn(r);n={createObj:()=>new Xe(c,u),layoutGroupId:2,defaultVerticalPos:0};break}case 9:if(i.length===0)this.endRepeatPlayCount=2;else if(_.Is.isIntegerGte(i[0],2))this.endRepeatPlayCount=i[0];else throw new M(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}n&&this.forEachStaffGroup(e,n.defaultVerticalPos,(s,a)=>{this.addLayoutObject(n.createObj(),s,n.layoutGroupId,a)}),this.navigationSet.add(r),this.disableExtension()}hasNavigation(e){return this.navigationSet.has(e)}addAnnotation(e,r,i){let n=this.lastAddedRhythmColumn;if(n){if(i.length===0)throw new M(6,"Cannot add annotation because annotation text is empty.")}else throw new M(6,"Cannot add annotation because anchor is undefined.");let s={text:i},a,c;switch(r){case 0:a=5,c=0,s.italic=!0;break;case 1:a=4,c=0,s.italic=!0;break}this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(n,s,.5,1);this.addLayoutObject(h,u,a,l),this.enableExtension(h)})}addLabel(e,r,i){let n=this.lastAddedRhythmColumn;if(n){if(i.length===0)throw new M(6,"Cannot add label because label text is empty.")}else throw new M(6,"Cannot add label because anchor is undefined.");let s={text:i},a,c;switch(r){case 0:a=1,c=1;break;case 1:a=6,c=0;break}this.forEachStaffGroup(e,c,(u,l)=>{let h=new lt(n,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 M(6,"Connective can be added to note group only.");if(e===0){let n=_.Is.isInteger(r[0])||_.Is.isEnumValue(r[0],ur)?r[0]:2,s=_.Is.isEnumValue(r[1],ve)?r[1]:0;i.startConnective(new yo(0,n,s,i))}else if(e===1){let n=_.Is.isInteger(r[0])?r[0]:2,s=_.Is.isEnumValue(r[1],ve)?r[1]:0;i.startConnective(new yo(1,n,s,i))}else if(e===2){let n=_.Is.isEnumValue(r[0],ve)?r[0]:0;i.startConnective(new yo(2,2,n,i))}}addExtension(e,r){if(this.addExtensionToMusicObjects.forEach(i=>{let n=i.getParent();if(i instanceof lt&&n instanceof wr){let s="dashed",a="bottom",c=new gi(i,n,e,r,s,a);i.setLink(c)}else throw new M(6,"Cannot add extension becaue no compatible music object to attach it to.")}),this.addExtensionToMusicObjects.length===0)throw new M(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 xi)}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.triplet&&this.createOldStyleTriplets(e),this.requestBeamsUpdate(),this.lastAddedRhythmColumn=i,this.lastAddedRhythmSymbol=r}addNoteGroup(e,r,i,n){let s=r.map(c=>typeof c=="string"?V.getNote(c):c),a=this.getRhythmColumn(e);this.addRhythmSymbol(e,new vt(a,e,s,i,n))}addRest(e,r,i){let n=this.getRhythmColumn(e);this.addRhythmSymbol(e,new Sr(n,e,r,i))}getRhythmColumn(e){let r=0;for(let i=this.columns.length-1;i>=0&&r===0;i--){let n=this.columns[i],s=n.getVoiceSymbol(e);s&&(r=n.positionTicks+s.rhythmProps.ticks)}for(let i=0;i<=this.columns.length;i++){let n=this.columns[i];if(n&&n.positionTicks===r)return n;if(!n||n.positionTicks>r){let s=new wr(this,r);return this.columns.splice(i,0,s),s}}throw new M(6,"Error in rhythm column. Should never get here.")}getMeasureTicks(){return this.getTimeSignature().measureTicks}getConsumedTicks(e){let r=0;return this.columns.forEach(i=>{oe().forEach(n=>{let s=i.getVoiceSymbol(n);s&&(e===void 0||e===n)&&(r=Math.max(r,i.positionTicks+s.rhythmProps.ticks))})}),r}getColumnsContentRect(){return new F(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(n=>n.getStaticObjects(e).forEach(s=>r==null?void 0:r.push(s))),this.staticObjectsCache.set(e,r));let i=this.layoutObjects.filter(n=>n.line===e&&n.isPositionResolved()).map(n=>n.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:n,verticalPos:s,line:a}=e;if(r.getLink()instanceof gi){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 d=p===l.measure?u.getHead():p.getBarLineLeft(),f=p===h.measure?h:p.getBarLineRight(),g=p.row.getNotationLines(),x=(c=g.find(b=>b.name!==""&&b.name===a.name))!=null?c:g[a.id];x&&p.addLayoutObject(new xo(p,x,u,d,f),x,n,s)}}}})}addBeamGroup(e){this.beamGroups.push(e)}requestBeamsUpdate(){this.needBeamsUpdate=!0}createOldStyleTriplets(e){let r=this.getVoiceSymbols(e);if(!(r.length<=2)){for(let i=0;i<r.length;){let n=r.slice(i,i+2),s=r.slice(i,i+3);n.length===2&&n.every(a=>a.triplet)&&n.every(a=>a.getBeamGroup()===void 0)&&fi.createTriplet(n)?i+=2:s.length===3&&s.every(a=>a.triplet)&&s.every(a=>a.getBeamGroup()===void 0)&&fi.createTriplet(s)?i+=3:i++}this.requestLayout()}}createBeams(){this.needBeamsUpdate&&(this.beamGroups=this.beamGroups.filter(e=>e.getType()===0?(e.detach(),!1):!0),oe().forEach(e=>{let r=this.getVoiceSymbols(e);if(!(r.length<=2)&&!Fs.DisableBeams){let i=[],n=0,s=0;this.isUpBeat()&&(n=s=Math.max(0,this.getMeasureTicks()-this.getConsumedTicks()));let a=this.getTimeSignature();r.forEach(c=>{for(i.push(c),s+=c.rhythmProps.ticks,n===0&&s===a.beamGroupLength&&Tn.setupBeamGroup(i);s>=a.beamGroupLength;)i=[],n=s=s-a.beamGroupLength})}}),this.needBeamsUpdate=!1,this.requestLayout())}static setupBeamGroup(e){let r=e.map(n=>{var s;return n instanceof vt&&((s=n.getBeamGroup())==null?void 0:s.isTriplet())!==!0?n:void 0});vt.setBeamCounts(r);let i=[];r.forEach(n=>{n&&n.hasBeamCount()?i.push(n):(fi.createBeam(i),i=[])}),fi.createBeam(i)}getBarLineLeft(){return this.barLineLeft}getBarLineRight(){return this.barLineRight}getVoiceSymbols(e){return su(e),this.voiceSymbols[e]===void 0&&(this.voiceSymbols[e]=[]),this.voiceSymbols[e]}completeRests(e){if(e===void 0){this.getConsumedTicks()===0?this.completeRests(0):oe().forEach(c=>{this.getConsumedTicks(c)>0&&this.completeRests(c)});return}let r=this.getMeasureTicks(),i=this.getConsumedTicks(e),n=r-i,s=[],a=_.Enum.getEnumValues(Gt);for(;n>0;)a.forEach(c=>{let u=new $t(c,!1);if(u.canDot()){let l=new $t(c,!0);for(;l.ticks<=n;)s.push(l),n-=l.ticks}for(;u.ticks<=n;)s.push(u),n-=u.ticks});s.reverse().forEach(c=>this.addRest(e,c.noteLength,{dotted:c.dotted}))}requestLayout(){this.needLayout||(this.needLayout=!0,this.row.requestLayout())}layout(e){var d;if(!this.needLayout)return;this.staticObjectsCache.clear(),this.requestRectUpdate();let{unitSize:r}=e;this.postMeasureBreakWidth=this.hasPostMeasureBreak()?ct.PostMeasureBreakWidth*r:0;let i=this===this.row.getFirstMeasure(),n=((d=this.getPrevMeasure())==null?void 0:d.hasPostMeasureBreak())===!0;this.tabStringNotesWidth=i&&this.row.hasTab?r*4:0;let s=i||n,a=i&&!this.row.isFirstRow(),c=i||n||!!this.alterKeySignature,u=!!this.alterTimeSignature,l=!!this.alterTempo;s||a||c||u||l?this.signatures=this.row.getStaves().map((f,g)=>{let x=this.signatures.find(I=>I.staff===f),b=x!=null?x:new qs(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 x=f.getTuningStrings()[g].format(1,1),b=new lt(this,{text:x,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 Gs(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,Tn.MinFlexContentWidth*r)}layoutWidth(e,r){if(!this.needLayout)return;r=Math.max(r,this.getMinWidth()),this.rect=new F,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 n=Math.max(0,...this.signatures.map(p=>p.getRect().width));i=this.barLineLeft.getRect(),this.barLineLeft.offset(this.rect.left+this.tabStringNotesWidth+n-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=_.Math.sum(this.columns.map(p=>p.getRect().width)),l=c/u,h=s;this.columns.forEach(p=>{i=p.getRect();let d=h+i.leftw*l;p.offset(d-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 go).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(),n=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)n(a.getDiatonicIdY(c));else if(a instanceof Pe)for(let c=0;c<6;c++)n(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))}};m(Tn,"MinFlexContentWidth",10);var bo=Tn;var eb=[1,6],rb=[2,3,4,5,6];function ib(o){for(;o;){if(o instanceof bo)return o;o=o.getParent()}throw new M(6,"Parent measure is required but not found!")}var Xs=class{constructor(t,e,r){this.groupName=t;this.staffsTabsAndGroups=e;this.verticalPosition=r}},Zs=class{constructor(t,e,r,i){this.musicObj=t;this.line=e;this.layoutGroupId=r;this.verticalPos=i;m(this,"anchor");m(this,"measure");m(this,"row");m(this,"layoutGroup");m(this,"positionResolved",!0);this.measure=ib(this.musicObj),this.row=this.measure.row;let n=this.musicObj.getParent();if(!n)throw new M(6,"Parent music object is required as an anchor.");this.anchor=n,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:n}=this,s=n.getTopLineY(),a=n.getBottomLineY(),c=t.unitSize*2,u=i===1?a+c+e.getRect().toph:s-c-e.getRect().bottomh,l=r.getStaticObjects(n),h=e.getShapeRects();return l.forEach(p=>{let d=p.getShapeRects();h.forEach(f=>{d.forEach(g=>{F.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 Xe)return this.musicObj.getText()}layout(t){this.line.addObject(this)}offset(t,e){this.musicObj.offset(t,e)}getRect(){return this.musicObj.getRect()}},Js=class{constructor(t){this.layoutGroupId=t;m(this,"layoutObjectTable",[]);m(this,"rowAlign");m(this,"widensColumn");this.layoutObjectTable[0]=[],this.layoutObjectTable[1]=[],this.rowAlign=rb.indexOf(t)>=0,this.widensColumn=eb.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 Ks=class extends it{constructor(e){super(e);m(this,"objects",[]);m(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 Js(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(n=>!n.isPositionResolved());let i;r.forEach(n=>{let s=n.resolveClosestToStaffY(e);i=n.verticalPos===1?Math.max(s,i!=null?i:s):Math.min(s,i!=null?i:s)}),r.forEach(n=>this.setObjectY(n,i))}layoutLayoutGroup(e,r,i){let n=r.getLayoutObjects(i).filter(s=>!s.isPositionResolved());n.forEach(s=>{let{musicObj:a,anchor:c}=s;a instanceof xi||a instanceof xo?a.layoutFitToMeasure(e):a.offset(c.getRect().centerX-a.getRect().centerX,0)}),r.rowAlign?this.alignObjectsY(e,n):n.forEach(s=>{let a=s.musicObj.getLink();if(a&&a.getHead()===s.musicObj){let c=[a.getHead(),...a.getTails()],u=n.filter(l=>c.some(h=>h===l.musicObj));this.alignObjectsY(e,u)}else this.alignObjectsY(e,[s])})}},Tt=class extends Ks{constructor(e,r,i){super(e);this.row=e;this.staffConfig=r;this.id=i;m(this,"clefImageAsset");m(this,"clefLineDiatonicId");m(this,"topLineDiatonicId");m(this,"middleLineDiatonicId");m(this,"bottomLineDiatonicId");m(this,"minDiatonicId");m(this,"maxDiatonicId");m(this,"joinedGrandStaff");m(this,"topLineY",0);m(this,"bottomLineY",0);m(this,"mi");let n=(s,a)=>V.getNote(s).diatonicId-(a?7:0);r.clef==="G"?(this.clefImageAsset=0,this.clefLineDiatonicId=n("G4",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId+2):(this.clefImageAsset=1,this.clefLineDiatonicId=n("F3",r.isOctaveDown===!0),this.middleLineDiatonicId=this.clefLineDiatonicId-2),this.topLineDiatonicId=this.middleLineDiatonicId+4,this.bottomLineDiatonicId=this.middleLineDiatonicId-4,this.minDiatonicId=r.minNote!==void 0?Math.min(n(r.minNote,!1),this.bottomLineDiatonicId):void 0,this.maxDiatonicId=r.maxNote!==void 0?Math.max(n(r.maxNote,!1),this.topLineDiatonicId):void 0,this.mi=new On(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 V.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 M(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 M(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*ct.StaffHeight;this.topLineY=-i/2,this.bottomLineY=i/2,this.rect=new F(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 Ks{constructor(e,r,i){super(e);this.row=e;this.tabConfig=r;this.id=i;m(this,"top",0);m(this,"bottom",0);m(this,"tuningName");m(this,"tuningStrings");m(this,"mi");_.Is.isArray(r.tuning)?(this.tuningName=void 0,this.tuningStrings=r.tuning.map(n=>V.getNote(n)).reverse()):typeof r.tuning=="string"?(this.tuningName=Ya(r.tuning),this.tuningStrings=Wn(this.tuningName)):(this.tuningName="Standard",this.tuningStrings=Wn(this.tuningName)),this.mi=new Rn(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*ct.TabHeight;this.top=-i/2,this.bottom=i/2,this.rect=new F(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 $s=class extends it{constructor(e,r,i){super(e);this.doc=e;this.prevRow=r;this.scoreConfig=i;m(this,"nextRow");m(this,"minWidth",0);m(this,"notationLines");m(this,"staves");m(this,"tabs");m(this,"measures",[]);m(this,"needLayout",!0);m(this,"mi");this.notationLines=this.createNotationLines(),this.staves=this.notationLines.filter(n=>n instanceof Tt),this.tabs=this.notationLines.filter(n=>n instanceof Pe),this.prevRow&&(this.prevRow.nextRow=this),this.mi=new Mn(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],n=e[r+1];i instanceof Tt&&i.isGrand()&&i.staffConfig.clef==="G"&&n instanceof Tt&&n.isGrand()&&n.staffConfig.clef==="F"&&(i.joinGrandStaff(n),n.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 M(6,"Top staff is required!")}getBottomStaff(){let e=this.staves[this.staves.length-1];if(e)return e;throw new M(6,"Bottom staff is required!")}getStaff(e){V.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 n=this.measures[i].pick(e,r);if(n.length>0)return[this,...n]}for(let i=0;i<this.notationLines.length;i++){let n=this.notationLines[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}getConnectivesContentRect(){let e=this.getRect(),r=this.getFirstMeasure(),i=r?r.getColumnsContentRect().left:e.left;return new F(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],n=i instanceof Tt?i.getDiatonicIdAt(e):void 0;if(n!==void 0)return n}}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 F(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 n=i,s=0;this.measures.forEach(u=>{n-=u.getSolidAreaWidth()+u.getPostMeasureBreakWidth(),s+=u.getMinColumnsAreaWidth()});let a=n/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,n=this.measures.length>0?Math.max(...this.measures.map(s=>s.getRect().bottom)):0;this.rect=new F(e,r,i,n)}alignStemsToBeams(){this.measures.forEach(e=>e.alignStemsToBeams())}layoutPositionLines(e){let{unitSize:r}=e;for(let i=1;i<this.notationLines.length;i++){let n=this.notationLines[i-1],s=this.notationLines[i];if(n instanceof Tt&&n.isGrand()&&n.staffConfig.clef==="G"&&s instanceof Tt&&s.isGrand()&&s.staffConfig.clef==="F"){let a=r*6;s.offset(0,n.getBottomLineY()-s.getTopLineY()+a)}else{let a=r*3;s.offset(0,n.calcBottom()-s.calcTop()+a)}}this.measures.forEach(i=>{i.requestRectUpdate(),i.getBarLineLeft().requestRectUpdate(),i.getBarLineRight().requestRectUpdate(),i.getColumns().forEach(n=>{n.requestRectUpdate(),oe().forEach(s=>{var a;return(a=n.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(),n=Math.min(...this.notationLines.map(a=>a.getTopLineY())),s=Math.max(...this.notationLines.map(a=>a.getBottomLineY()));e.drawLine(i,n,i,s)}this.measures.forEach(i=>i.draw(e)),this.notationLines.forEach(i=>i.draw(e)),r.restore()}}};var ta=class extends it{constructor(e,r,i,n){super(e);this.title=r;this.composer=i;this.arranger=n;m(this,"titleText");m(this,"composerText");m(this,"arrangerText");m(this,"mi");this.mi=new En(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 F(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 ea=class extends it{constructor(){super(void 0);m(this,"needLayout",!0);m(this,"renderer");m(this,"rows",[]);m(this,"measures",[]);m(this,"measuresPerRow",1/0);m(this,"curScoreConfig",[{type:"staff",clef:"G"}]);m(this,"header");m(this,"newRowRequested",!1);m(this,"allConnectiveProps",[]);m(this,"staffGroups",new Map);m(this,"mi");this.mi=new Zr(this)}getMusicInterface(){return this.mi}setScoreConfiguration(e){if(_.Is.isEnumValue(e,_r))switch(e){default:case 1:this.curScoreConfig=[{type:"staff",clef:"G"}];break;case 2:this.curScoreConfig=[{type:"staff",clef:"F"}];break;case 3:this.curScoreConfig=[{type:"staff",clef:"G",isGrand:!0},{type:"staff",clef:"F",isGrand:!0}];break;case 4:this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0}];break;case 8:this.curScoreConfig=[{type:"tab",tuning:"Standard"}];break;case 12:this.curScoreConfig=[{type:"staff",clef:"G",isOctaveDown:!0},{type:"tab",tuning:"Standard"}];break}else _.Is.isArray(e)?this.curScoreConfig=e:this.curScoreConfig=[e];for(let r=0;r<this.curScoreConfig.length-1;r++){let i=this.curScoreConfig[r],n=this.curScoreConfig[r+1];i.type==="staff"&&n.type==="staff"?i.clef==="G"&&i.isGrand&&n.clef==="F"&&n.isGrand?(i.minNote="C4",n.maxNote="B3",i.isOctaveDown=n.isOctaveDown=!1):i.isGrand=n.isGrand=!1:i.type==="staff"?i.isGrand=!1:n.type==="staff"&&(n.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 ta(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 $s(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 bo(e);return this.measures.push(r),e.addMeasure(r),this.requestLayout(),r}addStaffGroup(e,r,i){this.staffGroups.set(e,new Xs(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(n=>n.createBeams()),this.forEachMeasure(n=>n.createExtensions()),this.allConnectiveProps.forEach(n=>n.removeConnectives()),this.allConnectiveProps.forEach(n=>n.createConnectives()),this.rows.forEach(n=>n.resetLayoutGroups(e)),this.rows.forEach(n=>n.layout(e));let i=Math.max(ct.DocumentMinWidth*r,...this.rows.map(n=>1.4*n.getMinWidth()));this.rows.forEach(n=>n.layoutWidth(e,i)),this.rows.forEach(n=>n.layoutLayoutGroups(e)),this.rows.forEach(n=>n.layoutPositionLines(e)),this.rows.forEach(n=>n.layoutPadding(e)),this.rect=new F,this.header&&(this.header.layoutWidth(e,i),this.rect.expandInPlace(this.header.getRect())),this.rows.forEach(n=>{n.offset(-this.rect.left,this.rect.bottom+r*2-n.getRect().top),this.rect.expandInPlace(n.getRect())}),this.rows.forEach(n=>n.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 n=this.rows[i];if(!n.hasStaff||!n.getRect().contains(e,r))continue;let s=n.getDiatonicIdAt(r);if(s!==void 0)return{scoreRow:n,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 n=this.rows[i].pick(e,r);if(n.length>0)return[this,...n]}return[this]}};function U(o,t,e){if(!o)throw new M(6,`Invalid arg: ${t} = ${e}`)}function hu(o){if(typeof o!="string")return!1;{let t=V.parseNote(o);return t!==void 0&&t.octave!==void 0}}function ra(o){return _.Is.isNumber(o)&&oe().indexOf(o)>=0}function gm(o){return _.Is.isNumber(o)&&ru().indexOf(o)>=0}function xm(o){U(_.Is.isObject(o),"staffConfig",o),U(o.type==="staff","staffConfig.type",o.type),U(_.Is.isEnumValue(o.clef,vr),"staffConfig.clef",o.clef),U(_.Is.isBooleanOrUndefined(o.isOctaveDown),"staffConfig.isOctaveDown",o.isOctaveDown),U(_.Is.isUndefined(o.minNote)||hu(o.minNote),"staffConfig.minNote",o.minNote),U(_.Is.isUndefined(o.maxNote)||hu(o.maxNote),"staffConfig.maxNote",o.maxNote),U(_.Is.isUndefined(o.voiceIds)||_.Is.isArray(o.voiceIds)&&o.voiceIds.every(t=>_.Is.isNumber(t)),"staffConfig.voiceIds",o.voiceIds),U(_.Is.isBooleanOrUndefined(o.isGrand),"staffConfig.isGrand",o.isGrand)}function ym(o){U(_.Is.isObject(o),"tabConfig",o),U(o.type==="tab","tabConfig.type",o.type),typeof o.tuning=="string"?U(Oo.includes(o.tuning),"tabConfig.tuning",o.tuning):_.Is.isArray(o.tuning)&&U(o.tuning.length===6&&o.tuning.every(t=>hu(t)),"tabConfig.tuning",o.tuning),U(_.Is.isUndefined(o.voiceIds)||_.Is.isArray(o.voiceIds)&&o.voiceIds.every(t=>_.Is.isNumber(t)),"tabConfig.voiceIds",o.voiceIds)}function bm(o){U(_.Is.isObject(o),"noteOptions",o),U(_.Is.isBooleanOrUndefined(o.dotted),"noteOptions.dotted",o.dotted),U(_.Is.isEnumValueOrUndefined(o.stem,Le),"noteOptions.stem",o.stem),U(_.Is.isStringOrUndefined(o.color),"noteOptions.color",o.color),U(_.Is.isBooleanOrUndefined(o.arpeggio)||_.Is.isEnumValue(o.arpeggio,Hr),"noteOptions.arpeggio",o.arpeggio),U(_.Is.isBooleanOrUndefined(o.staccato),"noteOptions.staccato",o.staccato),U(_.Is.isBooleanOrUndefined(o.diamond),"noteOptions.diamond",o.diamond),U(_.Is.isBooleanOrUndefined(o.triplet),"noteOptions.triplet",o.triplet),U(_.Is.isUndefined(o.string)||gm(o.string)||_.Is.isArray(o.string)&&o.string.length>0&&o.string.every(t=>gm(t)),"noteOptions.string",o.string)}function ob(o){U(_.Is.isObject(o),"restOptions",o),U(_.Is.isBooleanOrUndefined(o.dotted),"restOptions.dotted",o.dotted),U(_.Is.isStringOrUndefined(o.staffPos)||_.Is.isInteger(o.staffPos)||o.staffPos instanceof V,"restOptions.staffPos",o.staffPos),U(_.Is.isStringOrUndefined(o.color),"restOptions.color",o.color),U(_.Is.isBooleanOrUndefined(o.hide),"restOptions.hide",o.hide),U(_.Is.isBooleanOrUndefined(o.triplet),"restOptions.triplet",o.triplet)}function ia(o){U(_.Is.isStringOrUndefined(o)||_.Is.isIntegerGte(o,0)||_.Is.isArray(o)&&o.every(t=>_.Is.isString(t)||_.Is.isIntegerGte(t,0)),"staffTabOrGroup",o)}var Nr=class{constructor(){m(this,"doc");this.doc=new ea}setScoreConfiguration(t){return _.Is.isEnumValue(t,_r)||(_.Is.isObject(t)&&t.type==="staff"?xm(t):_.Is.isObject(t)&&t.type==="tab"?ym(t):_.Is.isArray(t)?(U(t.length>0,"config",t),t.forEach(e=>{_.Is.isObject(e)&&e.type==="staff"?xm(e):_.Is.isObject(e)&&e.type==="tab"?ym(e):U(!1,"config",t)})):U(!1,"config",t)),this.doc.setScoreConfiguration(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 U(_.Is.isStringOrUndefined(t),"title",t),U(_.Is.isStringOrUndefined(e),"composer",e),U(_.Is.isStringOrUndefined(r),"arranger",r),this.doc.setHeader(t,e,r),this}setMeasuresPerRow(t){return U(_.Is.isIntegerGte(t,1)||t===1/0,"measuresPerRow",t),this.doc.setMeasuresPerRow(t),this}addMeasure(){return this.doc.addMeasure(),this}setKeySignature(...t){return U(t[0]instanceof jr||t[0]instanceof Fe||_.Is.isString(t[0])&&_.Is.isEnumValue(t[1],Ke),"keySignature",t),this.getMeasure().setKeySignature(...t),this}setTimeSignature(t){return U(t instanceof dr||_.Is.isString(t),"timeSignature",t),this.getMeasure().setTimeSignature(t),this}setTempo(t,e,r){return U(_.Is.isIntegerGte(t,1),"beatsPerMinute",t),e===void 0?U(_.Is.isUndefined(r),"dotted",r):(U(_.Is.isEnumValue(e,Gt),"beatLength",e),U(_.Is.isBooleanOrUndefined(r),"dotted",r)),this.getMeasure().setTempo(t,e,r),this}addNote(t,e,r,i){return U(ra(t),"voiceId",t),U(e instanceof V||_.Is.isString(e),"note",e),U(_.Is.isEnumValue(r,Gt),"noteLength",r),i!==void 0&&bm(i),this.getMeasure().addNoteGroup(t,[e],r,i),this}addChord(t,e,r,i){return U(ra(t),"voiceId",t),U(_.Is.isArray(e)&&e.length>=1&&e.every(n=>n instanceof V||_.Is.isString(n)),"notes",e),U(_.Is.isEnumValue(r,Gt),"noteLength",r),i!==void 0&&bm(i),this.getMeasure().addNoteGroup(t,e,r,i),this}addRest(t,e,r){return U(ra(t),"voiceId",t),U(_.Is.isEnumValue(e,Gt),"restLength",e),r!==void 0&&ob(r),this.getMeasure().addRest(t,e,r),this}addFermataInternal(t,e){return ia(t),U(_.Is.isEnumValue(e,rn),"fermata",e),this.getMeasure().addFermata(t,e),this}addFermata(t=0){return this.addFermataInternal(void 0,t)}addFermataTo(t,e=0){return this.addFermataInternal(t,e)}addNavigationInternal(t,e,...r){return ia(t),U(_.Is.isEnumValue(e,Ie),"navigation",e),e===9&&r.length>0?U(_.Is.isIntegerGte(r[0],1),"playCount",r[0]):e===10&&r.length>0&&U(r.every(i=>_.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)}addLabelInternal(t,e,r){return ia(t),U(_.Is.isEnumValue(e,po),"label",e),U(_.Is.isString(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)}addAnnotationInternal(t,e,r){return ia(t),U(_.Is.isEnumValue(e,hi),"annotation",e),U(_.Is.isString(r),"text",r),this.getMeasure().addAnnotation(t,e,r),this}addAnnotation(t,e){return this.addAnnotationInternal(void 0,t,e)}addAnnotationTo(t,e,r){return this.addAnnotationInternal(t,e,r)}addConnective(t,...e){if(U(_.Is.isEnumValue(t,Ir),"connective",t),t===0){U(_.Is.isUndefined(e[0])||_.Is.isInteger(e[0])||_.Is.isEnumValue(e[0],ur),"tieSpan",e[0]),U(_.Is.isEnumValueOrUndefined(e[1],ve),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t===1){U(_.Is.isUndefined(e[0])||_.Is.isInteger(e[0]),"slurSpan",e[0]),U(_.Is.isEnumValueOrUndefined(e[1],ve),"noteAnchor",e[1]);let r=e[0],i=e[1];this.getMeasure().addConnective(t,r,i)}else if(t===2){U(_.Is.isEnumValueOrUndefined(e[0],ve),"noteAnchor",e[0]);let r=e[0];this.getMeasure().addConnective(t,r)}return this}addExtension(t,e){return U(_.Is.isIntegerGte(t,0)||t===1/0||_.Is.isEnumValue(t,Gt),"extendionLength",t),U(_.Is.isBooleanOrUndefined(e),"extensionVisible",e),this.getMeasure().addExtension(t,e!=null?e:!0),this}addStaffGroup(t,e,r=3){return U(_.Is.isString(t)&&t.length>0,"groupName",t),U(_.Is.isString(e)&&e.length>0||_.Is.isIntegerGte(e,0)||_.Is.isArray(e)&&e.every(i=>_.Is.isString(i)&&i.length>0||_.Is.isIntegerGte(i,0)),"staffsTabsAndGroups",e),U(_.Is.isEnumValue(r,en),"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 U(_.Is.isUndefined(t)||ra(t),"voiceId",t),this.getMeasure().completeRests(t),this}addScaleArpeggio(t,e,r){U(_.Is.isString(e),"bottomNote",e),U(_.Is.isIntegerGte(r,1),"numOctaves",r);let i=this.getMeasure().getTimeSignature(),n=t.getScaleNotes(e,r);for(let s=0;s<n.length;s++){s%i.beatCount===0&&s>0&&this.addMeasure();let a=n[s];this.addNote(0,a,i.beatLength),this.addLabel(0,a.formatOmitOctave(1))}return this}};var Dn=class{constructor(t){this.type=t}},pi=class extends Dn{constructor(e,r,i,n){super(e);this.renderer=r;this.scoreRow=i;this.diatonicId=n}},di=class extends Dn{constructor(e,r,i){super(e);this.renderer=r;this.objects=i;if(arguments.length===0)throw new M(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 ge(o,t,e){if(!o)throw new M(6,`Invalid arg: ${t} = ${e}`)}function kn(o,t){if(o==null)throw new TypeError(t);return o}function nb(o){return _.Is.isNumber(o)&&oe().indexOf(o)>=0}function mu(o){if(o instanceof Tt||o instanceof Pe)return o.getMusicInterface();throw new M(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()}},oa=class oa extends bt{constructor(e){super(oa.Name);this.obj=e}getMusicObject(){return this.obj}getAccidental(){return this.obj.accidental}};m(oa,"Name","Accidental");var nn=oa,na=class na extends bt{constructor(e){super(na.Name);this.obj=e}getMusicObject(){return this.obj}};m(na,"Name","Connective");var wn=na,sa=class sa extends bt{constructor(e){super(sa.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmColumn(){return this.obj.col.getMusicInterface()}getNotationLine(){return mu(this.obj.line)}};m(sa,"Name","Arpeggio");var cn=sa,aa=class aa extends bt{constructor(e){super(aa.Name);this.obj=e}getMusicObject(){return this.obj}};m(aa,"Name","BeamGroup");var pn=aa,ca=class ca extends bt{constructor(e){super(ca.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};m(ca,"Name","StaffBeamGroup");var dn=ca,ua=class ua extends bt{constructor(e){super(ua.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 ge(_.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),new Ln(this,e).play()}};m(ua,"Name","Document");var Zr=ua,la=class la extends bt{constructor(e){super(la.Name);this.obj=e}getMusicObject(){return this.obj}getPassages(){return this.obj.passages}hasPassage(e){return ge(_.Is.isIntegerGte(e,1),"passage",e),this.obj.hasPassage(e)}};m(la,"Name","Ending");var vn=la,ha=class ha extends bt{constructor(e){super(ha.Name);this.obj=e}getMusicObject(){return this.obj}};m(ha,"Name","Fermata");var In=ha,pa=class pa extends bt{constructor(e){super(pa.Name);this.obj=e}getMusicObject(){return this.obj}getTitle(){return this.obj.title}getComposer(){return this.obj.composer}getArranger(){return this.obj.arranger}};m(pa,"Name","Header");var En=pa,da=class da extends bt{constructor(e){super(da.Name);this.obj=e}getMusicObject(){return this.obj}};m(da,"Name","Image");var on=da,ma=class ma extends bt{constructor(e){super(ma.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()}};m(ma,"Name","Measure");var Nn=ma,fa=class fa extends bt{constructor(e){super(fa.Name);this.obj=e}getMusicObject(){return this.obj}};m(fa,"Name","BarLineRight");var An=fa,ga=class ga extends bt{constructor(e){super(ga.Name);this.obj=e}getMusicObject(){return this.obj}};m(ga,"Name","BarLineLeft");var Cn=ga,xa=class xa extends bt{constructor(e){super(xa.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 M(6,"Bar line not let nor right.")}getNotationLine(){return mu(this.obj.line)}};m(xa,"Name","StaffTabBarLine");var _n=xa,ya=class ya extends bt{constructor(e){super(ya.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()}};m(ya,"Name","NoteGroup");var mn=ya,ba=class ba extends bt{constructor(e){super(ba.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()}};m(ba,"Name","StaffNoteGroup");var fn=ba,Aa=class Aa extends bt{constructor(e){super(Aa.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()}};m(Aa,"Name","TabNoteGroup");var gn=Aa,Ca=class Ca extends bt{constructor(e){super(Ca.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()}};m(Ca,"Name","Rest");var un=Ca,_a=class _a extends bt{constructor(e){super(_a.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()}};m(_a,"Name","StaffRest");var ln=_a,va=class va extends bt{constructor(e){super(va.Name);this.obj=e}getMusicObject(){return this.obj}getRhythmSymbol(e){var r;return ge(nb(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 Sr?r.getMusicInterface():void 0}};m(va,"Name","RhythmColumn");var xn=va,Ia=class Ia extends bt{constructor(e){super(Ia.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=>mu(e))}};m(Ia,"Name","ScoreRow");var Mn=Ia,Sa=class Sa extends bt{constructor(e){super(Sa.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()}};m(Sa,"Name","Staff");var On=Sa,wa=class wa extends bt{constructor(e){super(wa.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()}};m(wa,"Name","Tab");var Rn=wa,Ta=class Ta extends bt{constructor(e){super(Ta.Name);this.obj=e}getMusicObject(){return this.obj}getStaff(){return this.obj.staff.getMusicInterface()}};m(Ta,"Name","Signature");var an=Ta,Na=class Na extends bt{constructor(e){super(Na.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};m(Na,"Name","SpecialText");var yn=Na,Oa=class Oa extends bt{constructor(e){super(Oa.Name);this.obj=e}getMusicObject(){return this.obj}getText(){return this.obj.getText()}};m(Oa,"Name","Text");var sn=Oa,Ra=class Ra extends bt{constructor(e){super(Ra.Name);this.obj=e}getMusicObject(){return this.obj}};m(Ra,"Name","ExtensionLine");var Sn=Ra,jn=class jn{constructor(t,e){m(this,"player");ge(t instanceof Zr,"doc",t),ge(_.Is.isFunctionOrUndefined(e),"playStateChangeListener",e),this.player=new Hs,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()),eu()}play(){return jn.currentlyPlaying.add(this),this.player.play(),this}pause(){return this.player.pause(),this}stop(){return this.player.stop(),jn.currentlyPlaying.delete(this),this}};m(jn,"currentlyPlaying",new Set);var Ln=jn,pu=class{constructor(){m(this,"renderer");this.renderer=new Bs(this)}setDocument(t){return ge(_.Is.isUndefined(t)||t instanceof Zr,"doc",t),this.renderer.setDocument(t),this}setCanvas(t){return t=kn(_.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){ge(_.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)}}},le=class le{constructor(){m(this,"playButton");m(this,"stopButton");m(this,"playStopButton");m(this,"pauseButton");m(this,"onPlay");m(this,"onStop");m(this,"onPlayStop");m(this,"onPause");m(this,"playLabel","Play");m(this,"stopLabel","Stop");m(this,"pauseLabel","Pause");m(this,"playState",2);m(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 ge(_.Is.isUndefined(t)||t instanceof Zr,"doc",t),this.onStop(),t?this.player=new Ln(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 ge(_.Is.isStringOrUndefined(e),"btnLabel",e),le.removeOnClickListeners(this.playButton,this.onPlay),this.playButton=kn(_.Dom.getButton(t),"Play button required!"),this.playLabel=e!=null?e:"Play",le.removeOnClickListeners(this.playButton,"all"),le.addOnClickListener(this.playButton,this.onPlay),this.updateButtons(),this}setStopButton(t,e){return ge(_.Is.isStringOrUndefined(e),"btnLabel",e),le.removeOnClickListeners(this.stopButton,this.onStop),this.stopButton=kn(_.Dom.getButton(t),"Stop button required!"),this.stopLabel=e!=null?e:"Stop",le.removeOnClickListeners(this.stopButton,"all"),le.addOnClickListener(this.stopButton,this.onStop),this.updateButtons(),this}setPlayStopButton(t,e,r){return ge(_.Is.isStringOrUndefined(e),"playLabel",e),ge(_.Is.isStringOrUndefined(r),"stopLabel",r),le.removeOnClickListeners(this.playStopButton,this.onPlayStop),this.playStopButton=kn(_.Dom.getButton(t),"Play/stop button required!"),this.playLabel=e!=null?e:"Play",this.stopLabel=r!=null?r:"Stop",le.removeOnClickListeners(this.playStopButton,"all"),le.addOnClickListener(this.playStopButton,this.onPlayStop),this.updateButtons(),this}setPauseButton(t,e){return ge(_.Is.isStringOrUndefined(e),"btnLabel",e),le.removeOnClickListeners(this.pauseButton,this.onPause),this.pauseButton=kn(_.Dom.getButton(t),"Pause button required!"),this.pauseLabel=e!=null?e:"Pause",le.removeOnClickListeners(this.pauseButton,"all"),le.addOnClickListener(this.pauseButton,this.onPause),this.updateButtons(),this}static removeOnClickListeners(t,e){if(t){let r=this.savedOnClickListeners.get(t)||[],i=[];r.forEach(n=>{e===n||e==="all"?t.removeEventListener("click",n):i.push(n)}),this.savedOnClickListeners.set(t,i)}}static addOnClickListener(t,e){ge(_.Is.isFunction(e),"onClick",e),t.addEventListener("click",e);let r=this.savedOnClickListeners.get(t)||[];this.savedOnClickListeners.set(t,[...r,e])}};m(le,"savedOnClickListeners",new Map);var du=le;Xr();var gu={};_i(gu,{createAndanteByDiabelli:()=>cb,createFrereJacques:()=>sb,createGreensleeves:()=>ab});function sb(){return new Nr().setScoreConfiguration(4).setHeader("Frere Jacques").addMeasure().setKeySignature("G","Major").setTimeSignature("4/4").addNote(0,"G3",48).addNote(0,"A3",48).addNote(0,"B3",48).addNote(0,"G3",48).addMeasure().addNote(0,"G3",48).addNote(0,"A3",48).addNote(0,"B3",48).addNote(0,"G3",48).addMeasure().addNote(0,"B3",48).addNote(0,"C4",48).addNote(0,"D4",96).endRow().addMeasure().addNote(0,"B3",48).addNote(0,"C4",48).addNote(0,"D4",96).addMeasure().addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(0,"C4",24).addNote(0,"B3",48).addNote(0,"G3",48).endRow().addMeasure().addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(0,"C4",24).addNote(0,"B3",48).addNote(0,"G3",48).addMeasure().addNote(0,"G3",48).addNote(0,"D3",48).addNote(0,"G3",96).addMeasure().addNote(0,"G3",48).addNote(0,"D3",48).addNote(0,"G3",96).getDocument()}function ab(){return new Nr().setScoreConfiguration(4).setHeader("Greensleeves").addMeasure().setKeySignature("C","Major").setTimeSignature("6/8").setTempo(140).addNote(0,"A3",24).addMeasure().addNavigation(8).addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"D4",24).addNote(0,"E4",24,{dotted:!0}).addNote(0,"F4",12).addNote(0,"E4",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"A2",24).addNote(1,"E3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"A3",24).addNote(0,"A3",24,{dotted:!0}).addLabel(1,"F").addNote(0,"G#3",12).addNote(0,"A3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"F2",24).addNote(1,"A2",48).addMeasure().addNote(0,"B3",48,{stem:1}).addLabel(1,"E").addNote(0,"G#3",24).addNote(0,"E3",48).addNote(0,"A3",24).addNote(1,"E2",24,{stem:2}).addNote(1,"B2",48).addNote(1,"E2",24).addNote(1,"B2",48).endRow().addMeasure().addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"D4",24).addNote(0,"E4",24,{dotted:!0}).addNote(0,"F4",12).addNote(0,"E4",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"A2",24).addNote(1,"E3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",24,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"B3",12).addNote(0,"A3",24).addNote(0,"G#3",24,{dotted:!0}).addLabel(1,"E").addNote(0,"F#3",12).addNote(0,"G#3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"A3",48,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"A3",48,{dotted:!0}).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",24).addNote(1,"C4",24).addNote(1,"A2",48,{dotted:!0}).endRow().addMeasure().addChord(0,["C3","E3","G3","C4","G4"],48,{dotted:!0,arpeggio:0,stem:1}).addLabel(1,"C").addNote(0,"G4",24,{dotted:!0}).addNote(0,"F#4",12).addNote(0,"E4",24).addRest(1,48,{dotted:!0,hide:!0}).addNote(1,"C3",24,{stem:2}).addNote(1,"G3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",48,{stem:1}).addLabel(1,"Am").addNote(0,"A3",24).addNote(0,"A3",24,{dotted:!0}).addLabel(1,"F").addNote(0,"G#3",12).addNote(0,"A3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"F2",24).addNote(1,"A2",48).addMeasure().addNote(0,"B3",48,{stem:1}).addLabel(1,"E").addNote(0,"G#3",24).addNote(0,"E3",48,{dotted:!0}).addNote(1,"E2",24,{stem:2}).addNote(1,"B2",48).addNote(1,"E2",24).addNote(1,"B2",24).addNote(1,"E3",24).endRow().addMeasure().addNote(0,"G4",48,{dotted:!0,stem:1}).addLabel(1,"C").addNote(0,"G4",24,{dotted:!0}).addNote(0,"F#4",12).addNote(0,"E4",24).addNote(1,"C3",24,{stem:2}).addNote(1,"G3",24).addNote(1,"C4",24).addNote(1,"C3",24).addNote(1,"G3",48).addMeasure().addNote(0,"D4",48,{stem:1}).addLabel(1,"G").addNote(0,"B3",24).addNote(0,"G3",24,{dotted:!0}).addLabel(1,"Em").addNote(0,"A3",12).addNote(0,"B3",24).addNote(1,"G2",24,{stem:2}).addNote(1,"D3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNote(0,"C4",24,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"B3",12).addNote(0,"A3",24).addNote(0,"G#3",24,{dotted:!0}).addLabel(1,"E").addNote(0,"F#3",12).addNote(0,"G#3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",48).addNote(1,"E2",24).addNote(1,"B2",48).addMeasure().addNavigation(10,1).addNavigation(9).addNote(0,"A3",48,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"A3",48).addNote(0,"A3",24).addNote(1,"A2",24,{stem:2}).addNote(1,"E3",24).addNote(1,"C4",24).addNote(1,"A2",48,{dotted:!0}).addMeasure().addNavigation(10,2).addNote(0,"A3",48,{dotted:!0,stem:1}).addLabel(1,"Am").addNote(0,"A3",48,{dotted:!0}).addFermata().addNote(1,"A2",24,{stem:2}).addNote(1,"E3",24).addNote(1,"C4",24).addNote(1,"A2",48,{dotted:!0}).getDocument()}function cb(){return new Nr().setScoreConfiguration(4).setHeader("Andante","A. Diabelli").addMeasure().setKeySignature("D","Major").setTimeSignature("3/4").setTempo(80).addRest(0,24,{staffPos:"G4"}).addAnnotation(0,"p").addNote(0,"F#4",24,{stem:1}).addNote(0,"G4",24).addConnective(1,2,3).addNote(0,"F#4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(1,"D3",96,{dotted:!0,stem:2}).addMeasure().addNote(0,"C#4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"G4",48).addNote(1,"A2",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"f").addNote(0,"A3",24).addNote(0,"G#3",24).addConnective(1,2,3).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",24).addNote(1,"A2",96,{dotted:!0}).endRow().addMeasure().addNote(0,"D4",24,{string:3}).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"G4",24).addNote(0,"A4",48).addNote(1,"D3",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"G4"}).addAnnotation(0,"p").addNote(0,"F#4",24).addNote(0,"G4",24).addConnective(1,2,3).addNote(0,"F#4",24).addNote(0,"E4",24).addNote(0,"D4",24).addNote(1,"D3",96,{dotted:!0}).addMeasure().addNote(0,"C#4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"G4",48).addNote(1,"A2",96,{dotted:!0}).endRow().addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"f").addNote(0,"A3",24).addNote(0,"G#3",24).addConnective(1,2,3).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",24).addNote(1,"A2",96,{dotted:!0}).addMeasure().addNote(0,"D4",48).addRest(1,48,{staffPos:"D3"}).addNote(0,"D3",48).addNote(1,"D3",48).addRest(1,48,{staffPos:"B3"}).addNavigation(9).addMeasure().addRest(0,24,{staffPos:"D4"}).addAnnotation(0,"f").addNote(0,"D4",24).addNote(0,"E4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"C#4",24).addNote(0,"B3",24).addNote(1,"E2",96,{dotted:!0}).endRow().addMeasure().addNote(0,"C#4",24).addConnective(1,2,3).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",24).addNote(0,"E4",48).addNote(1,"A2",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"p").addNote(0,"E3",24).addNote(0,"D#3",24).addConnective(1,2,3).addNote(0,"E3",24).addNote(0,"F#3",24).addNote(0,"G#3",24).addNote(1,"E2",96,{dotted:!0}).addMeasure().addNote(0,"A3",24).addConnective(1,2,3).addNote(0,"G#3",24).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",48).addNote(1,"A2",96,{dotted:!0}).endRow().addMeasure().addRest(0,24,{staffPos:"G4"}).addAnnotation(0,"f").addNote(0,"G4",24).addNote(0,"A4",24).addConnective(1,2,3).addNote(0,"G4",24).addNote(0,"F#4",24).addNote(0,"E4",24).addNote(1,"A2",96,{dotted:!0}).addMeasure().addNote(0,"D4",24).addNote(0,"C#4",24).addNote(0,"D4",24).addNote(0,"E4",24).addNote(0,"F#4",48).addNote(1,"D3",96,{dotted:!0}).addMeasure().addRest(0,24,{staffPos:"B3"}).addAnnotation(0,"ff").addNote(0,"A3",24).addNote(0,"G#3",24).addConnective(1,2,3).addNote(0,"A3",24).addNote(0,"B3",24).addNote(0,"C#4",24).addNote(1,"A2",96,{dotted:!0}).addMeasure().addNote(0,"D4",48).addRest(1,48,{staffPos:"D3"}).addNote(0,"D3",48).addNote(1,"D3",48).addRest(1,48,{staffPos:"B3"}).endSong().getDocument()}return Tm(ub);})();
|
|
211
211
|
/*! Bundled license information:
|
|
212
212
|
|
|
213
213
|
tone/build/esm/core/Tone.js:
|