UNPKG

mercury-lang

Version:

Parser for the mercury live coding language

1 lines 2.05 MB
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MercuryParser=e()}}((function(){var define,module,exports;return function e(n,t,r){function i(a,c){if(!t[a]){if(!n[a]){var o="function"==typeof require&&require;if(!c&&o)return o(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var d=t[a]={exports:{}};n[a][0].call(d.exports,(function(e){return i(n[a][1][e]||e)}),d,d.exports,e,n,t,r)}return t[a].exports}for(var s="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,n,t){n.exports={new:["make"],ring:["list","array"],set:["apply","give"],amp:["amplitude","gain","vol","volume","vel","velocity"],beat:["rhythm","play"],env:["envelope","shape","transient","length","duration","dur"],note:["pitch"],time:["timing","interval"],offset:["position","start","startAt","from"],pan:["panning","spat","location"],slide:["portamento","glide","porta"],speed:["rate","playback"],sub:["deep","low"],super:["fat","unison"],add_fx:["fx","withFX","addFX","effect","cc","change"],res:["resonance","reson"],stretch:["beatstretch","loop"],wave2:["osc2","add_osc"],noise:["add_noise","with_noise"],group:["aux","bus"],name:["id"],address:["tag","url"],out:["channel","output","outlet"],clock:["sync","clockSync","midiClock","midiSync"],poly:["chords","polyphonic"],program:["programChange","pgm","pc"],tempo:["bpm"],signature:["timeSignature","timeSig","measure"],randomSeed:["seed"],lowPass:["lowpass","lopass","loPass","highCut","hiCut"],highPass:["highpass","hipass","hiPass","lowCut","loCut"],silence:["mute","killAll","hush"]}},{}],2:[function(e,n,t){const r={empty:{object:"",type:"",functions:{group:[],time:["1/1",0],beat:[1,-1],env:[1,250],amp:[1],add_fx:[],note:[0,0]}}},i={synth:{type:"saw",functions:{amp:[.7],wave2:["saw",0],pan:[0]}},polySynth:{type:"saw",functions:{amp:[.7],wave2:["saw",0],pan:[0]}},sample:{type:"kick_909",functions:{env:[-1],amp:[.9],stretch:[0,1,1],speed:[1],note:["off"],tune:[60],pan:[0]}},polySample:{type:"kick_909",functions:{note:[0,2]}},loop:{type:"amen",functions:{env:[-1],amp:[.9],stretch:[1,1,1],speed:[1],note:["off"],tune:[60],pan:[0]}},midi:{type:"default",functions:{env:[250],out:[1],chord:"off",sync:"off"}},input:{type:"default",functions:{env:[-1],amp:[.9],note:["off"],pan:[0]}}};function s(e){return e&&"object"==typeof e&&!Array.isArray(e)}function a(e,...n){if(!n.length)return e;const t=n.shift();if(s(e)&&s(t))for(const n in t)s(t[n])?(e[n]||Object.assign(e,{[n]:{}}),a(e[n],t[n])):Object.assign(e,{[n]:t[n]});return a(e,...n)}Object.keys(i).forEach((e=>{let n=JSON.parse(JSON.stringify(r.empty));i[e]=a(n,i[e])})),Object.assign(i,r),n.exports={instrumentDefaults:i}},{}],3:[function(e,n,t){const r=e("./src/mercuryParser.js").mercuryParser;n.exports=r},{"./src/mercuryParser.js":123}],4:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{abcToScientificNotation:()=>g,default:()=>b,distance:()=>z,scientificToAbcNotation:()=>h,tokenize:()=>m,transpose:()=>f}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch-distance"),d=e("@tonaljs/pitch-note"),p=(e,n)=>Array(n+1).join(e),l=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function m(e){const n=l.exec(e);return n?[n[1],n[2],n[3]]:["","",""]}function g(e){const[n,t,r]=m(e);if(""===t)return"";let i=4;for(let e=0;e<r.length;e++)i+=","===r.charAt(e)?-1:1;const s="_"===n[0]?n.replace(/_/g,"b"):"^"===n[0]?n.replace(/\^/g,"#"):"";return t.charCodeAt(0)>96?t.toUpperCase()+s+(i+1):t+s+i}function h(e){const n=(0,d.note)(e);if(n.empty||!n.oct&&0!==n.oct)return"";const{letter:t,acc:r,oct:i}=n;return("b"===r[0]?r.replace(/b/g,"_"):r.replace(/#/g,"^"))+(i>4?t.toLowerCase():t)+(5===i?"":i>4?p("'",i-5):p(",",4-i))}function f(e,n){return h((0,u.transpose)(g(e),n))}function z(e,n){return(0,u.distance)(g(e),g(n))}var b={abcToScientificNotation:g,scientificToAbcNotation:h,tokenize:m,transpose:f,distance:z}},{"@tonaljs/pitch-distance":18,"@tonaljs/pitch-note":20}],5:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{compact:()=>l,permutations:()=>f,range:()=>d,rotate:()=>p,shuffle:()=>h,sortedNoteNames:()=>m,sortedUniqNoteNames:()=>g}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch-note");function d(e,n){return e<n?function(e,n){const t=[];for(;n--;t[n]=n+e);return t}(e,n-e+1):function(e,n){const t=[];for(;n--;t[n]=e-n);return t}(e,e-n+1)}function p(e,n){const t=n.length,r=(e%t+t)%t;return n.slice(r,t).concat(n.slice(0,r))}function l(e){return e.filter((e=>0===e||e))}function m(e){return e.map((e=>(0,u.note)(e))).filter((e=>!e.empty)).sort(((e,n)=>e.height-n.height)).map((e=>e.name))}function g(e){return m(e).filter(((e,n,t)=>0===n||e!==t[n-1]))}function h(e,n=Math.random){let t,r,i=e.length;for(;i;)t=Math.floor(n()*i--),r=e[i],e[i]=e[t],e[t]=r;return e}function f(e){return 0===e.length?[[]]:f(e.slice(1)).reduce(((n,t)=>n.concat(e.map(((n,r)=>{const i=t.slice();return i.splice(r,0,e[0]),i})))),[])}},{"@tonaljs/pitch-note":20}],6:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{default:()=>w,detect:()=>m}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/chord-type"),d=e("@tonaljs/pcset"),p=e("@tonaljs/pitch-note"),l=e=>{const n=e.reduce(((e,n)=>{const t=(0,p.note)(n).chroma;return void 0!==t&&(e[t]=e[t]||(0,p.note)(n).name),e}),{});return e=>n[e]};function m(e,n={}){const t=e.map((e=>(0,p.note)(e).pc)).filter((e=>e));if(0===p.note.length)return[];const r=function(e,n,t){const r=e[0],i=(0,p.note)(r).chroma,s=l(e),a=(0,d.modes)(e,!1),c=[];return a.forEach(((e,a)=>{const o=t.assumePerfectFifth&&function(e){const n=parseInt(e,2);return v(n)?e:(16|n).toString(2)}(e);(0,u.all)().filter((n=>t.assumePerfectFifth&&function(e){const n=parseInt(e.chroma,2);return b(n)&&y(n)&&_(n)}(n)?n.chroma===o:n.chroma===e)).forEach((e=>{const t=e.aliases[0],o=s(a);a!==i?c.push({weight:.5*n,name:`${o}${t}/${r}`}):c.push({weight:1*n,name:`${o}${t}`})}))})),c}(t,1,n);return r.filter((e=>e.weight)).sort(((e,n)=>n.weight-e.weight)).map((e=>e.name))}var g=16,h=40,f=3,z=e=>n=>Boolean(n&e),b=z(384),y=z(g),_=z(f),v=z(h);var w={detect:m}},{"@tonaljs/chord-type":7,"@tonaljs/pcset":17,"@tonaljs/pitch-note":20}],7:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{add:()=>w,addAlias:()=>k,all:()=>y,chordType:()=>h,default:()=>M,entries:()=>_,get:()=>g,keys:()=>b,names:()=>f,removeAll:()=>v,symbols:()=>z}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pcset"),d=[["1P 3M 5P","major","M ^ maj"],["1P 3M 5P 7M","major seventh","maj7 Δ ma7 M7 Maj7 ^7"],["1P 3M 5P 7M 9M","major ninth","maj9 Δ9 ^9"],["1P 3M 5P 7M 9M 13M","major thirteenth","maj13 Maj13 ^13"],["1P 3M 5P 6M","sixth","6 add6 add13 M6"],["1P 3M 5P 6M 9M","sixth added ninth","6add9 6/9 69 M69"],["1P 3M 6m 7M","major seventh flat sixth","M7b6 ^7b6"],["1P 3M 5P 7M 11A","major seventh sharp eleventh","maj#4 Δ#4 Δ#11 M7#11 ^7#11 maj7#11"],["1P 3m 5P","minor","m min -"],["1P 3m 5P 7m","minor seventh","m7 min7 mi7 -7"],["1P 3m 5P 7M","minor/major seventh","m/ma7 m/maj7 mM7 mMaj7 m/M7 -Δ7 mΔ -^7 -maj7"],["1P 3m 5P 6M","minor sixth","m6 -6"],["1P 3m 5P 7m 9M","minor ninth","m9 -9"],["1P 3m 5P 7M 9M","minor/major ninth","mM9 mMaj9 -^9"],["1P 3m 5P 7m 9M 11P","minor eleventh","m11 -11"],["1P 3m 5P 7m 9M 13M","minor thirteenth","m13 -13"],["1P 3m 5d","diminished","dim ° o"],["1P 3m 5d 7d","diminished seventh","dim7 °7 o7"],["1P 3m 5d 7m","half-diminished","m7b5 ø -7b5 h7 h"],["1P 3M 5P 7m","dominant seventh","7 dom"],["1P 3M 5P 7m 9M","dominant ninth","9"],["1P 3M 5P 7m 9M 13M","dominant thirteenth","13"],["1P 3M 5P 7m 11A","lydian dominant seventh","7#11 7#4"],["1P 3M 5P 7m 9m","dominant flat ninth","7b9"],["1P 3M 5P 7m 9A","dominant sharp ninth","7#9"],["1P 3M 7m 9m","altered","alt7"],["1P 4P 5P","suspended fourth","sus4 sus"],["1P 2M 5P","suspended second","sus2"],["1P 4P 5P 7m","suspended fourth seventh","7sus4 7sus"],["1P 5P 7m 9M 11P","eleventh","11"],["1P 4P 5P 7m 9m","suspended fourth flat ninth","b9sus phryg 7b9sus 7b9sus4"],["1P 5P","fifth","5"],["1P 3M 5A","augmented","aug + +5 ^#5"],["1P 3m 5A","minor augmented","m#5 -#5 m+"],["1P 3M 5A 7M","augmented seventh","maj7#5 maj7+5 +maj7 ^7#5"],["1P 3M 5P 7M 9M 11A","major sharp eleventh (lydian)","maj9#11 Δ9#11 ^9#11"],["1P 2M 4P 5P","","sus24 sus4add9"],["1P 3M 5A 7M 9M","","maj9#5 Maj9#5"],["1P 3M 5A 7m","","7#5 +7 7+ 7aug aug7"],["1P 3M 5A 7m 9A","","7#5#9 7#9#5 7alt"],["1P 3M 5A 7m 9M","","9#5 9+"],["1P 3M 5A 7m 9M 11A","","9#5#11"],["1P 3M 5A 7m 9m","","7#5b9 7b9#5"],["1P 3M 5A 7m 9m 11A","","7#5b9#11"],["1P 3M 5A 9A","","+add#9"],["1P 3M 5A 9M","","M#5add9 +add9"],["1P 3M 5P 6M 11A","","M6#11 M6b5 6#11 6b5"],["1P 3M 5P 6M 7M 9M","","M7add13"],["1P 3M 5P 6M 9M 11A","","69#11"],["1P 3m 5P 6M 9M","","m69 -69"],["1P 3M 5P 6m 7m","","7b6"],["1P 3M 5P 7M 9A 11A","","maj7#9#11"],["1P 3M 5P 7M 9M 11A 13M","","M13#11 maj13#11 M13+4 M13#4"],["1P 3M 5P 7M 9m","","M7b9"],["1P 3M 5P 7m 11A 13m","","7#11b13 7b5b13"],["1P 3M 5P 7m 13M","","7add6 67 7add13"],["1P 3M 5P 7m 9A 11A","","7#9#11 7b5#9 7#9b5"],["1P 3M 5P 7m 9A 11A 13M","","13#9#11"],["1P 3M 5P 7m 9A 11A 13m","","7#9#11b13"],["1P 3M 5P 7m 9A 13M","","13#9"],["1P 3M 5P 7m 9A 13m","","7#9b13"],["1P 3M 5P 7m 9M 11A","","9#11 9+4 9#4"],["1P 3M 5P 7m 9M 11A 13M","","13#11 13+4 13#4"],["1P 3M 5P 7m 9M 11A 13m","","9#11b13 9b5b13"],["1P 3M 5P 7m 9m 11A","","7b9#11 7b5b9 7b9b5"],["1P 3M 5P 7m 9m 11A 13M","","13b9#11"],["1P 3M 5P 7m 9m 11A 13m","","7b9b13#11 7b9#11b13 7b5b9b13"],["1P 3M 5P 7m 9m 13M","","13b9"],["1P 3M 5P 7m 9m 13m","","7b9b13"],["1P 3M 5P 7m 9m 9A","","7b9#9"],["1P 3M 5P 9M","","Madd9 2 add9 add2"],["1P 3M 5P 9m","","Maddb9"],["1P 3M 5d","","Mb5"],["1P 3M 5d 6M 7m 9M","","13b5"],["1P 3M 5d 7M","","M7b5"],["1P 3M 5d 7M 9M","","M9b5"],["1P 3M 5d 7m","","7b5"],["1P 3M 5d 7m 9M","","9b5"],["1P 3M 7m","","7no5"],["1P 3M 7m 13m","","7b13"],["1P 3M 7m 9M","","9no5"],["1P 3M 7m 9M 13M","","13no5"],["1P 3M 7m 9M 13m","","9b13"],["1P 3m 4P 5P","","madd4"],["1P 3m 5P 6m 7M","","mMaj7b6"],["1P 3m 5P 6m 7M 9M","","mMaj9b6"],["1P 3m 5P 7m 11P","","m7add11 m7add4"],["1P 3m 5P 9M","","madd9"],["1P 3m 5d 6M 7M","","o7M7"],["1P 3m 5d 7M","","oM7"],["1P 3m 6m 7M","","mb6M7"],["1P 3m 6m 7m","","m7#5"],["1P 3m 6m 7m 9M","","m9#5"],["1P 3m 5A 7m 9M 11P","","m11A"],["1P 3m 6m 9m","","mb6b9"],["1P 2M 3m 5d 7m","","m9b5"],["1P 4P 5A 7M","","M7#5sus4"],["1P 4P 5A 7M 9M","","M9#5sus4"],["1P 4P 5A 7m","","7#5sus4"],["1P 4P 5P 7M","","M7sus4"],["1P 4P 5P 7M 9M","","M9sus4"],["1P 4P 5P 7m 9M","","9sus4 9sus"],["1P 4P 5P 7m 9M 13M","","13sus4 13sus"],["1P 4P 5P 7m 9m 13m","","7sus4b9b13 7b9b13sus4"],["1P 4P 7m 10m","","4 quartal"],["1P 5P 7m 9m 11P","","11b9"]],p={...u.EmptyPcset,name:"",quality:"Unknown",intervals:[],aliases:[]},l=[],m={};function g(e){return m[e]||p}var h=g;function f(){return l.map((e=>e.name)).filter((e=>e))}function z(){return l.map((e=>e.aliases[0])).filter((e=>e))}function b(){return Object.keys(m)}function y(){return l.slice()}var _=y;function v(){l=[],m={}}function w(e,n,t){const r=function(e){const n=n=>-1!==e.indexOf(n);return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}(e),i={...(0,u.get)(e),name:t||"",quality:r,intervals:e,aliases:n};l.push(i),i.name&&(m[i.name]=i),m[i.setNum]=i,m[i.chroma]=i,i.aliases.forEach((e=>k(i,e)))}function k(e,n){m[n]=e}d.forEach((([e,n,t])=>w(e.split(" "),t.split(" "),n))),l.sort(((e,n)=>e.setNum-n.setNum));var M={names:f,symbols:z,get:g,all:y,add:w,removeAll:v,keys:b,entries:_,chordType:h}},{"@tonaljs/pcset":17}],8:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{chord:()=>w,chordScales:()=>M,default:()=>E,degrees:()=>x,detect:()=>f.detect,extended:()=>T,get:()=>_,getChord:()=>v,notes:()=>S,reduced:()=>P,steps:()=>A,tokenize:()=>b,transpose:()=>k}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/chord-detect"),d=e("@tonaljs/chord-type"),p=e("@tonaljs/interval"),l=e("@tonaljs/pcset"),m=e("@tonaljs/pitch-distance"),g=e("@tonaljs/pitch-note"),h=e("@tonaljs/scale-type"),f=e("@tonaljs/chord-detect"),z={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function b(e){const[n,t,r,i]=(0,g.tokenizeNote)(e);return""===n?y("",e):"A"===n&&"ug"===i?y("","aug"):y(n+t,r+i)}function y(e,n){const t=n.split("/");if(1===t.length)return[e,t[0],""];const[r,i,s,a]=(0,g.tokenizeNote)(t[1]);return""!==r&&""===s&&""===a?[e,t[0],r+i]:[e,n,""]}function _(e){if(Array.isArray(e))return v(e[1]||"",e[0],e[2]);if(""===e)return z;{const[n,t,r]=b(e),i=v(t,n,r);return i.empty?v(e):i}}function v(e,n,t){const r=(0,d.get)(e),i=(0,g.note)(n||""),s=(0,g.note)(t||"");if(r.empty||n&&i.empty||t&&s.empty)return z;const a=(0,m.distance)(i.pc,s.pc),c=r.intervals.indexOf(a),o=c>=0,u=o?s:(0,g.note)(""),l=-1===c?NaN:c+1,h=s.pc&&s.pc!==i.pc,f=Array.from(r.intervals);if(o)for(let e=1;e<l;e++){const e=f[0][0],n=f[0][1],t=parseInt(e,10)+7;f.push(`${t}${n}`),f.shift()}else if(h){const e=(0,p.subtract)((0,m.distance)(i.pc,s.pc),"8P");e&&f.unshift(e)}const b=i.empty?[]:f.map((e=>(0,m.transpose)(i.pc,e)));e=-1!==r.aliases.indexOf(e)?e:r.aliases[0];const y=`${i.empty?"":i.pc}${e}${o&&l>1?"/"+u.pc:h?"/"+s.pc:""}`,_=`${n?i.pc+" ":""}${r.name}${o&&l>1?" over "+u.pc:h?" over "+s.pc:""}`;return{...r,name:_,symbol:y,tonic:i.pc,type:r.name,root:u.pc,bass:h?s.pc:"",intervals:f,rootDegree:l,notes:b}}var w=_;function k(e,n){const[t,r,i]=b(e);if(!t)return e;const s=(0,m.transpose)(i,n),a=s?"/"+s:"";return(0,m.transpose)(t,n)+r+a}function M(e){const n=_(e),t=(0,l.isSupersetOf)(n.chroma);return(0,h.all)().filter((e=>t(e.chroma))).map((e=>e.name))}function T(e){const n=_(e),t=(0,l.isSupersetOf)(n.chroma);return(0,d.all)().filter((e=>t(e.chroma))).map((e=>n.tonic+e.aliases[0]))}function P(e){const n=_(e),t=(0,l.isSubsetOf)(n.chroma);return(0,d.all)().filter((e=>t(e.chroma))).map((e=>n.tonic+e.aliases[0]))}function S(e,n){const t=_(e),r=n||t.tonic;return!r||t.empty?[]:t.intervals.map((e=>(0,m.transpose)(r,e)))}function x(e,n){const t=_(e),r=n||t.tonic,i=(0,m.tonicIntervalsTransposer)(t.intervals,r);return e=>e?i(e>0?e-1:e):""}function A(e,n){const t=_(e),r=n||t.tonic;return(0,m.tonicIntervalsTransposer)(t.intervals,r)}var E={getChord:v,get:_,detect:u.detect,chordScales:M,extended:T,reduced:P,tokenize:b,transpose:k,degrees:x,steps:A,notes:S,chord:w}},{"@tonaljs/chord-detect":6,"@tonaljs/chord-type":7,"@tonaljs/interval":12,"@tonaljs/pcset":17,"@tonaljs/pitch-distance":18,"@tonaljs/pitch-note":20,"@tonaljs/scale-type":26}],9:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};function u(e,n){return e<n?function(e,n){const t=[];for(;n--;t[n]=n+e);return t}(e,n-e+1):function(e,n){const t=[];for(;n--;t[n]=e-n);return t}(e,e-n+1)}function d(e,n){const t=n.length,r=(e%t+t)%t;return n.slice(r,t).concat(n.slice(0,r))}function p(e){return e.filter((e=>0===e||e))}function l(e,n=Math.random){let t,r,i=e.length;for(;i;)t=Math.floor(n()*i--),r=e[i],e[i]=e[t],e[t]=r;return e}function m(e){return 0===e.length?[[]]:m(e.slice(1)).reduce(((n,t)=>n.concat(e.map(((n,r)=>{const i=t.slice();return i.splice(r,0,e[0]),i})))),[])}((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{compact:()=>p,default:()=>g,permutations:()=>m,range:()=>u,rotate:()=>d,shuffle:()=>l}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var g={compact:p,permutations:m,range:u,rotate:d,shuffle:l}},{}],10:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o=(e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e},u=(e,n,t)=>(o(e,n,"default"),t&&o(t,n,"default")),d={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(d,{deprecate:()=>m,fillStr:()=>l,isNamed:()=>g}),n.exports=(r=d,o(i({},"__esModule",{value:!0}),r));var p=e("@tonaljs/pitch");u(d,e("@tonaljs/pitch"),n.exports),u(d,e("@tonaljs/pitch-distance"),n.exports),u(d,e("@tonaljs/pitch-interval"),n.exports),u(d,e("@tonaljs/pitch-note"),n.exports);var l=(e,n)=>Array(Math.abs(n)+1).join(e);function m(e,n,t){return function(...r){return console.warn(`${e} is deprecated. Use ${n}.`),t.apply(this,r)}}var g=m("isNamed","isNamedPitch",p.isNamedPitch)},{"@tonaljs/pitch":21,"@tonaljs/pitch-distance":18,"@tonaljs/pitch-interval":19,"@tonaljs/pitch-note":20}],11:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{default:()=>z,fraction:()=>f,get:()=>g,names:()=>p,shorthands:()=>l,value:()=>h}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=[];[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]].forEach((([e,n,t])=>function(e,n,t){u.push({empty:!1,dots:"",name:"",value:1/e,fraction:e<1?[1/e,1]:[1,e],shorthand:n,names:t})}(e,n,t)));var d={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function p(){return u.reduce(((e,n)=>(n.names.forEach((n=>e.push(n))),e)),[])}function l(){return u.map((e=>e.shorthand))}var m=/^([^.]+)(\.*)$/;function g(e){const[n,t,r]=m.exec(e)||[],i=u.find((e=>e.shorthand===t||e.names.includes(t)));if(!i)return d;const s=function(e,n){const t=Math.pow(2,n);let r=e[0]*t,i=e[1]*t;const s=r;for(let e=0;e<n;e++)r+=s/Math.pow(2,e+1);for(;r%2==0&&i%2==0;)r/=2,i/=2;return[r,i]}(i.fraction,r.length),a=s[0]/s[1];return{...i,name:e,dots:r,value:a,fraction:s}}var h=e=>g(e).value,f=e=>g(e).fraction,z={names:p,shorthands:l,get:g,value:h,fraction:f}},{}],12:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{add:()=>k,addTo:()=>M,default:()=>S,distance:()=>w,fromSemitones:()=>v,get:()=>l,invert:()=>b,name:()=>m,names:()=>p,num:()=>f,quality:()=>h,semitones:()=>g,simplify:()=>z,subtract:()=>T,transposeFifths:()=>P}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch-distance"),d=e("@tonaljs/pitch-interval");function p(){return"1P 2M 3M 4P 5P 6m 7m".split(" ")}var l=d.interval,m=e=>(0,d.interval)(e).name,g=e=>(0,d.interval)(e).semitones,h=e=>(0,d.interval)(e).q,f=e=>(0,d.interval)(e).num;function z(e){const n=(0,d.interval)(e);return n.empty?"":n.simple+n.q}function b(e){const n=(0,d.interval)(e);if(n.empty)return"";const t=(7-n.step)%7,r="perfectable"===n.type?-n.alt:-(n.alt+1);return(0,d.interval)({step:t,alt:r,oct:n.oct,dir:n.dir}).name}var y=[1,2,2,3,3,4,5,5,6,6,7,7],_="P m M m M P d P m M m M".split(" ");function v(e){const n=e<0?-1:1,t=Math.abs(e),r=t%12,i=Math.floor(t/12);return n*(y[r]+7*i)+_[r]}var w=u.distance,k=x(((e,n)=>[e[0]+n[0],e[1]+n[1]])),M=e=>n=>k(e,n),T=x(((e,n)=>[e[0]-n[0],e[1]-n[1]]));function P(e,n){const t=l(e);if(t.empty)return"";const[r,i,s]=t.coord;return(0,d.coordToInterval)([r+n,i,s]).name}var S={names:p,get:l,name:m,num:f,semitones:g,quality:h,fromSemitones:v,distance:w,invert:b,simplify:z,add:k,addTo:M,subtract:T,transposeFifths:P};function x(e){return(n,t)=>{const r=(0,d.interval)(n).coord,i=(0,d.interval)(t).coord;if(r&&i){const n=e(r,i);return(0,d.coordToInterval)(n).name}}}},{"@tonaljs/pitch-distance":18,"@tonaljs/pitch-interval":19}],13:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{default:()=>j,majorKey:()=>T,majorKeyChords:()=>P,majorTonicFromKeySignature:()=>E,minorKey:()=>A,minorKeyChords:()=>S}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/note"),d=e("@tonaljs/pitch-note"),p=e("@tonaljs/roman-numeral"),l=Object.freeze([]),m={type:"major",tonic:"",alteration:0,keySignature:""},g={tonic:"",grades:l,intervals:l,scale:l,triads:l,chords:l,chordsHarmonicFunction:l,chordScales:l,secondaryDominants:l,secondaryDominantSupertonics:l,substituteDominantsMinorRelative:l,substituteDominants:l,substituteDominantSupertonics:l,secondaryDominantsMinorRelative:l},h={...m,...g,type:"major",minorRelative:"",scale:l,substituteDominants:l,secondaryDominantSupertonics:l,substituteDominantsMinorRelative:l},f={...m,type:"minor",relativeMajor:"",natural:g,harmonic:g,melodic:g},z=(e,n,t="")=>n.map(((n,r)=>`${e[r]}${t}${n}`));function b(e,n,t,r,i){return s=>{const a=e.map((e=>(0,p.get)(e).interval||"")),c=a.map((e=>(0,u.transpose)(s,e))),o=z(c,t),d=c.map((e=>(0,u.transpose)(e,"5P"))).map((e=>c.includes(e)&&!o.includes(e+"7")?e+"7":"")),l=y(d,n),m=d.map((e=>{if(!e)return"";const n=e.slice(0,-1);return(0,u.transpose)(n,"5d")+"7"})),g=y(m,n);return{tonic:s,grades:e,intervals:a,scale:c,triads:z(c,n),chords:o,chordsHarmonicFunction:r.slice(),chordScales:z(c,i," "),secondaryDominants:d,secondaryDominantSupertonics:l,substituteDominants:m,substituteDominantSupertonics:g,secondaryDominantsMinorRelative:l,substituteDominantsMinorRelative:g}}}var y=(e,n)=>e.map(((e,t)=>{if(!e)return"";const r=e.slice(0,-1),i=(0,u.transpose)(r,"5P");return n[t].endsWith("m")?i+"m7":i+"m7b5"})),_=(e,n)=>{const t=(0,d.note)(e),r=(0,d.note)(n);return t.empty||r.empty?0:r.coord[0]-t.coord[0]},v=b("I II III IV V VI VII".split(" ")," m m m dim".split(" "),"maj7 m7 m7 maj7 7 m7 m7b5".split(" "),"T SD T SD D T D".split(" "),"major,dorian,phrygian,lydian,mixolydian,minor,locrian".split(",")),w=b("I II bIII IV V bVI bVII".split(" "),"m dim m m ".split(" "),"m7 m7b5 maj7 m7 m7 maj7 7".split(" "),"T SD T SD D SD SD".split(" "),"minor,locrian,major,dorian,phrygian,lydian,mixolydian".split(",")),k=b("I II bIII IV V bVI VII".split(" "),"m dim aug m dim".split(" "),"mMaj7 m7b5 +maj7 m7 7 maj7 o7".split(" "),"T SD T SD D SD D".split(" "),"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian".split(",")),M=b("I II bIII IV V VI VII".split(" "),"m m aug dim dim".split(" "),"m6 m7 +maj7 7 7 m7b5 m7b5".split(" "),"T SD T SD D ".split(" "),"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered".split(","));function T(e){const n=(0,d.note)(e).pc;if(!n)return h;const t=v(n),r=_("C",n);return{...t,type:"major",minorRelative:(0,u.transpose)(n,"-3m"),alteration:r,keySignature:(0,d.altToAcc)(r)}}function P(e){const n=[];return x(T(e),n),n}function S(e){const n=A(e),t=[];return x(n.natural,t),x(n.harmonic,t),x(n.melodic,t),t}function x(e,n){const t=(e,t)=>{if(!e)return;let r=n.find((n=>n.name===e));r||(r={name:e,roles:[]},n.push(r)),t&&!r.roles.includes(t)&&r.roles.push(t)};e.chords.forEach(((n,r)=>t(n,e.chordsHarmonicFunction[r]))),e.secondaryDominants.forEach(((n,r)=>t(n,`V/${e.grades[r]}`))),e.secondaryDominantSupertonics.forEach(((n,r)=>t(n,`ii/${e.grades[r]}`))),e.substituteDominants.forEach(((n,r)=>t(n,`subV/${e.grades[r]}`))),e.substituteDominantSupertonics.forEach(((n,r)=>t(n,`subii/${e.grades[r]}`)))}function A(e){const n=(0,d.note)(e).pc;if(!n)return f;const t=_("C",n)-3;return{type:"minor",tonic:n,relativeMajor:(0,u.transpose)(n,"3m"),alteration:t,keySignature:(0,d.altToAcc)(t),natural:w(n),harmonic:k(n),melodic:M(n)}}function E(e){return"number"==typeof e?(0,u.transposeFifths)("C",e):"string"==typeof e&&/^b+|#+$/.test(e)?(0,u.transposeFifths)("C",(0,d.accToAlt)(e)):null}var j={majorKey:T,majorTonicFromKeySignature:E,minorKey:A}},{"@tonaljs/note":16,"@tonaljs/pitch-note":20,"@tonaljs/roman-numeral":25}],14:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{chroma:()=>y,default:()=>M,freqToMidi:()=>h,isMidi:()=>d,midiToFreq:()=>l,midiToNoteName:()=>b,pcset:()=>_,pcsetDegrees:()=>k,pcsetNearest:()=>v,pcsetSteps:()=>w,toMidi:()=>p}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch-note");function d(e){return+e>=0&&+e<=127}function p(e){if(d(e))return+e;const n=(0,u.note)(e);return n.empty?null:n.midi}function l(e,n=440){return Math.pow(2,(e-69)/12)*n}var m=Math.log(2),g=Math.log(440);function h(e){const n=12*(Math.log(e)-g)/m+69;return Math.round(100*n)/100}var f="C C# D D# E F F# G G# A A# B".split(" "),z="C Db D Eb E F Gb G Ab A Bb B".split(" ");function b(e,n={}){if(isNaN(e)||e===-1/0||e===1/0)return"";e=Math.round(e);const t=(!0===n.sharps?f:z)[e%12];if(n.pitchClass)return t;return t+(Math.floor(e/12)-1)}function y(e){return e%12}function _(e){return Array.isArray(e)?e.map(y).sort(((e,n)=>e-n)).filter(((e,n,t)=>0===n||e!==t[n-1])):e.split("").reduce(((e,n,t)=>(t<12&&"1"===n&&e.push(t),e)),[])}function v(e){const n=_(e);return e=>{const t=y(e);for(let r=0;r<12;r++){if(n.includes(t+r))return e+r;if(n.includes(t-r))return e-r}}}function w(e,n){const t=_(e),r=t.length;return e=>{const i=e<0?(r- -e%r)%r:e%r,s=Math.floor(e/r);return t[i]+12*s+n}}function k(e,n){const t=w(e,n);return e=>{if(0!==e)return t(e>0?e-1:e)}}var M={chroma:y,freqToMidi:h,isMidi:d,midiToFreq:l,midiToNoteName:b,pcsetNearest:v,pcset:_,pcsetDegrees:k,pcsetSteps:w,toMidi:p}},{"@tonaljs/pitch-note":20}],15:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{all:()=>_,default:()=>A,distance:()=>S,entries:()=>v,get:()=>b,mode:()=>y,names:()=>w,notes:()=>k,relativeTonic:()=>x,seventhChords:()=>P,triads:()=>T}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/collection"),d=e("@tonaljs/interval"),p=e("@tonaljs/pcset"),l=e("@tonaljs/pitch-distance"),m=e("@tonaljs/scale-type"),g=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],h={...p.EmptyPcset,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},f=g.map((function(e){const[n,t,r,i,s,a,c]=e,o=c?[c]:[],u=Number(t).toString(2);return{empty:!1,intervals:(0,m.get)(i).intervals,modeNum:n,chroma:u,normalized:u,name:i,setNum:t,alt:r,triad:s,seventh:a,aliases:o}})),z={};function b(e){return"string"==typeof e?z[e.toLowerCase()]||h:e&&e.name?b(e.name):h}f.forEach((e=>{z[e.name]=e,e.aliases.forEach((n=>{z[n]=e}))}));var y=b;function _(){return f.slice()}var v=_;function w(){return f.map((e=>e.name))}function k(e,n){return b(e).intervals.map((e=>(0,l.transpose)(n,e)))}function M(e){return(n,t)=>{const r=b(n);if(r.empty)return[];const i=(0,u.rotate)(r.modeNum,e),s=r.intervals.map((e=>(0,l.transpose)(t,e)));return i.map(((e,n)=>s[n]+e))}}var T=M(g.map((e=>e[4]))),P=M(g.map((e=>e[5])));function S(e,n){const t=b(n),r=b(e);return t.empty||r.empty?"":(0,d.simplify)((0,d.transposeFifths)("1P",r.alt-t.alt))}function x(e,n,t){return(0,l.transpose)(t,S(e,n))}var A={get:b,names:w,all:_,distance:S,relativeTonic:x,notes:k,triads:T,seventhChords:P,entries:v,mode:y}},{"@tonaljs/collection":9,"@tonaljs/interval":12,"@tonaljs/pcset":17,"@tonaljs/pitch-distance":18,"@tonaljs/scale-type":26}],16:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{accidentals:()=>y,ascending:()=>q,chroma:()=>k,default:()=>J,descending:()=>F,distance:()=>x,enharmonic:()=>L,freq:()=>w,fromFreq:()=>T,fromFreqSharps:()=>P,fromMidi:()=>M,fromMidiSharps:()=>S,get:()=>f,midi:()=>v,name:()=>z,names:()=>h,octave:()=>_,pitchClass:()=>b,simplify:()=>N,sortedNames:()=>I,sortedUniqNames:()=>R,tr:()=>E,trBy:()=>C,trFifths:()=>O,trFrom:()=>B,transpose:()=>A,transposeBy:()=>j,transposeFifths:()=>H,transposeFrom:()=>D,transposeOctaves:()=>G}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/midi"),d=e("@tonaljs/pitch-distance"),p=e("@tonaljs/pitch-note"),l=["C","D","E","F","G","A","B"],m=e=>e.name,g=e=>e.map(p.note).filter((e=>!e.empty));function h(e){return void 0===e?l.slice():Array.isArray(e)?g(e).map(m):[]}var f=p.note,z=e=>f(e).name,b=e=>f(e).pc,y=e=>f(e).acc,_=e=>f(e).oct,v=e=>f(e).midi,w=e=>f(e).freq,k=e=>f(e).chroma;function M(e){return(0,u.midiToNoteName)(e)}function T(e){return(0,u.midiToNoteName)((0,u.freqToMidi)(e))}function P(e){return(0,u.midiToNoteName)((0,u.freqToMidi)(e),{sharps:!0})}function S(e){return(0,u.midiToNoteName)(e,{sharps:!0})}var x=d.distance,A=d.transpose,E=d.transpose,j=e=>n=>A(n,e),C=j,D=e=>n=>A(e,n),B=D;function H(e,n){return A(e,[n,0])}var O=H;function G(e,n){return A(e,[0,n])}var q=(e,n)=>e.height-n.height,F=(e,n)=>n.height-e.height;function I(e,n){return n=n||q,g(e).sort(n).map(m)}function R(e){return I(e,q).filter(((e,n,t)=>0===n||e!==t[n-1]))}var N=e=>{const n=f(e);return n.empty?"":(0,u.midiToNoteName)(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:null===n.midi})};function L(e,n){const t=f(e);if(t.empty)return"";const r=f(n||(0,u.midiToNoteName)(t.midi||t.chroma,{sharps:t.alt<0,pitchClass:!0}));if(r.empty||r.chroma!==t.chroma)return"";if(void 0===t.oct)return r.pc;const i=t.chroma-t.alt,s=r.chroma-r.alt,a=i>11||s<0?-1:i<0||s>11?1:0,c=t.oct+a;return r.pc+c}var J={names:h,get:f,name:z,pitchClass:b,accidentals:y,octave:_,midi:v,ascending:q,descending:F,distance:x,sortedNames:I,sortedUniqNames:R,fromMidi:M,fromMidiSharps:S,freq:w,fromFreq:T,fromFreqSharps:P,chroma:k,transpose:A,tr:E,transposeBy:j,trBy:j,transposeFrom:D,trFrom:D,transposeFifths:H,transposeOctaves:G,trFifths:H,simplify:N,enharmonic:L}},{"@tonaljs/midi":14,"@tonaljs/pitch-distance":18,"@tonaljs/pitch-note":20}],17:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{EmptyPcset:()=>m,chroma:()=>k,chromas:()=>x,default:()=>O,filter:()=>H,get:()=>v,includes:()=>B,intervals:()=>M,isChroma:()=>z,isEqual:()=>E,isNoteIncludedIn:()=>D,isSubsetOf:()=>j,isSupersetOf:()=>C,modes:()=>A,notes:()=>S,num:()=>T,pcset:()=>w}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/collection"),d=e("@tonaljs/pitch-distance"),p=e("@tonaljs/pitch-interval"),l=e("@tonaljs/pitch-note"),m={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},g=e=>Number(e).toString(2).padStart(12,"0"),h=e=>parseInt(e,2),f=/^[01]{12}$/;function z(e){return f.test(e)}var b=e=>"number"==typeof e&&e>=0&&e<=4095,y=e=>e&&z(e.chroma),_={[m.chroma]:m};function v(e){const n=z(e)?e:b(e)?g(e):Array.isArray(e)?function(e){if(0===e.length)return m.chroma;let n;const t=[0,0,0,0,0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++)n=(0,l.note)(e[r]),n.empty&&(n=(0,p.interval)(e[r])),n.empty||(t[n.chroma]=1);return t.join("")}(e):y(e)?e.chroma:m.chroma;return _[n]=_[n]||function(e){const n=h(e),t=function(e){const n=e.split("");return n.map(((e,t)=>(0,u.rotate)(t,n).join("")))}(e).map(h).filter((e=>e>=2048)).sort()[0],r=g(t),i=function(e){const n=[];for(let t=0;t<12;t++)"1"===e.charAt(t)&&n.push(P[t]);return n}(e);return{empty:!1,name:"",setNum:n,chroma:e,normalized:r,intervals:i}}(n)}var w=v,k=e=>v(e).chroma,M=e=>v(e).intervals,T=e=>v(e).setNum,P=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function S(e){return v(e).intervals.map((e=>(0,d.transpose)("C",e)))}function x(){return(0,u.range)(2048,4095).map(g)}function A(e,n=!0){const t=v(e).chroma.split("");return(0,u.compact)(t.map(((e,r)=>{const i=(0,u.rotate)(r,t);return n&&"0"===i[0]?null:i.join("")})))}function E(e,n){return v(e).setNum===v(n).setNum}function j(e){const n=v(e).setNum;return e=>{const t=v(e).setNum;return n&&n!==t&&(t&n)===t}}function C(e){const n=v(e).setNum;return e=>{const t=v(e).setNum;return n&&n!==t&&(t|n)===t}}function D(e){const n=v(e);return e=>{const t=(0,l.note)(e);return n&&!t.empty&&"1"===n.chroma.charAt(t.chroma)}}var B=D;function H(e){const n=D(e);return e=>e.filter(n)}var O={get:v,chroma:k,num:T,intervals:M,chromas:x,isSupersetOf:C,isSubsetOf:j,isNoteIncludedIn:D,isEqual:E,filter:H,modes:A,notes:S,pcset:v}},{"@tonaljs/collection":9,"@tonaljs/pitch-distance":18,"@tonaljs/pitch-interval":19,"@tonaljs/pitch-note":20}],18:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{distance:()=>m,tonicIntervalsTransposer:()=>l,transpose:()=>p}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch-interval"),d=e("@tonaljs/pitch-note");function p(e,n){const t=(0,d.note)(e),r=Array.isArray(n)?n:(0,u.interval)(n).coord;if(t.empty||!r||r.length<2)return"";const i=t.coord,s=1===i.length?[i[0]+r[0]]:[i[0]+r[0],i[1]+r[1]];return(0,d.coordToNote)(s).name}function l(e,n){const t=e.length;return r=>{if(!n)return"";const i=r<0?(t- -r%t)%t:r%t,s=Math.floor(r/t),a=p(n,[0,s]);return p(a,e[i])}}function m(e,n){const t=(0,d.note)(e),r=(0,d.note)(n);if(t.empty||r.empty)return"";const i=t.coord,s=r.coord,a=s[0]-i[0],c=2===i.length&&2===s.length?s[1]-i[1]:-Math.floor(7*a/12),o=r.height===t.height&&null!==r.midi&&t.oct===r.oct&&t.step>r.step;return(0,u.coordToInterval)([a,c],o).name}},{"@tonaljs/pitch-interval":19,"@tonaljs/pitch-note":20}],19:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{coordToInterval:()=>b,interval:()=>h,tokenizeInterval:()=>m}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch"),d=(e,n)=>Array(Math.abs(n)+1).join(e),p=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),l=new RegExp("^([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})|(AA|A|P|M|m|d|dd)([-+]?\\d+)$");function m(e){const n=l.exec(`${e}`);return null===n?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var g={};function h(e){return"string"==typeof e?g[e]||(g[e]=function(e){const n=m(e);if(""===n[0])return p;const t=+n[0],r=n[1],i=(Math.abs(t)-1)%7,s=z[i];if("M"===s&&"P"===r)return p;const a="M"===s?"majorable":"perfectable",c=""+t+r,o=t<0?-1:1,d=8===t||-8===t?t:o*(i+1),l=function(e,n){return"M"===n&&"majorable"===e||"P"===n&&"perfectable"===e?0:"m"===n&&"majorable"===e?-1:/^A+$/.test(n)?n.length:/^d+$/.test(n)?-1*("perfectable"===e?n.length:n.length+1):0}(a,r),g=Math.floor((Math.abs(t)-1)/7),h=o*(f[i]+l+12*g),b=(o*(f[i]+l)%12+12)%12,y=(0,u.coordinates)({step:i,alt:l,oct:g,dir:o});return{empty:!1,name:c,num:t,q:r,step:i,alt:l,dir:o,type:a,simple:d,semitones:h,chroma:b,coord:y,oct:g}}(e)):(0,u.isPitch)(e)?h(function(e){const{step:n,alt:t,oct:r=0,dir:i}=e;if(!i)return"";const s=n+1+7*r,a=0===s?n+1:s,c=i<0?"-":"",o="M"===z[n]?"majorable":"perfectable";return c+a+function(e,n){return 0===n?"majorable"===e?"M":"P":-1===n&&"majorable"===e?"m":n>0?d("A",n):d("d","perfectable"===e?n:n+1)}(o,t)}(e)):(0,u.isNamedPitch)(e)?h(e.name):p}var f=[0,2,4,5,7,9,11],z="PMMPPMM";function b(e,n){const[t,r=0]=e,i=n||7*t+12*r<0?[-t,-r,-1]:[t,r,1];return h((0,u.pitch)(i))}},{"@tonaljs/pitch":21}],20:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{accToAlt:()=>h,altToAcc:()=>g,coordToNote:()=>y,note:()=>f,stepToLetter:()=>m,tokenizeNote:()=>b}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch"),d=(e,n)=>Array(Math.abs(n)+1).join(e),p=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),l=new Map,m=e=>"CDEFGAB".charAt(e),g=e=>e<0?d("b",-e):d("#",e),h=e=>"b"===e[0]?-e.length:e.length;function f(e){const n=JSON.stringify(e),t=l.get(n);if(t)return t;const r="string"==typeof e?function(e){const n=b(e);if(""===n[0]||""!==n[3])return p;const t=n[0],r=n[1],i=n[2],s=(t.charCodeAt(0)+3)%7,a=h(r),c=i.length?+i:void 0,o=(0,u.coordinates)({step:s,alt:a,oct:c}),d=t+r+i,l=t+r,m=(v[s]+a+120)%12,g=void 0===c?_(v[s]+a,12)-1188:v[s]+a+12*(c+1),f=g>=0&&g<=127?g:null,z=void 0===c?null:440*Math.pow(2,(g-69)/12);return{empty:!1,acc:r,alt:a,chroma:m,coord:o,freq:z,height:g,letter:t,midi:f,name:d,oct:c,pc:l,step:s}}(e):(0,u.isPitch)(e)?f(function(e){const{step:n,alt:t,oct:r}=e,i=m(n);if(!i)return"";const s=i+g(t);return r||0===r?s+r:s}(e)):(0,u.isNamedPitch)(e)?f(e.name):p;return l.set(n,r),r}var z=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function b(e){const n=z.exec(e);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function y(e){return f((0,u.pitch)(e))}var _=(e,n)=>(e%n+n)%n,v=[0,2,4,5,7,9,11]},{"@tonaljs/pitch":21}],21:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};function u(e){return null!==e&&"object"==typeof e&&"name"in e&&"string"==typeof e.name}((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{chroma:()=>p,coordinates:()=>z,height:()=>l,isNamedPitch:()=>u,isPitch:()=>g,midi:()=>m,pitch:()=>y}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var d=[0,2,4,5,7,9,11],p=({step:e,alt:n})=>(d[e]+n+120)%12,l=({step:e,alt:n,oct:t,dir:r=1})=>r*(d[e]+n+12*(void 0===t?-100:t)),m=e=>{const n=l(e);return void 0!==e.oct&&n>=-12&&n<=115?n+12:null};function g(e){return null!==e&&"object"==typeof e&&"step"in e&&"number"==typeof e.step&&"alt"in e&&"number"==typeof e.alt&&!isNaN(e.step)&&!isNaN(e.alt)}var h=[0,2,4,-1,1,3,5],f=h.map((e=>Math.floor(7*e/12)));function z(e){const{step:n,alt:t,oct:r,dir:i=1}=e,s=h[n]+7*t;if(void 0===r)return[i*s];return[i*s,i*(r-f[n]-4*t)]}var b=[3,0,4,1,5,2,6];function y(e){const[n,t,r]=e,i=b[function(e){const n=(e+1)%7;return n<0?7+n:n}(n)],s=Math.floor((n+1)/7);if(void 0===t)return{step:i,alt:s,dir:r};return{step:i,alt:s,oct:t+4*s+f[i],dir:r}}},{}],22:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{default:()=>h,fromRomanNumerals:()=>m,toRomanNumerals:()=>g}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/chord"),d=e("@tonaljs/pitch-distance"),p=e("@tonaljs/pitch-interval"),l=e("@tonaljs/roman-numeral");function m(e,n){return n.map(l.get).map((n=>(0,d.transpose)(e,(0,p.interval)(n))+n.chordType))}function g(e,n){return n.map((n=>{const[t,r]=(0,u.tokenize)(n),i=(0,d.distance)(e,t);return(0,l.get)((0,p.interval)(i)).name+r}))}var h={fromRomanNumerals:m,toRomanNumerals:g}},{"@tonaljs/chord":8,"@tonaljs/pitch-distance":18,"@tonaljs/pitch-interval":19,"@tonaljs/roman-numeral":25}],23:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{chromatic:()=>l,default:()=>m,numeric:()=>p}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/collection"),d=e("@tonaljs/midi");function p(e){const n=(0,u.compact)(e.map((e=>"number"==typeof e?e:(0,d.toMidi)(e))));return e.length&&n.length===e.length?n.reduce(((e,n)=>{const t=e[e.length-1];return e.concat((0,u.range)(t,n).slice(1))}),[n[0]]):[]}function l(e,n){return p(e).map((e=>(0,d.midiToNoteName)(e,n)))}var m={numeric:p,chromatic:l}},{"@tonaljs/collection":9,"@tonaljs/midi":14}],24:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};function u(...e){return e.reduce(((e,n)=>(n.toString(2).split("").forEach((n=>{e.push(parseInt(n))})),e)),[])}function d(e){const n=[];for(let t=0;t<e.length;t++){const r=parseInt("0x"+e[t]);(isNaN(r)?"0000":r.toString(2).padStart(4,"0")).split("").forEach((e=>{n.push("1"===e?1:0)}))}return n}function p(...e){return e.reduce(((e,n)=>{e.push(1);for(let t=0;t<n;t++)e.push(0);return e}),[])}function l(e,n=.5,t=Math.random){const r=[];for(let i=0;i<e;i++)r.push(t()>=n?1:0);return r}function m(e,n=Math.random){return e.map((e=>n()<=e?1:0))}function g(e,n){const t=e.length,r=[];for(let i=0;i<t;i++){const s=((i-n)%t+t)%t;r[i]=e[s]}return r}function h(e,n){const t=[];let r=-1;for(let i=0;i<e;i++){const s=Math.floor(i*(n/e));t[i]=s!==r?1:0,r=s}return t}((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{binary:()=>u,euclid:()=>h,hex:()=>d,onsets:()=>p,probability:()=>m,random:()=>l,rotate:()=>g}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r))},{}],25:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{default:()=>w,get:()=>g,names:()=>f,romanNumeral:()=>h,tokenize:()=>b}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pitch"),d=e("@tonaljs/pitch-interval"),p=e("@tonaljs/pitch-note"),l={empty:!0,name:"",chordType:""},m={};function g(e){return"string"==typeof e?m[e]||(m[e]=function(e){const[n,t,r,i]=b(e);if(!r)return l;const s=r.toUpperCase(),a=_.indexOf(s),c=(0,p.accToAlt)(t),o=1;return{empty:!1,name:n,roman:r,interval:(0,d.interval)({step:a,alt:c,dir:o}).name,acc:t,chordType:i,alt:c,step:a,major:r===s,oct:0,dir:o}}(e)):"number"==typeof e?g(_[e]||""):(0,u.isPitch)(e)?(n=e,g((0,p.altToAcc)(n.alt)+_[n.step])):(0,u.isNamedPitch)(e)?g(e.name):l;var n}var h=g;function f(e=!0){return(e?_:v).slice()}var z=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function b(e){return z.exec(e)||["","","",""]}var y="I II III IV V VI VII",_=y.split(" "),v=y.toLowerCase().split(" ");var w={names:f,get:g,romanNumeral:h}},{"@tonaljs/pitch":21,"@tonaljs/pitch-interval":19,"@tonaljs/pitch-note":20}],26:[function(e,n,t){"use strict";var r,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})})(o,{NoScaleType:()=>p,add:()=>v,addAlias:()=>w,all:()=>z,default:()=>k,entries:()=>b,get:()=>h,keys:()=>y,names:()=>g,removeAll:()=>_,scaleType:()=>f}),n.exports=(r=o,((e,n,t,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let o of a(n))c.call(e,o)||o===t||i(e,o,{get:()=>n[o],enumerable:!(r=s(n,o))||r.enumerable});return e})(i({},"__esModule",{value:!0}),r));var u=e("@tonaljs/pcset"),d=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2M 3m 4P 5P 6m 7m","minor","aeolian"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neapolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5p pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7m pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neapolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 6A","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whol