abcjs
Version:
Renderer for abc music notation
3 lines • 437 kB
JavaScript
/*! abcjs_plugin v6.6.0 Copyright © 2009-2024 Paul Rosen and Gregory Dyke (https://abcjs.net) */
/*! For license information please see abcjs_plugin.LICENSE */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.abcjs=t():e.ABCJS=t()}(this,(function(){return e={7001:function(e,t,r){"use strict";var a=r(1592).TuneBook,n=r(8905),i=r(5253),s=new function(){var e=!1;try{e=abcjs_is_user_script}catch(e){}this.show_midi=!e,this.hide_abc=!1,this.render_before=!1,this.midi_options={},this.render_options={},this.render_classname="abcrendered",this.text_classname="abctext",this.auto_render_threshold=20,this.show_text="show score for: ",this.debug=!1};s.start=function(){var e=window.document.body;this.errors="";var t=this.getABCContainingElements(e);if(0!==t.length){if(this.debug)for(var r=0;r<t.length;r++){var a="Possible ABC found ("+(r+1)+" of "+t.length+"):\n\n"+t[r].innerText;alert(a)}var n=t.map(this.convertToDivs,this).reduce((function(e,t){return e.concat(t)}));this.auto_render=n.length<=this.auto_render_threshold,n.forEach((function(e){this.render(e,e.abctext_)}),this)}},s.getABCContainingElements=function(e){for(var t,r=[],a=!1,n=0,i=e.childNodes.length;n<i;++n)3!==(t=e.childNodes[n]).nodeType||a?1===t.nodeType&&"TEXTAREA"!==t.tagName&&(r=r.concat(this.getABCContainingElements(t))):t.nodeValue.match(/^\s*X:/m)&&"TEXTAREA"!==t.parentNode.tagName&&(r.push(e),a=!0);return r},s.convertToDivs=function(e){for(var t,r="",a=null,n=!1,i=[],s=Array.prototype.slice.call(e.childNodes),o=0,c=s.length;o<c;++o)if(3!==(t=s[o]).nodeType||t.nodeValue.match(/^\s*$/))n&&"BR"===t.tagName||n&&1===t.nodeType?(r+="\n",a.appendChild(t)):n&&(n=!1,r=r.replace(/\n+/,"\n"),a.abctext_=r,i.push(a));else{var l=t.nodeValue;l.match(/^\s*X:/m)&&(n=!0,r="",(a=document.createElement("DIV")).className=this.text_classname,t.parentElement.insertBefore(a,t),this.hide_abc&&(a.style.display="none")),n&&(r+=l.replace(/^\n+/,""),a.appendChild(t))}return n&&(r=r.replace(/\n+$/,"\n").replace(/^\n+/,"\n"),a.abctext_=r,i.push(a)),i},s.render=function(e,t){var r=document.createElement("DIV");r.className=this.render_classname,this.render_before?e.parentElement.insertBefore(r,e):e.nextSibling?e.parentElement.insertBefore(r,e.nextSibling):e.parentElement.appendChild(r);var s=this;try{this.debug&&alert("About to render:\n\n"+t);var o=new a(t),c=new n;c.parse(o.tunes[0].abc);var l=c.getTune(),h=function(){try{var t=new i(r,s.render_options);t.engraveABC(l)}catch(a){r.remove(),(r=document.createElement("DIV")).className=s.render_classname,(t=new i(r)).engraveABC(l),s.render_before?e.parentElement.insertBefore(r,e):e.nextSibling?e.parentElement.insertBefore(r,e.nextSibling):e.parentElement.appendChild(r)}},d=document.createElement("A");d.className="abcshow",d.href="#",d.innerHTML=this.show_text+(l.metaText.title||"untitled"),this.auto_render?h():(d.onclick=function(){return h(),d.remove(),!1},r.parentElement.insertBefore(d,r))}catch(e){this.errors+=e}};var o=!0;"undefined"!=typeof abcjs_plugin_autostart&&(o=abcjs_plugin_autostart),o&&"undefined"!=typeof window&&void 0!==window.document&&("loading"!==window.document.readyState?s.start():document.addEventListener("DOMContentLoaded",(function(){s.start()})));var c={plugin:s};e.exports=c},1592:function(e,t,r){function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}var n=r(8905),i=r(9565),s=r(2426),o={};!function(){"use strict";o.numberOfTunes=function(e){var t=e.split("\nX:").length;return 0===t&&(t=1),t};var e=o.TuneBook=function(e){var t=i(e);this.header=t.header,this.tunes=t.tunes};e.prototype.getTuneById=function(e){for(var t=0;t<this.tunes.length;t++)if(this.tunes[t].id===""+e)return this.tunes[t];return null},e.prototype.getTuneByTitle=function(e){for(var t=0;t<this.tunes.length;t++)if(this.tunes[t].title===e)return this.tunes[t];return null},o.parseOnly=function(e,t){for(var r=o.numberOfTunes(e),a=[],n=0;n<r;n++)a.push(1);return o.renderEngine((function(){}),a,e,t)},o.renderEngine=function(t,r,i,o){var c=[];if(void 0!==r&&void 0!==i){var l;(!(l=r)||l.propertyIsEnumerable("length")||"object"!==a(l)||"number"!=typeof l.length)&&(r=[r]),void 0===o&&(o={});for(var h=o.startingTune?parseInt(o.startingTune,10):0,d=new e(i),f=new n,u=0;u<r.length;u++){var p=r[u];if("*"===p||"string"==typeof p&&(p=document.getElementById(p)),p)if(h>=0&&h<d.tunes.length){f.parse(d.tunes[h].abc,o,d.tunes[h].startPos-d.header.length);var m=f.getTune();o.tablature&&(m.tablatures=s.preparePlugins(m,h,o));var g=f.getWarnings();g&&(m.warnings=g);var v=t(p,m,u,d.tunes[h].abc);c.push(v||m)}else p.innerHTML&&(p.innerHTML="");h++}return c}},o.extractMeasures=function(t){for(var r=[],a=new e(t),n=0;n<a.tunes.length;n++){for(var i=a.tunes[n],s=i.abc.split("K:"),c=s[1].split("\n"),l=s[0]+"K:"+c[0]+"\n",h=null,d=null,f=null,u=[],p=!1,m=o.parseOnly(i.abc)[0],g=m.getPickupLength()>0,v=0;v<m.lines.length;v++){var b=m.lines[v];if(b.staff)for(var y=0;y<1;y++)for(var x=b.staff[y],k=0;k<1;k++)for(var w=x.voices[k],T=0;T<w.length;T++){var C=w[T];if(null===f&&C.startChar>=0&&(f=C.startChar,d=void 0===C.chord?h:null),C.chord&&(h=C),"bar"===C.el_type){if(p){var S={abc:i.abc.substring(f,C.endChar)};(h=d&&d.chord&&d.chord.length>0?d.chord[0].name:null)&&(S.lastChord=h),C.startEnding&&(S.startEnding=C.startEnding),C.endEnding&&(S.endEnding=C.endEnding),u.push(S),f=null,p=!1}}else"note"===C.el_type&&(p=!0)}}r.push({header:l,measures:u,hasPickup:g})}return r}}(),e.exports=o},9447:function(e,t,r){var a=r(4914).relativeMajor,n={acc:"sharp",note:"f"},i={acc:"sharp",note:"c"},s={acc:"sharp",note:"g"},o={acc:"sharp",note:"d"},c={acc:"sharp",note:"A"},l={acc:"sharp",note:"e"},h={acc:"flat",note:"B"},d={acc:"flat",note:"e"},f={acc:"flat",note:"A"},u={acc:"flat",note:"d"},p={acc:"flat",note:"G"},m={acc:"flat",note:"c"},g={"C#":[n,i,s,o,c,l,{acc:"sharp",note:"B"}],"F#":[n,i,s,o,c,l],B:[n,i,s,o,c],E:[n,i,s,o],A:[n,i,s],D:[n,i],G:[n],C:[],F:[h],Bb:[h,d],Eb:[h,d,f],Cm:[h,d,f],Ab:[h,d,f,u],Db:[h,d,f,u,p],Gb:[h,d,f,u,p,m],Cb:[h,d,f,u,p,m,{acc:"flat",note:"F"}],"A#":[h,d],"B#":[],"D#":[h,d,f],"E#":[h],"G#":[h,d,f,u],none:[]};e.exports=function(e){var t=g[a(e)];return t?JSON.parse(JSON.stringify(t)):null}},4914:function(e){var t={C:{modes:["CMaj","CIon","Amin","AAeo","Am","GMix","DDor","EPhr","FLyd","BLoc"],stepsFromC:0},Db:{modes:["DbMaj","DbIon","Bbmin","BbAeo","Bbm","AbMix","EbDor","FPhr","GbLyd","CLoc"],stepsFromC:1},D:{modes:["DMaj","DIon","Bmin","BAeo","Bm","AMix","EDor","F#Phr","GLyd","C#Loc"],stepsFromC:2},Eb:{modes:["EbMaj","EbIon","Cmin","CAeo","Cm","BbMix","FDor","GPhr","AbLyd","DLoc"],stepsFromC:3},E:{modes:["EMaj","EIon","C#min","C#Aeo","C#m","BMix","F#Dor","G#Phr","ALyd","D#Loc"],stepsFromC:4},F:{modes:["FMaj","FIon","Dmin","DAeo","Dm","CMix","GDor","APhr","BbLyd","ELoc"],stepsFromC:5},Gb:{modes:["GbMaj","GbIon","Ebmin","EbAeo","Ebm","DbMix","AbDor","BbPhr","CbLyd","FLoc"],stepsFromC:6},G:{modes:["GMaj","GIon","Emin","EAeo","Em","DMix","ADor","BPhr","CLyd","F#Loc"],stepsFromC:7},Ab:{modes:["AbMaj","AbIon","Fmin","FAeo","Fm","EbMix","BbDor","CPhr","DbLyd","GLoc"],stepsFromC:8},A:{modes:["AMaj","AIon","F#min","F#Aeo","F#m","EMix","BDor","C#Phr","DLyd","G#Loc"],stepsFromC:9},Bb:{modes:["BbMaj","BbIon","Gmin","GAeo","Gm","FMix","CDor","DPhr","EbLyd","ALoc"],stepsFromC:10},B:{modes:["BMaj","BIon","G#min","G#Aeo","G#m","F#Mix","C#Dor","D#Phr","ELyd","A#Loc"],stepsFromC:11},"C#":{modes:["C#Maj","C#Ion","A#min","A#Aeo","A#m","G#Mix","D#Dor","E#Phr","F#Lyd","B#Loc"],stepsFromC:1},"F#":{modes:["F#Maj","F#Ion","D#min","D#Aeo","D#m","C#Mix","G#Dor","A#Phr","BLyd","E#Loc"],stepsFromC:6},Cb:{modes:["CbMaj","CbIon","Abmin","AbAeo","Abm","GbMix","DbDor","EbPhr","FbLyd","BbLoc"],stepsFromC:11}},r=["maj","ion","min","aeo","m","mix","dor","phr","lyd","loc"],a=null;e.exports={relativeMajor:function(e){a||function(){a={};for(var e=Object.keys(t),r=0;r<e.length;r++){var n=t[e[r]];a[e[r].toLowerCase()]=e[r];for(var i=0;i<n.modes.length;i++){var s=n.modes[i].toLowerCase();a[s]=e[r]}}}();var r=e.toLowerCase().match(/([a-g][b#]?)(maj|ion|min|aeo|mix|dor|phr|lyd|loc|m)?/);if(!r||!r[2])return e;r=r[1]+r[2];var n=a[r];return n||e},relativeMode:function(e,r){var a=t[e];if(!a)return e;if(""===r)return e;var n=r.toLowerCase().match(/^(maj|ion|min|aeo|mix|dor|phr|lyd|loc|m)/);if(!n)return e;for(var i=n[1],s=0;s<a.modes.length;s++){var o=a.modes[s],c=o.toLowerCase().indexOf(i);if(-1!==c&&c===o.length-i.length)return o.substring(0,o.length-i.length)}return e},transposeKey:function(e,r){var a=t[e];if(!a)return e;for(;r<0;)r+=12;for(var n=(a.stepsFromC+r)%12,i=0;i<Object.keys(t).length;i++){var s=Object.keys(t)[i];if(t[s].stepsFromC===n)return s}return e},isLegalMode:function(e){return r.indexOf(e.toLowerCase())>=0}}},6780:function(e,t,r){var a=r(5008),n=r(4331),i=r(1028),s=r(9716),o=r(351);e.exports=function(){function e(e,t,r,a){for(var n=0;n<a.length;n++)e[r][a[n]]=t[r][a[n]]}function t(e,t){for(;t<e.length&&null===e[t].left;)t++;return e[t]}this.reset=function(){this.version="1.1.0",this.media="screen",this.metaText={},this.metaTextInfo={},this.formatting={},this.lines=[],this.staffNum=0,this.voiceNum=0,this.lineNum=0,this.runningFonts={},delete this.visualTranspose},this.reset(),this.copyTopInfo=function(t){var r=["tempo","title","header","rhythm","origin","composer","author","partOrder"];e(this,t,"metaText",r),e(this,t,"metaTextInfo",r)},this.copyBottomInfo=function(t){var r=["unalignedWords","book","source","discography","notes","transcription","history","abc-copyright","abc-creator","abc-edited-by","footer"];e(this,t,"metaText",r),e(this,t,"metaTextInfo",r)},this.getBeatLength=function(){var e=this.getMeterFraction(),t=1;return 6===e.num||9===e.num||12===e.num||3===e.num&&8===e.den?t=3:8!==e.den||5!==e.num&&7!==e.num||(t=2),t/e.den},this.getPickupLength=function(){var e=this.getBarLength(),t=function(e,t){for(var r=0,a=0;a<e.length;a++)if(e[a].staff)for(var n=0;n<e[a].staff.length;n++)for(var i=0;i<e[a].staff[n].voices.length;i++)for(var s=e[a].staff[n].voices[i],o=1,c=0;c<s.length;c++){var l=s[c].rest&&"spacer"===s[c].rest.type;if(s[c].startTriplet&&(o=s[c].tripletMultiplier),s[c].duration&&!l&&"tempo"!==s[c].el_type&&(r+=s[c].duration*o),s[c].endTriplet&&(o=1),r>=t&&(r-=t),"bar"===s[c].el_type)return r}return r}(this.lines,e);return t<1e-8||e-t<1e-8?0:t},this.getBarLength=function(){var e=this.getMeterFraction();return e.num/e.den},this.getTotalTime=function(){return this.totalTime},this.getTotalBeats=function(){return this.totalBeats},this.millisecondsPerMeasure=function(e){var t;if(e)t=e;else{var r=this.metaText?this.metaText.tempo:null;t=this.getBpm(r)}return t<=0&&(t=1),this.getBeatsPerMeasure()/t*6e4},this.getBeatsPerMeasure=function(){var e=this.getBeatLength();return this.getBarLength()/e},this.getMeter=function(){for(var e=0;e<this.lines.length;e++){var t=this.lines[e];if(t.staff)for(var r=0;r<t.staff.length;r++){var a=t.staff[r].meter;if(a)return a}}return{type:"common_time"}},this.getMeterFraction=function(){var e=this.getMeter(),t=4,r=4;if(e)if("specified"===e.type){if(e.value&&e.value.length>0&&e.value[0].num.indexOf("+")>0){var a=e.value[0].num.split("+");t=0;for(var n=0;n<a.length;n++)t+=parseInt(a[n],10)}else t=parseInt(e.value[0].num,10);r=parseInt(e.value[0].den,10)}else"cut_time"===e.type?(t=2,r=2):"common_time"===e.type&&(t=4,r=4);return this.meter={num:t,den:r},this.meter},this.getKeySignature=function(){for(var e=0;e<this.lines.length;e++){var t=this.lines[e];if(t.staff)for(var r=0;r<t.staff.length;r++)if(t.staff[r].key)return t.staff[r].key}return{}},this.getElementFromChar=function(e){for(var t=0;t<this.lines.length;t++){var r=this.lines[t];if(r.staff)for(var a=0;a<r.staff.length;a++)for(var n=r.staff[a],i=0;i<n.voices.length;i++)for(var s=n.voices[i],o=0;o<s.length;o++){var c=s[o];if(c.startChar&&c.endChar&&c.startChar<=e&&c.endChar>e)return c}}return null},this.addElementToEvents=function(e,t,r,n,i,s,o,c,l,h){if(t.hint)return{isTiedState:void 0,duration:0};var d=t.durationClass?t.durationClass:t.duration;if(t.abcelem.rest&&"spacer"===t.abcelem.rest.type&&(d=0),d>0){for(var f=[],u=0;u<t.elemset.length;u++)null!==t.elemset[u]&&f.push(t.elemset[u]);var p=t.startTie;if(void 0!==l)e["event"+l].elements.push(f),h&&(e["event"+r]||(e["event"+r]={type:"event",milliseconds:r,line:s,measureNumber:o,top:n,height:i,left:null,width:0,elements:[],startChar:null,endChar:null,startCharArray:[],endCharArray:[]}),e["event"+r].measureStart=!0,h=!1),p||(l=void 0);else{if(e["event"+r]){if(e["event"+r].left?e["event"+r].left=Math.min(e["event"+r].left,t.x):e["event"+r].left=t.x,e["event"+r].elements.push(f),e["event"+r].startCharArray.push(t.abcelem.startChar),e["event"+r].endCharArray.push(t.abcelem.endChar),null===e["event"+r].startChar&&(e["event"+r].startChar=t.abcelem.startChar),null===e["event"+r].endChar&&(e["event"+r].endChar=t.abcelem.endChar),t.abcelem.midiPitches&&t.abcelem.midiPitches.length)for(e["event"+r].midiPitches||(e["event"+r].midiPitches=[]),u=0;u<t.abcelem.midiPitches.length;u++)e["event"+r].midiPitches.push(t.abcelem.midiPitches[u]);if(t.abcelem.midiGraceNotePitches&&t.abcelem.midiGraceNotePitches.length){e["event"+r].midiGraceNotePitches||(e["event"+r].midiGraceNotePitches=[]);for(var m=0;m<t.abcelem.midiGraceNotePitches.length;m++)e["event"+r].midiGraceNotePitches.push(t.abcelem.midiGraceNotePitches[m])}}else e["event"+r]={type:"event",milliseconds:r,line:s,measureNumber:o,top:n,height:i,left:t.x,width:t.w,elements:[f],startChar:t.abcelem.startChar,endChar:t.abcelem.endChar,startCharArray:[t.abcelem.startChar],endCharArray:[t.abcelem.endChar],midiPitches:t.abcelem.midiPitches?a.cloneArray(t.abcelem.midiPitches):[]},t.abcelem.midiGraceNotePitches&&(e["event"+r].midiGraceNotePitches=a.cloneArray(t.abcelem.midiGraceNotePitches));h&&(e["event"+r].measureStart=!0,h=!1)}}return{isTiedState:l,duration:d/c,nextIsBar:h||"bar"===t.type}},this.makeVoicesArray=function(){for(var e=[],t=[],r={},a=0;a<this.engraver.staffgroups.length;a++){var i=this.engraver.staffgroups[a];if(i&&i.staffs&&i.staffs.length>0)for(var s=i.staffs[0],o=s.absoluteY,c=o-s.top*n.STEP,l=i.staffs[i.staffs.length-1],h=(o=l.absoluteY)-l.bottom*n.STEP-c,d=i.voices,f=0;f<d.length;f++)if(!d[f].staff||!d[f].staff.isTabStaff){var u=!1;e[f]||(e[f]=[]),void 0===t[f]&&(t[f]=0);for(var p=d[f].children,m=0;m<p.length;m++)"tempo"===p[m].type&&(r[t[f]]=this.getBpm(p[m].abcelem)),e[f].push({top:c,height:h,line:i.line,measureNumber:t[f],elem:p[m]}),"bar"===p[m].type&&u&&t[f]++,"note"!==p[m].type&&"rest"!==p[m].type||(u=!0)}}return this.tempoLocations=r,e},this.setupEvents=function(e,r,a,n){n||(n=1);for(var i,s=[],o={},c=e,l=!0,h=this.makeVoicesArray(),d=0,f=0;f<h.length;f++){var u=c,p=Math.round(1e3*u),m=0,g=-1,v=h[f],b=a;r=this.getBeatLength()*b/60;for(var y=-1,x=0;x<v.length;x++){var k=v[x].measureNumber;y!==k&&this.tempoLocations[k]&&(b=this.tempoLocations[k],r=n*this.getBeatLength()*b/60,y=k);var w,T=v[x].elem,C=this.addElementToEvents(o,T,p,v[x].top,v[x].height,v[x].line,v[x].measureNumber,r,i,l);if(i=C.isTiedState,l=C.nextIsBar,u+=C.duration,T.duration>0&&o["event"+p]&&(w="event"+p),p=Math.round(1e3*u),"bar"===T.type){var S=T.abcelem.type,E="bar_right_repeat"===S||"bar_dbl_repeat"===S,M="1"===T.abcelem.startEnding,_="bar_left_repeat"===S||"bar_dbl_repeat"===S||"bar_right_repeat"===S;if(E){x>0&&(o[w].endX=T.x),-1===g&&(g=x);var N=0;y=-1;for(var A=m;A<g;A++){y!==(k=v[A].measureNumber)&&this.tempoLocations[k]&&(b=this.tempoLocations[k],r=n*this.getBeatLength()*b/60,y=k);var B=v[A].elem;i=(C=this.addElementToEvents(o,B,p,v[A].top,v[A].height,v[A].line,v[A].measureNumber,r,i,l)).isTiedState,l=C.nextIsBar,u+=C.duration,N=p,p=Math.round(1e3*u)}o["event"+N]&&(o["event"+N].endX=v[g].elem.x),l=!0,g=-1}M&&(g=x),_&&(m=x)}}d=Math.max(d,p)}return function(e){for(var t,r,a,n,i=e.length-1;i>=0;i--){var s=e[i];"bar"===s.type?(s.top=a,s.nextTop=t,t=a,s.bottom=n,s.nextBottom=r,r=n):"event"===s.type&&(a=s.top,n=s.top+s.height)}}(s=function(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(e[r]);return t.sort((function(e,t){var r=e.milliseconds-t.milliseconds;return 0!==r?r:"bar"===e.type?-1:1}))}(o)),function(e,r){if(!(r.length<1)){for(var a=0;a<r.length-1;a++){var n=r[a],i=t(r,a+1);if(null!==n.left){var s=i&&n.top===i.top?i.left:e[n.line].staffGroup.w;void 0!==n.endX?s>n.left&&(n.endX=Math.min(n.endX,s)):n.endX=s}}var o=r[r.length-1];o.endX=e[o.line].staffGroup.w}}(this.lines,s),s.push({type:"end",milliseconds:d}),this.addUsefulCallbackInfo(s,b*n),s},this.addUsefulCallbackInfo=function(e,t){for(var r=this.millisecondsPerMeasure(t),a=0;a<e.length;a++)e[a].millisecondsPerMeasure=r},this.getBpm=function(e){var t;if(e||(e=this.metaText?this.metaText.tempo:null),e){t=e.bpm;var r=this.getBeatLength();t=t*(e.duration&&e.duration.length>0?e.duration[0]:r)/r}if(!t){t=180;var a=this.getMeterFraction();a&&3!==a.num&&a.num%3==0&&(t=120)}return t},this.setTiming=function(e,t){if(t=t||0,!this.engraver||!this.engraver.staffgroups)return console.log("setTiming cannot be called before the tune is drawn."),this.noteTimings=[],this.noteTimings;var r=this.metaText?this.metaText.tempo:null,a=this.getBpm(r),n=1;e?r&&(n=e/a):e=a;var i=this.getBeatLength(),s=e/60,o=this.getBarLength()/i*t/s;o&&(o-=this.getPickupLength()/i/s);var c=i*s;return this.noteTimings=this.setupEvents(o,c,e,n),this.noteTimings.length>0?(this.totalTime=this.noteTimings[this.noteTimings.length-1].milliseconds/1e3,this.totalBeats=this.totalTime*s):(this.totalTime=void 0,this.totalBeats=void 0),this.noteTimings},this.setUpAudio=function(e){e||(e={});var t=i(this,e);return s(t,e,this.formatting.percmap,this.formatting.midi)},this.deline=function(e){return o(this.lines,e)},this.findSelectableElement=function(e){return this.engraver&&this.engraver.selectables?this.engraver.findSelectableElement(e):null},this.getSelectableArray=function(){return this.engraver&&this.engraver.selectables?this.engraver.selectables:[]}}},351:function(e){function t(e,t){return"abselem"===e?"abselem":t}function r(e,t){e.el_type="meter",e.startChar=-1,e.endChar=-1;for(var r=0;r<t.length;r++)t[r].unshift(e)}function a(e,t){e.el_type="key",e.startChar=-1,e.endChar=-1;for(var r=0;r<t.length;r++)t[r].unshift(e)}function n(e,t){e.el_type="clef",e.startChar=-1,e.endChar=-1;for(var r=0;r<t.length;r++)t[r].unshift(e)}function i(e,t,r){e.el_type="font",e.type=r,e.startChar=-1,e.endChar=-1;for(var a=0;a<t.length;a++)t[a].unshift(e)}function s(e,r){return!e||JSON.stringify(e,t)===JSON.stringify(r,t)}function o(e){for(var t={},r=Object.keys(e),a=0;a<r.length;a++)if("staff"!==r[a])t[r[a]]=e[r[a]];else{t.staff=[];for(var n=0;n<e.staff.length;n++){for(var i={},s=Object.keys(e.staff[n]),o=0;o<s.length;o++)if("voices"!==s[o])i[s[o]]=e.staff[n][s[o]];else{i.voices=[];for(var c=0;c<e.staff[n].voices.length;c++)i.voices.push([].concat(e.staff[n].voices[c]))}t.staff.push(i)}}return t}e.exports=function(e,t){t||(t={});for(var c=!!t.lineBreaks,l=[],h=!1,d=[],f=[],u=[],p=[],m=[],g=[],v=[],b=0;b<e.length;b++){var y=o(e[b]);if(y.staff){if(h&&!y.vskip)for(var x=l[l.length-1],k=0;k<x.staff.length;k++){var w=y.staff[k],T=x.staff[k];if(w&&(s(w.meter,d[k])||(r(w.meter,w.voices),d[k]=w.meter,delete w.meter),s(w.key,f[k])||(a(w.key,w.voices),f[k]=w.key,delete w.key),w.title&&(T.abbrevTitle=w.title),s(w.clef,u[k])||(n(w.clef,w.voices),u[k]=w.clef,delete w.clef),s(w.vocalfont,p[k])||(i(w.vocalfont,w.voices,"vocalfont"),p[k]=w.vocalfont,delete w.vocalfont),s(w.gchordfont,m[k])||(i(w.gchordfont,w.voices,"gchordfont"),m[k]=w.gchordfont,delete w.gchordfont),s(w.tripletfont,g[k])||(i(w.tripletfont,w.voices,"tripletfont"),g[k]=w.tripletfont,delete w.tripletfont),s(w.annotationfont,v[k])||(i(w.annotationfont,w.voices,"annotationfont"),v[k]=w.annotationfont,delete w.annotationfont)),w)for(var C=0;C<T.voices.length;C++){var S=T.voices[C],E=w.voices[C];c&&S.push({el_type:"break"}),E&&(T.voices[C]=S.concat(E))}}else{for(var M=0;M<y.staff.length;M++)f[M]=y.staff[M].key,d[M]=y.staff[M].meter,u[M]=y.staff[M].clef;l.push(o(y))}h=!0}else h=!1,l.push(y)}return l}},5008:function(e){var t={cloneArray:function(e){for(var t=[],r=0;r<e.length;r++)t.push(Object.assign({},e[r]));return t},cloneHashOfHash:function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=Object.assign({},e[r]));return t},cloneHashOfArrayOfHash:function(e){var r={};for(var a in e)e.hasOwnProperty(a)&&(r[a]=t.cloneArray(e[a]));return r},strip:function(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")},startsWith:function(e,t){return 0===e.indexOf(t)},endsWith:function(e,t){var r=e.length-t.length;return r>=0&&e.lastIndexOf(t)===r},last:function(e){return 0===e.length?null:e[e.length-1]}};e.exports=t},8905:function(e,t,r){var a=r(5008),n=r(8360),i=r(9928),s=r(6476),o=r(1881),c=r(1756),l=r(6225),h=r(6780),d=r(575);e.exports=function(){"use strict";var e,t=new h,r=new d(t),f="",u="";function p(e,t,r){e.positioning||(e.positioning={}),e.positioning[t]=r}function m(e,t,r){e.fonts||(e.fonts={}),e.fonts[t]=r}this.getTune=function(){var e={formatting:t.formatting,lines:t.lines,media:t.media,metaText:t.metaText,metaTextInfo:t.metaTextInfo,version:t.version,addElementToEvents:t.addElementToEvents,addUsefulCallbackInfo:t.addUsefulCallbackInfo,getTotalTime:t.getTotalTime,getTotalBeats:t.getTotalBeats,getBarLength:t.getBarLength,getBeatLength:t.getBeatLength,getBeatsPerMeasure:t.getBeatsPerMeasure,getBpm:t.getBpm,getMeter:t.getMeter,getMeterFraction:t.getMeterFraction,getPickupLength:t.getPickupLength,getKeySignature:t.getKeySignature,getElementFromChar:t.getElementFromChar,makeVoicesArray:t.makeVoicesArray,millisecondsPerMeasure:t.millisecondsPerMeasure,setupEvents:t.setupEvents,setTiming:t.setTiming,setUpAudio:t.setUpAudio,deline:t.deline,findSelectableElement:t.findSelectableElement,getSelectableArray:t.getSelectableArray};return t.lineBreaks&&(e.lineBreaks=t.lineBreaks),t.visualTranspose&&(e.visualTranspose=t.visualTranspose),t.chordGrid&&(e.chordGrid=t.chordGrid),e};var g,v,b={reset:function(){for(var e in this)this.hasOwnProperty(e)&&"function"!=typeof this[e]&&delete this[e];this.iChar=0,this.key={accidentals:[],root:"none",acc:"",mode:""},this.meter=null,this.origMeter=null,this.hasMainTitle=!1,this.default_length=.125,this.clef={type:"treble",verticalPos:0},this.octave=0,this.next_note_duration=0,this.start_new_line=!0,this.is_in_header=!0,this.partForNextLine={},this.tempoForNextLine=[],this.havent_set_length=!0,this.voices={},this.staves=[],this.macros={},this.currBarNumber=1,this.barCounter={},this.ignoredDecorations=[],this.score_is_present=!1,this.inEnding=!1,this.inTie=[],this.inTieChord={},this.vocalPosition="auto",this.dynamicPosition="auto",this.chordPosition="auto",this.ornamentPosition="auto",this.volumePosition="auto",this.openSlurs=[],this.freegchord=!1,this.endingHoldOver={}},differentFont:function(e,t){return this[e].decoration!==t[e].decoration||this[e].face!==t[e].face||this[e].size!==t[e].size||this[e].style!==t[e].style||this[e].weight!==t[e].weight},addFormattingOptions:function(e,t,r){"note"===r?("auto"!==this.vocalPosition&&p(e,"vocalPosition",this.vocalPosition),"auto"!==this.dynamicPosition&&p(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&p(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&p(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&p(e,"volumePosition",this.volumePosition),this.differentFont("annotationfont",t)&&m(e,"annotationfont",this.annotationfont),this.differentFont("gchordfont",t)&&m(e,"gchordfont",this.gchordfont),this.differentFont("vocalfont",t)&&m(e,"vocalfont",this.vocalfont),this.differentFont("tripletfont",t)&&m(e,"tripletfont",this.tripletfont)):"bar"===r&&("auto"!==this.dynamicPosition&&p(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&p(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&p(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&p(e,"volumePosition",this.volumePosition),this.differentFont("measurefont",t)&&m(e,"measurefont",this.measurefont),this.differentFont("repeatfont",t)&&m(e,"repeatfont",this.repeatfont))},duplicateStartEndingHoldOvers:function(){this.endingHoldOver={inTie:[],inTieChord:{}};for(var e=0;e<this.inTie.length;e++)if(this.endingHoldOver.inTie.push([]),this.inTie[e])for(var t=0;t<this.inTie[e].length;t++)this.endingHoldOver.inTie[e].push(this.inTie[e][t]);for(var r in this.inTieChord)this.inTieChord.hasOwnProperty(r)&&(this.endingHoldOver.inTieChord[r]=this.inTieChord[r])},restoreStartEndingHoldOvers:function(){if(this.endingHoldOver.inTie){this.inTie=[],this.inTieChord={};for(var e=0;e<this.endingHoldOver.inTie.length;e++){this.inTie.push([]);for(var t=0;t<this.endingHoldOver.inTie[e].length;t++)this.inTie[e].push(this.endingHoldOver.inTie[e][t])}for(var r in this.endingHoldOver.inTieChord)this.endingHoldOver.inTieChord.hasOwnProperty(r)&&(this.inTieChord[r]=this.endingHoldOver.inTieChord[r])}}},y=function(e){var t=e.replace(/\x12/g," ");return(t=(t=t.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")},x=function(t,r,a){r||(r=" ");var n=r[a];" "!==n&&n||(n="SPACE");var i,s=y(r.substring(a-64,a))+'<span style="text-decoration:underline;font-size:1.3em;font-weight:bold;">'+n+"</span>"+y(r.substring(a+1).substring(0,64));!function(e){b.warnings||(b.warnings=[]),b.warnings.push(e)}("Music Line:"+e.lineIndex+":"+(a+1)+": "+t+": "+s),i={message:t,line:r,startChar:b.iChar+a,column:a},b.warningObjects||(b.warningObjects=[]),b.warningObjects.push(i)};this.getWarnings=function(){return b.warnings},this.getWarningObjects=function(){return b.warningObjects};var k=function(t,r){if(r.indexOf("")>=0)f+=r;else if(r=f+r,f="",t){"-"!==(r=a.strip(r))[r.length-1]&&(r+=" ");for(var n=[],i=0,s=!1,o=function(t){var o=a.strip(r.substring(i,t));if(o=o.replace(/\\([-_*|~])/g,"$1"),i=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),n.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=!1,l=0;l<r.length;l++){switch(r[l]){case" ":case"":o(l);break;case"-":!c&&!o(l)&&n.length>0&&(a.last(n).divider="-",n.push({skip:!0,to:"next"}));break;case"_":c||(o(l),n.push({skip:!0,to:"slur"}));break;case"*":c||(o(l),n.push({skip:!0,to:"next"}));break;case"|":c||(o(l),n.push({skip:!0,to:"bar"}));break;case"~":c||(s=!0)}c="\\"===r[l]}t.forEach((function(e){if(0!==n.length)if(n[0].skip){switch(n[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&n.shift();break;case"bar":"bar"===e.el_type&&n.shift()}"bar"!==e.el_type&&(void 0===e.lyric?e.lyric=[{syllable:"",divider:" "}]:e.lyric.push({syllable:"",divider:" "}))}else if("note"===e.el_type&&void 0===e.rest){var t=n.shift();t.syllable&&(t.syllable=t.syllable.replace(/ +/g," ")),void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else x("Can't add words before the first line of music",t,0)},w=function(t,r){if(r.indexOf("")>=0)u+=r;else if(r=u+r,u="",t){"-"!==(r=a.strip(r))[r.length-1]&&(r+=" ");for(var n=[],i=0,s=!1,o=function(t){var o=a.strip(r.substring(i,t));if(i=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),n.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=0;c<r.length;c++)switch(r[c]){case" ":case"":o(c);break;case"-":!o(c)&&n.length>0&&(a.last(n).divider="-",n.push({skip:!0,to:"next"}));break;case"_":o(c),n.push({skip:!0,to:"slur"});break;case"*":o(c),n.push({skip:!0,to:"next"});break;case"|":o(c),n.push({skip:!0,to:"bar"});break;case"~":s=!0}t.forEach((function(e){if(0!==n.length)if(n[0].skip)switch(n[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&n.shift();break;case"bar":"bar"===e.el_type&&n.shift()}else if("note"===e.el_type&&void 0===e.rest){var t=n.shift();void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else x("Can't add symbols before the first line of music",t,0)},T=function(e){if(a.startsWith(e,"%%")){var t=n.addDirective(e.substring(2));t&&x(t,e,2)}else{var i=e.indexOf("%");if(i>=0&&(e=e.substring(0,i)),0!==(e=e.replace(/\s+$/,"")).length)if(f)k(r.getCurrentVoice(),e.substring(2));else if(u)w(r.getCurrentVoice(),e.substring(2));else if(e.length<2||":"!==e[1]||v.lineContinuation)v.parseMusic(e);else{var s=g.parseHeader(e);s.regular&&v.parseMusic(e),s.newline&&v.startNewLine(),s.words&&k(r.getCurrentVoice(),e.substring(2)),s.symbols&&w(r.getCurrentVoice(),e.substring(2))}}};function C(e,t){e.push({el_type:"hint"});for(var r=0;r<t.length;r++){var a=t[r],n=Object.assign({},a);if(e.push(n),"bar"===a.el_type)return}}function S(e,t){for(var r=0;r<e.length;r++){var a=e[r],n=t[r];if(n)for(var i=0;i<n.voices.length;i++){var s=n.voices[i],o=a.voices[i];o&&C(o,s)}}}this.parse=function(h,d,p){d||(d={}),p||(p=0),t.reset();var m=(h=h.replace(/\r\n?/g,"\n")+"\n").split("\n\\");if(m.length>1){for(var y=1;y<m.length;y++)for(;m[y].length>0&&"\n"!==m[y][0];)m[y]=m[y].substr(1),m[y-1]+=" ";h=m.join(" ")}var C=(h=h.replace(/\\([ \t]*)(%.*)*\n/g,(function(e,t,r){return t+""+(r?Array(r.length+1).join(" "):"")+"\n"}))).split("\n");0===a.last(C).length&&C.pop(),e=new o(C,b),g=new i(e,x,b,t,r),v=new s(e,x,b,t,r,g),d.print&&(t.media="print"),b.reset(),b.iChar=p,d.visualTranspose?(b.globalTranspose=parseInt(d.visualTranspose),0===b.globalTranspose?b.globalTranspose=void 0:r.setVisualTranspose(d.visualTranspose)):b.globalTranspose=void 0,d.lineBreaks&&(b.lineBreaks=d.lineBreaks),g.reset(e,x,b,t);try{d.format&&n.globalFormatting(d.format);for(var E=e.nextLine();E;){if(d.header_only&&!1===b.is_in_header)throw"normal_abort";if(d.stop_on_warning&&b.warnings)throw"normal_abort";var M=b.is_in_header;T(E),M&&!b.is_in_header&&(r.setRunningFont("annotationfont",b.annotationfont),r.setRunningFont("gchordfont",b.gchordfont),r.setRunningFont("tripletfont",b.tripletfont),r.setRunningFont("vocalfont",b.vocalfont)),E=e.nextLine()}f&&k(r.getCurrentVoice(),""),u&&w(r.getCurrentVoice(),""),b.openSlurs=r.cleanUp(b.barsperstaff,b.staffnonote,b.openSlurs)}catch(e){if("normal_abort"!==e)throw e}var _=792,N=612;switch(b.papersize){case"legal":_=1008,N=612;break;case"A4":_=842.4,N=597.6}if(b.landscape){var A=_;_=N,N=A}if(t.formatting.pagewidth||(t.formatting.pagewidth=N),t.formatting.pageheight||(t.formatting.pageheight=_),d.hint_measures&&function(){for(var e=0;e<t.lines.length;e++){var r=t.lines[e].staff;if(r){for(var a=e+1;a<t.lines.length&&void 0===t.lines[a].staff;)a++;a<t.lines.length&&S(r,t.lines[a].staff)}}}(),c.wrapLines(t,b.lineBreaks,b.barNumbers),d.chordGrid)try{t.chordGrid=l(t)}catch(e){switch(e.message){case"notCommonTime":x("Chord grid only works for 2/2 and 4/4 time.",0,0);break;case"noChords":x("No chords are found in the tune.",0,0);break;default:x(e.message,0,0)}}}}},9565:function(e,t,r){var a=r(5008);e.exports=function(e){"use strict";for(var t="",r=e.match(/(\s*)/),n=(e=a.strip(e)).split("\nX:"),i=1;i<n.length;i++)n[i]="X:"+n[i];var s=r?r[0].length:0,o=[];n.forEach((function(e){o.push({abc:e,startPos:s}),s+=e.length+1})),o.length>1&&!a.startsWith(o[0].abc,"X:")&&o.shift().abc.split("\n").forEach((function(e){a.startsWith(e,"%%")&&(t+=e+"\n")}));var c=t;return o.forEach((function(e){var r=e.abc.indexOf("\n\n");r>0&&(e.abc=e.abc.substring(0,r)),e.pure=e.abc,e.abc=t+e.abc,e.title="";var n=e.pure.split("T:");n.length>1&&(n=n[1].split("\n"),e.title=a.strip(n[0]));var i=e.pure.substring(2,e.pure.indexOf("\n"));e.id=a.strip(i)})),{header:c,tunes:o}}},8360:function(e,t,r){var a=r(5008),n={};!function(){"use strict";var e,t,r,i,s;n.initialize=function(a,n,o,c,l){e=a,t=n,i=c,s=l,(r=o).annotationfont={face:"Helvetica",size:12,weight:"normal",style:"normal",decoration:"none"},r.gchordfont={face:"Helvetica",size:12,weight:"normal",style:"normal",decoration:"none"},r.historyfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},r.infofont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},r.measurefont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},r.partsfont={face:'"Times New Roman"',size:15,weight:"normal",style:"normal",decoration:"none"},r.repeatfont={face:'"Times New Roman"',size:13,weight:"normal",style:"normal",decoration:"none"},r.textfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},r.tripletfont={face:"Times",size:11,weight:"normal",style:"italic",decoration:"none"},r.vocalfont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},r.wordsfont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},i.formatting.composerfont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},i.formatting.subtitlefont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},i.formatting.tempofont={face:'"Times New Roman"',size:15,weight:"bold",style:"normal",decoration:"none"},i.formatting.titlefont={face:'"Times New Roman"',size:20,weight:"normal",style:"normal",decoration:"none"},i.formatting.footerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},i.formatting.headerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},i.formatting.voicefont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},i.formatting.tablabelfont={face:'"Trebuchet MS"',size:16,weight:"normal",style:"normal",decoration:"none"},i.formatting.tabnumberfont={face:'"Arial"',size:11,weight:"normal",style:"normal",decoration:"none"},i.formatting.tabgracefont={face:'"Arial"',size:8,weight:"normal",style:"normal",decoration:"none"},i.formatting.annotationfont=r.annotationfont,i.formatting.gchordfont=r.gchordfont,i.formatting.historyfont=r.historyfont,i.formatting.infofont=r.infofont,i.formatting.measurefont=r.measurefont,i.formatting.partsfont=r.partsfont,i.formatting.repeatfont=r.repeatfont,i.formatting.textfont=r.textfont,i.formatting.tripletfont=r.tripletfont,i.formatting.vocalfont=r.vocalfont,i.formatting.wordsfont=r.wordsfont};var o={gchordfont:!0,measurefont:!0,partsfont:!0,annotationfont:!0,composerfont:!0,historyfont:!0,infofont:!0,subtitlefont:!0,textfont:!0,titlefont:!0,voicefont:!0},c=function(e,r,a,n,i){function s(){var s=parseInt(e[0].token);return e.shift(),r?0===e.length?{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s}:1===e.length&&"box"===e[0].token&&o[i]?{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s,box:!0}:(t("Extra parameters in font definition.",a,n),{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s}):(t("Can't set just the size of the font since there is no default value.",a,n),{face:'"Times New Roman"',weight:"normal",style:"normal",decoration:"none",size:s})}if("*"===e[0].token){if(e.shift(),"number"===e[0].type)return s();t("Expected font size number after *.",a,n)}if("number"===e[0].type)return s();for(var c,l=[],h="normal",d="normal",f="none",u=!1,p="face",m=!1;e.length;){var g=e.shift(),v=g.token.toLowerCase();switch(p){case"face":m||"utf"!==v&&"number"!==g.type&&"bold"!==v&&"italic"!==v&&"underline"!==v&&"box"!==v?l.length>0&&"-"===g.token?(m=!0,l[l.length-1]=l[l.length-1]+g.token):m?(m=!1,l[l.length-1]=l[l.length-1]+g.token):l.push(g.token):"number"===g.type?(c?t("Font size specified twice in font definition.",a,n):c=g.token,p="modifier"):"bold"===v?h="bold":"italic"===v?d="italic":"underline"===v?f="underline":"box"===v?(o[i]?u=!0:t('This font style doesn\'t support "box"',a,n),p="finished"):"utf"===v?(g=e.shift(),p="size"):t("Unknown parameter "+g.token+" in font definition.",a,n);break;case"size":"number"===g.type?c?t("Font size specified twice in font definition.",a,n):c=g.token:t("Expected font size in font definition.",a,n),p="modifier";break;case"modifier":"bold"===v?h="bold":"italic"===v?d="italic":"underline"===v?f="underline":"box"===v?(o[i]?u=!0:t('This font style doesn\'t support "box"',a,n),p="finished"):t("Unknown parameter "+g.token+" in font definition.",a,n);break;case"finished":t('Extra characters found after "box" in font definition.',a,n)}}void 0===c?r?c=r.size:(t("Must specify the size of the font since there is no default value.",a,n),c=12):c=parseFloat(c),""===(l=l.join(" "))&&(r?l=r.face:(t("Must specify the name of the font since there is no default value.",a,n),l="sans-serif"));var b=function(e){switch(e){case"Arial-Italic":return{face:"Arial",weight:"normal",style:"italic",decoration:"none"};case"Arial-Bold":return{face:"Arial",weight:"bold",style:"normal",decoration:"none"};case"Bookman-Demi":return{face:"Bookman,serif",weight:"bold",style:"normal",decoration:"none"};case"Bookman-DemiItalic":return{face:"Bookman,serif",weight:"bold",style:"italic",decoration:"none"};case"Bookman-Light":return{face:"Bookman,serif",weight:"normal",style:"normal",decoration:"none"};case"Bookman-LightItalic":return{face:"Bookman,serif",weight:"normal",style:"italic",decoration:"none"};case"Courier":return{face:'"Courier New"',weight:"normal",style:"normal",decoration:"none"};case"Courier-Oblique":return{face:'"Courier New"',weight:"normal",style:"italic",decoration:"none"};case"Courier-Bold":return{face:'"Courier New"',weight:"bold",style:"normal",decoration:"none"};case"Courier-BoldOblique":return{face:'"Courier New"',weight:"bold",style:"italic",decoration:"none"};case"AvantGarde-Book":return{face:"AvantGarde,Arial",weight:"normal",style:"normal",decoration:"none"};case"AvantGarde-BookOblique":return{face:"AvantGarde,Arial",weight:"normal",style:"italic",decoration:"none"};case"AvantGarde-Demi":case"Avant-Garde-Demi":return{face:"AvantGarde,Arial",weight:"bold",style:"normal",decoration:"none"};case"AvantGarde-DemiOblique":return{face:"AvantGarde,Arial",weight:"bold",style:"italic",decoration:"none"};case"Helvetica-Oblique":return{face:"Helvetica",weight:"normal",style:"italic",decoration:"none"};case"Helvetica-Bold":return{face:"Helvetica",weight:"bold",style:"normal",decoration:"none"};case"Helvetica-BoldOblique":return{face:"Helvetica",weight:"bold",style:"italic",decoration:"none"};case"Helvetica-Narrow":return{face:'"Helvetica Narrow",Helvetica',weight:"normal",style:"normal",decoration:"none"};case"Helvetica-Narrow-Oblique":return{face:'"Helvetica Narrow",Helvetica',weight:"normal",style:"italic",decoration:"none"};case"Helvetica-Narrow-Bold":return{face:'"Helvetica Narrow",Helvetica',weight:"bold",style:"normal",decoration:"none"};case"Helvetica-Narrow-BoldOblique":return{face:'"Helvetica Narrow",Helvetica',weight:"bold",style:"italic",decoration:"none"};case"Palatino-Roman":return{face:"Palatino",weight:"normal",style:"normal",decoration:"none"};case"Palatino-Italic":return{face:"Palatino",weight:"normal",style:"italic",decoration:"none"};case"Palatino-Bold":return{face:"Palatino",weight:"bold",style:"normal",decoration:"none"};case"Palatino-BoldItalic":return{face:"Palatino",weight:"bold",style:"italic",decoration:"none"};case"NewCenturySchlbk-Roman":return{face:'"New Century",serif',weight:"normal",style:"normal",decoration:"none"};case"NewCenturySchlbk-Italic":return{face:'"New Century",serif',weight:"normal",style:"italic",decoration:"none"};case"NewCenturySchlbk-Bold":return{face:'"New Century",serif',weight:"bold",style:"normal",decoration:"none"};case"NewCenturySchlbk-BoldItalic":return{face:'"New Century",serif',weight:"bold",style:"italic",decoration:"none"};case"Times":case"Times-Roman":case"Times-Narrow":case"Times-Courier":case"Times-New-Roman":return{face:'"Times New Roman"',weight:"normal",style:"normal",decoration:"none"};case"Times-Italic":case"Times-Italics":return{face:'"Times New Roman"',weight:"normal",style:"italic",decoration:"none"};case"Times-Bold":return{face:'"Times New Roman"',weight:"bold",style:"normal",decoration:"none"};case"Times-BoldItalic":return{face:'"Times New Roman"',weight:"bold",style:"italic",decoration:"none"};case"ZapfChancery-MediumItalic":return{face:'"Zapf Chancery",cursive,serif',weight:"normal",style:"normal",decoration:"none"};default:return null}}(l),y={};return b?(y.face=b.face,y.weight=b.weight,y.style=b.style,y.decoration=b.decoration,y.size=c,u&&(y.box=!0),y):(y.face=l,y.weight=h,y.style=d,y.decoration=f,y.size=c,u&&(y.box=!0),y)},l=function(e,t,a){return 0===t.length?'Directive "'+e+'" requires a font as a parameter.':(r[e]=c(t,r[e],a,0,e),r.is_in_header&&(i.formatting[e]=r[e]),null)},h=function(e,t){var r="";t.forEach((function(e){r+=e.token}));var a=parseFloat(r);if(isNaN(a)||0===a)return'Directive "'+e+'" requires a number as a parameter.';i.formatting.scale=a},d=["acoustic-bass-drum","bass-drum-1","side-stick","acoustic-snare","hand-clap","electric-snare","low-floor-tom","closed-hi-hat","high-floor-tom","pedal-hi-hat","low-tom","open-hi-hat","low-mid-tom","hi-mid-tom","crash-cymbal-1","high-tom","ride-cymbal-1","chinese-cymbal","ride-bell","tambourine","splash-cymbal","cowbell","crash-cymbal-2","vibraslap","ride-cymbal-2","hi-bongo","low-bongo","mute-hi-conga","open-hi-conga","low-conga","high-timbale","low-timbale","high-agogo","low-agogo","cabasa","maracas","short-whistle","long-whistle","short-guiro","long-guiro","claves","hi-wood-block","low-wood-block","mute-cuica","open-cuica","mute-triangle","open-triangle"],f=function(e,t,a,n,i){if(1!==a.length||"number"!==a[0].type)return'Directive "'+t+'" requires a number as a parameter.';var s=a[0].intt;return void 0!==n&&s<n?'Directive "'+t+'" requires a number greater than or equal to '+n+" as a parameter.":void 0!==i&&s>i?'Directive "'+t+'" requires a number less than or equal to '+i+" as a parameter.":(r[e]=s,null)},u=function(e,t,a){if(1===a.length&&("true"===a[0].token||"false"===a[0].token))return r[e]="true"===a[0].token,null;var n=f(e,t,a,0,1);return null!==n?n:(r[e]=1===r[e],null)},p=function(e,t,a,n){if(1!==a.length)return'Directive "'+t+'" requires one of [ '+n.join(", ")+" ] as a parameter.";for(var i=a[0].token,s=!1,o=0;!s&&o<n.length;o++)n[o]===i&&(s=!0);return s?(r[e]=i,null):'Directive "'+t+'" requires one of [ '+n.join(", ")+" ] as a parameter."},m=["nobarlines","barlines","beataccents","nobeataccents","droneon","droneoff","drumon","drumoff","fermatafixed","fermataproportional","gchordon","gchordoff","controlcombo","temperamentnormal","noportamento"],g=["gchord","ptstress","beatstring"],v=["bassvol","chordvol","c","channel","beatmod","deltaloudness","drumbars","gracedivider","makechordchannels","randomchordattack","chordattack","stressmodel","transpose","rtranspose","vol","volinc","gchordbars"],b=["program"],y=["ratio","snt","bendvelocity","pitchbend","control","temperamentlinear"],x=["beat"],k=["drone"],w=["portamento"],T=["expand","grace","trim"],C=["drum","chordname"],S=["bassprog","chordprog"];n.parseFontChangeLine=function(e){var t=(e=e.replace(/\$\$/g,"")).split("$");if(t.length>1&&r.setfont){var a=[];""!==t[0]&&a.push({text:t[0]});for(var n=1;n<t.length;n++)if("0"===t[n][0])a.push({text:t[n].substring(1).replace(/\x03/g,"$$")});else{var i=parseInt(t[n][0],10);r.setfont[i]?a.push({font:r.setfont[i],text:t[n].substring(1).replace(/\x03/g,"$$")}):a[a.length-1].text+="$"+t[n].replace(/\x03/g,"$$")}return a}return e.replace(/\x03/g,"$$")};var E=["auto","above","below","hidden"];function M(e){if(0===e.length)return{value:1};if(1===e.length)if("number"===e[0].type){if(e[0].floatt>=0||e[0].floatt<=1)return{value:e[0].floatt}}else{if("false"===e[0].token)return{value:0};if("true"===e[0].token)return{value:1}}return{error:"Directive stretchlast requires zero or one parameter: false, true, or number between 0 and 1 (received "+e[0].token+")"}}n.addDirective=function(o){var _=e.tokenize(o,0,o.length);if(0===_.length||"alpha"!==_[0].type)return null;var N=o.substring(o.indexOf(_[0].token)+_[0].token.length);N=e.stripComment(N);var A,B=_.shift().token.toLowerCase(),P="";switch(B){case"bagpipes":i.formatting.bagpipes=!0;break;case"flatbeams":i.formatting.flatbeams=!0;break;case"jazzchords":i.formatting.jazzchords=!0;break;case"accentAbove":i.formatting.accentAbove=!0;break;case"germanAlphabet":i.formatting.germanAlphabet=!0;break;case"landscape":r.landscape=!0;break;case"papersize":r.papersize=N;break;case"graceslurs":if(1!==_.length)return"Directive graceslurs requires one parameter: 0 or 1";if("0"===_[0].token||"false"===_[0].token)i.formatting.graceSlurs=!1;else{if("1"!==_[0].token&&"true"!==_[0].token)return"Directive graceslurs requires one parameter: 0 or 1 (received "+_[0].token+")";i.formatting.graceSlurs=!0}break;case"lineThickness":var L=M(_);if(void 0!==L.value&&(i.formatting.lineThickness=L.value),L.error)return L.error;break;case"stretchlast":var z=M(_);if(void 0!==z.value&&(i.formatting.stretchlast=z.value),z.error)return z.error;break;case"titlecaps":r.titlecaps=!0;break;case"titleleft":i.formatting.titleleft=!0;break;case"measurebox":i.formatting.measurebox=!0;break;case"vocal":return p("vocalPosition",B,_,E);case"dynamic":return p("dynamicPosition",B,_,E);case"gchord":return p("chordPosition",B,_,E);case"ornament":return p("ornamentPosition",B,_,E);case"volume":return p("volumePosition",B,_,E);case"botmargin":case"botspace":case"composerspace":case"indent":case"leftmargin":case"linesep":case"musicspace":case"partsspace":case"pageheight":case"pagewidth":case"rightmargin":case"stafftopmargin":case"staffsep":case"staffwidth":case"subtitlespace":case"sysstaffsep":case"systemsep":case"textspace":case"titlespace":case"topmargin":case"topspace":case"vocalspace":case"wordsspace":return function(t,r){var a=e.getMeasurement(r);return 0===a.used||0!==r.length?'Directive "'+t+'" requires a measurement as a parameter.':(i.formatting[t]=a.value,null)}(B,_);case"voicescale":if(1!==_.length||"number"!==_[0].type)return"voicescale requires one float as a parameter";var O=_.shift();return r.currentVoice&&(r.currentVoice.scale=O.floatt,s.changeVoiceScale(r.currentVoice.scale)),null;case"voicecolor":if(1!==_.length)return"voicecolor requires one string as a parameter";var H=_.shift();return r.currentVoice&&(r.currentVoice.color=H.token,s.changeVoiceColor(r.currentVoice.color)),null;case"vskip":var I=Math.round(function(t,r){var a=e.getMeasurement(r);return 0===a.used||0!==r.length?{error:'Directive "'+t+'" requires a measurement as a parameter.'}:a.value}(B,_));return I.error?I.error:(s.addSpacing(I),null);case"scale":h(B,_);break;case"sep":if(0===_.length)s.addSeparator(14,14,85,{startChar:r.iChar,endChar:r.iChar+5});else{var D=e.getMeasurement(_);if(0===D.used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var F=D.value;if(0===(D=e.getMeasurement(_)).used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var V=D.value;if(0===(D=e.getMeasurement(_)).used||0!==_.length)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var Y=D.value;s.addSeparator(F,V,Y,{startChar:r.iChar,endChar:r.iChar+N.length})}break;case"barsperstaff":if(null!==(P=f("barsperstaff",B,_)))return P;break;case"staffnonote":if(1!==_.length)return"Directive staffnonote requires one parameter: 0 or 1";if("0"===_[0].token)r.staffnonote=!0;else{if("1"!==_[0].token)return"Directive staffnonote requires one parameter: 0 or 1 (received "+_[0].token+")";r.staffnonote=!1}break;case"printtempo":if(null!==(P=u("printTempo",B,_)))return P;break;case"partsbox":if(null!==(P=u("partsBox",B,_)))return P;r.partsfont.box=r.partsBox;break;case"freegchord":if(null!==(P=u("freegchord",B,_)))return P;break;case"measurenb":case"barnumbers":if(null!==(P=f("barNumbers",B,_)))return P;break;case"setbarnb":if(1!==_.length||"number"!==_[0].type)return"Directive setbarnb requires a number as a parameter.";r.currBarNumber=s.setBarNumberImmediate(_[0].intt);break;case"keywarn":if(1!==_.length||"number"!==_[0].type||1!==_[0].intt&&0!==_[0].intt)return"Directive "+B+" requires 0 or 1 as a parameter.";r[B]=1===_[0].intt;break;case"begintext":var G="";for(A=e.nextLine();A&&0!==A.indexOf("%%endtext");){if(a.startsWith(A,"%%")){var j=A.substring(2);G+=j=j.trim()+"\n"}else G+=A.trim()+"\n";A=e.nextLine()}s.addText(G,{startChar:r.iChar,endChar:r.iChar+G.length+7});break;case"continueall":r.continueall=!0;break;case"beginps":for(A=e.nextLine();A&&0!==A.indexOf("%%endps");)e.nextLine();t("Postscript ignored",o,0);break;case"deco":N.length>0&&r.ignoredDecorations.push(N.substring(0,N.indexOf(" "))),t("Decoration redefinition ignored",o,0);break;case"text":var W=e.translateString(N);s.addText(n.parseFontChangeLine(W),{startChar:r.iChar,endChar:r.iChar+N.length+7});break;case"center":var q=e.translateString(N);s.addCentered(n.parseFontChangeLine(q));break;case"font":break;case"setfont":var R=e.tokenize(N,0,N.length);if(R.length>=4&&"-"===R[0].token&&"number"===R[1].type){var X=parseInt(R[1].token);X>=1&&X<=9&&(r.setfont||(r.setfont=[]),R.shift(),R.shift(),r.setfont[X]=c(R,r.setfont[X],o,0,"setfont"))}break;case"gchordfont":case"partsfont":case"tripletfont":case"vocalfont":case"textfont":case"annotationfont":case"historyfont":case"infofont":case"measurefont":case"repeatfont":case"wordsfont":return l(B,_,o);case"composerfont":case"subtitlefont":case"tempofont":case"titlefont":case"voicefont":case"footerfont":case"headerfont":return function(e,t,r){return 0===t.length?'Directive "'+e+'" requires a font as a parameter.':(i.formatting[e]=c(t,i.formatting[e],r,0,e),null)}(B,_,o);case"barlabelfont":case"barnumberfont":case"barnumfont":return l("measurefont",_,o);case"staves":case"score":r.score_is_present=!0;for(var U,K=function(e,t,n,i,s){(t||0===r.staves.length)&&r.staves.push({index:r.staves.length,numVoices:0});var o=a.last(r.staves);void 0!==n&&void 0===o.bracket&&(o.bracket=n),void 0!==i&&void 0===o.brace&&(o.brace=i),s&&(o.connectBarLines="end"),void 0===r.voices[e]&&(r.voices[e]={staffNum:o.index,index:o.numVo