abcjs
Version:
Renderer for abc music notation
3 lines • 467 kB
JavaScript
/*! abcjs_basic v6.2.0 Copyright © 2009-2022 Paul Rosen and Gregory Dyke (https://abcjs.net) */
/*! For license information please see abcjs_basic.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={1045:function(e,t,r){var n=r(1185),i=r(6306),a=r(1592),s=r(1028),o=r(5633),c={};c.signature="abcjs-basic v"+n,Object.keys(i).forEach((function(e){c[e]=i[e]})),Object.keys(a).forEach((function(e){c[e]=a[e]})),c.renderAbc=r(6859),c.TimingCallbacks=r(5681);var l=r(6020);c.setGlyph=l.setSymbol,c.strTranspose=o;var h=r(5594),u=r(8471),d=r(522),f=r(2029),p=r(6313),m=r(5281),g=r(8702),v=r(5049),b=r(4718),y=r(3450),x=r(562);c.synth={CreateSynth:h,instrumentIndexToName:u,pitchToNoteName:d,SynthController:y,SynthSequence:f,CreateSynthControl:p,registerAudioContext:m,activeAudioContext:g,supportsAudio:v,playEvent:b,getMidiFile:x,sequence:s},c.Editor=r(5294),c.EditArea=r(2945),e.exports=c},6306:function(e,t,r){var n=r(5681),i={};!function(){"use strict";var e,t;i.startAnimation=function(r,i,a){function s(e){for(var t=0;t<e.length;t++){var r=e[t];r.classList.contains("abcjs-bar")||(r.style.display="none")}}var o;function c(e){a.hideCurrentMeasure?function(e){s(r.querySelectorAll(e))}(e):a.hideFinishedMeasures&&function(e){o&&s(r.querySelectorAll(o)),o=e}(e)}e&&(e.stop(),e=void 0),a.showCursor&&((t=r.querySelector(".abcjs-cursor"))||((t=document.createElement("DIV")).className="abcjs-cursor cursor",t.style.position="absolute",r.appendChild(t),r.style.position="relative")),(e=new n(i,{qpm:a.bpm,eventCallback:function(r){if(r){if(r.measureStart){var n=".abcjs-l"+(i=r).line+".abcjs-m"+i.measureNumber;n&&c(n)}t&&(t.style.left=r.left+"px",t.style.top=r.top+"px",t.style.width=r.width+"px",t.style.height=r.height+"px")}else e.stop(),e=void 0;var i}})).start()},i.pauseAnimation=function(t){e&&(t?e.pause():e.start())},i.stopAnimation=function(){e&&(e.stop(),e=void 0)}}(),e.exports=i},4321:function(e,t,r){var n=r(4916),i=r(5952),a={violin:"ViolinTab",guitar:"GuitarTab"},s={inited:!1,plugins:{},register:function(e){var t=e.name,r=e.tablature;this.plugins[t]=r},setError:function(e,t){e.warnings?e.warning.push(t):e.warnings=[t]},preparePlugins:function(e,t,r){var n=null;if(r.tablature){var i=r.tablature;n=[];for(var s=0;s<i.length;s++){var o=i[s],c=o.instrument;if(null==c)return this.setError(e,"tablature 'instrument' is missing"),n;var l=a[c],h=null;if(l&&(h=this.plugins[l]),!h)return this.setError(e,"Undefined tablature plugin: "+c),n;0!=r.visualTranspose&&(o.visualTranspose=r.visualTranspose),o.abcSrc=r.tablature.abcSrc;var u={classz:h,tuneNumber:t,params:o,instance:null};n.push(u)}}return n},layoutTablatures:function(e,t){for(var r=t.tablatures,n=0;n<t.lines.length;n++){var i=t.lines[n],a=i.staff;if(a)for(var s=0;s<a.length;s++)if(r[s]){var o=r[s];null==o.instance&&(o.instance=new o.classz,o.instance.init(t,o.tuneNumber,o.params,s)),o.instance.render(e,i,s)}}},init:function(){this.inited||(this.register(new n),this.register(new i),this.inited=!0)}};e.exports=s},5681:function(e){e.exports=function(e,t){var r=this;if(t||(t={}),r.qpm=t.qpm?parseInt(t.qpm,10):null,!r.qpm){var n=e.metaText?e.metaText.tempo:null;r.qpm=e.getBpm(n)}r.extraMeasuresAtBeginning=t.extraMeasuresAtBeginning?parseInt(t.extraMeasuresAtBeginning,10):0,r.beatCallback=t.beatCallback,r.eventCallback=t.eventCallback,r.lineEndCallback=t.lineEndCallback,r.lineEndAnticipation=t.lineEndAnticipation?parseInt(t.lineEndAnticipation,10):0,r.beatSubdivisions=t.beatSubdivisions?parseInt(t.beatSubdivisions,10):1,r.joggerTimer=null,r.replaceTarget=function(e){r.noteTimings=e.setTiming(r.qpm,r.extraMeasuresAtBeginning),0===e.noteTimings.length&&e.setTiming(0,0),r.lineEndCallback&&(r.lineEndTimings=function(e,t){for(var r=[],n=null,i=0;i<e.length;i++){var a=e[i];"end"!==a.type&&a.top!==n&&(r.push({measureNumber:a.measureNumber,milliseconds:a.milliseconds-t,top:a.top,bottom:a.top+a.height}),n=a.top)}return r}(e.noteTimings,r.lineEndAnticipation)),r.startTime=null,r.currentBeat=0,r.currentEvent=0,r.currentLine=0,r.currentTime=0,r.isPaused=!1,r.isRunning=!1,r.pausedPercent=null,r.justUnpaused=!1,r.newSeekPercent=0,r.lastTimestamp=0,0!==r.noteTimings.length&&(r.millisecondsPerBeat=1e3/(r.qpm/60)/r.beatSubdivisions,r.lastMoment=r.noteTimings[r.noteTimings.length-1].milliseconds,r.totalBeats=Math.round(r.lastMoment/r.millisecondsPerBeat))},r.replaceTarget(e),r.doTiming=function(e){if(r.lastTimestamp!==e&&(r.lastTimestamp=e,r.startTime||(r.startTime=e),!r.isPaused&&r.isRunning)){for(r.currentTime=e-r.startTime,r.currentTime+=16;r.noteTimings.length>r.currentEvent&&r.noteTimings[r.currentEvent].milliseconds<r.currentTime;){if(r.eventCallback&&"event"===r.noteTimings[r.currentEvent].type){var t=r.startTime;r.eventCallback(r.noteTimings[r.currentEvent]),t!==r.startTime&&(r.currentTime=e-r.startTime)}r.currentEvent++}if(r.lineEndCallback&&r.lineEndTimings.length>r.currentLine&&r.lineEndTimings[r.currentLine].milliseconds<r.currentTime&&r.currentEvent<r.noteTimings.length){var n=r.noteTimings[r.currentEvent].milliseconds===r.currentTime?r.noteTimings[r.currentEvent]:r.noteTimings[r.currentEvent-1];r.lineEndCallback(r.lineEndTimings[r.currentLine],n,{line:r.currentLine,endTimings:r.lineEndTimings,currentTime:r.currentTime}),r.currentLine++}if(r.currentTime<r.lastMoment){if(requestAnimationFrame(r.doTiming),r.currentBeat*r.millisecondsPerBeat<r.currentTime){var i=r.doBeatCallback(e);null!==i&&(r.currentTime=i)}}else if(r.currentBeat<=r.totalBeats&&r.beatCallback){var a=r.doBeatCallback(e);null!==a&&(r.currentTime=a),requestAnimationFrame(r.doTiming)}if(r.currentTime>=r.lastMoment)if(r.eventCallback){var s=r.eventCallback(null);r.shouldStop(s).then((function(e){e&&r.stop()}))}else r.stop()}},r.shouldStop=function(e){return new Promise((function(t){return e?"continue"===e?t(!1):void(e.then&&e.then((function(e){t("continue"!==e)}))):t(!0)}))},r.doBeatCallback=function(e){if(r.beatCallback){for(var t,n,i=r.currentEvent;i<r.noteTimings.length&&null===r.noteTimings[i].left;)i++;if(i<r.noteTimings.length){for(t=r.noteTimings[i].milliseconds,i=Math.max(0,r.currentEvent-1);i>=0&&null===r.noteTimings[i].left;)i--;n=r.noteTimings[i]}var a={},s={};if(n){a.top=n.top,a.height=n.height;var o=Math.max(0,e-r.startTime-n.milliseconds),c=t-n.milliseconds,l=n.endX-n.left,h=c?o*l/c:0;a.left=n.left+h,0===r.currentEvent&&n.milliseconds>e-r.startTime&&(a.left=void 0),s={timestamp:e,startTime:r.startTime,ev:n,endMs:t,offMs:o,offPx:h,gapMs:c,gapPx:l}}else s={timestamp:e,startTime:r.startTime};var u=r.startTime;if(r.beatCallback(r.currentBeat/r.beatSubdivisions,r.totalBeats/r.beatSubdivisions,r.lastMoment,a,s),u!==r.startTime)return e-r.startTime;r.currentBeat++}return null},r.animationJogger=function(){r.isRunning&&(r.doTiming(performance.now()),r.joggerTimer=setTimeout(r.animationJogger,60))},r.start=function(e,t){if(r.isRunning=!0,r.isPaused&&(r.isPaused=!1,void 0===e&&(r.justUnpaused=!0)),e)r.setProgress(e,t);else if(0===e)r.reset();else if(null!==r.pausedPercent){var n=performance.now();r.currentTime=r.lastMoment*r.pausedPercent,r.startTime=n-r.currentTime,r.pausedPercent=null,r.reportNext=!0}requestAnimationFrame(r.doTiming),r.joggerTimer=setTimeout(r.animationJogger,60)},r.pause=function(){r.isPaused=!0;var e=performance.now();r.pausedPercent=(e-r.startTime)/r.lastMoment,r.isRunning=!1,r.joggerTimer&&(clearTimeout(r.joggerTimer),r.joggerTimer=null)},r.currentMillisecond=function(){return r.currentTime},r.reset=function(){r.currentBeat=0,r.currentEvent=0,r.currentLine=0,r.startTime=null,r.pausedPercent=null},r.stop=function(){r.pause(),r.reset()},r.setProgress=function(e,t){var n;switch(t){case"seconds":r.currentTime=1e3*e,r.currentTime<0&&(r.currentTime=0),r.currentTime>r.lastMoment&&(r.currentTime=r.lastMoment),n=r.currentTime/r.lastMoment;break;case"beats":r.currentTime=e*r.millisecondsPerBeat*r.beatSubdivisions,r.currentTime<0&&(r.currentTime=0),r.currentTime>r.lastMoment&&(r.currentTime=r.lastMoment),n=r.currentTime/r.lastMoment;break;default:(n=e)<0&&(n=0),n>1&&(n=1),r.currentTime=r.lastMoment*n}r.isRunning||(r.pausedPercent=n);var i=performance.now();for(r.startTime=i-r.currentTime,r.currentEvent,r.currentEvent=0;r.noteTimings.length>r.currentEvent&&r.noteTimings[r.currentEvent].milliseconds<r.currentTime;)r.currentEvent++;if(r.lineEndCallback)for(r.currentLine=0;r.lineEndTimings.length>r.currentLine&&r.lineEndTimings[r.currentLine].milliseconds+r.lineEndAnticipation<r.currentTime;)r.currentLine++;var a=r.currentBeat;r.currentBeat=Math.floor(r.currentTime/r.millisecondsPerBeat),r.beatCallback&&a!==r.currentBeat&&r.doBeatCallback(r.startTime+r.currentTime),r.eventCallback&&r.currentEvent>=0&&"event"===r.noteTimings[r.currentEvent].type&&r.eventCallback(r.noteTimings[r.currentEvent]),r.lineEndCallback&&r.lineEndCallback(r.lineEndTimings[r.currentLine],r.noteTimings[r.currentEvent],{line:r.currentLine,endTimings:r.lineEndTimings}),r.joggerTimer=setTimeout(r.animationJogger,60)}}},1592:function(e,t,r){function n(e){return n="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},n(e)}var i=r(8905),a=r(9565),s=r(4321),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=a(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),n=[],i=0;i<r;i++)n.push(1);return o.renderEngine((function(){}),n,e,t)},o.renderEngine=function(t,r,a,o){var c=[];if(void 0!==r&&void 0!==a){var l;(!(l=r)||l.propertyIsEnumerable("length")||"object"!==n(l)||"number"!=typeof l.length)&&(r=[r]),void 0===o&&(o={});for(var h=o.startingTune?parseInt(o.startingTune,10):0,u=new e(a),d=new i,f=0;f<r.length;f++){var p=r[f];if("*"===p||"string"==typeof p&&(p=document.getElementById(p)),p)if(h>=0&&h<u.tunes.length){d.parse(u.tunes[h].abc,o,u.tunes[h].startPos-u.header.length);var m=d.getTune();o.tablature&&(s.init(),m.tablatures=s.preparePlugins(m,h,o));var g=d.getWarnings();g&&(m.warnings=g);var v=t(p,m,f,u.tunes[h].abc);c.push(v||m)}else p.innerHTML&&(p.innerHTML="");h++}return c}},o.extractMeasures=function(t){for(var r=[],n=new e(t),i=0;i<n.tunes.length;i++){for(var a=n.tunes[i],s=a.abc.split("K:"),c=s[1].split("\n"),l=s[0]+"K:"+c[0]+"\n",h=null,u=null,d=null,f=[],p=!1,m=o.parseOnly(a.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],w=0;w<1;w++)for(var k=x.voices[w],C=0;C<k.length;C++){var T=k[C];if(null===d&&T.startChar>=0&&(d=T.startChar,u=void 0===T.chord?h:null),T.chord&&(h=T),"bar"===T.el_type){if(p){var _={abc:a.abc.substring(d,T.endChar)};(h=u&&u.chord&&u.chord.length>0?u.chord[0].name:null)&&(_.lastChord=h),T.startEnding&&(_.startEnding=T.startEnding),T.endEnding&&(_.endEnding=T.endEnding),f.push(_),d=null,p=!1}}else"note"===T.el_type&&(p=!0)}}r.push({header:l,measures:f,hasPickup:g})}return r}}(),e.exports=o},6859:function(e,t,r){var n=r(1592),i=(r(6780),r(5253)),a=r(8905),s=r(1756),o={};function c(){var e=window.innerWidth;for(var t in o)if(o.hasOwnProperty(t)){var r=o[t];e-=2*r.offsetLeft,r.style.width=e+"px"}}try{window.addEventListener("resize",c),window.addEventListener("orientationChange",c)}catch(e){}function l(e,t,r,n,a){r.viewportHorizontal?(e.innerHTML='<div class="abcjs-inner"></div>',r.scrollHorizontal?(e.style.overflowX="auto",e.style.overflowY="hidden"):e.style.overflow="hidden",o[e.id]=e,e=e.children[0]):r.viewportVertical?(e.innerHTML='<div class="abcjs-inner scroll-amount"></div>',e.style.overflowX="hidden",e.style.overflowY="auto",e=e.children[0]):e.innerHTML="";var s=new i(e,r);s.engraveABC(t,n,a),t.engraver=s,(r.viewportVertical||r.viewportHorizontal)&&(e.parentNode.style.width=e.style.width)}e.exports=function(e,t,r,o,c){var h,u={};if(r){for(h in r)r.hasOwnProperty(h)&&(u[h]=r[h]);u.warnings_id&&u.tablature&&(u.tablature.warning_id=u.warnings_id)}if(o)for(h in o)o.hasOwnProperty(h)&&("listener"===h?o[h].highlight&&(u.clickListener=o[h].highlight):u[h]=o[h]);if(c)for(h in c)c.hasOwnProperty(h)&&(u[h]=c[h]);return n.renderEngine((function(e,t,r,n){var o=!1;return"*"===e&&(o=!0,(e=document.createElement("div")).setAttribute("style","visibility: hidden;"),document.body.appendChild(e)),u.afterParsing&&u.afterParsing(t,r,n),!o&&u.wrap&&u.staffwidth?(t=function(e,t,r,n,o){var c=new i(e,o).getMeasureWidths(t),h=s.calcLineWraps(t,c,o);if(h.reParse){var u=new a;u.parse(n,h.revisedParams),t=u.getTune();var d=u.getWarnings();d&&(t.warnings=d)}return l(e,t,h.revisedParams,r,0),t.explanation=h.explanation,t}(e,t,r,n,u),t):(l(e,t,u,r,0),o&&e.parentNode.removeChild(e),null)}),e,t,u)}},9447:function(e,t,r){var n=r(4914).relativeMajor,i={acc:"sharp",note:"f"},a={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"},u={acc:"flat",note:"e"},d={acc:"flat",note:"A"},f={acc:"flat",note:"d"},p={acc:"flat",note:"G"},m={acc:"flat",note:"c"},g={"C#":[i,a,s,o,c,l,{acc:"sharp",note:"B"}],"F#":[i,a,s,o,c,l],B:[i,a,s,o,c],E:[i,a,s,o],A:[i,a,s],D:[i,a],G:[i],C:[],F:[h],Bb:[h,u],Eb:[h,u,d],Cm:[h,u,d],Ab:[h,u,d,f],Db:[h,u,d,f,p],Gb:[h,u,d,f,p,m],Cb:[h,u,d,f,p,m,{acc:"flat",note:"F"}],"A#":[h,u],"B#":[],"D#":[h,u,d],"E#":[h],"G#":[h,u,d,f],none:[]};e.exports=function(e){var t=g[n(e)];return t?JSON.parse(JSON.stringify(t)):null}},4914:function(e){var t={C:{modes:["CMaj","Amin","Am","GMix","DDor","EPhr","FLyd","BLoc"],stepsFromC:0},Db:{modes:["DbMaj","Bbmin","Bbm","AbMix","EbDor","FPhr","GbLyd","CLoc"],stepsFromC:1},D:{modes:["DMaj","Bmin","Bm","AMix","EDor","F#Phr","GLyd","C#Loc"],stepsFromC:2},Eb:{modes:["EbMaj","Cmin","Cm","BbMix","FDor","GPhr","AbLyd","DLoc"],stepsFromC:3},E:{modes:["EMaj","C#min","C#m","BMix","F#Dor","G#Phr","ALyd","D#Loc"],stepsFromC:4},F:{modes:["FMaj","Dmin","Dm","CMix","GDor","APhr","BbLyd","ELoc"],stepsFromC:5},Gb:{modes:["GbMaj","Ebmin","Ebm","DbMix","AbDor","BbPhr","CbLyd","FLoc"],stepsFromC:6},G:{modes:["GMaj","Emin","Em","DMix","ADor","BPhr","CLyd","F#Loc"],stepsFromC:7},Ab:{modes:["AbMaj","Fmin","Fm","EbMix","BbDor","CPhr","DbLyd","GLoc"],stepsFromC:8},A:{modes:["AMaj","F#min","F#m","EMix","BDor","C#Phr","DLyd","G#Loc"],stepsFromC:9},Bb:{modes:["BbMaj","Gmin","Gm","FMix","CDor","DPhr","EbLyd","ALoc"],stepsFromC:10},B:{modes:["BMaj","G#min","G#m","F#Mix","C#Dor","D#Phr","ELyd","A#Loc"],stepsFromC:11},"C#":{modes:["C#Maj","A#min","A#m","G#Mix","D#Dor","E#Phr","F#Lyd","B#Loc"],stepsFromC:1},"F#":{modes:["F#Maj","D#min","D#m","C#Mix","G#Dor","A#Phr","BLyd","E#Loc"],stepsFromC:6},Cb:{modes:["CbMaj","Abmin","Abm","GbMix","DbDor","EbPhr","FbLyd","BbLoc"],stepsFromC:11}},r=null;e.exports={relativeMajor:function(e){r||function(){r={};for(var e=Object.keys(t),n=0;n<e.length;n++){var i=t[e[n]];r[e[n].toLowerCase()]=e[n];for(var a=0;a<i.modes.length;a++){var s=i.modes[a].toLowerCase();r[s]=e[n]}}}();var n=e.toLowerCase().match(/([a-g][b#]?)(maj|min|mix|dor|phr|lyd|loc|m)?/);if(!n||!n[2])return e;n=n[1]+n[2];var i=r[n];return i||e},relativeMode:function(e,r){var n=t[e];if(!n)return e;if(""===r)return e;var i=r.toLowerCase().match(/^(maj|min|mix|dor|phr|lyd|loc|m)/);if(!i)return e;for(var a=i[1],s=0;s<n.modes.length;s++){var o=n.modes[s],c=o.toLowerCase().indexOf(a);if(-1!==c&&c===o.length-a.length)return o.substring(0,o.length-a.length)}return e},transposeKey:function(e,r){var n=t[e];if(!n)return e;for(;r<0;)r+=12;for(var i=(n.stepsFromC+r)%12,a=0;a<Object.keys(t).length;a++){var s=Object.keys(t)[a];if(t[s].stepsFromC===i)return s}return e}}},6780:function(e,t,r){var n=r(5008),i=r(4331),a=r(1028),s=r(9716),o=r(351);e.exports=function(){function e(e,t,r,n){for(var i=0;i<n.length;i++)e[r][n[i]]=t[r][n[i]]}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),t/e.den},this.getPickupLength=function(){var e=this.getBarLength(),t=function(e,t){for(var r=0,n=0;n<e.length;n++)if(e[n].staff)for(var i=0;i<e[n].staff.length;i++)for(var a=0;a<e[n].staff[i].voices.length;a++)for(var s=e[n].staff[i].voices[a],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 n=t.staff[r].meter;if(n)return n}}return{type:"common_time"}},this.getMeterFraction=function(){var e=this.getMeter(),t=4,r=4;return e&&("specified"===e.type?(t=parseInt(e.value[0].num,10),r=parseInt(e.value[0].den,10)):"cut_time"===e.type?(t=2,r=2):"common_time"===e.type&&(t=4,r=4)),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 n=0;n<r.staff.length;n++)for(var i=r.staff[n],a=0;a<i.voices.length;a++)for(var s=i.voices[a],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,i,a,s,o,c,l,h){if(t.hint)return{isTiedState:void 0,duration:0};var u=t.durationClass?t.durationClass:t.duration;if(t.abcelem.rest&&"spacer"===t.abcelem.rest.type&&(u=0),u>0){for(var d=[],f=0;f<t.elemset.length;f++)null!==t.elemset[f]&&d.push(t.elemset[f]);var p=t.startTie;if(void 0!==l)e["event"+l].elements.push(d),h&&(e["event"+r]||(e["event"+r]={type:"event",milliseconds:r,line:s,measureNumber:o,top:i,height:a,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(d),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=[]),f=0;f<t.abcelem.midiPitches.length;f++)e["event"+r].midiPitches.push(t.abcelem.midiPitches[f]);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:i,height:a,left:t.x,width:t.w,elements:[d],startChar:t.abcelem.startChar,endChar:t.abcelem.endChar,startCharArray:[t.abcelem.startChar],endCharArray:[t.abcelem.endChar],midiPitches:t.abcelem.midiPitches?n.cloneArray(t.abcelem.midiPitches):[]},t.abcelem.midiGraceNotePitches&&(e["event"+r].midiGraceNotePitches=n.cloneArray(t.abcelem.midiGraceNotePitches));h&&(e["event"+r].measureStart=!0,h=!1),p&&(l=r)}}return{isTiedState:l,duration:u/c,nextIsBar:h||"bar"===t.type}},this.makeVoicesArray=function(){for(var e=[],t=[],r={},n=0;n<this.engraver.staffgroups.length;n++){var a=this.engraver.staffgroups[n];if(a&&a.staffs&&a.staffs.length>0)for(var s=a.staffs[0],o=s.absoluteY,c=o-s.top*i.STEP,l=a.staffs[a.staffs.length-1],h=(o=l.absoluteY)-l.bottom*i.STEP-c,u=a.voices,d=0;d<u.length;d++)if(!u[d].staff||!u[d].staff.isTabStaff){var f=!1;e[d]||(e[d]=[]),void 0===t[d]&&(t[d]=0);for(var p=u[d].children,m=0;m<p.length;m++)"tempo"===p[m].type&&(r[t[d]]=this.getBpm(p[m].abcelem)),e[d].push({top:c,height:h,line:a.line,measureNumber:t[d],elem:p[m]}),"bar"===p[m].type&&f&&t[d]++,"note"!==p[m].type&&"rest"!==p[m].type||(f=!0)}}return this.tempoLocations=r,e},this.setupEvents=function(e,r,n,i){i||(i=1);for(var a,s=[],o={},c=e,l=!0,h=this.makeVoicesArray(),u=0,d=0;d<h.length;d++){var f=c,p=Math.round(1e3*f),m=0,g=-1,v=h[d],b=n;r=this.getBeatLength()*b/60;for(var y=-1,x=0;x<v.length;x++){var w=v[x].measureNumber;y!==w&&this.tempoLocations[w]&&(b=this.tempoLocations[w],r=i*this.getBeatLength()*b/60,y=w);var k,C=v[x].elem,T=this.addElementToEvents(o,C,p,v[x].top,v[x].height,v[x].line,v[x].measureNumber,r,a,l);if(a=T.isTiedState,l=T.nextIsBar,f+=T.duration,C.duration>0&&o["event"+p]&&(k="event"+p),p=Math.round(1e3*f),"bar"===C.type){var _=C.abcelem.type,S="bar_right_repeat"===_||"bar_dbl_repeat"===_,E="1"===C.abcelem.startEnding,M="bar_left_repeat"===_||"bar_dbl_repeat"===_||"bar_right_repeat"===_;if(S){x>0&&(o[k].endX=C.x),-1===g&&(g=x);var N=0;y=-1;for(var A=m;A<g;A++){y!==(w=v[A].measureNumber)&&this.tempoLocations[w]&&(b=this.tempoLocations[w],r=i*this.getBeatLength()*b/60,y=w);var B=v[A].elem;a=(T=this.addElementToEvents(o,B,p,v[A].top,v[A].height,v[A].line,v[A].measureNumber,r,a,l)).isTiedState,l=T.nextIsBar,f+=T.duration,N=p,p=Math.round(1e3*f)}o["event"+N]&&(o["event"+N].endX=v[g].elem.x),l=!0,g=-1}E&&(g=x),M&&(m=x)}}u=Math.max(u,p)}return function(e){for(var t,r,n,i,a=e.length-1;a>=0;a--){var s=e[a];"bar"===s.type?(s.top=n,s.nextTop=t,t=n,s.bottom=i,s.nextBottom=r,r=i):"event"===s.type&&(n=s.top,i=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 n=0;n<r.length-1;n++){var i=r[n],a=t(r,n+1);if(null!==i.left){var s=a&&i.top===a.top?a.left:e[i.line].staffGroup.w;void 0!==i.endX?s>i.left&&(i.endX=Math.min(i.endX,s)):i.endX=s}}var o=r[r.length-1];o.endX=e[o.line].staffGroup.w}}(this.lines,s),s.push({type:"end",milliseconds:u}),this.addUsefulCallbackInfo(s,b*i),s},this.addUsefulCallbackInfo=function(e,t){for(var r=this.millisecondsPerMeasure(t),n=0;n<e.length;n++)e[n].millisecondsPerMeasure=r},this.getBpm=function(e){var t;if(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 n=this.getMeterFraction();n&&3!==n.num&&n.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."),void(this.noteTimings=[]);var r=this.metaText?this.metaText.tempo:null,n=this.getBpm(r),i=1;e?r&&(i=e/n):e=n;var a=this.getBeatLength(),s=e/60,o=this.getBarLength()/a*t/s;o&&(o-=this.getPickupLength()/a/s);var c=a*s;return this.noteTimings=this.setupEvents(o,c,e,i),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=a(this,e);return s(t,e,this.formatting.percmap,this.formatting.midi)},this.deline=function(e){return o(this.lines,e)}}},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 n(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 i(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 a(e,t,r){e.el_type="font",e.type=r,e.startChar=-1,e.endChar=-1;for(var n=0;n<t.length;n++)t[n].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),n=0;n<r.length;n++)if("staff"!==r[n])t[r[n]]=e[r[n]];else{t.staff=[];for(var i=0;i<e.staff.length;i++){for(var a={},s=Object.keys(e.staff[i]),o=0;o<s.length;o++)if("voices"!==s[o])a[s[o]]=e.staff[i][s[o]];else{a.voices=[];for(var c=0;c<e.staff[i].voices.length;c++)a.voices.push([].concat(e.staff[i].voices[c]))}t.staff.push(a)}}return t}e.exports=function(e,t){t||(t={});for(var c=!!t.lineBreaks,l=[],h=!1,u=[],d=[],f=[],p=[],m=[],g=[],v=[],b=0;b<e.length;b++){var y=e[b];if(y.staff){if(h&&!y.vskip)for(var x=l[l.length-1],w=0;w<x.staff.length;w++){var k=y.staff[w],C=x.staff[w];if(k&&(s(k.meter,u[w])||(r(k.meter,k.voices),u[w]=k.meter,delete k.meter),s(k.key,d[w])||(n(k.key,k.voices),d[w]=k.key,delete k.key),k.title&&(C.abbrevTitle=k.title),s(k.clef,f[w])||(i(k.clef,k.voices),f[w]=k.clef,delete k.clef),s(k.vocalfont,p[w])||(a(k.vocalfont,k.voices,"vocalfont"),p[w]=k.vocalfont,delete k.vocalfont),s(k.gchordfont,m[w])||(a(k.gchordfont,k.voices,"gchordfont"),m[w]=k.gchordfont,delete k.gchordfont),s(k.tripletfont,g[w])||(a(k.tripletfont,k.voices,"tripletfont"),g[w]=k.tripletfont,delete k.tripletfont),s(k.annotationfont,v[w])||(a(k.annotationfont,k.voices,"annotationfont"),v[w]=k.annotationfont,delete k.annotationfont)),k)for(var T=0;T<C.voices.length;T++){var _=C.voices[T],S=k.voices[T];c&&_.push({el_type:"break"}),S&&(C.voices[T]=_.concat(S))}}else{for(var E=0;E<y.staff.length;E++)d[E]=y.staff[E].key,u[E]=y.staff[E].meter,f[E]=y.staff[E].clef;l.push(o(y))}h=!0}else h=!1,l.push(y)}return l}},2945:function(e){try{if("function"!=typeof window.CustomEvent){var t=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),r};t.prototype=window.Event.prototype,window.CustomEvent=t}}catch(e){}var r=function(e){this.textarea=document.getElementById(e),this.initialText=this.textarea.value,this.isDragging=!1};r.prototype.addSelectionListener=function(e){this.textarea.onmousemove=function(t){this.isDragging&&e.fireSelectionChanged()}},r.prototype.addChangeListener=function(e){this.changelistener=e,this.textarea.onkeyup=function(){e.fireChanged()},this.textarea.onmousedown=function(){this.isDragging=!0,e.fireSelectionChanged()},this.textarea.onmouseup=function(){this.isDragging=!1,e.fireChanged()},this.textarea.onchange=function(){e.fireChanged()}},r.prototype.getSelection=function(){return{start:this.textarea.selectionStart,end:this.textarea.selectionEnd}},r.prototype.setSelection=function(e,t){if(this.textarea.setSelectionRange)this.textarea.setSelectionRange(e,t);else if(this.textarea.createTextRange){var r=this.textarea.createTextRange();r.collapse(!0),r.moveEnd("character",t),r.moveStart("character",e),r.select()}this.textarea.focus()},r.prototype.getString=function(){return this.textarea.value},r.prototype.setString=function(e){this.textarea.value=e,this.initialText=this.getString(),this.changelistener&&this.changelistener.fireChanged()},r.prototype.getElem=function(){return this.textarea},e.exports=r},5294:function(e,t,r){var n=r(5008),i=r(3450),a=r(5049),s=r(6859),o=r(2945),c=function(e,t){this.abcjsParams=function(e){var t,r={};if(e.abcjsParams)for(t in e.abcjsParams)e.abcjsParams.hasOwnProperty(t)&&(r[t]=e.abcjsParams[t]);if(e.midi_options)for(t in e.midi_options)e.midi_options.hasOwnProperty(t)&&(r[t]=e.midi_options[t]);if(e.parser_options)for(t in e.parser_options)e.parser_options.hasOwnProperty(t)&&(r[t]=e.parser_options[t]);if(e.render_options)for(t in e.render_options)e.render_options.hasOwnProperty(t)&&(r[t]=e.render_options[t]);return r.tablature&&e.warnings_id&&(r.tablature.warnings_id=e.warnings_id),r}(t),t.indicate_changed&&(this.indicate_changed=!0),this.editarea="string"==typeof e?new o(e):e,this.editarea.addSelectionListener(this),this.editarea.addChangeListener(this),t.canvas_id?this.div=t.canvas_id:t.paper_id?this.div=t.paper_id:(this.div=document.createElement("DIV"),this.editarea.getElem().parentNode.insertBefore(this.div,this.editarea.getElem())),"string"==typeof this.div&&(this.div=document.getElementById(this.div)),t.selectionChangeCallback&&(this.selectionChangeCallback=t.selectionChangeCallback),this.clientClickListener=this.abcjsParams.clickListener,this.abcjsParams.clickListener=this.highlight.bind(this),t.synth&&a()&&(this.synth={el:t.synth.el,cursorControl:t.synth.cursorControl,options:t.synth.options}),t.generate_midi&&(this.generate_midi=t.generate_midi,this.abcjsParams.generateDownload&&("string"==typeof t.midi_download_id?this.downloadMidi=document.getElementById(t.midi_download_id):t.midi_download_id&&(this.downloadMidi=t.midi_download_id)),!1!==this.abcjsParams.generateInline&&("string"==typeof t.midi_id?this.inlineMidi=document.getElementById(t.midi_id):t.midi_id&&(this.inlineMidi=t.midi_id))),t.warnings_id?"string"==typeof t.warnings_id?this.warningsdiv=document.getElementById(t.warnings_id):this.warningsdiv=t.warnings_id:t.generate_warnings&&(this.warningsdiv=document.createElement("div"),this.div.parentNode.insertBefore(this.warningsdiv,this.div)),this.onchangeCallback=t.onchange,this.currentAbc="",this.tunes=[],this.bReentry=!1,this.parseABC(),this.modelChanged(),this.addClassName=function(e,t){return function(e,t){var r=e.className;return r.length>0&&(r===t||new RegExp("(^|\\s)"+t+"(\\s|$)").test(r))}(e,t)||(e.className+=(e.className?" ":"")+t),e},this.removeClassName=function(e,t){return e.className=n.strip(e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ")),e},this.setReadOnly=function(e){var t="abc_textarea_readonly",r=this.editarea.getElem();e?(r.setAttribute("readonly","yes"),this.addClassName(r,t)):(r.removeAttribute("readonly"),this.removeClassName(r,t))}};c.prototype.redrawMidi=function(){if(this.generate_midi&&!this.midiPause){var e=new window.CustomEvent("generateMidi",{detail:{tunes:this.tunes,abcjsParams:this.abcjsParams,downloadMidiEl:this.downloadMidi,inlineMidiEl:this.inlineMidi,engravingEl:this.div}});window.dispatchEvent(e)}if(this.synth){var t=this.synth.synthControl;this.synth.synthControl||(this.synth.synthControl=new i,this.synth.synthControl.load(this.synth.el,this.synth.cursorControl,this.synth.options)),this.synth.synthControl.setTune(this.tunes[0],t,this.synth.options)}},c.prototype.modelChanged=function(){if(!this.bReentry){this.bReentry=!0;try{this.timerId=null,this.synth&&this.synth.synthControl&&this.synth.synthControl.disable(!0),this.tunes=s(this.div,this.currentAbc,this.abcjsParams),this.tunes.length>0&&(this.warnings=this.tunes[0].warnings),this.redrawMidi()}catch(e){console.error("ABCJS error: ",e),this.warnings||(this.warnings=[]),this.warnings.push(e.message)}this.warningsdiv&&(this.warningsdiv.innerHTML=this.warnings?this.warnings.join("<br />"):"No errors"),this.updateSelection(),this.bReentry=!1}},c.prototype.paramChanged=function(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this.abcjsParams[t]=e[t]);this.currentAbc="",this.fireChanged()},c.prototype.synthParamChanged=function(e){if(this.synth){if(this.synth.options={},e)for(var t in e)e.hasOwnProperty(t)&&(this.synth.options[t]=e[t]);this.currentAbc="",this.fireChanged()}},c.prototype.parseABC=function(){var e=this.editarea.getString();return e===this.currentAbc?(this.updateSelection(),!1):(this.currentAbc=e,!0)},c.prototype.updateSelection=function(){var e=this.editarea.getSelection();try{this.tunes.length>0&&this.tunes[0].engraver&&this.tunes[0].engraver.rangeHighlight(e.start,e.end)}catch(e){}this.selectionChangeCallback&&this.selectionChangeCallback(e.start,e.end)},c.prototype.fireSelectionChanged=function(){this.updateSelection()},c.prototype.setDirtyStyle=function(e){if(void 0!==this.indicate_changed){var t,r,i="abc_textarea_dirty",a=this.editarea.getElem();e?function(e,t){var r=e.className;return r.length>0&&(r===t||new RegExp("(^|\\s)"+t+"(\\s|$)").test(r))}(t=a,r=i)||(t.className+=(t.className?" ":"")+r):function(e,t){e.className=n.strip(e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," "))}(a,i)}},c.prototype.fireChanged=function(){if(!this.bIsPaused&&this.parseABC()){var e=this;this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout((function(){e.modelChanged()}),300);var t=this.isDirty();this.wasDirty!==t&&(this.wasDirty=t,this.setDirtyStyle(t)),this.onchangeCallback&&this.onchangeCallback(this)}},c.prototype.setNotDirty=function(){this.editarea.initialText=this.editarea.getString(),this.wasDirty=!1,this.setDirtyStyle(!1)},c.prototype.isDirty=function(){return void 0!==this.indicate_changed&&this.editarea.initialText!==this.editarea.getString()},c.prototype.highlight=function(e,t,r,n,i,a){this.editarea.setSelection(e.startChar,e.endChar),this.selectionChangeCallback&&this.selectionChangeCallback(e.startChar,e.endChar),this.clientClickListener&&this.clientClickListener(e,t,r,n,i,a)},c.prototype.pause=function(e){this.bIsPaused=e,e||this.fireChanged()},c.prototype.millisecondsPerMeasure=function(){return this.synth&&this.synth.synthControl&&this.synth.synthControl.visualObj?this.synth.synthControl.visualObj.millisecondsPerMeasure():0},c.prototype.pauseMidi=function(e){this.midiPause=e,e||this.redrawMidi()},e.exports=c},3284:function(e,t,r){var n,i=r(9991);!function(){"use strict";function e(e,t,r){for(var n=Object.keys(t),i=0;i<n.length;i++)n[i]=parseFloat(n[i]);n.sort((function(e,t){return e-t}));for(var a=0,s=0;s<n.length;s++){var o=t[n[s]];if(n[s]>a){var c=(n[s]-a)*r;e.addRest(c),a=n[s]}for(var l=0;l<o.length;l++){var h=o[l];h.volume?e.startNote(h.pitch,h.volume,h.cents):e.endNote(h.pitch)}}}n=function(t,r){void 0===r&&(r={});var n=t.setUpAudio(r),a=i(),s=t.metaText?t.metaText.title:void 0;s&&s.length>128&&(s=s.substring(0,124)+"...");var o=t.getKeySignature(),c=t.getMeterFraction(),l=n.tempo/60;a.setGlobalInfo(n.tempo,s,o,c);for(var h=0;h<n.tracks.length;h++){a.startTrack();for(var u={},d=0;d<n.tracks[h].length;d++){var f=n.tracks[h][d];switch(f.cmd){case"text":a.setText(f.type,f.text);break;case"program":var p=0;r.pan&&r.pan.length>h&&(p=r.pan[h]),128===f.instrument?(a.setChannel(9,p),a.setInstrument(0)):(a.setChannel(f.channel,p),a.setInstrument(f.instrument));break;case"note":var m=f.gap*l,g=f.start,v=g+f.duration-m;u[g]||(u[g]=[]),u[g].push({pitch:f.pitch,volume:f.volume,cents:f.cents}),u[v]||(u[v]=[]),u[v].push({pitch:f.pitch,volume:0});break;default:console.log("MIDI create Unknown: "+f.cmd)}}e(a,u,1920),a.endTrack()}return a.getData()}}(),e.exports=n},5008:function(e){var t={clone:function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t},cloneArray:function(e){for(var r=[],n=0;n<e.length;n++)r.push(t.clone(e[n]));return r},cloneHashOfHash:function(e){var r={};for(var n in e)e.hasOwnProperty(n)&&(r[n]=t.clone(e[n]));return r},cloneHashOfArrayOfHash:function(e){var r={};for(var n in e)e.hasOwnProperty(n)&&(r[n]=t.cloneArray(e[n]));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 n=r(5008),i=r(8360),a=r(9928),s=r(6476),o=r(1881),c=r(1756),l=r(6780),h=r(575);e.exports=function(){"use strict";var e,t=new l,r=new h(t),u="",d="";function f(e,t,r){e.positioning||(e.positioning={}),e.positioning[t]=r}function p(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};return t.lineBreaks&&(e.lineBreaks=t.lineBreaks),t.visualTranspose&&(e.visualTranspose=t.visualTranspose),e};var m,g,v={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&&f(e,"vocalPosition",this.vocalPosition),"auto"!==this.dynamicPosition&&f(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&f(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&f(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&f(e,"volumePosition",this.volumePosition),this.differentFont("annotationfont",t)&&p(e,"annotationfont",this.annotationfont),this.differentFont("gchordfont",t)&&p(e,"gchordfont",this.gchordfont),this.differentFont("vocalfont",t)&&p(e,"vocalfont",this.vocalfont),this.differentFont("tripletfont",t)&&p(e,"tripletfont",this.tripletfont)):"bar"===r&&("auto"!==this.dynamicPosition&&f(e,"dynamicPosition",this.dynamicPosition),"auto"!==this.chordPosition&&f(e,"chordPosition",this.chordPosition),"auto"!==this.ornamentPosition&&f(e,"ornamentPosition",this.ornamentPosition),"auto"!==this.volumePosition&&f(e,"volumePosition",this.volumePosition),this.differentFont("measurefont",t)&&p(e,"measurefont",this.measurefont),this.differentFont("repeatfont",t)&&p(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])}}},b=function(e){var t=e.replace(/\x12/g," ");return(t=(t=t.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")},y=function(t,r,n){r||(r=" ");var i=r[n];" "!==i&&i||(i="SPACE");var a,s=b(r.substring(n-64,n))+'<span style="text-decoration:underline;font-size:1.3em;font-weight:bold;">'+i+"</span>"+b(r.substring(n+1).substring(0,64));!function(e){v.warnings||(v.warnings=[]),v.warnings.push(e)}("Music Line:"+e.lineIndex+":"+(n+1)+": "+t+": "+s),a={message:t,line:r,startChar:v.iChar+n,column:n},v.warningObjects||(v.warningObjects=[]),v.warningObjects.push(a)};this.getWarnings=function(){return v.warnings},this.getWarningObjects=function(){return v.warningObjects};var x=function(t,r){if(r.indexOf("")>=0)u+=r;else if(r=u+r,u="",t){"-"!==(r=n.strip(r))[r.length-1]&&(r+=" ");for(var i=[],a=0,s=!1,o=function(t){var o=n.strip(r.substring(a,t));if(o=o.replace(/\\([-_*|~])/g,"$1"),a=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),i.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)&&i.length>0&&(n.last(i).divider="-",i.push({skip:!0,to:"next"}));break;case"_":c||(o(l),i.push({skip:!0,to:"slur"}));break;case"*":c||(o(l),i.push({skip:!0,to:"next"}));break;case"|":c||(o(l),i.push({skip:!0,to:"bar"}));break;case"~":c||(s=!0)}c="\\"===r[l]}t.forEach((function(e){if(0!==i.length)if(i[0].skip){switch(i[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&i.shift();break;case"bar":"bar"===e.el_type&&i.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=i.shift();t.syllable&&(t.syllable=t.syllable.replace(/ +/g," ")),void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else y("Can't add words before the first line of music",t,0)},w=function(t,r){if(r.indexOf("")>=0)d+=r;else if(r=d+r,d="",t){"-"!==(r=n.strip(r))[r.length-1]&&(r+=" ");for(var i=[],a=0,s=!1,o=function(t){var o=n.strip(r.substring(a,t));if(a=t+1,o.length>0){s&&(o=o.replace(/~/g," "));var c=r[t];return"_"!==c&&"-"!==c&&(c=" "),i.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)&&i.length>0&&(n.last(i).divider="-",i.push({skip:!0,to:"next"}));break;case"_":o(c),i.push({skip:!0,to:"slur"});break;case"*":o(c),i.push({skip:!0,to:"next"});break;case"|":o(c),i.push({skip:!0,to:"bar"});break;case"~":s=!0}t.forEach((function(e){if(0!==i.length)if(i[0].skip)switch(i[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&i.shift();break;case"bar":"bar"===e.el_type&&i.shift()}else if("note"===e.el_type&&void 0===e.rest){var t=i.shift();void 0===e.lyric?e.lyric=[t]:e.lyric.push(t)}}))}else y("Can't add symbols before the first line of music",t,0)},k=function(e){if(n.startsWith(e,"%%")){var t=i.addDirective(e.substring(2));t&&y(t,e,2)}else{var a=e.indexOf("%");if(a>=0&&(e=e.substring(0,a)),0!==(e=e.replace(/\s+$/,"")).length)if(u)x(r.getCurrentVoice(),e.substring(2));else if(d)w(r.getCurrentVoice(),e.substring(2));else if(e.length<2||":"!==e[1]||g.lineContinuation)g.parseMusic(e);else{var s=m.parseHeader(e);s.regular&&g.parseMusic(e),s.newline&&g.startNewLine(),s.words&&x(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 i=t[r],a=n.clone(i);if(e.push(a),"bar"===i.el_type)return}}function T(e,t){for(var r=0;r<e.length;r++){var n=e[r],i=t[r];if(i)for(var a=0;a<i.voices.length;a++){var s=i.voices[a],o=n.voices[a];o&&C(o,s)}}}this.parse=function(l,h,f){h||(h={}),f||(f=0),t.reset();var p=(l=l.replace(/\r\n?/g,"\n")+"\n").split("\n\\");if(p.length>1){for(var b=1;b<p.length;b++)for(;p[b].length>0&&"\n"!==p[b][0];)p[b]=p[b].substr(1),p[b-1]+=" ";l=p.join(" ")}var C=(l=l.replace(/\\([ \t]*)(%.*)*\n/g,(function(e,t,r){return t+""+(r?Array(r.length+1).join(" "):"")+"\n"}))).split("\n");0===n.last(C).length&&C.pop(),e=new o(C,v),m=new a(e,y,v,t,r),g=new s(e,y,v,t,r,m),h.print&&(t.media="print"),v.reset(),v.iChar=f,h.visualTranspose?(v.globalTranspose=parseInt(h.visualTranspose),0===v.globalTranspose?v.globalTranspose=void 0:r.setVisualTranspose(h.visualTranspose)):v.globalTranspose=void 0,h.lineBreaks&&(v.lineBreaks=h.lineBreaks),m.reset(e,y,v,t);try{h.format&&i.globalFormatting(h.format);for(var _=e.nextLine();_;){if(h.header_only&&!1===v.is_in_header)throw"normal_abort";if(h.stop_on_warning&&v.warnings)throw"normal_abort";var S=v.is_in_header;k(_),S&&!v.is_in_header&&(r.setRunningFont("annotationfont",v.annotationfont),r.setRunningFont("gchordfont",v.gchordfont),r.setRunningFont("tripletfont",v.tripletfont),r.setRunningFont("vocalfont",v.vocalfont)),_=e.nextLine()}u&&x(r.getCurrentVoice(),""),d&&w(r.getCurrentVoice(),""),v.openSlurs=r.cleanUp(v.barsperstaff,v.staffnonote,v.openSlurs)}catch(e){if("normal_abort"!==e)throw e}var E=792,M=612;switch(v.papersize){case"legal":E=1008,M=612;break;case"A4":E=842.4,M=597.6}if(v.landscape){var N=E;E=M,M=N}t.formatting.pagewidth||(t.formatting.pagewidth=M),t.formatting.pageheight||(t.formatting.pageheight=E),h.hint_measures&&function(){for(var e=0;e<t.lines.length;e++){var r=t.lines[e].staff;if(r){for(var n=e+1;n<t.lines.length&&void 0===t.lines[n].staff;)n++;n<t.lines.length&&T(r,t.lines[n].staff)}}}(),c.wrapLines(t,v.lineBreaks,v.barNumbers)}}},9565:function(e,t,r){var n=r(5008);e.exports=function(e){"use strict";for(var t="",r=e.match(/(\s*)/),i=(e=n.strip(e)).split("\nX:"),a=1;a<i.length;a++)i[a]="X:"+i[a];var s=r?r[0].length:0,o=[];i.forEach((function(e){o.push({abc:e,startPos:s}),s+=e.length+1})),o.length>1&&!n.startsWith(o[0].abc,"X:")&&o.shift().abc.split("\n").forEach((function(e){n.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 i=e.pure.split("T:");i.length>1&&(i=i[1].split("\n"),e.title=n.strip(i[0]));var a=e.pure.substring(2,e.pure.indexOf("\n"));e.id=n.strip(a)})),{header:c,tunes:o}}},8360:function(e,t,r){var n=r(5008),i={};!function(){"use strict";var e,t,r,a,s;i.initialize=function(n,i,o,c,l){e=n,t=i,a=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"},a.formatting.composerfont={face:'"Times New Roman"',size:14,weight:"normal",style:"italic",decoration:"none"},a.formatting.subtitlefont={face:'"Times New Roman"',size:16,weight:"normal",style:"normal",decoration:"none"},a.formatting.tempofont={face:'"Times New Roman"',size:15,weight:"bold",style:"normal",decoration:"none"},a.formatting.titlefont={face:'"Times New Roman"',size:20,weight:"normal",style:"normal",decoration:"none"},a.formatting.footerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},a.formatting.headerfont={face:'"Times New Roman"',size:12,weight:"normal",style:"normal",decoration:"none"},a.formatting.voicefont={face:'"Times New Roman"',size:13,weight:"bold",style:"normal",decoration:"none"},a.formatting.tablabelfont={face:'"Trebuchet MS"',size:16,weight:"normal",style:"normal",decoration:"none"},a.formatting.tabnumberfont={face:'"Arial"',size:11,weight:"normal",style:"normal",decoration:"none"},a.formatting.tabgracefont={face:'"Arial"',size:8,weight:"normal",style:"normal",decoration:"none"},a.formatting.annotationfont=r.annotationfont,a.formatting.gchordfont=r.gchordfont,a.formatting.historyfont=r.historyfont,a.formatting.infofont=r.infofont,a.formatting.measurefont=r.measurefont,a.formatting.partsfont=r.partsfont,a.formatting.repeatfont=r.repeatfont,a.formatting.textfont=r.textfont,a.formatting.tripletfont=r.tripletfont,a.formatting.vocalfont=r.vocalfont,a.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,n,i,a){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[a]?{face:r.face,weight:r.weight,style:r.style,decoration:r.decoration,size:s,box:!0}:(t("Extra parameters in font definition.",n,i),{face:r.face,weigh