/*! abcjs_basic v6.4.4 Copyright © 2009-2024 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),a=r(6306),i=r(1592),s=r(1028),o=r(5633),c={};c.signature="abcjs-basic v"+n,Object.keys(a).forEach((function(e){c[e]=a[e]})),Object.keys(i).forEach((function(e){c[e]=i[e]})),c.renderAbc=r(6859),c.tuneMetrics=r(9989),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),k=r(9991);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,midiRenderer:k},c.Editor=r(5294),c.EditArea=r(2945),e.exports=c},6306:function(e,t,r){var n=r(5681),a={};!function(){"use strict";var e,t;a.startAnimation=function(r,a,i){function s(e){for(var t=0;tr.currentEvent&&r.noteTimings[r.currentEvent].millisecondsr.currentLine&&r.lineEndTimings[r.currentLine].milliseconds=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,a=r.currentEvent;a=0&&null===r.noteTimings[a].left;)a--;n=r.noteTimings[a]}var i={},s={};if(n){i.top=n.top,i.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;i.left=n.left+h,0===r.currentEvent&&n.milliseconds>e-r.startTime&&(i.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,i,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 a=performance.now();for(r.startTime=a-r.currentTime,r.currentEvent,r.currentEvent=0;r.noteTimings.length>r.currentEvent&&r.noteTimings[r.currentEvent].millisecondsr.currentLine&&r.lineEndTimings[r.currentLine].milliseconds+r.lineEndAnticipation=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 a=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=0&&h0,v=0;v=0&&(d=T.startChar,u=void 0===T.chord?h:null),T.chord&&(h=T),"bar"===T.el_type){if(p){var S={abc:i.abc.substring(d,T.endChar)};(h=u&&u.chord&&u.chord.length>0?u.chord[0].name:null)&&(S.lastChord=h),T.startEnding&&(S.startEnding=T.startEnding),T.endEnding&&(S.endEnding=T.endEnding),f.push(S),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),a=(r(6780),r(5253)),i=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,i){r.viewportHorizontal?(e.innerHTML='
',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='
',e.style.overflowX="hidden",e.style.overflowY="auto",e=e.children[0]):e.innerHTML="";var s=new a(e,r);s.engraveABC(t,n,i),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)),!o&&u.wrap&&u.staffwidth?(t=function(e,t,r,n,o){var c=new a(e,o).getMeasureWidths(t),h=s.calcLineWraps(t,c,o);if(h.reParse){var u=new i;u.parse(n,h.revisedParams),t=u.getTune();var d=u.getWarnings();d&&(t.warnings=d)}return o.afterParsing&&o.afterParsing(t,r,n),l(e,t,h.revisedParams,r,0),t.explanation=h.explanation,t}(e,t,r,n,u),t):(u.afterParsing&&u.afterParsing(t,r,n),l(e,t,u,r,0),o&&e.parentNode.removeChild(e),null)}),e,t,u)}},9989:function(e,t,r){var n=r(1592),a=r(5253);e.exports=function(e,t){return n.renderEngine((function(e,r,n,i){(e=document.createElement("div")).setAttribute("style","visibility: hidden;"),document.body.appendChild(e);var s=new a(e,t).getMeasureWidths(r);return e.parentNode.removeChild(e),{sections:s}}),"*",e,t)}},9447:function(e,t,r){var n=r(4914).relativeMajor,a={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"},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#":[a,i,s,o,c,l,{acc:"sharp",note:"B"}],"F#":[a,i,s,o,c,l],B:[a,i,s,o,c],E:[a,i,s,o],A:[a,i,s],D:[a,i],G:[a],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=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;ee)return c}}return null},this.addElementToEvents=function(e,t,r,a,i,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;f0)for(var s=i.staffs[0],o=s.absoluteY,c=o-s.top*a.STEP,l=i.staffs[i.staffs.length-1],h=(o=l.absoluteY)-l.bottom*a.STEP-c,u=i.voices,d=0;d0&&o["event"+p]&&(w="event"+p),p=Math.round(1e3*f),"bar"===C.type){var S=C.abcelem.type,_="bar_right_repeat"===S||"bar_dbl_repeat"===S,E="1"===C.abcelem.startEnding,M="bar_left_repeat"===S||"bar_dbl_repeat"===S||"bar_right_repeat"===S;if(_){x>0&&(o[w].endX=C.x),-1===g&&(g=x);var N=0;y=-1;for(var A=m;A=0;i--){var s=e[i];"bar"===s.type?(s.top=n,s.nextTop=t,t=n,s.bottom=a,s.nextBottom=r,r=a):"event"===s.type&&(n=s.top,a=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;na.left&&(a.endX=Math.min(a.endX,s)):a.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*a),s},this.addUsefulCallbackInfo=function(e,t){for(var r=this.millisecondsPerMeasure(t),n=0;n0?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."),this.noteTimings=[],this.noteTimings;var r=this.metaText?this.metaText.tempo:null,n=this.getBpm(r),a=1;e?r&&(a=e/n):e=n;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,a),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;r0&&(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 a,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("
"):"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,a="abc_textarea_dirty",i=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=i,r=a)||(t.className+=(t.className?" ":"")+r):function(e,t){e.className=n.strip(e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," "))}(i,a)}},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,a,i){this.editarea.setSelection(e.startChar,e.endChar),this.selectionChangeCallback&&this.selectionChangeCallback(e.startChar,e.endChar),this.clientClickListener&&this.clientClickListener(e,t,r,n,a,i)},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,a=r(9991);!function(){"use strict";function e(e,t,r){for(var n=Object.keys(t),a=0;ai){var c=(n[s]-i)*r;e.addRest(c),i=n[s]}for(var l=0;l128&&(s=s.substring(0,124)+"...");var o=t.getKeySignature(),c=t.getMeterFraction(),l=n.tempo,h=l/60;8==c.den&&(h=(l=6e4/(t.millisecondsPerMeasure()/c.num)/2)/60),i.setGlobalInfo(l,s,o,c);for(var u=0;uu&&(m=r.pan[u]),128===p.instrument?(i.setChannel(9,m),i.setInstrument(0)):(i.setChannel(p.channel,m),i.setInstrument(p.instrument));break;case"note":var g=p.gap*h,v=p.start,b=v+p.duration-g;d[v]||(d[v]=[]),d[v].push({pitch:p.pitch,volume:p.volume,cents:p.cents}),d[b]||(d[b]=[]),d[b].push({pitch:p.pitch,volume:0});break;default:console.log("MIDI create Unknown: "+p.cmd)}}e(i,d,1920),i.endTrack()}return i.getData()}}(),e.exports=n},5008:function(e){var t={cloneArray:function(e){for(var t=[],r=0;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),a=r(8360),i=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,findSelectableElement:t.findSelectableElement,getSelectableArray:t.getSelectableArray};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/g,">")},y=function(t,r,n){r||(r=" ");var a=r[n];" "!==a&&a||(a="SPACE");var i,s=b(r.substring(n-64,n))+''+a+""+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),i={message:t,line:r,startChar:v.iChar+n,column:n},v.warningObjects||(v.warningObjects=[]),v.warningObjects.push(i)};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 a=[],i=0,s=!1,o=function(t){var o=n.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=" "),a.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=!1,l=0;l0&&(n.last(a).divider="-",a.push({skip:!0,to:"next"}));break;case"_":c||(o(l),a.push({skip:!0,to:"slur"}));break;case"*":c||(o(l),a.push({skip:!0,to:"next"}));break;case"|":c||(o(l),a.push({skip:!0,to:"bar"}));break;case"~":c||(s=!0)}c="\\"===r[l]}t.forEach((function(e){if(0!==a.length)if(a[0].skip){switch(a[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&a.shift();break;case"bar":"bar"===e.el_type&&a.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=a.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)},k=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 a=[],i=0,s=!1,o=function(t){var o=n.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=" "),a.push({syllable:e.translateString(o),divider:c}),s=!1,!0}return!1},c=0;c0&&(n.last(a).divider="-",a.push({skip:!0,to:"next"}));break;case"_":o(c),a.push({skip:!0,to:"slur"});break;case"*":o(c),a.push({skip:!0,to:"next"});break;case"|":o(c),a.push({skip:!0,to:"bar"});break;case"~":s=!0}t.forEach((function(e){if(0!==a.length)if(a[0].skip)switch(a[0].to){case"next":case"slur":"note"===e.el_type&&null!==e.pitches&&a.shift();break;case"bar":"bar"===e.el_type&&a.shift()}else if("note"===e.el_type&&void 0===e.rest){var t=a.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)},w=function(e){if(n.startsWith(e,"%%")){var t=a.addDirective(e.substring(2));t&&y(t,e,2)}else{var i=e.indexOf("%");if(i>=0&&(e=e.substring(0,i)),0!==(e=e.replace(/\s+$/,"")).length)if(u)x(r.getCurrentVoice(),e.substring(2));else if(d)k(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&&k(r.getCurrentVoice(),e.substring(2))}}};function C(e,t){e.push({el_type:"hint"});for(var r=0;r1){for(var b=1;b0&&"\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 i(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&&a.globalFormatting(h.format);for(var S=e.nextLine();S;){if(h.header_only&&!1===v.is_in_header)throw"normal_abort";if(h.stop_on_warning&&v.warnings)throw"normal_abort";var _=v.is_in_header;w(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)),S=e.nextLine()}u&&x(r.getCurrentVoice(),""),d&&k(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;e1&&!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 a=e.pure.split("T:");a.length>1&&(a=a[1].split("\n"),e.title=n.strip(a[0]));var i=e.pure.substring(2,e.pure.indexOf("\n"));e.id=n.strip(i)})),{header:c,tunes:o}}},8360:function(e,t,r){var n=r(5008),a={};!function(){"use strict";var e,t,r,i,s;a.initialize=function(n,a,o,c,l){e=n,t=a,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,n,a,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.",n,a),{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.",n,a),{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 *.",n,a)}if("number"===e[0].type)return s();for(var c,l=[],h="normal",u="normal",d="none",f=!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.",n,a):c=g.token,p="modifier"):"bold"===v?h="bold":"italic"===v?u="italic":"underline"===v?d="underline":"box"===v?(o[i]?f=!0:t('This font style doesn\'t support "box"',n,a),p="finished"):"utf"===v?(g=e.shift(),p="size"):t("Unknown parameter "+g.token+" in font definition.",n,a);break;case"size":"number"===g.type?c?t("Font size specified twice in font definition.",n,a):c=g.token:t("Expected font size in font definition.",n,a),p="modifier";break;case"modifier":"bold"===v?h="bold":"italic"===v?u="italic":"underline"===v?d="underline":"box"===v?(o[i]?f=!0:t('This font style doesn\'t support "box"',n,a),p="finished"):t("Unknown parameter "+g.token+" in font definition.",n,a);break;case"finished":t('Extra characters found after "box" in font definition.',n,a)}}void 0===c?r?c=r.size:(t("Must specify the size of the font since there is no default value.",n,a),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.",n,a),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,f&&(y.box=!0),y):(y.face=l,y.weight=h,y.style=u,y.decoration=d,y.size=c,f&&(y.box=!0),y)},l=function(e,t,n){return 0===t.length?'Directive "'+e+'" requires a font as a parameter.':(r[e]=c(t,r[e],n,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 n=parseFloat(r);if(isNaN(n)||0===n)return'Directive "'+e+'" requires a number as a parameter.';i.formatting.scale=n},u=["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"],d=function(e,t,n,a,i){if(1!==n.length||"number"!==n[0].type)return'Directive "'+t+'" requires a number as a parameter.';var s=n[0].intt;return void 0!==a&&si?'Directive "'+t+'" requires a number less than or equal to '+i+" as a parameter.":(r[e]=s,null)},f=function(e,t,n){if(1===n.length&&("true"===n[0].token||"false"===n[0].token))return r[e]="true"===n[0].token,null;var a=d(e,t,n,0,1);return null!==a?a:(r[e]=1===r[e],null)},p=function(e,t,n,a){if(1!==n.length)return'Directive "'+t+'" requires one of [ '+a.join(", ")+" ] as a parameter.";for(var i=n[0].token,s=!1,o=0;!s&&o1&&r.setfont){var n=[];""!==t[0]&&n.push({text:t[0]});for(var a=1;a=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+")"}}a.addDirective=function(o){var M=e.tokenize(o,0,o.length);if(0===M.length||"alpha"!==M[0].type)return null;var N=o.substring(o.indexOf(M[0].token)+M[0].token.length);N=e.stripComment(N);var A,B=M.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!==M.length)return"Directive graceslurs requires one parameter: 0 or 1";if("0"===M[0].token||"false"===M[0].token)i.formatting.graceSlurs=!1;else{if("1"!==M[0].token&&"true"!==M[0].token)return"Directive graceslurs requires one parameter: 0 or 1 (received "+M[0].token+")";i.formatting.graceSlurs=!0}break;case"lineThickness":var L=E(M);if(void 0!==L.value&&(i.formatting.lineThickness=L.value),L.error)return L.error;break;case"stretchlast":var O=E(M);if(void 0!==O.value&&(i.formatting.stretchlast=O.value),O.error)return O.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,M,_);case"dynamic":return p("dynamicPosition",B,M,_);case"gchord":return p("chordPosition",B,M,_);case"ornament":return p("ornamentPosition",B,M,_);case"volume":return p("volumePosition",B,M,_);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 n=e.getMeasurement(r);return 0===n.used||0!==r.length?'Directive "'+t+'" requires a measurement as a parameter.':(i.formatting[t]=n.value,null)}(B,M);case"voicescale":if(1!==M.length||"number"!==M[0].type)return"voicescale requires one float as a parameter";var H=M.shift();return r.currentVoice&&(r.currentVoice.scale=H.floatt,s.changeVoiceScale(r.currentVoice.scale)),null;case"voicecolor":if(1!==M.length)return"voicecolor requires one string as a parameter";var z=M.shift();return r.currentVoice&&(r.currentVoice.color=z.token,s.changeVoiceColor(r.currentVoice.color)),null;case"vskip":var D=Math.round(function(t,r){var n=e.getMeasurement(r);return 0===n.used||0!==r.length?{error:'Directive "'+t+'" requires a measurement as a parameter.'}:n.value}(B,M));return D.error?D.error:(s.addSpacing(D),null);case"scale":h(B,M);break;case"sep":if(0===M.length)s.addSeparator(14,14,85,{startChar:r.iChar,endChar:r.iChar+5});else{var F=e.getMeasurement(M);if(0===F.used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var j=F.value;if(0===(F=e.getMeasurement(M)).used)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var I=F.value;if(0===(F=e.getMeasurement(M)).used||0!==M.length)return'Directive "'+B+'" requires 3 numbers: space above, space below, length of line';var V=F.value;s.addSeparator(j,I,V,{startChar:r.iChar,endChar:r.iChar+N.length})}break;case"barsperstaff":if(null!==(P=d("barsperstaff",B,M)))return P;break;case"staffnonote":if(1!==M.length)return"Directive staffnonote requires one parameter: 0 or 1";if("0"===M[0].token)r.staffnonote=!0;else{if("1"!==M[0].token)return"Directive staffnonote requires one parameter: 0 or 1 (received "+M[0].token+")";r.staffnonote=!1}break;case"printtempo":if(null!==(P=f("printTempo",B,M)))return P;break;case"partsbox":if(null!==(P=f("partsBox",B,M)))return P;r.partsfont.box=r.partsBox;break;case"freegchord":if(null!==(P=f("freegchord",B,M)))return P;break;case"measurenb":case"barnumbers":if(null!==(P=d("barNumbers",B,M)))return P;break;case"setbarnb":if(1!==M.length||"number"!==M[0].type)return"Directive setbarnb requires a number as a parameter.";r.currBarNumber=s.setBarNumberImmediate(M[0].intt);break;case"begintext":var Y="";for(A=e.nextLine();A&&0!==A.indexOf("%%endtext");)n.startsWith(A,"%%")?Y+=A.substring(2)+"\n":Y+=A+"\n",A=e.nextLine();s.addText(Y,{startChar:r.iChar,endChar:r.iChar+Y.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 G=e.translateString(N);s.addText(a.parseFontChangeLine(G),{startChar:r.iChar,endChar:r.iChar+N.length+7});break;case"center":var q=e.translateString(N);s.addCentered(a.parseFontChangeLine(q));break;case"font":break;case"setfont":var W=e.tokenize(N,0,N.length);if(W.length>=4&&"-"===W[0].token&&"number"===W[1].type){var R=parseInt(W[1].token);R>=1&&R<=9&&(r.setfont||(r.setfont=[]),W.shift(),W.shift(),r.setfont[R]=c(W,r.setfont[R],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,M,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,M,o);case"barlabelfont":case"barnumberfont":case"barnumfont":return l("measurefont",M,o);case"staves":case"score":r.score_is_present=!0;for(var X,U=function(e,t,a,i,s){(t||0===r.staves.length)&&r.staves.push({index:r.staves.length,numVoices:0});var o=n.last(r.staves);void 0!==a&&void 0===o.bracket&&(o.bracket=a),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.numVoices},o.numVoices++)},K=!1,$=!1,Q=!1,J=!1,Z=!1,ee=!1,te=!1,re=function(){if(te=!0,X){var e="start";X.staffNum>0&&("start"!==r.staves[X.staffNum-1].connectBarLines&&"continue"!==r.staves[X.staffNum-1].connectBarLines||(e="continue")),r.staves[X.staffNum].connectBarLines=e}};M.length;){var ne=M.shift();switch(ne.token){case"(":K?t("Can't nest parenthesis in %%score",o,ne.start):(K=!0,J=!0);break;case")":!K||J?t("Unexpected close parenthesis in %%score",o,ne.start):K=!1;break;case"[":$?t("Can't nest brackets in %%score",o,ne.start):($=!0,Z=!0);break;case"]":!$||Z?t("Unexpected close bracket in %%score",o,ne.start):($=!1,r.staves[X.staffNum].bracket="end");break;case"{":Q?t("Can't nest braces in %%score",o,ne.start):(Q=!0,ee=!0);break;case"}":!Q||ee?t("Unexpected close brace in %%score",o,ne.start):(Q=!1,r.staves[X.staffNum].brace="end");break;case"|":re();break;default:for(var ae="";("alpha"===ne.type||"number"===ne.type)&&(ae+=ne.token,ne.continueId);)ne=M.shift();U(ae,!K||J,Z?"start":$?"continue":void 0,ee?"start":Q?"continue":void 0,te),J=!1,Z=!1,ee=!1,te=!1,X=r.voices[ae],"staves"===B&&re()}}break;case"newpage":var ie=e.getInt(N);s.addNewPage(0===ie.digits?-1:ie.value);break;case"abc":var se=N.split(" ");switch(se[0]){case"-copyright":case"-creator":case"-edited-by":case"-version":case"-charset":var oe=se.shift();s.addMetaText(B+oe,se.join(" "),{startChar:r.iChar,endChar:r.iChar+N.length+5});break;default:return"Unknown directive: "+B+se[0]}break;case"header":case"footer":var ce=e.getMeat(N,0,N.length);'"'===(ce=N.substring(ce.start,ce.end))[0]&&'"'===ce[ce.length-1]&&(ce=ce.substring(1,ce.length-1));var le=ce.split("\t"),he={};he=1===le.length?{left:"",center:le[0],right:""}:2===le.length?{left:le[0],center:le[1],right:""}:{left:le[0],center:le[1],right:le[2]},le.length>3&&t("Too many tabs in "+B+": "+le.length+" found.",N,0),s.addMetaTextObj(B,he,{startChar:r.iChar,endChar:r.iChar+o.length});break;case"midi":var ue=e.tokenize(N,0,N.length,!0);ue.length>0&&"="===ue[0].token&&ue.shift(),0===ue.length?t("Expected midi command",N,0):function(e,r,n){var a=e.shift().token,i=[];if(m.indexOf(a)>=0)0!==e.length&&t("Unexpected parameter in MIDI "+a,n,0);else if(g.indexOf(a)>=0)1!==e.length?t("Expected one parameter in MIDI "+a,n,0):i.push(e[0].token);else if(v.indexOf(a)>=0)1!==e.length?t("Expected one parameter in MIDI "+a,n,0):"number"!==e[0].type?t("Expected one integer parameter in MIDI "+a,n,0):i.push(e[0].intt);else if(b.indexOf(a)>=0)1!==e.length&&2!==e.length?t("Expected one or two parameters in MIDI "+a,n,0):"number"!==e[0].type||2===e.length&&"number"!==e[1].type?t("Expected integer parameter in MIDI "+a,n,0):(i.push(e[0].intt),2===e.length&&i.push(e[1].intt));else if(y.indexOf(a)>=0)2!==e.length?t("Expected two parameters in MIDI "+a,n,0):"number"!==e[0].type||"number"!==e[1].type?t("Expected two integer parameters in MIDI "+a,n,0):(i.push(e[0].intt),i.push(e[1].intt));else if(w.indexOf(a)>=0)2!==e.length?t("Expected two parameters in MIDI "+a,n,0):"alpha"!==e[0].type||"number"!==e[1].type?t("Expected one string and one integer parameters in MIDI "+a,n,0):(i.push(e[0].token),i.push(e[1].intt));else if("drummap"===a)2===e.length&&"alpha"===e[0].type&&"number"===e[1].type?(r.formatting||(r.formatting={}),r.formatting.midi||(r.formatting.midi={}),r.formatting.midi.drummap||(r.formatting.midi.drummap={}),r.formatting.midi.drummap[e[0].token]=e[1].intt,i=r.formatting.midi.drummap):3===e.length&&"punct"===e[0].type&&"alpha"===e[1].type&&"number"===e[2].type?(r.formatting||(r.formatting={}),r.formatting.midi||(r.formatting.midi={}),r.formatting.midi.drummap||(r.formatting.midi.drummap={}),r.formatting.midi.drummap[e[0].token+e[1].token]=e[2].intt,i=r.formatting.midi.drummap):t("Expected one note name and one integer parameter in MIDI "+a,n,0);else if(C.indexOf(a)>=0)3!==e.length||"number"!==e[0].type||"/"!==e[1].token||"number"!==e[2].type?t("Expected fraction parameter in MIDI "+a,n,0):(i.push(e[0].intt),i.push(e[2].intt));else if(x.indexOf(a)>=0)4!==e.length?t("Expected four parameters in MIDI "+a,n,0):"number"!==e[0].type||"number"!==e[1].type||"number"!==e[2].type||"number"!==e[3].type?t("Expected four integer parameters in MIDI "+a,n,0):(i.push(e[0].intt),i.push(e[1].intt),i.push(e[2].intt),i.push(e[3].intt));else if(k.indexOf(a)>=0)5!==e.length?t("Expected five parameters in MIDI "+a,n,0):"number"!==e[0].type||"number"!==e[1].type||"number"!==e[2].type||"number"!==e[3].type||"number"!==e[4].type?t("Expected five integer parameters in MIDI "+a,n,0):(i.push(e[0].intt),i.push(e[1].intt),i.push(e[2].intt),i.push(e[3].intt),i.push(e[4].intt));else if(b.indexOf(a)>=0)1!==e.length||4!==e.length?t("Expected one or two parameters in MIDI "+a,n,0):"number"!==e[0].type?t("Expected integer parameter in MIDI "+a,n,0):4===e.length?("octave"!==e[1].token&&t("Expected octave parameter in MIDI "+a,n,0),"="!==e[2].token&&t("Expected octave parameter in MIDI "+a,n,0),"number"!==e[3].type&&t("Expected integer parameter for octave in MIDI "+a,n,0)):(i.push(e[0].intt),4===e.length&&i.push(e[3].intt));else if(T.indexOf(a)>=0)if(e.length<2)t("Expected string parameter and at least one integer parameter in MIDI "+a,n,0);else if("alpha"!==e[0].type)t("Expected string parameter and at least one integer parameter in MIDI "+a,n,0);else{var o=e.shift();for(i.push(o.token);e.length>0;)"number"!==(o=e.shift()).type&&t("Expected integer parameter in MIDI "+a,n,0),i.push(o.intt)}else if(S.indexOf(a)>=0)if(1!==e.length&&2!==e.length)t("Expected one or two parameters in MIDI "+a,n,0);else if("number"!==e[0].type)t("Expected integer parameter in MIDI "+a,n,0);else if(2===e.length&&"alpha"!==e[1].type)t("Expected alpha parameter in MIDI "+a,n,0);else if(i.push(e[0].intt),2===e.length){var c=e[1].token;-1!=c.indexOf("octave=")?(c=c.replace("octave=",""),c=parseInt(c),isNaN(c)?t("Expected octave value in MIDI"+a):(c<-1&&(t("Expected octave= in MIDI "+a+" to be >= -1 (recv:"+c+")"),c=-1),c>3&&(t("Expected octave= in MIDI "+a+" to be <= 3 (recv:"+c+")"),c=3),i.push(c))):t("Expected octave= in MIDI"+a)}s.hasBeginMusic()?s.appendElement("midi",-1,-1,{cmd:a,params:i}):(void 0===r.formatting.midi&&(r.formatting.midi={}),r.formatting.midi[a]=i)}(ue,i,N);break;case"percmap":var de=function(e){var t=e.split(/\s+/);if(2!==t.length&&3!==t.length)return{error:'Expected parameters "abc-note", "drum-sound", and optionally "note-head"'};var r=t[0],n=parseInt(t[1],10);if((isNaN(n)||n<35||n>81)&&t[1]&&(n=u.indexOf(t[1].toLowerCase())+35),isNaN(n)||n<35||n>81)return{error:'Expected drum name, received "'+t[1]+'"'};var a={sound:n};return 3===t.length&&(a.noteHead=t[2]),{key:r,value:a}}(N);de.error?t(de.error,o,8):(i.formatting.percmap||(i.formatting.percmap={}),i.formatting.percmap[de.key]=de.value);break;case"map":case"playtempo":case"auquality":case"continuous":case"nobarcheck":i.formatting[B]=N;break;default:return"Unknown directive: "+B}return null},a.globalFormatting=function(n){for(var a in n)if(n.hasOwnProperty(a)){var s,o=""+n[a],c=e.tokenize(o,0,o.length);switch(a){case"titlefont":case"gchordfont":case"composerfont":case"footerfont":case"headerfont":case"historyfont":case"infofont":case"measurefont":case"partsfont":case"repeatfont":case"subtitlefont":case"tempofont":case"textfont":case"voicefont":case"tripletfont":case"vocalfont":case"wordsfont":case"annotationfont":case"tablabelfont":case"tabnumberfont":case"tabgracefont":l(a,c,o);break;case"scale":h(a,c);break;case"partsbox":null!==(s=f("partsBox",a,c))&&t(s),r.partsfont.box=r.partsBox;break;case"freegchord":null!==(s=f("freegchord",a,c))&&t(s);break;case"fontboxpadding":1===c.length&&"number"===c[0].type||t('Directive "'+a+'" requires a number as a parameter.'),i.formatting.fontboxpadding=c[0].floatt;break;case"stafftopmargin":1===c.length&&"number"===c[0].type||t('Directive "'+a+'" requires a number as a parameter.'),i.formatting.stafftopmargin=c[0].floatt;break;case"stretchlast":var u=E(c);if(void 0!==u.value&&(i.formatting.stretchlast=u.value),u.error)return u.error;break;default:t("Formatting directive unrecognized: ",a,0)}}}}(),e.exports=a},9928:function(e,t,r){var n=r(5008),a=r(8360),i=r(9708);e.exports=function(e,t,r,s,o){this.reset=function(e,t,r,n){i.initialize(e,t,r,n,o),a.initialize(e,t,r,n,o)},this.reset(e,t,r,s),this.setTitle=function(e,t){r.hasMainTitle?o.addSubtitle(e,{startChar:r.iChar,endChar:r.iChar+t+2}):(o.addMetaText("title",e,{startChar:r.iChar,endChar:r.iChar+t+2}),r.hasMainTitle=!0)},this.setMeter=function(n){if("C"===(n=e.stripComment(n)))return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"common_time"};if("C|"===n)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"cut_time"};if("o"===n)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_perfectum"};if("c"===n)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_imperfectum"};if("o."===n)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_perfectum_prolatio"};if("c."===n)return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),{type:"tempus_imperfectum_prolatio"};if(0===n.length||"none"===n.toLowerCase())return!0===r.havent_set_length&&(r.default_length=.125,r.havent_set_length=!1),null;var a=e.tokenize(n,0,n.length);try{var i=function(){var e=function(){var e={value:0,num:""},t=a.shift();for("("===t.token&&(t=a.shift());;){if("number"!==t.type)throw"Expected top number of meter";if(e.value+=parseInt(t.token),e.num+=t.token,0===a.length||"/"===a[0].token)return e;if(")"===(t=a.shift()).token){if(0===a.length||"/"===a[0].token)return e;throw"Unexpected paren in meter"}if("."!==t.token&&"+"!==t.token)throw"Expected top number of meter";if(e.num+=t.token,0===a.length)throw"Expected top number of meter";t=a.shift()}return e}();if(0===a.length)return e;var t=a.shift();if("/"!==t.token)throw"Expected slash in meter";if("number"!==(t=a.shift()).type)throw"Expected bottom number of meter";return e.den=t.token,e.value=e.value/parseInt(e.den),e};if(0===a.length)throw"Expected meter definition in M: line";for(var s={type:"specified",value:[]},o=0;;){var c=i();o+=c.value;var l={num:c.num};if(void 0!==c.den&&(l.den=c.den),s.value.push(l),0===a.length)break}return!0===r.havent_set_length&&(r.default_length=o<.75?.0625:.125,r.havent_set_length=!1),s}catch(e){t(e,n,0)}return null},this.calcTempo=function(e){var t=1/4;r.meter&&"specified"===r.meter.type?t=1/parseInt(r.meter.value[0].den):r.origMeter&&"specified"===r.origMeter.type&&(t=1/parseInt(r.origMeter.value[0].den));for(var n=0;n0&&(r.default_length=i/s,r.havent_set_length=!1)}else 1===a.length&&"1"===a[0]&&(r.default_length=1,r.havent_set_length=!1)};var c={larghissimo:20,adagissimo:24,sostenuto:28,grave:32,largo:40,lento:50,larghetto:60,adagio:68,adagietto:74,andante:80,andantino:88,"marcia moderato":84,"andante moderato":100,moderato:112,allegretto:116,"allegro moderato":120,allegro:126,animato:132,agitato:140,veloce:148,"mosso vivo":156,vivace:164,vivacissimo:172,allegrissimo:176,presto:184,prestissimo:210};this.setTempo=function(n,a,i,s){try{var o=e.tokenize(n,a,i);if(0===o.length)throw"Missing parameter in Q: field";var l={startChar:s+a-2,endChar:s+i},h=!0,u=o.shift();if("quote"===u.type&&(l.preString=u.token,u=o.shift(),0===o.length))return c[l.preString.toLowerCase()]&&(l.bpm=c[l.preString.toLowerCase()],l.suppressBpm=!0),{type:"immediate",tempo:l};if("alpha"===u.type&&"C"===u.token){if(0===o.length)throw"Missing tempo after C in Q: field";if("punct"===(u=o.shift()).type&&"="===u.token){if(0===o.length)throw"Missing tempo after = in Q: field";if("number"!==(u=o.shift()).type)throw"Expected number after = in Q: field";l.duration=[1],l.bpm=parseInt(u.token)}else{if("number"!==u.type)throw"Expected number or equal after C in Q: field";if(l.duration=[parseInt(u.token)],0===o.length)throw"Missing = after duration in Q: field";if("punct"!==(u=o.shift()).type||"="!==u.token)throw"Expected = after duration in Q: field";if(0===o.length)throw"Missing tempo after = in Q: field";if("number"!==(u=o.shift()).type)throw"Expected number after = in Q: field";l.bpm=parseInt(u.token)}}else{if("number"!==u.type)throw"Unknown value in Q: field";var d=parseInt(u.token);if(0===o.length||"quote"===o[0].type)l.duration=[1],l.bpm=d;else{if(h=!1,"punct"!==(u=o.shift()).type&&"/"!==u.token)throw"Expected fraction in Q: field";if("number"!==(u=o.shift()).type)throw"Expected fraction in Q: field";var f=parseInt(u.token);for(l.duration=[d/f];o.length>0&&"="!==o[0].token&&"quote"!==o[0].type;){if("number"!==(u=o.shift()).type)throw"Expected fraction in Q: field";if(d=parseInt(u.token),"punct"!==(u=o.shift()).type&&"/"!==u.token)throw"Expected fraction in Q: field";if("number"!==(u=o.shift()).type)throw"Expected fraction in Q: field";f=parseInt(u.token),l.duration.push(d/f)}if("punct"!==(u=o.shift()).type&&"="!==u.token)throw"Expected = in Q: field";if("number"!==(u=o.shift()).type)throw"Expected tempo in Q: field";l.bpm=parseInt(u.token)}}if(0!==o.length&&("quote"===(u=o.shift()).type&&(l.postString=u.token,u=o.shift()),0!==o.length))throw"Unexpected string at end of Q: field";return!1===r.printTempo&&(l.suppress=!0),{type:h?"delaySet":"immediate",tempo:l}}catch(e){return t(e,n,a),{type:"none"}}},this.letter_to_inline_header=function(n,c,l){var h=!1,u=e.eatWhiteSpace(n,c);if(c+=u,n.length>=c+5&&"["===n[c]&&":"===n[c+2]){var d=n.indexOf("]",c),f=r.iChar+c,p=r.iChar+d+1;switch(n.substring(c,c+3)){case"[I:":var m=a.addDirective(n.substring(c+3,d));return m&&t(m,n,c),[d-c+1+u];case"[M:":var g=this.setMeter(n.substring(c+3,d));return o.hasBeginMusic()&&g?o.appendStartingElement("meter",f,p,g):r.meter=g,[d-c+1+u];case"[K:":var v=i.parseKey(n.substring(c+3,d),!0);return v.foundClef&&o.hasBeginMusic()&&o.appendStartingElement("clef",f,p,r.clef),v.foundKey&&o.hasBeginMusic()&&o.appendStartingElement("key",f,p,i.fixKey(r.clef,r.key)),[d-c+1+u];case"[P:":var b=a.parseFontChangeLine(n.substring(c+3,d));return l||s.lines.length<=s.lineNum?r.partForNextLine={title:b,startChar:f,endChar:p}:o.appendElement("part",f,p,{title:b}),[d-c+1+u];case"[L:":return this.setDefaultLength(n,c+3,d),[d-c+1+u];case"[Q:":if(d>0){var y=this.setTempo(n,c+3,d,r.iChar);return"delaySet"===y.type?o.hasBeginMusic()?o.appendElement("tempo",f,p,this.calcTempo(y.tempo)):r.tempoForNextLine=["tempo",f,p,this.calcTempo(y.tempo)]:"immediate"===y.type&&(!l&&o.hasBeginMusic()?o.appendElement("tempo",f,p,y.tempo):r.tempoForNextLine=["tempo",f,p,y.tempo]),[d-c+1+u,n[c+1],n.substring(c+3,d)]}break;case"[V:":if(d>0)return h=i.parseVoice(n,c+3,d),[d-c+1+u,n[c+1],n.substring(c+3,d),h];break;case"[r:":return[d-c+1+u]}}return[0]},this.letter_to_body_header=function(e,s){var c=!1;if(e.length>=s+3)switch(e.substring(s,s+2)){case"I:":var l=a.addDirective(e.substring(s+2));return l&&t(l,e,s),[e.length];case"M:":var h=this.setMeter(e.substring(s+2));return o.hasBeginMusic()&&h&&o.appendStartingElement("meter",r.iChar+s,r.iChar+e.length,h),[e.length];case"K:":var u=i.parseKey(e.substring(s+2),o.hasBeginMusic());return u.foundClef&&o.hasBeginMusic()&&o.appendStartingElement("clef",r.iChar+s,r.iChar+e.length,r.clef),u.foundKey&&o.hasBeginMusic()&&o.appendStartingElement("key",r.iChar+s,r.iChar+e.length,i.fixKey(r.clef,r.key)),[e.length];case"P:":return o.hasBeginMusic()&&o.appendElement("part",r.iChar+s,r.iChar+e.length,{title:e.substring(s+2)}),[e.length];case"L:":return this.setDefaultLength(e,s+2,e.length),[e.length];case"Q:":var d=e.indexOf("",s+2);-1===d&&(d=e.length);var f=this.setTempo(e,s+2,d,r.iChar);return"delaySet"===f.type?o.appendElement("tempo",r.iChar+s,r.iChar+e.length,this.calcTempo(f.tempo)):"immediate"===f.type&&o.appendElement("tempo",r.iChar+s,r.iChar+e.length,f.tempo),[d,e[s],n.strip(e.substring(s+2))];case"V:":return c=i.parseVoice(e,s+2,e.length),[e.length,e[s],n.strip(e.substring(s+2)),c]}return[0]};var l={A:"author",B:"book",C:"composer",D:"discography",F:"url",G:"group",I:"instruction",N:"notes",O:"origin",R:"rhythm",S:"source",W:"unalignedWords",Z:"transcription"};this.parseHeader=function(n){var c=l[n[0]],h=n.length-2,u=e.translateString(e.stripComment(n.substring(2)));if("unalignedWords"===c||"notes"===c)o.addMetaTextArray(c,a.parseFontChangeLine(u),{startChar:r.iChar,endChar:r.iChar+n.length});else if(void 0!==c)o.addMetaText(c,a.parseFontChangeLine(u),{startChar:r.iChar,endChar:r.iChar+n.length});else{var d=r.iChar,f=d+n.length;switch(n[0]){case"H":for(o.addMetaTextArray("history",a.parseFontChangeLine(u),{startChar:r.iChar,endChar:r.iChar+n.length}),n=e.peekLine();n&&":"!==n[1];)e.nextLine(),o.addMetaTextArray("history",a.parseFontChangeLine(e.translateString(e.stripComment(n))),{startChar:r.iChar,endChar:r.iChar+n.length}),n=e.peekLine();break;case"K":this.resolveTempo();var p=i.parseKey(n.substring(2),!1);!r.is_in_header&&o.hasBeginMusic()&&(p.foundClef&&o.appendStartingElement("clef",d,f,r.clef),p.foundKey&&o.appendStartingElement("key",d,f,i.fixKey(r.clef,r.key))),r.is_in_header=!1;break;case"L":this.setDefaultLength(n,2,n.length);break;case"M":r.origMeter=r.meter=this.setMeter(n.substring(2));break;case"P":r.is_in_header?o.addMetaText("partOrder",a.parseFontChangeLine(u),{startChar:r.iChar,endChar:r.iChar+n.length}):r.partForNextLine={title:u,startChar:d,endChar:f};break;case"Q":var m=this.setTempo(n,2,n.length,r.iChar);"delaySet"===m.type?r.tempo=m.tempo:"immediate"===m.type&&(s.metaText.tempo?r.tempoForNextLine=["tempo",d,f,m.tempo]:s.metaText.tempo=m.tempo);break;case"T":r.titlecaps&&(u=u.toUpperCase()),this.setTitle(a.parseFontChangeLine(e.theReverser(u)),h);break;case"U":this.addUserDefinition(n,2,n.length);break;case"V":if(i.parseVoice(n,2,n.length),!r.is_in_header)return{newline:!0};break;case"s":return{symbols:!0};case"w":return{words:!0};case"X":break;case"E":case"m":t("Ignored header",n,0);break;default:return{regular:!0}}}return{}}}},9708:function(e,t,r){var n=r(8360),a=r(2821),i={};!function(){var e,t,r,s;i.initialize=function(n,a,i,o,c){e=n,t=a,r=i,s=c},i.standardKey=function(e,t,n,i){return a.keySignature(r,e,t,n,i)};var o={treble:{clef:"treble",pitch:4,mid:0},"treble+8":{clef:"treble+8",pitch:4,mid:0},"treble-8":{clef:"treble-8",pitch:4,mid:0},"treble^8":{clef:"treble+8",pitch:4,mid:0},treble_8:{clef:"treble-8",pitch:4,mid:0},treble1:{clef:"treble",pitch:2,mid:2},treble2:{clef:"treble",pitch:4,mid:0},treble3:{clef:"treble",pitch:6,mid:-2},treble4:{clef:"treble",pitch:8,mid:-4},treble5:{clef:"treble",pitch:10,mid:-6},perc:{clef:"perc",pitch:6,mid:0},none:{clef:"none",mid:0},bass:{clef:"bass",pitch:8,mid:-12},"bass+8":{clef:"bass+8",pitch:8,mid:-12},"bass-8":{clef:"bass-8",pitch:8,mid:-12},"bass^8":{clef:"bass+8",pitch:8,mid:-12},bass_8:{clef:"bass-8",pitch:8,mid:-12},"bass+16":{clef:"bass",pitch:8,mid:-12},"bass-16":{clef:"bass",pitch:8,mid:-12},"bass^16":{clef:"bass",pitch:8,mid:-12},bass_16:{clef:"bass",pitch:8,mid:-12},bass1:{clef:"bass",pitch:2,mid:-6},bass2:{clef:"bass",pitch:4,mid:-8},bass3:{clef:"bass",pitch:6,mid:-10},bass4:{clef:"bass",pitch:8,mid:-12},bass5:{clef:"bass",pitch:10,mid:-14},tenor:{clef:"alto",pitch:8,mid:-8},tenor1:{clef:"alto",pitch:2,mid:-2},tenor2:{clef:"alto",pitch:4,mid:-4},tenor3:{clef:"alto",pitch:6,mid:-6},tenor4:{clef:"alto",pitch:8,mid:-8},tenor5:{clef:"alto",pitch:10,mid:-10},alto:{clef:"alto",pitch:6,mid:-6},alto1:{clef:"alto",pitch:2,mid:-2},alto2:{clef:"alto",pitch:4,mid:-4},alto3:{clef:"alto",pitch:6,mid:-6},alto4:{clef:"alto",pitch:8,mid:-8},alto5:{clef:"alto",pitch:10,mid:-10},"alto+8":{clef:"alto+8",pitch:6,mid:-6},"alto-8":{clef:"alto-8",pitch:6,mid:-6},"alto^8":{clef:"alto+8",pitch:6,mid:-6},alto_8:{clef:"alto-8",pitch:6,mid:-6}},c=function(e,t){var r=o[e];return(r?r.mid:0)+t};i.fixClef=function(e){var t=o[e.type];t&&(e.clefPos=t.pitch,e.type=t.clef)},i.deepCopyKey=function(e){var t={accidentals:[],root:e.root,acc:e.acc,mode:e.mode};return e.accidentals.forEach((function(e){t.accidentals.push(Object.assign({},e))})),t};var l={A:5,B:6,C:0,D:1,E:2,F:3,G:4,a:12,b:13,c:7,d:8,e:9,f:10,g:11};i.addPosToKey=function(e,t){var r=e.verticalPos;t.accidentals.forEach((function(e){var t=l[e.note];t-=r,e.verticalPos=t})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){var t=l[e.note];t-=r,e.verticalPos=t})),r<-10?(t.accidentals.forEach((function(e){e.verticalPos-=7,(e.verticalPos>=11||10===e.verticalPos&&"flat"===e.acc)&&(e.verticalPos-=7),"A"===e.note&&"sharp"===e.acc&&(e.verticalPos-=7),"G"!==e.note&&"F"!==e.note||"flat"!==e.acc||(e.verticalPos-=7)})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){e.verticalPos-=7,(e.verticalPos>=11||10===e.verticalPos&&"flat"===e.acc)&&(e.verticalPos-=7),"A"===e.note&&"sharp"===e.acc&&(e.verticalPos-=7),"G"!==e.note&&"F"!==e.note||"flat"!==e.acc||(e.verticalPos-=7)}))):r<-4?(t.accidentals.forEach((function(e){e.verticalPos-=7,-8!==r||"f"!==e.note&&"g"!==e.note||"sharp"!==e.acc||(e.verticalPos-=7)})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){e.verticalPos-=7,-8!==r||"f"!==e.note&&"g"!==e.note||"sharp"!==e.acc||(e.verticalPos-=7)}))):r>=7&&(t.accidentals.forEach((function(e){e.verticalPos+=7})),t.impliedNaturals&&t.impliedNaturals.forEach((function(e){e.verticalPos+=7})))},i.fixKey=function(e,t){var r=Object.assign({},t);return i.addPosToKey(e,r),r};var h=function(e){var t=0,r=e[t++];"^"!==r&&"_"!==r||(r=e[t++]);var n=l[r];for(void 0===n&&(n=6);t0){l.foundKey=!0;var u="",d="";o[0].token.length>1?o[0].token=o[0].token.substring(1):o.shift();var f=h.token;if(o.length>0){var p=e.getSharpFlat(o[0].token);if(p.len>0&&(o[0].token.length>1?o[0].token=o[0].token.substring(1):o.shift(),f+=p.token,u=p.token),o.length>0){var m=e.getMode(o[0].token);m.len>0&&(o.shift(),f+=m.token,d=m.token)}if(void 0===i.standardKey(f,h.token,u,0))return t("Unsupported key signature: "+f,a,0),l}var g,v=i.deepCopyKey(r.key),b=!s&&r.globalTranspose?-r.globalTranspose:0;if(s&&(g=r.globalTransposeOrigKeySig),r.key=i.deepCopyKey(i.standardKey(f,h.token,u,b)),s&&(r.globalTransposeOrigKeySig=g),r.key.mode=d,v){for(var y,x=0;x0;)switch(o[0].token){case"m":case"middle":if(o.shift(),0===o.length)return t("Expected = after middle",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after middle",a,k.start);break}if(0===o.length)return t("Expected parameter after middle=",a,0),l;var E=e.getPitchFromTokens(o);E.warn&&t(E.warn,a,0),E.position&&(r.clef.verticalPos=E.position-6);break;case"transpose":if(o.shift(),0===o.length)return t("Expected = after transpose",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after transpose",a,k.start);break}if(0===o.length)return t("Expected parameter after transpose=",a,0),l;if("number"!==o[0].type){t("Expected number after transpose",a,o[0].start);break}r.clef.transpose=o[0].intt,o.shift();break;case"stafflines":if(o.shift(),0===o.length)return t("Expected = after stafflines",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after stafflines",a,k.start);break}if(0===o.length)return t("Expected parameter after stafflines=",a,0),l;if("number"!==o[0].type){t("Expected number after stafflines",a,o[0].start);break}r.clef.stafflines=o[0].intt,o.shift();break;case"staffscale":if(o.shift(),0===o.length)return t("Expected = after staffscale",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after staffscale",a,k.start);break}if(0===o.length)return t("Expected parameter after staffscale=",a,0),l;if("number"!==o[0].type){t("Expected number after staffscale",a,o[0].start);break}r.clef.staffscale=o[0].floatt,o.shift();break;case"octave":if(o.shift(),0===o.length)return t("Expected = after octave",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after octave",a,k.start);break}if(0===o.length)return t("Expected parameter after octave=",a,0),l;if("number"!==o[0].type){t("Expected number after octave",a,o[0].start);break}r.octave=o[0].intt,o.shift();break;case"style":if(o.shift(),0===o.length)return t("Expected = after style",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after style",a,k.start);break}if(0===o.length)return t("Expected parameter after style=",a,0),l;switch(o[0].token){case"normal":case"harmonic":case"rhythm":case"x":case"triangle":r.style=o[0].token,o.shift();break;default:t("error parsing style element: "+o[0].token,a,o[0].start)}break;case"clef":if(o.shift(),0===o.length)return t("Expected = after clef",a,0),l;if("="!==(k=o.shift()).token){t("Expected = after clef",a,k.start);break}if(0===o.length)return t("Expected parameter after clef=",a,0),l;case"treble":case"bass":case"alto":case"tenor":case"perc":case"none":var M=o.shift();switch(M.token){case"treble":case"tenor":case"alto":case"bass":case"perc":case"none":break;case"C":case"c":M.token="alto";break;case"F":case"f":M.token="bass";break;case"G":case"g":M.token="treble";break;default:t("Expected clef name. Found "+M.token,a,M.start)}o.length>0&&"number"===o[0].type&&(M.token+=o[0].token,o.shift()),o.length>1&&("-"===o[0].token||"+"===o[0].token||"^"===o[0].token||"_"===o[0].token)&&"8"===o[1].token&&(M.token+=o[0].token+o[1].token,o.shift(),o.shift()),r.clef={type:M.token,verticalPos:c(M.token,0)},r.currentVoice&&void 0!==r.currentVoice.transpose&&(r.clef.transpose=r.currentVoice.transpose),l.foundClef=!0;break;default:t("Unknown parameter: "+o[0].token,a,o[0].start),o.shift()}return l},i.parseVoice=function(n,a,i){var o=e.getMeat(n,a,i),l=o.start,u=o.end,d=e.getToken(n,l,u);if(0!==d.length){var f=!1;void 0===r.voices[d]&&(r.voices[d]={},f=!0,r.score_is_present&&t("Can't have an unknown V: id when the %score directive is present",n,l)),l+=d.length,l+=e.eatWhiteSpace(n,l);for(var p={startStaff:f},m=function(r){var a=e.getVoiceToken(n,l,u);void 0!==a.warn?t("Expected value for "+r+" in voice: "+a.warn,n,l):void 0!==a.err?t("Expected value for "+r+" in voice: "+a.err,n,l):0===a.token.length&&'"'!==n[l]?t("Expected value for "+r+" in voice",n,l):p[r]=a.token,l+=a.len},g=function(a,i,s){var o=e.getVoiceToken(n,l,u);void 0!==o.warn?t("Expected value for "+i+" in voice: "+o.warn,n,l):void 0!==o.err?t("Expected value for "+i+" in voice: "+o.err,n,l):0===o.token.length&&'"'!==n[l]?t("Expected value for "+i+" in voice",n,l):("number"===s&&(o.token=parseFloat(o.token)),r.voices[a][i]=o.token),l+=o.len},v=function(r,a){var i=e.getVoiceToken(n,l,u);if(void 0!==i.warn)t("Expected value for "+r+" in voice: "+i.warn,n,l);else if(void 0!==i.err)t("Expected value for "+r+" in voice: "+i.err,n,l);else{if(0!==i.token.length||'"'===n[l])return"number"===a&&(i.token=parseFloat(i.token)),i.token;t("Expected value for "+r+" in voice",n,l)}l+=i.len},b=function(a,i){var s=e.getVoiceToken(n,l,u);if(void 0!==s.warn)t("Expected one of (_B, _E, _b, _e) for "+i+" in voice: "+s.warn,n,l);else if(0===s.token.length&&'"'!==n[l])t("Expected one of (_B, _E, _b, _e) for "+i+" in voice",n,l);else{var o={_B:2,_E:9,_b:-10,_e:-3}[s.token];o?r.voices[a][i]=o:t("Expected one of (_B, _E, _b, _e) for "+i+" in voice",n,l)}l+=s.len};l0&&(t+=u[0],"V"===u[1]&&this.startNewLine());for(var d=0;t0)t+=p[0],"V"===p[1]&&(l=!0);else{var m;for((!o.hasBeginMusic()||l&&!this.lineContinuation)&&(this.startNewLine(),l=!1);;)if((m=n.eatWhiteSpace(e,t))>0&&(t+=m),t>0&&""===e[t-1]&&(m=c.letter_to_body_header(e,t))[0]>0&&("V"===m[1]&&this.startNewLine(),t=m[0],i.start_new_line=!1),(m=P(e,t))[0]>0&&(t+=m[0]),(m=E(e,t))[0]>0){S.chord||(S.chord=[]);var g=n.translateString(m[1]);g=g.replace(/;/g,"\n");for(var y=!1,x=0;x0&&(S.force_end_beam_last=!0),t+=k}else if((m=-1===v.indexOf(e[t])?B(e,t):[0])[0]>0)null===m[1]?t+10&&(0===m[1].indexOf("style=")?S.style=m[1].substr(6):(void 0===S.decoration&&(S.decoration=[]),"beambr1"===m[1]?S.beambr=1:"beambr2"===m[1]?S.beambr=2:S.decoration.push(m[1]))),t+=m[0];else{if(!((m=M(e,t))[0]>0))break;S.gracenotes=m[1],t+=m[0]}if((m=L(e,t))[0]>0){d=0,void 0!==S.gracenotes&&(S.rest={type:"spacer"},S.duration=.125,i.addFormattingOptions(S,s.formatting,"note"),o.appendElement("note",r+t,r+t+m[0],S),i.measureNotEmpty=!0,S={});var w={type:m[1]};0===w.type.length?a("Unknown bar type",e,t):(i.inEnding&&"bar_thin"!==w.type&&(w.endEnding=!0,i.inEnding=!1),m[2]&&(w.startEnding=m[2],i.inEnding&&(w.endEnding=!0),i.inEnding=!0,"bar_right_repeat"===m[1]?i.restoreStartEndingHoldOvers():i.duplicateStartEndingHoldOvers()),void 0!==S.decoration&&(w.decoration=S.decoration),void 0!==S.chord&&(w.chord=S.chord),w.startEnding&&void 0===i.barFirstEndingNum?i.barFirstEndingNum=i.currBarNumber:w.startEnding&&w.endEnding&&i.barFirstEndingNum?i.currBarNumber=i.barFirstEndingNum:w.endEnding&&(i.barFirstEndingNum=void 0),"bar_invisible"!==w.type&&i.measureNotEmpty&&F()&&(i.currBarNumber++,i.barNumbers&&i.currBarNumber%i.barNumbers==0&&(w.barNumber=i.currBarNumber)),i.addFormattingOptions(S,s.formatting,"bar"),o.appendElement("bar",r+f,r+t+m[0],w),i.measureNotEmpty=!1,S={}),t+=m[0]}else if("&"===e[t])(m=N(e,t))[0]>0&&(o.appendElement("overlay",r,r+1,{}),t+=1,d++);else{if((m=O(e,t)).consumed>0&&(void 0!==m.startSlur&&(S.startSlur=m.startSlur),m.dottedSlur&&(S.dottedSlur=!0),void 0!==m.triplet&&(h>0?a("Can't nest triplets",e,t):(S.startTriplet=m.triplet,S.tripletMultiplier=m.tripletQ/m.triplet,S.tripletR=m.num_notes,h=void 0===m.num_notes?m.triplet:m.num_notes)),t+=m.consumed),"["===e[t]){t++;for(var C=null,j=!1,I=!1;!I;){var V=B(e,t);V[0]>0&&(t+=V[0]);var Y=z(e,t,{},!1);if(null!==Y&&void 0!==Y.pitch)V[0]>0&&0!==V[1].indexOf("style=")&&(void 0===S.decoration&&(S.decoration=[]),S.decoration.push(V[1])),Y.end_beam&&(S.end_beam=!0,delete Y.end_beam),void 0===S.pitches?(S.duration=Y.duration,S.pitches=[Y]):S.pitches.push(Y),delete Y.duration,V[0]>0&&0===V[1].indexOf("style=")&&(S.pitches[S.pitches.length-1].style=V[1].substr(6)),i.inTieChord[S.pitches.length]&&(Y.endTie=!0,i.inTieChord[S.pitches.length]=void 0),Y.startTie&&(i.inTieChord[S.pitches.length]=!0),t=Y.endChar,delete Y.endChar;else if(" "===e[t])a("Spaces are not allowed in chords",e,t),t++;else{if(t0&&(!S.rest||"spacer"!==S.rest.type)&&0==--h&&(S.endTriplet=!0);for(var G=!1;t":case"<":var q=D(e,t);t+=q[0]-1,i.next_note_duration=q[2],C?C*=q[1]:C=q[1];break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"/":var W=n.getFraction(e,t);C=W.value;var R=e[t=W.index];" "===R&&(j=!0),"-"===R||")"===R||" "===R||"<"===R||">"===R?t--:G=!0;break;case"0":C=0;break;default:G=!0}G||t++}}else a("Expected ']' to end the chords",e,t);void 0!==S.pitches&&(null!==C&&(S.duration=S.duration*C,j&&H(S)),i.addFormattingOptions(S,s.formatting,"note"),o.appendElement("note",r+f,r+t,S),i.measureNotEmpty=!0,S={}),I=!0}}}else{var X={},U=z(e,t,X,!0);void 0!==X.endTie&&_(i,d,!0),null!==U&&(void 0!==U.pitch?(S.pitches=[{}],void 0!==U.accidental&&(S.pitches[0].accidental=U.accidental),S.pitches[0].pitch=U.pitch,S.pitches[0].name=U.name,(U.midipitch||0===U.midipitch)&&(S.pitches[0].midipitch=U.midipitch),void 0!==U.endSlur&&(S.pitches[0].endSlur=U.endSlur),void 0!==U.endTie&&(S.pitches[0].endTie=U.endTie),void 0!==U.startSlur&&(S.pitches[0].startSlur=U.startSlur),void 0!==S.startSlur&&(S.pitches[0].startSlur=S.startSlur),void 0!==S.dottedSlur&&(S.pitches[0].dottedSlur=!0),void 0!==U.startTie&&(S.pitches[0].startTie=U.startTie),void 0!==S.startTie&&(S.pitches[0].startTie=S.startTie)):(S.rest=U.rest,"multimeasure"===U.rest.type&&F()&&(i.currBarNumber+=U.rest.text-1),void 0!==U.endSlur&&(S.endSlur=U.endSlur),void 0!==U.endTie&&(S.rest.endTie=U.endTie),void 0!==U.startSlur&&(S.startSlur=U.startSlur),void 0!==U.startTie&&(S.rest.startTie=U.startTie),void 0!==S.startTie&&(S.rest.startTie=S.startTie)),void 0!==U.chord&&(S.chord=U.chord),void 0!==U.duration&&(S.duration=U.duration),void 0!==U.decoration&&(S.decoration=U.decoration),void 0!==U.graceNotes&&(S.graceNotes=U.graceNotes),delete S.startSlur,delete S.dottedSlur,T(i,d,S)&&(void 0!==S.pitches?S.pitches[0].endTie=!0:"spacer"!==S.rest.type&&(S.rest.endTie=!0),_(i,d,!1)),(U.startTie||S.startTie)&&_(i,d,!0),t=U.endChar,h>0&&(!U.rest||"spacer"!==U.rest.type)&&0==--h&&(S.endTriplet=!0),U.end_beam&&H(S),S.rest&&"rest"===S.rest.type&&1===S.duration&&A(i)<=1&&(S.rest.type="whole",S.duration=A(i)),S.duration<1&&-1===b.indexOf(S.duration)&&0!==S.duration&&(S.rest&&"spacer"===S.rest.type||a("Duration not representable: "+e.substring(f,t),e,t)),i.addFormattingOptions(S,s.formatting,"note"),o.appendElement("note",r+f,r+t,S)||(this.startNewLine(),o.appendElement("note",r+f,r+t,S)),i.measureNotEmpty=!0,S={})}t===f&&(" "!==e[t]&&"`"!==e[t]&&a("Unknown character ignored",e,t),t++)}}}this.lineContinuation=e.indexOf("")>=0||u[0]>0,this.lineContinuation||(S={})}};var _=function(e,t,r){var n=e.currentVoice?100*e.currentVoice.staffNum+e.currentVoice.index:0;void 0===e.inTie[t]&&(e.inTie[t]=[]),e.inTie[t][n]=r},E=function(e,t){if('"'===e[t]){var r=n.getBrackettedSubstring(e,t,5);if(r[2]||a("Missing the closing quote while parsing the chord symbol",e,t),r[0]>0&&r[1].length>0&&"^"===r[1][0])r[1]=r[1].substring(1),r[2]="above";else if(r[0]>0&&r[1].length>0&&"_"===r[1][0])r[1]=r[1].substring(1),r[2]="below";else if(r[0]>0&&r[1].length>0&&"<"===r[1][0])r[1]=r[1].substring(1),r[2]="left";else if(r[0]>0&&r[1].length>0&&">"===r[1][0])r[1]=r[1].substring(1),r[2]="right";else if(r[0]>0&&r[1].length>0&&"@"===r[1][0]){r[1]=r[1].substring(1);var s=n.getFloat(r[1]);if(0===s.digits)return a("Missing first position in absolutely positioned annotation.",e,t),r[1]=r[1].replace("@",""),r[2]="above",r;if(r[1]=r[1].substring(s.digits),","!==r[1][0])return a("Missing comma absolutely positioned annotation.",e,t),r[1]=r[1].replace("@",""),r[2]="above",r;r[1]=r[1].substring(1);var o=n.getFloat(r[1]);if(0===o.digits)return a("Missing second position in absolutely positioned annotation.",e,t),r[1]=r[1].replace("@",""),r[2]="above",r;r[1]=r[1].substring(o.digits);var c=n.skipWhiteSpace(r[1]);r[1]=r[1].substring(c),r[2]=null,r[3]={x:s.value,y:o.value}}else!0!==i.freegchord&&(r[1]=r[1].replace(/([ABCDEFG0-9])b/g,"$1♭"),r[1]=r[1].replace(/([ABCDEFG0-9])#/g,"$1♯"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)o([^A-Za-z])/g,"$1$2°$3"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)o$/g,"$1$2°"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)0([^A-Za-z])/g,"$1$2ø$3"),r[1]=r[1].replace(/^([ABCDEFG])([♯♭]?)\^([^A-Za-z])/g,"$1$2∆$3")),r[2]="default",r[1]=h.chordName(i,r[1]);return r}return[0,""]},M=function(e,t){if("{"===e[t]){var r=n.getBrackettedSubstring(e,t,1,"}");r[2]||a("Missing the closing '}' while parsing grace note",e,t),")"===e[t+r[0]]&&(r[0]++,r[1]+=")");for(var s=[],o=0,c=!1;o0&&(s[s.length-1].endBeam=!0):a("Unknown character '"+r[1][o]+"' while parsing grace note",e,t),o++)}if(s.length)return[r[0],s]}return[0]};function N(e,t){if("&"===e[t]){for(var r=t;e[t]&&":"!==e[t]&&"|"!==e[t];)t++;return[t-r,e.substring(r+1,t)]}return[0]}function A(e){var t=e.origMeter;return t&&"specified"===t.type&&t.value&&0!==t.value.length?parseInt(t.value[0].num,10)/parseInt(t.value[0].den,10):1}var B=function(e,t){var r=i.macros[e[t]];if(void 0!==r)return"!"!==r[0]&&"+"!==r[0]||(r=r.substring(1)),"!"!==r[r.length-1]&&"+"!==r[r.length-1]||(r=r.substring(0,r.length-1)),d.includes(r)?[1,r]:f.includes(r)?("hidden"===i.volumePosition&&(r=""),[1,r]):p.includes(r)?("hidden"===i.dynamicPosition&&(r=""),[1,r]):(i.ignoredDecorations.includes(r)||a("Unknown macro: "+r,e,t),[1,""]);switch(e[t]){case".":if("("===e[t+1]||"-"===e[t+1])break;return[1,"staccato"];case"u":return[1,"upbow"];case"v":return[1,"downbow"];case"~":return[1,"irishroll"];case"!":case"+":var s=n.getBrackettedSubstring(e,t,5);if(s[1].length>1&&("^"===s[1][0]||"_"===s[1][0])&&(s[1]=s[1].substring(1)),d.includes(s[1]))return s;if(f.includes(s[1]))return"hidden"===i.volumePosition&&(s[1]=""),s;if(p.includes(s[1]))return"hidden"===i.dynamicPosition&&(s[1]=""),s;var o=m.findIndex((function(e){return s[1]===e[0]}));return o>=0?(s[1]=m[o][1],s):(o=g.findIndex((function(e){return s[1]===e[0]})))>=0?(s[1]=g[o][1],"hidden"===i.dynamicPosition&&(s[1]=""),s):"!"!==e[t]||1!==s[0]&&"!"===e[t+s[0]-1]?(a("Unknown decoration: "+s[1],e,t),s[1]="",s):[1,null];case"H":return[1,"fermata"];case"J":return[1,"slide"];case"L":return[1,"accent"];case"M":return[1,"mordent"];case"O":return[1,"coda"];case"P":return[1,"pralltriller"];case"R":return[1,"roll"];case"S":return[1,"segno"];case"T":return[1,"trill"]}return[0,0]},P=function(e,t){for(var r=t;n.isWhiteSpace(e[t]);)t++;return[t-r]},L=function(e,t){var r=n.getBarLine(e,t);if(0===r.len)return[0,""];if(r.warn)return a(r.warn,e,t),[r.len,""];for(var i=0;i="2"&&e[t+1]<="9"?(void 0!==r.triplet?a("Can't nest triplets",e,t):(r.triplet=e[t+1]-"0",r.tripletQ=w[r.triplet],r.num_notes=r.triplet,t+2="1"&&e[t+4]<="9"?(r.num_notes=e[t+4]-"0",t+=3):a("expected number after the two colons after the triplet to mark the duration",e,t):t+3="1"&&e[t+3]<="9"?(r.tripletQ=e[t+3]-"0",t+4="1"&&e[t+5]<="9"&&(r.num_notes=e[t+5]-"0",t+=4):t+=2):a("expected number after the triplet to mark the duration",e,t))),t++):void 0===r.startSlur?r.startSlur=1:r.startSlur++),t++;return r.consumed=t-i,r};C.prototype.startNewLine=function(){var e={startChar:-1,endChar:-1};i.partForNextLine.title&&(e.part=i.partForNextLine),e.clef=i.currentVoice&&void 0!==i.staves[i.currentVoice.staffNum].clef?Object.assign({},i.staves[i.currentVoice.staffNum].clef):Object.assign({},i.clef);var t=i.currentVoice?i.currentVoice.scoreTranspose:0;if(e.key=l.standardKey(i.key.root+i.key.acc+i.key.mode,i.key.root,i.key.acc,t),e.key.mode=i.key.mode,i.key.impliedNaturals&&(e.key.impliedNaturals=i.key.impliedNaturals),i.key.explicitAccidentals)for(var r=0;r=0?(r.duration=s.getBarLength(),r.rest.text=1,u="Zduration"):(a&&0!==i.next_note_duration?(r.duration=i.default_length*i.next_note_duration,i.next_note_duration=0,d=!0):r.duration=i.default_length,u="duration");break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"0":case"/":if("octave"===u||"duration"===u){var p=n.getFraction(e,t);for(r.duration=r.duration*p.value,r.endChar=p.index;p.index"!==e[t])return r;t--,u="broken_rhythm";break;case">":case"<":if(!l(u))return null;if(!a)return r.endChar=t,r;var g=D(e,t);t+=g[0]-1,i.next_note_duration=g[2],r.duration=g[1]*r.duration,u="end_slur";break;default:return l(u)?(r.endChar=t,r):null}if(++t===e.length)return l(u)?(r.endChar=t,r):null}return null},D=function(e,t){switch(e[t]){case">":return t"===e[t+1]&&">"===e[t+2]?[3,1.875,.125]:t"===e[t+1]?[2,1.75,.25]:[1,1.5,.5];case"<":return t","accent"],["tr","trill"],["plus","+"],["emphasis","accent"],["^","umarcato"],["marcato","umarcato"]],e.exports.accentDynamicPseudonyms=[["<(","crescendo("],["<)","crescendo)"],[">(","diminuendo("],[">)","diminuendo)"]],e.exports.nonDecorations="ABCDEFGabcdefgxyzZ[]|^_{",e.exports.durations=[.5,.75,.875,.9375,.96875,.984375,.25,.375,.4375,.46875,.484375,.4921875,.125,.1875,.21875,.234375,.2421875,.24609375,.0625,.09375,.109375,.1171875,.12109375,.123046875,.03125,.046875,.0546875,.05859375,.060546875,.0615234375,.015625,.0234375,.02734375,.029296875,.0302734375,.03076171875],e.exports.pitches={A:5,B:6,C:0,D:1,E:2,F:3,G:4,a:12,b:13,c:7,d:8,e:9,f:10,g:11},e.exports.rests={x:"invisible",X:"invisible-multimeasure",y:"spacer",z:"rest",Z:"multimeasure"},e.exports.accMap={dblflat:"__",flat:"_",natural:"=",sharp:"^",dblsharp:"^^",quarterflat:"_/",quartersharp:"^/"},e.exports.tripletQ={2:3,3:2,4:3,5:2,6:2,7:2,8:3,9:2}},1881:function(e,t,r){var n=r(5008),a=function(e,t){this.lineIndex=0,this.lines=e,this.multilineVars=t,this.skipWhiteSpace=function(e){for(var t=0;t=e.length};this.eatWhiteSpace=function(e,t){for(var r=t;r="a"&&e[t]<="z"||e[t]>="A"&&e[t]<="Z");)t++;return t},n=this.skipWhiteSpace(e);if(r(e,n))return{len:0};var a=e.substring(n,n+3).toLowerCase();switch((a.length>1&&" "===a[1]||"^"===a[1]||"_"===a[1]||"="===a[1])&&(a=a[0]),a){case"mix":return{len:t(e,n),token:"Mix"};case"dor":return{len:t(e,n),token:"Dor"};case"phr":return{len:t(e,n),token:"Phr"};case"lyd":return{len:t(e,n),token:"Lyd"};case"loc":return{len:t(e,n),token:"Loc"};case"aeo":case"min":case"m":return{len:t(e,n),token:"m"};case"maj":case"ion":return{len:t(e,n),token:""}}return{len:0}},this.getClef=function(e,t){var a=e,i=this.skipWhiteSpace(e);if(r(e,i))return{len:0};var s=!1,o=e.substring(i);if(n.startsWith(o,"clef=")&&(s=!0,o=o.substring(5),i+=5),0===o.length&&s)return{len:i+5,warn:"No clef specified: "+a};var c=this.skipWhiteSpace(o);if(r(o,c))return{len:0};c>0&&(i+=c,o=o.substring(c));var l=null;if(n.startsWith(o,"treble"))l="treble";else if(n.startsWith(o,"bass3"))l="bass3";else if(n.startsWith(o,"bass"))l="bass";else if(n.startsWith(o,"tenor"))l="tenor";else if(n.startsWith(o,"alto2"))l="alto2";else if(n.startsWith(o,"alto1"))l="alto1";else if(n.startsWith(o,"alto"))l="alto";else if(!t&&s&&n.startsWith(o,"none"))l="none";else if(n.startsWith(o,"perc"))l="perc";else if(!t&&s&&n.startsWith(o,"C"))l="tenor";else if(!t&&s&&n.startsWith(o,"F"))l="bass";else{if(t||!s||!n.startsWith(o,"G"))return{len:i+5,warn:"Unknown clef specified: "+a};l="treble"}return o=o.substring(l.length),(c=this.isMatch(o,"+8"))>0?l+="+8":(c=this.isMatch(o,"-8"))>0&&(l+="-8"),{len:i+l.length,token:l,explicit:s}},this.getBarLine=function(e,t){switch(e[t]){case"]":switch(e[++t]){case"|":return{len:2,token:"bar_thick_thin"};case"[":return e[++t]>="1"&&e[t]<="9"||'"'===e[t]?{len:2,token:"bar_invisible"}:{len:1,warn:"Unknown bar symbol"};default:return{len:1,token:"bar_invisible"}}break;case":":switch(e[++t]){case":":return{len:2,token:"bar_dbl_repeat"};case"|":switch(e[++t]){case"]":return"|"===e[++t]&&":"===e[++t]?{len:5,token:"bar_dbl_repeat"}:{len:3,token:"bar_right_repeat"};case"|":return":"===e[++t]?{len:4,token:"bar_dbl_repeat"}:{len:3,token:"bar_right_repeat"};default:return{len:2,token:"bar_right_repeat"}}break;default:return{len:1,warn:"Unknown bar symbol"}}break;case"[":if("|"!==e[++t])return e[t]>="1"&&e[t]<="9"||'"'===e[t]?{len:1,token:"bar_invisible"}:{len:0};switch(e[++t]){case":":return{len:3,token:"bar_left_repeat"};case"]":return{len:3,token:"bar_invisible"};default:return{len:2,token:"bar_thick_thin"}}break;case"|":switch(e[++t]){case"]":return{len:2,token:"bar_thin_thick"};case"|":return":"===e[++t]?{len:3,token:"bar_left_repeat"}:{len:2,token:"bar_thin_thin"};case":":for(var r=0;":"===e[t+r];)r++;return{len:1+r,token:"bar_left_repeat"};default:return{len:1,token:"bar_thin"}}}return{len:0}},this.getTokenOf=function(e,t){for(var r=0;r0;){var r;if("^"===e[0].token){if(r="sharp",e.shift(),0===e.length)return{accs:t,warn:"Expected note name after "+r};switch(e[0].token){case"^":r="dblsharp",e.shift();break;case"/":r="quartersharp",e.shift()}}else if("="===e[0].token)r="natural",e.shift();else{if("_"!==e[0].token)return{accs:t};if(r="flat",e.shift(),0===e.length)return{accs:t,warn:"Expected note name after "+r};switch(e[0].token){case"_":r="dblflat",e.shift();break;case"/":r="quarterflat",e.shift()}}if(0===e.length)return{accs:t,warn:"Expected note name after "+r};switch(e[0].token[0]){case"a":case"b":case"c":case"d":case"e":case"f":case"g":case"A":case"B":case"C":case"D":case"E":case"F":case"G":void 0===t&&(t=[]),t.push({acc:r,note:e[0].token[0]}),1===e[0].token.length?e.shift():e[0].token=e[0].token.substring(1);break;default:return{accs:t,warn:"Expected note name after "+r+" Found: "+e[0].token}}}return{accs:t}},this.getKeyAccidental=function(e){var t={"^":"sharp","^^":"dblsharp","=":"natural",_:"flat",__:"dblflat","_/":"quarterflat","^/":"quartersharp"},n=this.skipWhiteSpace(e);if(r(e,n))return{len:0};var a=null;switch(e[n]){case"^":case"_":case"=":a=e[n];break;default:return{len:0}}if(n++,r(e,n))return{len:1,warn:"Expected note name after accidental"};switch(e[n]){case"a":case"b":case"c":case"d":case"e":case"f":case"g":case"A":case"B":case"C":case"D":case"E":case"F":case"G":return{len:n+1,token:{acc:t[a],note:e[n]}};case"^":case"_":case"/":if(a+=e[n],n++,r(e,n))return{len:2,warn:"Expected note name after accidental"};switch(e[n]){case"a":case"b":case"c":case"d":case"e":case"f":case"g":case"A":case"B":case"C":case"D":case"E":case"F":case"G":return{len:n+1,token:{acc:t[a],note:e[n]}};default:return{len:2,warn:"Expected note name after accidental"}}break;default:return{len:1,warn:"Expected note name after accidental"}}},this.isWhiteSpace=function(e){return" "===e||"\t"===e||""===e},this.getMeat=function(e,t,r){var n=e.indexOf("%",t);for(n>=0&&n="A"&&e<="Z"||e>="a"&&e<="z"},i=function(e){return e>="0"&&e<="9"};this.tokenize=function(e,t,r,n){var s=this.getMeat(e,t,r);t=s.start,r=s.end;for(var o,c=[];t=r?{len:1,err:"Missing close quote"}:{len:a-t+1,token:this.translateString(e.substring(n+1,a))}}for(var i=n;i=0?n.strip(e.substring(0,t)):n.strip(e)},this.getInt=function(e){var t=parseInt(e);if(isNaN(t))return{digits:0};var r=""+t;return{value:t,digits:e.indexOf(r)+r.length}},this.getFloat=function(e){var t=parseFloat(e);if(isNaN(t))return{digits:0};var r=""+t;return{value:t,digits:e.indexOf(r)+r.length}},this.getMeasurement=function(e){if(0===e.length)return{used:0};var t=1,r="";if("-"===e[0].token)e.shift(),r="-",t++;else if("number"!==e[0].type)return{used:0};if(r+=e.shift().token,0===e.length)return{used:1,value:parseInt(r)};var n=e.shift();if("."===n.token){if(t++,0===e.length)return{used:t,value:parseInt(r)};if("number"===e[0].type&&(r=r+"."+(n=e.shift()).token,t++,0===e.length))return{used:t,value:parseFloat(r)};n=e.shift()}switch(n.token){case"pt":case"px":return{used:t+1,value:parseFloat(r)};case"cm":return{used:t+1,value:parseFloat(r)/2.54*72};case"in":return{used:t+1,value:72*parseFloat(r)};default:return e.unshift(n),{used:t,value:parseFloat(r)}}};var u=function(e){return e=(e=e.replace(/\\n/g,"\n")).replace(/\\"/g,'"')};this.getBrackettedSubstring=function(e,t,r,n){for(var a=n||e[t],i=t+1,s=!1;ie.length-1&&(i=e.length-1),[i-t+1,u(e.substring(t+1,i)),!1])}};a.prototype.peekLine=function(){return this.lines[this.lineIndex]},a.prototype.nextLine=function(){if(this.lineIndex>0&&(this.multilineVars.iChar+=this.lines[this.lineIndex-1].length+1),this.lineIndex11&&(f%=12);var p="m"===t[0]?l[f]:c[f],m=p+t,g=i(m);g.length>0&&"flat"===g[0].acc&&(e.localTransposePreferFlats=!0);var v=m.charCodeAt(0)-h.charCodeAt(0);return e.localTranspose>0?v<0?v+=7:0===v&&("#"!==h[1]&&"b"!==m[1]||(v+=7)):e.localTranspose<0&&(v>0?v-=7:0===v&&("b"!==h[1]&&"#"!==m[1]||(v-=7))),e.localTranspose>0?e.localTransposeVerticalMovement=v+7*Math.floor(e.localTranspose/12):e.localTransposeVerticalMovement=v+7*Math.ceil(e.localTranspose/12),d?{accidentals:g,root:p[0],acc:p.length>1?p[1]:""}:{accidentals:[],root:r,acc:n}},s.chordName=function(e,t){return a(t,e.localTranspose,e.localTransposePreferFlats,e.freegchord)};var h=["c","d","e","f","g","a","b"],u={dblflat:-2,flat:-1,natural:0,sharp:1,dblsharp:2},d={"-2":"dblflat","-1":"flat",0:"natural",1:"sharp",2:"dblsharp"},f={"-2":"__","-1":"_",0:"=",1:"^",2:"^^"};s.note=function(e,t){if(e.localTranspose&&"perc"!==e.clef.type){var r=t.pitch;if(e.localTransposeVerticalMovement&&(t.pitch=t.pitch+e.localTransposeVerticalMovement,t.name)){var a=t.accidental?t.name.substring(1):t.name,i=t.accidental?t.name[0]:"",s=n.pitchIndex(a);t.name=i+n.noteName(s+e.localTransposeVerticalMovement)}if(t.accidental){var o=function(e,t,r,n,a){for(var i=h[(e+49)%7],s=0,o=0;o2&&(t++,p-="b"===l||"e"===l?1:2),[t,p]}(r,t.pitch,t.accidental,e.globalTransposeOrigKeySig,e.targetKey);t.pitch=o[0],t.accidental=d[o[1]],t.name&&(t.name=f[o[1]]+t.name.replace(/[_^=]/g,""))}}},e.exports=s},867:function(e){var t={},r=["C,,,","D,,,","E,,,","F,,,","G,,,","A,,,","B,,,","C,,","D,,","E,,","F,,","G,,","A,,","B,,","C,","D,","E,","F,","G,","A,","B,","C","D","E","F","G","A","B","c","d","e","f","g","a","b","c'","d'","e'","f'","g'","a'","b'","c''","d''","e''","f''","g''","a''","b''","c'''","d'''","e'''","f'''","g'''","a'''","b'''"];t.pitchIndex=function(e){return r.indexOf(e)},t.noteName=function(e){return r[e]},e.exports=t},4208:function(e){var t=["C","C♯","D","D♯","E","F","F♯","G","G♯","A","A♯","B"],r=["C","D♭","D","E♭","E","F","G♭","G","A♭","A","B♭","B"],n=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],a=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"];e.exports=function(e,i,s,o){if(!i||i%12==0)return e;for(;i<0;)i+=12;i>11&&(i%=12);var c=e.match(/^([A-G][b#♭♯]?)([^\/]+)?\/?([A-G][b#♭♯]?)?(.+)?/);if(!c)return e;var l,h=c[1],u=c[2],d=c[3],f=c[4];return(l=t.indexOf(h))<0&&(l=r.indexOf(h)),l<0&&(l=n.indexOf(h)),l<0&&(l=a.indexOf(h)),l<0||(l+=i,l%=12,e=s?o?a[l]:r[l]:o?n[l]:t[l],u&&(e+=u),d&&((l=t.indexOf(d))<0&&(l=r.indexOf(d)),l<0&&(l=n.indexOf(d)),l<0&&(l=a.indexOf(d)),e+="/",l>=0?(l+=i,l%=12,e+=s?o?a[l]:r[l]:o?n[l]:t[l]):e+=d),f&&(e+=f)),e}},575:function(e,t,r){var n=r(9708);function a(e){if(!e)return!1;if("string"==typeof e)return!1;for(var t=0;t0&&o[l].voice.push({el_type:"note",duration:u,rest:{type:"invisible"},startChar:g.startChar,endChar:g.endChar}),o[l].voice.push(g)),u=0):"note"===g.el_type?d?o[l].voice.push(g):(u+=g.duration,r[n]+=g.duration):"scale"!==g.el_type&&"stem"!==g.el_type&&"overlay"!==g.el_type&&"style"!==g.el_type&&"transpose"!==g.el_type&&"color"!==g.el_type||o[l].voice.push(g);else{t=!0,d=!0,p=m,o[l].hasOverlay=!0,0===f&&(f=r[n]);for(var v=0;v=e.lines[v].staff[0].voices.length&&e.lines[v].staff[0].voices.push([{el_type:"note",duration:r[v],rest:{type:"invisible"},startChar:g.startChar,endChar:g.endChar}])}}o[l].hasOverlay&&0===o[l].snip.length&&o[l].snip.push({start:p,len:h.length-p})}for(l=0;l=0;y--){var x=b.snip[y];s.voices[l].splice(x.start,x.len),s.voices[l].splice(x.start+1,0,{el_type:"stem",direction:"auto"});var k=c(s.voices[l],x.start);s.voices[l].splice(k,0,{el_type:"stem",direction:"up"})}for(y=0;y0&&"bar"!==e[r].el_type;r--);return r}function l(e,t,r,n){var a;n[t]||(n[t]=[]),n[t][r]||(n[t][r]=[]);for(var i=function(e,i,s){if(void 0===n[t][r][s]){for(a=0;a=t&&ot;){if(e[t].staff)return e[t];t++}return null}function d(e){e.potentialStartBeam&&e.potentialEndBeam&&(e.potentialStartBeam.startBeam=!0,e.potentialEndBeam.endBeam=!0),delete e.potentialStartBeam,delete e.potentialEndBeam}function f(e){for(var t=0;t0){if(void 0!==n.voices[0]){for(var a=!1,i=0;i0&&x[x.length-1].barNumber){var w=u(e.lines,b);w&&(w.staff[0].barNumber=x[x.length-1].barNumber),delete x[x.length-1].barNumber}}}return delete e.staffNum,delete e.voiceNum,delete e.lineNum,delete e.potentialStartBeam,delete e.potentialEndBeam,delete e.vskipPending,i},this.addTieToLastNote=function(t){var r=function(e){if(!e.lines[e.lineNum])return null;if(!e.lines[e.lineNum].staff)return null;if(!e.lines[e.lineNum].staff[e.staffNum])return null;var t=e.lines[e.lineNum].staff[e.staffNum].voices[e.voiceNum];if(!t)return null;for(var r=t.length-1;r>=0;r--){var n=t[r];if("note"===n.el_type)return n}return null}(e);return!!(r&&r.pitches&&r.pitches.length>0)&&(r.pitches[0].startTie={},t&&(r.pitches[0].startTie.style="dotted"),!0)},this.appendElement=function(n,a,s,o){var c;return o.el_type=n,null!==a&&(o.startChar=a),null!==s&&(o.endChar=s),"note"===n?((c=o).duration?c.duration:0)>=.25||o.force_end_beam_last&&void 0!==e.potentialStartBeam?g(e):o.end_beam&&void 0!==e.potentialStartBeam?void 0===o.rest?function(e,t){t.potentialStartBeam.startBeam=!0,e.endBeam=!0,delete t.potentialStartBeam,delete t.potentialEndBeam}(o,e):g(e):void 0===o.rest&&(void 0===e.potentialStartBeam?o.end_beam||(e.potentialStartBeam=o,delete e.potentialEndBeam):e.potentialEndBeam=o):g(e),delete o.end_beam,delete o.force_end_beam_last,o.rest&&"invisible"===o.rest.type&&delete o.decoration,!(e.lines.length<=e.lineNum||e.lines[e.lineNum].staff.length<=e.staffNum||(function(e,t,r,n,a){var i=t.lines[t.lineNum].staff[t.staffNum];if(void 0!==r.pitches){var s=i.workingClef.verticalPos;r.pitches.forEach((function(e){e.verticalPos=e.pitch-s}))}if(void 0!==r.gracenotes){var o=i.workingClef.verticalPos;r.gracenotes.forEach((function(e){e.verticalPos=e.pitch-o}))}i.voices.length<=t.voiceNum&&(n[a]||(n[a]={}),y(e,t,n[a])),i.voices[t.voiceNum].push(r)}(t,e,o,r,i),0))},this.appendStartingElement=function(t,r,n,a){var i;d(e),"key"===t&&(i=a.impliedNaturals,delete a.impliedNaturals,delete a.explicitAccidentals);var s=Object.assign({},a);if(e.lines[e.lineNum]){var o=e.lines[e.lineNum].staff;if(o){o.length<=e.staffNum&&(o[e.staffNum]={},o[e.staffNum].clef=Object.assign({},o[0].clef),o[e.staffNum].key=Object.assign({},o[0].key),o[0].meter&&(o[e.staffNum].meter=Object.assign({},o[0].meter)),o[e.staffNum].workingClef=Object.assign({},o[0].workingClef),o[e.staffNum].voices=[[]]),"clef"===t&&(o[e.staffNum].workingClef=s);for(var c=o[e.staffNum].voices[e.voiceNum],l=0;l0){var r=t[t.length-1];if("bar"!==r.el_type)return e-1;void 0!==r.barNumber&&(r.barNumber=e)}return e},this.hasBeginMusic=function(){for(var t=0;t=0;r--)if(void 0!==e.lines[r].staff)return!1;return!0},this.getCurrentVoice=function(){var t=function(e,t){for(;t>=0;){if(e[t].staff)return e[t];t--}return null}(e.lines,e.lineNum);if(!t)return null;var r=t.staff[e.staffNum];return r&&void 0!==r.voices[e.voiceNum]?r.voices[e.voiceNum]:null},this.setCurrentVoice=function(t,r,n){e.staffNum=t,e.voiceNum=r,i=n;for(var a=0;a0?(r.push(i-1),n.push(Math.round(a-s)),a=s):is&&ds?(l.push(d-1),c++,o=Math.max(o,s),s=Math.abs(n-t[c]),i.push(a-f),a=f):s=p}i.push(a)}function a(e,t,r,a){for(var i=Math.ceil(e.total/t),s=Math.floor(e.total/i),o=[],c=0;ct&&(s=!0),o%r==r-1&&(o!==e.length-1&&n.push(o),a.push(Math.round(i)),i=0);return{failed:s,totals:a,lineBreaks:n}}e.exports={wrapLines:function(e,t,r){if(t&&0!==e.lines.length){var n=e.deline({lineBreaks:!1}),a=function(e,t){for(var r=[],n=0,a=0,i=0,s=0;s0&&(n[c.line].staff[c.staff].barNumber=s);for(var h=Object.keys(l),u=0;u=0;p--)if("key"===f[p].el_type){a[c.staff]={root:f[p].root,acc:f[p].acc,mode:f[p].mode,accidentals:f[p].accidentals.filter((function(e){return"natural"!==e.acc}))};break}for(p=f.length-1;p>=0;p--)if("stem"===f[p].el_type){i[10*c.staff+c.voice]={direction:f[p].direction};break}if(void 0!==r&&0===c.staff&&0===c.voice)for(p=0;p0&&p.measureWidths.length<25&&(k=a(p,g,0,b),b.attempts.push({type:"Optimize",failed:k.failed,reason:k.reason,lineBreaks:k.lineBreaks,totals:k.totals}),k.failed||(y=k.lineBreaks))}u.push(y),d.push(b)}var w=function(e,t,r){var n={lineBreaks:e,staffwidth:t};for(var a in r)r.hasOwnProperty(a)&&"wrap"!==a&&"staffwidth"!==a&&(n[a]=r[a]);return{revisedParams:n}}(u,n.staffwidth,n);return w.explanation=d,w.reParse=!0,w}}},5633:function(e,t,r){var n,a=r(9447),i=r(4914),s=i.relativeMajor,o=i.transposeKey,c=i.relativeMode,l=r(4208);!function(){"use strict";function e(e,r,n){var a=[],i=r.getKeySignature();if("Hp"===i.root||"HP"===i.root)return a;a=a.concat(function(e,t){for(var r=[],n=e.split("K:"),a=n[0].length,i=1;i2?n+=7:-12===r&&(n-=7):r>0&&n<0?n+=7:r<0&&n>0&&(n-=7),r>12?n+=7:r<-12&&(n-=7),n}function h(e,t,n,a,s,o){for(var c=[],h=i(s,n,o),u={},d={},m=0;m1?i[1]:"",accidentals:l}}function p(e,t,r,n){for(var a=e.pitch,i=u.indexOf(e.name),s=(u.indexOf(t.root)+a)%7,o=i+r,c=e.oct;o>6;)c++,o-=7;for(;o<0;)c--,o+=7;for(var l=u[s],h="",d=e.adj,f="=",m=0;m4&&(l=l.toLowerCase()),{acc:h,name:l,upper:l.toUpperCase()}}var m=/([_^=]*)([A-Ga-g])([,']*)/,g=/([_^=]*[A-Ga-g][,']*)(\d*\/*\d*)([\>\<\-\)\.\s\\]*)/,v=/([_^=]*[A-Ga-g][,']*)?(\d*\/*\d*)?([\>\<\-\)]*)?/,b=/(\s*)$/;function y(e,t,r,n){var a="none"===t?0:u.indexOf(t),i=e.match(m),s=i[2].toUpperCase(),o=u.indexOf(s)-a;o<0&&(o+=7);var c=d.indexOf(i[3]);s===i[2]&&c--;var l=n[s]||r[s]||"=";return{acc:i[1],name:s,pitch:o,oct:c,adj:C(i[1],r[s],n[s]),courtesy:i[1]===l}}function x(e,t,r,n,a){var i=e.substring(t,r),s=i.match(new RegExp(g.source+b.source),"");if(s){var o=s[1].length,c=s[2].length+s[3].length+s[4].length;t+=r-t-o-c,r-=c}else if(s=i.match(new RegExp(/([^\[]*)/.source+/\[/.source+v.source+v.source+v.source+v.source+v.source+v.source+v.source+v.source+/\-?](\d*\/*\d*)?([\>\<\-\)]*)/.source+b.source))){for(var l=1+s[1].length,h=0;h=0;t--)if("program"===u[t].cmd)return void(u[t].channel=e)}function L(e){return e/1e6}function O(e){return Math.round(e*k*1e6)/1e6}function H(e){switch(parseInt(e.den,10)){case 2:return.5;case 4:return.25;case 8:return e.num%3==0?.375:.125;case 16:return.125}return.25}function z(e,t){var r=t.start,n=t.duration,a=O(1/32);switch(e){case"trill":for(var i=2;n>0;)u.push({cmd:"note",pitch:t.pitch+i,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),i=2===i?0:2,n-=a,r+=a;break;case"mordent":u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),n-=a,r+=a,u.push({cmd:"note",pitch:t.pitch+2,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),n-=a,r+=a,u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:n,gap:0,instrument:h});break;case"lowermordent":u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),n-=a,r+=a,u.push({cmd:"note",pitch:t.pitch-2,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),n-=a,r+=a,u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:n,gap:0,instrument:h});break;case"turn":a=t.duration/4,u.push({cmd:"note",pitch:t.pitch+2,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r+a,duration:a,gap:0,instrument:h,style:"decoration"}),u.push({cmd:"note",pitch:t.pitch-1,volume:t.volume,start:r+2*a,duration:a,gap:0,instrument:h,style:"decoration"}),u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r+3*a,duration:a,gap:0,instrument:h,style:"decoration"});break;case"roll":for(;n>0;)u.push({cmd:"note",pitch:t.pitch,volume:t.volume,start:r,duration:a,gap:0,instrument:h,style:"decoration"}),n-=2*a,r+=2*a}}function D(e,t){var r,n=function(e,t){if(t)return 0;var r;if(null!=g)r=g,g=void 0;else if(T)if(B>e)r=E;else{var n=(e-m)/H(w);r=0===n?S:parseInt(n,10)===n?_:E}else r=_;return v&&(r+=v,v=void 0),r<0&&(r=0),r>127&&(r=127),t?0:r}(L(e.time),t);if(p.processChord(e),e.gracenotes&&e.pitches&&e.pitches.length>0&&e.pitches[0]&&(r=function(e,t){for(var r,n=0,a=[],s=0;s0?F.endType="tenuto":d&&(F.endType=d),F.endType){case"tenuto":F.gap=-.001;break;case"staccato":var I=.4*F.duration;F.gap=o/60*I;break;default:F.gap=0}u.push(F)}}}u.length}var Y=function(e){return e.pitches&&e.pitches.length>0&&e.pitches[0]?e.pitches[0].duration:e.elem?e.elem.duration:e.duration}(e);f=Math.max(f,L(e.time)+O(Y))}n=function(n,i,C,O){i||(i={}),O||(O={}),e=[],t=[0,0,0,0,0,0,0],s=[],o=i.qpm,c=void 0,k=1,l=void 0,h=void 0,u=void 0,d=void 0,f=0,x=C,w={num:4,den:4},T=!0,S=105,_=95,E=85,M=.25,g=void 0,v=void 0,N=0,b=[],A={},y=1,n.length>0&&n[0].length>0&&(B=n[0][0].pickupLength),void 0===i.bassprog||O.bassprog||(O.bassprog=[i.bassprog]),void 0===i.bassvol||O.bassvol||(O.bassvol=[i.bassvol]),void 0===i.chordprog||O.chordprog||(O.chordprog=[i.chordprog]),void 0===i.chordvol||O.chordvol||(O.chordvol=[i.chordvol]),void 0===i.gchord||O.gchord||(O.gchord=[i.gchord]),p=new a(n.length,i.chordsOff,O,w),function(e,t){for(var r=0;r=0)&&(j=!0);for(var V=0;V0&&"program"===u[u.length-1].cmd)u[u.length-1].instrument=Y.program;else{var R;for(R=u.length-1;R>=0&&"program"!==u[R].cmd;R--);(R<0||u[R].instrument!==Y.program)&&u.push({cmd:"program",channel:0,instrument:Y.program})}break;case"channel":P(Y.channel);break;case"drum":A=G(Y.params),q();break;case"gchordOn":p.gChordOn(Y);break;case"beat":S=Y.beats[0],_=Y.beats[1],E=Y.beats[2];break;case"vol":g=Y.volume;break;case"volinc":v=Y.volume;break;case"beataccents":T=Y.value;break;case"gchord":case"bassprog":case"chordprog":case"bassvol":case"chordvol":case"gchordbars":p.paramChange(Y);break;default:console.log("MIDI creation. Unknown el_type: "+Y.el_type+"\n")}}void 0===u[0].instrument&&(u[0].instrument=l||0),d&&u.unshift(d),s.push(u),p.finish(),b.length}return i.detuneOctave&&function(e,t){for(var r={},n=0;n1){var c=(o=o.sort((function(e,t){return e.pitch-t.pitch})))[o.length-1],l=c.pitch%12,h=!1;for(a=0;!h&&a0&&s.push(b),{tempo:o,instrument:l,tracks:s,totalDuration:f}};var F=[0,2,4,5,7,9,11];function j(n){if(void 0!==n.midipitch)return n.midipitch;var a=n.pitch;if(n.accidental)switch(n.accidental){case"sharp":e[a]=1;break;case"flat":e[a]=-1;break;case"natural":e[a]=0;break;case"dblsharp":e[a]=2;break;case"dblflat":e[a]=-2;break;case"quartersharp":e[a]=.25;break;case"quarterflat":e[a]=-.25}var i=12*function(e){return Math.floor(e/7)}(a)+F[Y(a)]+60;return void 0!==e[a]?i+=e[a]:i+=t[Y(a)],i+=r}function I(e){var t=[0,0,0,0,0,0,0];if(!e.accidentals)return t;for(var r=0;r=0?(e.pitch=Math.round(e.pitch),e.cents=-50):t.indexOf(".25")>=0&&(e.pitch=Math.round(e.pitch),e.cents=50),e}function Y(e){return(e%=7)<0&&(e+=7),e}function G(e){if(0===e.pattern.length||!1===e.on)return{on:!1};for(var t=e.pattern[0],r=[],n="",a=0,i=0;it&&(r=r.substring(0,t)),function(e){for(var t="",r=0;r>=7;for(var n=r.length-1;n>=0;n--){t<<=8;var a=r[n];0!==n&&(a|=128),t|=a}var s=t.toString(16).length;return i(t,s+=s%2)}t.prototype.setTempo=function(e){0===this.trackcount&&(this.startTrack(),this.track+="%00%FF%51%03"+i(Math.round(6e7/e),6),this.endTrack())},t.prototype.setGlobalInfo=function(e,t,n,a){if(0===this.trackcount){this.startTrack();var s=Math.round(6e7/e);this.track+="%00%FF%51%03"+i(s,6),n&&(this.track+=function(e){if(!e||!e.accidentals)return"";for(var t="%00%FF%59%02",r=0,n=256,a=0;a=0)return n;return n}function i(e,t,r){for(var n=Math.min(e.length,t+3),a=t;a=0)return e[a].decoration[i];return null}function s(e){for(var t=0;t=0&&"bar"!==r[n].el_type;)r[n].noChordVoice=!0,n--}function o(e,t){if(e&&!(e.length<=t)&&e[t].title)return e[t].title.join(" ")}function c(e,t){var r=1/4;e.duration&&(r=e.duration[0]);var n=60;return e.bpm&&(n=e.bpm),r*n/t}function l(t){var r;switch(t.type){case"common_time":r={el_type:"meter",num:4,den:4};break;case"cut_time":r={el_type:"meter",num:2,den:2};break;case"specified":r={el_type:"meter",num:t.value[0].num,den:t.value[0].den};break;default:r={el_type:"meter"}}return e=r.num/r.den,r}function h(e){for(var t=[],r=0;r=0;r--)if(e[r].el_type===t.el_type)return void(JSON.stringify(e[r])!==JSON.stringify(t)&&e.push(t));e.push(t)}n=function(n,h){var p,m=(h=h||{}).program||0,g=h.midiTranspose||0;n.visualTranspose&&(g-=n.visualTranspose);var v=h.channel||0,b=!1,y=h.drum||"",x=h.drumBars||1,k=h.drumIntro||0,w=""!==y,C=!!h.drumOff,T=[];m=parseInt(m,10),g=parseInt(g,10),10===(v=parseInt(v,10))&&(m=t),y=y.split(" "),x=parseInt(x,10),k=parseInt(k,10);var S=n.formatting.bagpipes;S&&(m=71);var _=[];if(n.formatting.midi){var E=n.formatting.midi;E.program&&E.program.length>0&&(m=E.program[0],E.program.length>1&&(m=E.program[1],v=E.program[0]),b=!0),E.transpose&&(g=E.transpose[0]),E.channel&&(v=E.channel[0],b=!0),E.drum&&(y=E.drum),E.drumbars&&(x=E.drumbars[0]),E.drumon&&(w=!0),10===v&&(m=t),E.beat&&_.push({el_type:"beat",beats:E.beat}),E.nobeataccents&&_.push({el_type:"beataccents",value:!1})}p=h.qpm?parseInt(h.qpm,10):n.metaText.tempo?c(n.metaText.tempo,n.getBeatLength()):h.defaultQpm?h.defaultQpm:180;var M=[];S&&M.push({el_type:"bagpipes"}),M.push({el_type:"instrument",program:m}),v&&M.push({el_type:"channel",channel:v}),g&&M.push({el_type:"transpose",transpose:g}),M.push({el_type:"tempo",qpm:p});for(var N=0;N<_.length;N++)M.push(_[N]);var A,B=[],P=[],L=[],O=[0],H={};H[0]={el_type:"tempo",qpm:p,timing:0};for(var z=[],D=[],F=!1,j=n.lines,I=0;I=0?t="pppp":e.decoration.indexOf("ppp")>=0?t="ppp":e.decoration.indexOf("pp")>=0?t="pp":e.decoration.indexOf("p")>=0?t="p":e.decoration.indexOf("mp")>=0?t="mp":e.decoration.indexOf("mf")>=0?t="mf":e.decoration.indexOf("f")>=0?t="f":e.decoration.indexOf("ff")>=0?t="ff":e.decoration.indexOf("fff")>=0?t="fff":e.decoration.indexOf("ffff")>=0&&(t="ffff"),t&&(A=n[t].slice(0),B[q].push({el_type:"beat",beats:A.slice(0)}),P[X]=!1,L[X]=!1),e.decoration.indexOf("crescendo(")>=0){var a=r(U,te,"crescendo)"),s=Math.min(127,A[0]+50),o=i(U,te+a+1,Object.keys(n));o&&(s=n[o][0]),P[X]=a>0&&Math.floor((s-A[0])/a),L[X]=!1}else if(e.decoration.indexOf("crescendo)")>=0)P[X]=!1;else if(e.decoration.indexOf("diminuendo(")>=0){var c=r(U,te,"diminuendo)"),l=Math.max(15,A[0]-50),h=i(U,te+c+1,Object.keys(n));h&&(l=n[h][0]),P[X]=!1,L[X]=c>0&&Math.floor((l-A[0])/c)}else e.decoration.indexOf("diminuendo)")>=0&&(L[X]=!1)},G=V.staff,q=0,W=0;W=0?B[q].push({el_type:"transpose",transpose:-12}):R.clef.type.indexOf("+8")>=0&&B[q].push({el_type:"transpose",transpose:12})),n.formatting.midi&&n.formatting.midi.drumoff&&(B[q].push({el_type:"bar"}),B[q].push({el_type:"drum",params:{pattern:"",on:!1}}));var Q=0,J=0,Z=0,ee=0;A=[105,95,85,1];for(var te=0;te=0?B[q].push({el_type:"transpose",transpose:-12}):re.type.indexOf("+8")>=0&&B[q].push({el_type:"transpose",transpose:12}));break;case"tempo":p=c(re,n.getBeatLength()),B[q].push({el_type:"tempo",qpm:p,timing:O[q]}),H[""+O[q]]={el_type:"tempo",qpm:p,timing:O[q]};break;case"bar":Q>0&&B[q].push({el_type:"bar"}),Y(re),Q=0;var se="bar_right_repeat"===re.type||"bar_dbl_repeat"===re.type,oe="1"===re.startEnding,ce="bar_left_repeat"===re.type||"bar_dbl_repeat"===re.type||"bar_right_repeat"===re.type;if(se){var le=z[q];le||(le=0);var he=D[q];he||(he=B[q].length);for(var ue=le;ue=0&&i!==t[""+o.timing].qpm&&(i=t[""+o.timing].qpm,"tempo"===o.el_type?(o.qpm=t[""+o.timing].qpm,s++):(e[n].splice(s,0,{el_type:"tempo",qpm:t[""+o.timing].qpm,timing:o.timing}),s+=2))}}(B,H),k)for(var pe=n.getPickupLength(),me=0;mege;)ge++;if(B[me].length>ge){for(ie=0;ie0&&B[0].length>0&&(B[0][0].pickupLength=n.getPickupLength()),B}}(),e.exports=n},8702:function(e,t,r){var n=r(5281);e.exports=function(){return window.abcjsAudioContext||n(),window.abcjsAudioContext}},2710:function(e){e.exports=function(e){return Math.pow(2,e/1200)}},7207:function(e){var t=function(e,t,r,n){this.chordTrack=[],this.chordTrackFinished=!1,this.chordChannel=e,this.currentChords=[],this.lastChord,this.chordLastBar,this.chordsOff=!!t,this.gChordTacet=this.chordsOff,this.hasRhythmHead=!1,this.transpose=0,this.lastBarTime=0,this.meter=n,this.tempoChangeFactor=1,this.bassInstrument=r.bassprog&&r.bassprog.length>=1?r.bassprog[0]:0,this.chordInstrument=r.chordprog&&r.chordprog.length>=1?r.chordprog[0]:0,this.bassOctaveShift=r.bassprog&&2===r.bassprog.length?r.bassprog[1]:0,this.chordOctaveShift=r.chordprog&&2===r.chordprog.length?r.chordprog[1]:0,this.boomVolume=r.bassvol&&1===r.bassvol.length?r.bassvol[0]:64,this.chickVolume=r.chordvol&&1===r.chordvol.length?r.chordvol[0]:48,r.gchord&&r.gchord.length>0?this.overridePattern=a(r.gchord[0]):this.overridePattern=void 0};function r(e,t,r,a){var i=[];if(!e)return i;t.indexOf("boom")>=0?i.push(r?e.boom:e.boom2):a&&i.push(e.boom);var s=e.chick.length;if(t.indexOf("chick")>=0)for(var o=0;o0&&!this.chordTrackFinished&&(this.resolveChords(this.lastBarTime,i(e.time)),this.currentChords=[]),this.chordLastBar=this.lastChord},t.prototype.gChordOn=function(e){this.chordsOff||(this.gChordTacet=e.tacet)},t.prototype.paramChange=function(e){switch(e.el_type){case"gchord":e.param&&e.param.length>0?this.overridePattern=a(e.param):this.overridePattern=void 0;break;case"bassprog":this.bassInstrument=e.value,null!=e.octaveShift&&null!=e.octaveShift?this.bassOctaveShift=e.octaveShift:this.bassOctaveShift=0;break;case"chordprog":this.chordInstrument=e.value,null!=e.octaveShift&&null!=e.octaveShift?this.chordOctaveShift=e.octaveShift:this.chordOctaveShift=0;break;case"bassvol":this.boomVolume=e.param;break;case"chordvol":this.chickVolume=e.param;break;default:console.log("unhandled midi param",e)}},t.prototype.finish=function(){this.chordTrackEmpty()||(this.chordTrackFinished=!0)},t.prototype.addTrack=function(e){this.chordTrackEmpty()||e.push(this.chordTrack)},t.prototype.findChord=function(e){if(this.gChordTacet)return"break";if(this.chordTrackFinished||!e.chord||0===e.chord.length)return null;for(var t=0;t=0)return"break"}return null},t.prototype.interpretChord=function(e){if(0!==e.length){if("break"===e)return{chick:[]};var t=e.substring(0,1);if("("===t){if(0===(e=e.substring(1,e.length-2)).length)return;t=e.substring(0,1)}var r=this.basses[t];if(r){for(var n=this.transpose;n<-8;)n+=12;for(;n>8;)n-=12;(r+=n)<33?r+=12:r>44&&(r-=12);var a,i=r,s=(r+=12*this.bassOctaveShift)-5;1===e.length&&(a=this.chordNotes(r,""));var o=e.substring(1),c=o.substring(0,1);"b"===c||"♭"===c?(i--,r--,s--,o=o.substring(1)):"#"!==c&&"♯"!==c||(i++,r++,s++,o=o.substring(1));var l=o.split("/");if((a=this.chordNotes(i,l[0])).length>=3&&(s=s+(a[2]-a[0])-7),2===l.length&&this.basses[l[1].substring(0,1)]){var h={"#":1,"♯":1,b:-1,"♭":-1}[l[1].substring(1)]||0;r=this.basses[l[1].substring(0,1)]+h+n,s=r+=12*this.bassOctaveShift}return{boom:r,boom2:s,chick:a}}}},t.prototype.chordNotes=function(e,t){var r=this.chordIntervals[t];r||(r="ma"===t.slice(0,2).toLowerCase()||"M"===t[0]?this.chordIntervals.M:"m"===t[0]||"-"===t[0]?this.chordIntervals.m:this.chordIntervals.M),e+=12,e+=12*this.chordOctaveShift;for(var n=[],a=0;a0&&c[u-1]&&c[u]&&c[u-1].boom!==c[u].boom&&(d=!0);var p=l[u],m=p.indexOf("boom")>=0,g=!m&&0!==u&&l[0].indexOf("boom")>=0&&(!c[u-1]||c[u-1].boom!==c[u].boom),v=r(c[u],p,d,g);m&&(d=!1);for(var b=0;b0){var s=e.gap?e.gap:0,o=e.duration;s=Math.min(s,2*o/3);var c={pitch:e.pitch,instrument:i,start:Math.round(1e6*e.start)/1e6,end:Math.round(1e6*(e.start+o-s))/1e6,volume:e.volume};e.startChar&&(c.startChar=e.startChar),e.endChar&&(c.endChar=e.endChar),e.style&&(c.style=e.style),e.cents&&(c.cents=e.cents),t[r].push(c)}break;case"program":a=n[e.instrument];break;case"text":break;default:console.log("Unhandled midi event",e)}}))})),t}},6313:function(e,t,r){var n=r(5049),a=r(5281),i=r(8702),s=r(1225),o=r(9733),c=r(5075),l=r(5343),h=r(6987);function u(e,t,r,s,o){var c=!0;if(i()?c="suspended"===i().state:a(),!n())throw{status:"NotSupported",message:"This browser does not support audio."};(c||o)&&r&&r.classList.add("abcjs-loading"),c?i().resume().then((function(){s?s().then((function(n){d(e,t,r,o)})):d(e,t,r,o)})):d(e,t,r,o)}function d(e,t,r,n){n?e(t).then((function(){r&&r.classList.remove("abcjs-loading")})):(e(t),r&&r.classList.remove("abcjs-loading"))}e.exports=function(e,t){var r=this;if("string"==typeof e){var n=e;if(!(e=document.querySelector(n)))throw new Error('Cannot find element "'+n+'" in the DOM.')}else if(!(e instanceof HTMLElement))throw new Error("The first parameter must be a valid element or selector in the DOM.");if(r.parent=e,r.options={},t&&(r.options=Object.assign({},t)),r.options.ac&&a(r.options.ac),function(e,t){var r=!!t.loopHandler,n=!!t.restartHandler,a=!!t.playHandler||!!t.playPromiseHandler,i=!!t.progressHandler,u=!!t.warpHandler,d=!1!==t.hasClock,f='
\n';if(r){var p=t.repeatTitle?t.repeatTitle:"Click to toggle play once/repeat.";f+='\n"}if(n){var m=t.restartTitle?t.restartTitle:"Click to go to beginning.";f+='\n"}if(a){var g=t.playTitle?t.playTitle:"Click to play/pause.";f+='\n"}if(i){var v=t.randomTitle?t.randomTitle:"Click to change the playback position.";f+='\n'}if(d&&(f+='\n'),u){var b=t.warpTitle?t.warpTitle:"Change the playback speed.";f+=' ( '+(t.bpm?t.bpm:"BPM")+")\n"}f+='
CSS required: load abcjs-audio.css
',f+="
\n",e.innerHTML=f}(r.parent,r.options),function(e){var t=!!e.options.loopHandler,r=!!e.options.restartHandler,n=!!e.options.playHandler||!!e.options.playPromiseHandler,a=!!e.options.progressHandler,i=!!e.options.warpHandler,s=e.parent.querySelector(".abcjs-midi-start");t&&e.parent.querySelector(".abcjs-midi-loop").addEventListener("click",(function(t){u(e.options.loopHandler,t,s,e.options.afterResume)})),r&&e.parent.querySelector(".abcjs-midi-reset").addEventListener("click",(function(t){u(e.options.restartHandler,t,s,e.options.afterResume)})),n&&s.addEventListener("click",(function(t){u(e.options.playPromiseHandler||e.options.playHandler,t,s,e.options.afterResume,!!e.options.playPromiseHandler)})),a&&e.parent.querySelector(".abcjs-midi-progress-background").addEventListener("click",(function(t){u(e.options.progressHandler,t,s,e.options.afterResume)})),i&&e.parent.querySelector(".abcjs-midi-tempo").addEventListener("change",(function(t){u(e.options.warpHandler,t,s,e.options.afterResume)}))}(r),r.disable=function(e){var t=r.parent.querySelector(".abcjs-inline-audio");e?t.classList.add("abcjs-disabled"):t.classList.remove("abcjs-disabled")},r.setWarp=function(e,t){r.parent.querySelector(".abcjs-midi-tempo").value=Math.round(t),r.setTempo(e)},r.setTempo=function(e){var t=r.parent.querySelector(".abcjs-midi-current-tempo");t&&(t.innerHTML=Math.round(e))},r.resetAll=function(){for(var e=r.parent.querySelectorAll(".abcjs-pushed"),t=0;t0){if(e.debugCallback&&e.debugCallback("pending "+JSON.stringify(l)),i?i*=2:i=50,i<9e4)return new Promise((function(t,n){setTimeout((function(){var s=[];for(u=0;u75&&(t=75),t=t/50-1;var a=0,i=.25;8===r.den&&(i/=2);for(var s=i/2,o=s*t,c=0;c=l[h].start+s)){var d=u.start;u.start+=o,u.volume*=1+a,h>0&&l[h-1].end==d&&(l[h-1].end=u.start,l[h-1].volume*=1-a)}}}}(c,e.options.swing,e.meterFraction,e.pickupLength),e.sequenceCallback&&e.sequenceCallback(c,e.callbackContext);var l=function(e,t){if(null==t)return null;var r=[];if(t.length){for(var n=0;n1&&(a=1),r.push(a)}else r.push(0);return r}var i=parseFloat(t);if(i*(e-1)>2)return null;for(var s=e%2==0,o=s?0-i/2:0,c=o+i,l=0;lr?l[r]:0;t.forEach((function(t){var r=t.instrument+":"+t.pitch+":"+t.volume+":"+Math.round(1e3*(t.end-t.start))/1e3+":"+n+":"+i+":"+(t.cents?t.cents:0);e.debugCallback&&e.debugCallback("noteMapTrack "+r),h[r]||(h[r]=[]),h[r].push(t.start)}))}));for(var d=[],f=s().createBuffer(2,o,s().sampleRate),p=0;p0?e.audioBuffers[0].duration:0;return{status:s().state,duration:t}}e.audioBuffers=[f],e.debugCallback&&(e.debugCallback("sampleRate = "+s().sampleRate),e.debugCallback("totalSamples = "+o),e.debugCallback("creationTime = "+Math.floor(1e3*(s().currentTime-n))+"ms")),Promise.all(d).then((function(){"suspended"===s().state?s().resume().then((function(){r(b(e))})):"interrupted"===s().state?s().suspend().then((function(){s().resume().then((function(){r(b(e))}))})):r(b(e))}))}))):Promise.reject(new Error(f))},e.start=function(){if(!e.audioBufferPossible)throw new Error(f);e.debugCallback&&e.debugCallback("start called");var t=e.pausedTimeSec?e.pausedTimeSec:0;e._kickOffSound(t),e.startTimeSec=s().currentTime-t,e.pausedTimeSec=void 0,e.debugCallback&&e.debugCallback("MIDI STARTED",e.startTimeSec)},e.pause=function(){if(!e.audioBufferPossible)throw new Error(f);return e.debugCallback&&e.debugCallback("pause called"),e.pausedTimeSec=e.stop(),e.pausedTimeSec},e.resume=function(){e.start()},e.seek=function(t,r){var n;switch(r){case"seconds":n=t;break;case"beats":n=t*e.millisecondsPerMeasure/e.beatsPerMeasure/1e3;break;default:n=(e.duration-e.fadeLength/1e3)*t}if(!e.audioBufferPossible)throw new Error(f);e.debugCallback&&e.debugCallback("seek called sec="+n),e.isRunning?(e.stop(),e._kickOffSound(n)):e.pausedTimeSec=n,e.pausedTimeSec=n},e.stop=function(){return e.isRunning=!1,e.pausedTimeSec=void 0,e.directSource.forEach((function(e){try{e.stop()}catch(e){console.log("direct source didn't stop:",e)}})),e.directSource=[],s().currentTime-e.startTimeSec},e.finished=function(){e.startTimeSec=void 0,e.pausedTimeSec=void 0,e.isRunning=!1},e.download=function(){return h(e)},e.getAudioBuffer=function(){return e.audioBuffers[0]},e.getIsRunning=function(){return e.isRunning},e._deviceCapable=function(){return!!o()||(console.warn(f),e.debugCallback&&e.debugCallback(f),!1)},e._kickOffSound=function(t){e.isRunning=!0,e.directSource=[],e.audioBuffers.forEach((function(t,r){e.directSource[r]=s().createBufferSource(),e.directSource[r].buffer=t,e.directSource[r].connect(s().destination)})),e.directSource.forEach((function(e){e.start(0,t)})),e.onEnded&&(e.directSource[0].onended=function(){e.onEnded(e.callbackContext)})}}},873:function(e){e.exports=function(e){return window.URL.createObjectURL(function(e){var t,r,n=e[0],a=n.numberOfChannels,i=n.length*a*2+44,s=new ArrayBuffer(i),o=new DataView(s),c=[],l=0,h=0;for(d(1179011410),d(i-8),d(1163280727),d(544501094),d(16),u(1),u(a),d(n.sampleRate),d(2*n.sampleRate*a),u(2*a),u(16),d(1635017060),d(i-h-4),t=0;t';t.preTextDownload&&(i+=t.preTextDownload);var s,o,c=e.metaText&&e.metaText.title?e.metaText.title:"Untitled";return s=t.downloadLabel&&(o=t.downloadLabel)&&"[object Function]"==={}.toString.call(o)?t.downloadLabel(e,n):t.downloadLabel?t.downloadLabel.replace(/%T/,c):'Download MIDI for "'+c+'"',c=c.toLowerCase().replace(/'/g,"").replace(/\W/g,"_").replace(/__/g,"_"),i+=''+s+"",t.postTextDownload&&(i+=t.postTextDownload),i+""};e.exports=function(e,t){var r={};if(t)for(var s in t)t.hasOwnProperty(s)&&(r[s]=t[s]);function o(e,t,n){var s=a(t,r);switch(r.midiOutputType){case"encoded":return s;case"binary":var o=s.replace("data:audio/midi,","");o=(o=o.replace(/MThd/g,"%4d%54%68%64")).replace(/MTrk/g,"%4d%54%72%6b");for(var c=new ArrayBuffer(o.length/3),l=new Uint8Array(c),h=0;h4)for(a=a.toLowerCase(),t-=5;t>0;)a+="'",t--;else for(;t<4;)a+=",",t++;return a}}},522:function(e){e.exports={21:"A0",22:"Bb0",23:"B0",24:"C1",25:"Db1",26:"D1",27:"Eb1",28:"E1",29:"F1",30:"Gb1",31:"G1",32:"Ab1",33:"A1",34:"Bb1",35:"B1",36:"C2",37:"Db2",38:"D2",39:"Eb2",40:"E2",41:"F2",42:"Gb2",43:"G2",44:"Ab2",45:"A2",46:"Bb2",47:"B2",48:"C3",49:"Db3",50:"D3",51:"Eb3",52:"E3",53:"F3",54:"Gb3",55:"G3",56:"Ab3",57:"A3",58:"Bb3",59:"B3",60:"C4",61:"Db4",62:"D4",63:"Eb4",64:"E4",65:"F4",66:"Gb4",67:"G4",68:"Ab4",69:"A4",70:"Bb4",71:"B4",72:"C5",73:"Db5",74:"D5",75:"Eb5",76:"E5",77:"F5",78:"Gb5",79:"G5",80:"Ab5",81:"A5",82:"Bb5",83:"B5",84:"C6",85:"Db6",86:"D6",87:"Eb6",88:"E6",89:"F6",90:"Gb6",91:"G6",92:"Ab6",93:"A6",94:"Bb6",95:"B6",96:"C7",97:"Db7",98:"D7",99:"Eb7",100:"E7",101:"F7",102:"Gb7",103:"G7",104:"Ab7",105:"A7",106:"Bb7",107:"B7",108:"C8",109:"Db8",110:"D8",111:"Eb8",112:"E8",113:"F8",114:"Gb8",115:"G8",116:"Ab8",117:"A8",118:"Bb8",119:"B8",120:"C9",121:"Db9"}},5058:function(e){var t={f0:"_C",n0:"=C",s0:"^C",x0:"C",f1:"_D",n1:"=D",s1:"^D",x1:"D",f2:"_E",n2:"=E",s2:"^E",x2:"E",f3:"_F",n3:"=F",s3:"^F",x3:"F",f4:"_G",n4:"=G",s4:"^G",x4:"G",f5:"_A",n5:"=A",s5:"^A",x5:"A",f6:"_B",n6:"=B",s6:"^B",x6:"B",f7:"_c",n7:"=c",s7:"^c",x7:"c",f8:"_d",n8:"=d",s8:"^d",x8:"d",f9:"_e",n9:"=e",s9:"^e",x9:"e",f10:"_f",n10:"=f",s10:"^f",x10:"f",f11:"_g",n11:"=g",s11:"^g",x11:"g",f12:"_a",n12:"=a",s12:"^a",x12:"a",f13:"_b",n13:"=b",s13:"^b",x13:"b",f14:"_c'",n14:"=c'",s14:"^c'",x14:"c'",f15:"_d'",n15:"=d'",s15:"^d'",x15:"d'",f16:"_e'",n16:"=e'",s16:"^e'",x16:"e'"};e.exports=function(e){var r=(e.accidental?e.accidental[0]:"x")+e.verticalPos;return t[r]}},4586:function(e,t,r){var n=r(4771),a=r(522),i=r(2710),s=function(e,t,r){for(var n=0;n<2;n++)for(var a=t.getChannelData(n),i=e.getChannelData(n),s=0;s=1&&parseInt(e.cursorControl.beatSubdivisions,10)<=64&&(r=parseInt(e.cursorControl.beatSubdivisions,10)),e.timer=new i(e.visualObj,{beatCallback:e.beatCallback,eventCallback:e.eventCallback,lineEndCallback:e.lineEndCallback,qpm:e.currentTempo,extraMeasuresAtBeginning:e.cursorControl?e.cursorControl.extraMeasuresAtBeginning:void 0,lineEndAnticipation:e.cursorControl?e.cursorControl.lineEndAnticipation:0,beatSubdivisions:r}),e.cursorControl&&e.cursorControl.onReady&&"function"==typeof e.cursorControl.onReady&&e.cursorControl.onReady(e),e.isLoaded=!0,e.isLoading=!1,Promise.resolve({status:"created",notesStatus:t})}))},e.destroy=function(){e.timer&&(e.timer.reset(),e.timer.stop(),e.timer=null),e.midiBuffer&&(e.midiBuffer.stop(),e.midiBuffer=null),e.setProgress(0,1),e.control&&e.control.resetAll()},e.play=function(){return e.runWhenReady(e._play,void 0)},e.runWhenReady=function(t,r){return e.visualObj?e.isLoading?(n=500,new Promise((function(e){setTimeout(e,n)}))).then((function(){return e.isLoading?e.runWhenReady(t,r):t(r)})):e.isLoaded?t(r):e.go().then((function(){return t(r)})):Promise.resolve({status:"loading"});var n},e._play=function(){return s().resume().then((function(){return e.isStarted=!e.isStarted,e.isStarted?(e.cursorControl&&e.cursorControl.onStart&&"function"==typeof e.cursorControl.onStart&&e.cursorControl.onStart(),e.midiBuffer.start(),e.timer.start(e.percent),e.control&&e.control.pushPlay(!0)):e.pause(),Promise.resolve({status:"ok"})}))},e.pause=function(){e.timer&&(e.timer.pause(),e.midiBuffer.pause(),e.control&&e.control.pushPlay(!1))},e.toggleLoop=function(){e.isLooping=!e.isLooping,e.control&&e.control.pushLoop(e.isLooping)},e.restart=function(){e.timer&&(e.timer.setProgress(0),e.midiBuffer.seek(0))},e.randomAccess=function(t){return e.runWhenReady(e._randomAccess,t)},e._randomAccess=function(t){var r=t.target.classList.contains("abcjs-midi-progress-indicator")?t.target.parentNode:t.target,n=(t.x-r.getBoundingClientRect().left)/r.offsetWidth;return n<0&&(n=0),n>1&&(n=1),e.seek(n),Promise.resolve({status:"ok"})},e.seek=function(t,r){e.timer&&e.midiBuffer&&(e.timer.setProgress(t,r),e.midiBuffer.seek(t,r))},e.setWarp=function(t){if(parseInt(t,10)>0){e.warp=parseInt(t,10);var r=e.isStarted,n=e.percent;return e.destroy(),e.isStarted=!1,e.go().then((function(){return e.setProgress(n,1e3*e.midiBuffer.duration),e.control&&e.control.setWarp(e.currentTempo,e.warp),r?e.play().then((function(){return e.seek(n),Promise.resolve()})):(e.seek(n),Promise.resolve())}))}return Promise.resolve()},e.onWarp=function(t){var r=t.target.value;return e.setWarp(r)},e.setProgress=function(t,r){e.percent=t,e.control&&e.control.setProgress(t,r)},e.finished=function(){if(e.timer.reset(),e.isLooping)return e.timer.start(0),e.midiBuffer.finished(),e.midiBuffer.start(),"continue";e.timer.stop(),e.isStarted&&(e.control&&e.control.pushPlay(!1),e.isStarted=!1,e.midiBuffer.finished(),e.cursorControl&&e.cursorControl.onFinished&&"function"==typeof e.cursorControl.onFinished&&e.cursorControl.onFinished(),e.setProgress(0,1))},e.beatCallback=function(t,r,n,a){var i=t/r;e.setProgress(i,n),e.cursorControl&&e.cursorControl.onBeat&&"function"==typeof e.cursorControl.onBeat&&e.cursorControl.onBeat(t,r,n,a)},e.eventCallback=function(t){if(!t)return e.finished();e.cursorControl&&e.cursorControl.onEvent&&"function"==typeof e.cursorControl.onEvent&&e.cursorControl.onEvent(t)},e.lineEndCallback=function(t,r){e.cursorControl&&e.cursorControl.onLineEnd&&"function"==typeof e.cursorControl.onLineEnd&&e.cursorControl.onLineEnd(t,r)},e.getUrl=function(){return e.midiBuffer.download()},e.download=function(t){var r=e.getUrl(),n=document.createElement("a");document.body.appendChild(n),n.setAttribute("style","display: none;"),n.href=r,n.download=t||"output.wav",n.click(),window.URL.revokeObjectURL(r),document.body.removeChild(n)}}},2029:function(e){e.exports=function(){var e=this;e.tracks=[],e.totalDuration=0,e.currentInstrument=[],e.starts=[],e.addTrack=function(){return e.tracks.push([]),e.currentInstrument.push(0),e.starts.push(0),e.tracks.length-1},e.setInstrument=function(t,r){e.tracks[t].push({channel:0,cmd:"program",instrument:r}),e.currentInstrument[t]=r},e.appendNote=function(t,r,n,a,i){var s={cmd:"note",duration:n,gap:0,instrument:e.currentInstrument[t],pitch:r,start:e.starts[t],volume:a};i&&(s.cents=i),e.tracks[t].push(s),e.starts[t]+=n,e.totalDuration=Math.max(e.totalDuration,e.starts[t])}}},2426:function(e,t,r){var n=r(6074),a={violin:{name:"StringTab",defaultTuning:["G,","D","A","e"],isTabBig:!1,tabSymbolOffset:0},fiddle:{name:"StringTab",defaultTuning:["G,","D","A","e"],isTabBig:!1,tabSymbolOffset:0},mandolin:{name:"StringTab",defaultTuning:["G,","D","A","e"],isTabBig:!1,tabSymbolOffset:0},guitar:{name:"StringTab",defaultTuning:["E,","A,","D","G","B","e"],isTabBig:!0,tabSymbolOffset:0},fiveString:{name:"StringTab",defaultTuning:["C,","G,","D","A","e"],isTabBig:!1,tabSymbolOffset:-.95}},i={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){this.inited||(this.register(new n),this.inited=!0);var i=null;if(r.tablature){var s=r.tablature;i=[];for(var o=0;o0)for(var a=r.length,i=0;i1&&r&&r.length>0)for(a=r.length,i=0;i=0;n--)if(t.pitch+t.pitchAltered>=e.stringPitches[n]){var a=t.pitch+t.pitchAltered-e.stringPitches[n];return"^"===t.quarter?a-=.5:"v"===t.quarter&&(a+=.5),{num:Math.round(a),str:e.stringPitches.length-1-n,note:t}}return{num:"?",str:e.stringPitches.length-1,note:t}}function l(e,t){var r={num:"?",str:0,note:t};e.push(r),e.error=t.emit()+": unexpected note for instrument"}function h(e){var t=e.tuning,r=e.capo,s=e.params.highestNote;this.linePitch=e.linePitch,this.highestNote="a'",s&&(this.highestNote=s),this.measureAccidentals={},this.capo=0,r&&(this.capo=parseInt(r,10)),this.transpose=e.transpose?e.transpose:0,this.tuning=t,this.stringPitches=[];for(var o=0;o0&&(this.capoTuning=function(e){var t=null,r=e.tuning;if(e.capo>0){t=[];for(var n=0;n0&&(r=e.capoTuning);for(var n=r.length-1,a=0;a1?(o=s(this,e)).error&&(i=o.error):e[0].endTie||((r=new a(e[0].name,this.clefTranspose)).checkKeyAccidentals(this.accidentals,this.measureAccidentals),(n=c(this,r))?o.push(n):(l(o,r),i=o.error))),i)return o;var h=null;if(t){h=[];for(var u=0;u0&&(r+=" capo:"+e.capo),t=t.replace("%T",r)),t}return""},h.prototype.suppress=function(e){return!!e.params.suppress},e.exports=h},8918:function(e){function t(e,t){this.numLines=e,this.lineSpace=t,this.verticalSize=this.numLines*this.lineSpace,this.bar={pitch:3,pitch2:t*e,height:5}}t.prototype.bypass=function(e){var t=e.staffGroup.voices;return!!(t.length>0&&t[0].isPercussion)},t.prototype.setRelative=function(e,t,r){switch(e.type){case"bar":t.pitch=this.bar.pitch,t.pitch2=this.bar.pitch2,t.height=this.height;break;case"symbol":var n=this.bar.pitch2/2;if("dots.dot"==e.name)return r?(t.pitch=n,!1):(t.pitch=n+this.lineSpace,!0)}return r},e.exports=t},6776:function(e,t,r){var n=r(2842),a=n.noteToMidi,i=n.midiToNote;function s(e,t){var r=a(e);t&&(r+=t);var n,s=i(r),o=!1,c=!1,l=null,h=null,u=!1,d=0;e.startsWith("_")?(o=!0,d=-1,"/"==e[1]?(o=!1,h="v",d=0):"_"==e[1]&&(u=!0,d-=1)):e.startsWith("^")?(c=!0,d=1,"/"==e[1]?(c=!1,h="^",d=0):"^"==e[1]&&(u=!0,d+=1)):e.startsWith("=")&&(l=!0,d=0),((n=o||c||null!=h)||l)&&(s=null!=h||u?e.slice(2):e.slice(1));var f=(s.match(/,/g)||[]).length,p=(s.match(/'/g)||[]).length;this.pitch=r,this.pitchAltered=0,this.name=s,this.acc=d,this.isSharp=c,this.isKeySharp=!1,this.isDouble=u,this.isAltered=n,this.isFlat=o,this.isKeyFlat=!1,this.natural=l,this.quarter=h,this.isLower=this.name==this.name.toLowerCase(),this.name=this.name[0].toUpperCase(),this.hasComma=f,this.isQuoted=p}s.prototype.sameNoteAs=function(e){return e.pitch===this.pitch},s.prototype.isLowerThan=function(e){return e.pitch>this.pitch},s.prototype.checkKeyAccidentals=function(e,t){if(!this.isAltered&&!this.natural)if(t[this.name.toUpperCase()])switch(t[this.name.toUpperCase()]){case"__":return this.acc=-2,void(this.pitchAltered=-2);case"_":return this.acc=-1,void(this.pitchAltered=-1);case"=":return this.acc=0,void(this.pitchAltered=0);case"^":return this.acc=1,void(this.pitchAltered=1);case"^^":return this.acc=2,void(this.pitchAltered=2)}else if(e)for(var r=this.name,n=0;n=0){if(r===t)return e.extra[n].x+e.extra[n].w/2;r++}return-1}function f(e){if(e.abcelem){var t=e.abcelem;if(t.rest)return t.gracenotes}return null}function p(e,t,r){var n=e.semantics.notesToNumber(t,r);if(n.error)return e.setError(n.error),n;if(n.graces&&n.notes){var a=n.notes.length-1;n.notes[a].graces=n.graces}return n}function m(e,t,r,n,a){for(var i=0;i=0&&(e.semantics.clefTranspose=-12),k.abcelem.type.indexOf("+8")>=0&&(e.semantics.clefTranspose=12)),k.type){case"staff-extra key-signature":this.accidentals=k.abcelem.accidentals,e.semantics.accidentals=this.accidentals;break;case"bar":e.semantics.measureAccidentals={};var T=!1;x===g.children.length-1&&(T=!0);var S=o(k,e);if(S.abcelem.barNumber){delete S.abcelem.barNumber;for(var _=0;_0&&(y.abselem=M,r.push(y),v.children.push(M))}}},e.exports=h},4785:function(e,t,r){var n=r(3197),a=r(4240),i=r(4331);function s(e,t,r){var n=e.semantics,a=t.controller.getTextSize,i=n.tabInfos(e),s=!0;if(n.suppress(e)&&(s=!1),s){var o=a.calc(i,"tablabelfont","text instrumentname");return r.tabNameInfos={textSize:{height:o.height,width:o.width},name:i},o.height}return 0}function o(e,t){return!(!t[e].isTabStaff||e!==t.length-1&&t[e+1].isTabStaff)}function c(e,t){for(var r=t;r>=0;r--)if(!e[r].isTabStaff)return r;return-1}function l(e,t){return"clef"===e[t].children[0].abcelem.el_type?null:0==t?"none":e[t-1].children[0]}e.exports=function(e,t,r,h){var u=new a,d={clef:{type:"TAB"}},f=e.linePitch*e.nbLines,p=r.staff;if(p){var m=p[0];if(m&&m.clef&&0==m.clef.stafflines)return void e.setError("No tablatures when stafflines=0");p.splice(p.length,0,d)}var g=r.staffGroup,v=g.voices,b=function(e){for(var t=0,r=0;rt&&(t=n.specialY.lyricHeightBelow)}return t}(v[0]),y=h,x=g.staffs[y],k=f+3-x.bottom-b;x.isTabStaff&&(k=x.top);var w={bottom:-1,isTabStaff:!0,specialY:{tempoHeightAbove:0,partHeightAbove:0,volumeHeightAbove:0,dynamicHeightAbove:0,endingHeightAbove:0,chordHeightAbove:0,lyricHeightAbove:0,lyricHeightBelow:0,chordHeightBelow:0,volumeHeightBelow:0,dynamicHeightBelow:0},lines:e.nbLines,linePitch:e.linePitch,dy:.15,top:k},C=function(e,t){for(var r=0,n=0,a=0;;){if(!t[r])return-1;if(t[r].isTabStaff||(a=t[r].voices.length),t[r].isTabStaff){if(n++,o(r,t)&&n=e){if(r+1==t.length)return r+1;if(!t[r+1].isTabStaff)return r+1}if(++r>t.length)return-1}}(h,g.staffs);if(-1!==C){w.parentIndex=C-1,g.staffs.splice(C,0,w),g.height+=f+3;var T=function(e,t){for(var r=t;r>=0;r--)if(!e[r].isTabStaff)return e[r];return null}(g.staffs,C),S=1;(function(e,t){return 1===function(e){for(var t=0,r=0;r1})(g.staffs,T)&&(S=T.voices.length),d.voices=[];for(var _=0;_0&&(E.duplicate=!0);var M=s(e,t,E)/i.STEP;M=Math.max(M,1),g.staffs[h].top+=1,g.height+=M,E.staff=w;var N=v.length;v.splice(v.length,0,E);var A=l(v,_+h);d.voices[_]=[],u.build(e,v,d.voices[_],_,h,A,N)}!function(e){for(var t=0;t0&&(i[0].invisible=!0);break;case"meter":i[0]=l(a,this.tuneNumber),this.startlimitelem=i[0],r.duplicate&&i.length>0&&(i[0].invisible=!0);break;case"clef":if(i[0]=s(a,this.tuneNumber),!i[0])return null;r.duplicate&&i.length>0&&(i[0].invisible=!0);break;case"key":var h=o(a,this.tuneNumber);h&&(i[0]=h,this.startlimitelem=i[0]),r.duplicate&&i.length>0&&(i[0].invisible=!0);break;case"stem":this.stemdir="auto"===a.direction?void 0:a.direction;break;case"part":var u=new n(a,0,0,"part",this.tuneNumber),d=this.getTextSize.calc(a.title,"partsfont","part");u.addFixedX(new f(a.title,0,0,void 0,{type:"part",height:d.height/p.STEP})),i[0]=u;break;case"tempo":var m=new n(a,0,0,"tempo",this.tuneNumber);m.addFixedX(new g(a,this.tuneNumber,c)),i[0]=m;break;case"style":"normal"===a.head?delete this.style:this.style=a.head;break;case"hint":T=!0,this.saveState();break;case"midi":break;case"scale":this.voiceScale=a.size;break;case"color":this.voiceColor=a.color,r.color=this.voiceColor;break;default:var v=new n(a,0,0,"unsupported",this.tuneNumber);v.addFixed(new f("element type "+a.el_type,0,0,void 0,{type:"debug"})),i[0]=v}return i},_.prototype.createBeam=function(e,t,r){var n=[],i=new a(this.stemHeight*this.voiceScale,this.stemdir,this.flatBeams,r[0]);T&&i.setHint();for(var s=0;se.pitches[r+1].pitch){t=!1;var n=e.pitches[r];e.pitches[r]=e.pitches[r+1],e.pitches[r+1]=n}}while(!t)},A=function(e,t,r,n,a,i,s,o,c){for(var l=r;l>11;l--)l%2!=0||n||e.addFixed(new f(null,o,(a+4)*c,l,{type:"ledger"}));for(l=t;l<1;l++)l%2!=0||n||e.addFixed(new f(null,o,(a+4)*c,l,{type:"ledger"}));for(l=0;l1&&(p=new a(i,"grace",s),T&&p.setHint(),p.mainNote=r);var m=[];for(u=e.gracenotes.length-1;u>=0;u--)o+=10,m[u]=o,e.gracenotes[u].accidental&&(o+=7);for(u=0;u=6?"down":"up";for(n&&(_=n),(a=t.style?t.style:a)&&"normal"!==a||(a="note"),(m=i?S[a].nostem:S[a][-s])||console.log("noteSymbol:",a,s,i),g="down"===_?t.pitches.length-2:1;"down"===_?g>=0:g11||M.verticalPos<1)&&x.push(M.verticalPos-M.verticalPos%2),"down"===_?b=d.getSymbolWidth(m)+2:v=d.getSymbolWidth(m)+2)}var A=t.pitches.length;for(g=0;g0&&(h.bottom=h.bottom-1),e.addHead(h)),b+=z.accidentalshiftx,y=Math.max(y,z.dotshiftx)}if(H){var D=Math.round(70*this.voiceScale)/10,F="down"===_?t.minpitch-D:t.minpitch+1/3;F>6&&!n&&(F=6);var j="down"===_?t.maxpitch-1/3:t.maxpitch+D;j<6&&!n&&(j=6);var I="down"===_||0===e.heads.length?0:e.heads[0].w,V="down"===_?1:-1;h&&"noteheads.slash.quarter"===h.c&&("down"===_?j-=1:F+=1),h&&"noteheads.triangle.quarter"===h.c&&("down"===_?j-=.7:F-=1.2),e.addRight(new f(null,I,0,F,{type:"stem",pitch2:j,linewidth:V,bottom:F-1})),u=Math.min(F,j)}return{noteHead:h,roomTaken:b,roomTakenRight:y,min:u,additionalLedgers:x,dir:_,symbolWidth:T}},_.prototype.addLyric=function(e,t){var r="";t.lyric.forEach((function(e){var t=" "===e.divider?"":e.divider;r+=e.syllable+t+"\n"}));var n=this.getTextSize.calc(r,"vocalfont","lyric"),a=t.positioning?t.positioning.vocalPosition:"below";e.addCentered(new f(r,0,n.width,void 0,{type:"lyric",position:a,height:n.height/p.STEP,dim:this.getTextSize.attr("vocalfont","lyric")}))},_.prototype.createNote=function(e,t,r,a){var i,s=null,o=0,l=0,h=0,u=[],p=C(e),m=!1;0===p&&(m=!0,p=.25,t=!0);for(var g=Math.floor(Math.log(p)/Math.log(2)),v=0,y=Math.pow(2,g),k=y/2;y1,this.stemdir,r,g,this.voiceScale);s=M.noteHead,o=M.roomTaken,l=M.roomTakenRight}else{var N=this.addNoteToAbcElement(E,e,v,this.stemdir,this.style,m,g,t,a);void 0!==N.min&&(this.minY=Math.min(N.min,this.minY)),s=N.noteHead,o=N.roomTaken,l=N.roomTakenRight,u=N.additionalLedgers,i=N.dir,h=N.symbolWidth}if(void 0!==e.lyric&&this.addLyric(E,e),void 0!==e.gracenotes&&(o+=this.addGraceNotes(e,a,E,s,this.stemHeight*this.voiceScale,this.isBagpipes,o)),e.decoration){var B=t&&"up"!==i?Math.min(-3,E.bottom-6):E.bottom;this.decoration.createDecoration(a,e.decoration,E.top,s?s.w:0,E,o,i,B,e.positioning,this.hasVocals,this.accentAbove)}if(e.barNumber&&E.addFixed(new f(e.barNumber,-10,0,0,{type:"barNumber"})),A(E,e.minpitch,e.maxpitch,e.rest,h,u,i,-2,1),void 0!==e.chord){var P=x(this.getTextSize,E,e,o,l,h,this.jazzchords,this.germanAlphabet);o=P.roomTaken,l=P.roomTakenRight}return e.startTriplet&&(this.triplet=new b(e.startTriplet,s,{flatBeams:this.flatBeams})),e.endTriplet&&this.triplet&&this.triplet.setCloseAnchor(s),!this.triplet||e.startTriplet||e.endTriplet||e.rest&&"spacer"===e.rest.type||this.triplet.middleNote(s),E},_.prototype.addSlursAndTies=function(e,t,r,n,a,i){if(t.endTie&&this.ties.length>0){for(var s=!1,o=0;o10&&"treble"===t.abcelem.type?13.5:11;t.addFixed(new f(e,n,r.width,a+r.height/p.STEP,{type:"barNumber",dim:this.getTextSize.attr("measurefont","bar-number")}))},_.prototype.createBarLine=function(e,t,r){var a=new n(t,0,10,"bar",this.tuneNumber),i=null,s=0;t.barNumber&&this.addMeasureNumber(t.barNumber,a);var o="bar_right_repeat"===t.type||"bar_dbl_repeat"===t.type,c="bar_left_repeat"!==t.type&&"bar_thick_thin"!==t.type&&"bar_invisible"!==t.type,l="bar_right_repeat"===t.type||"bar_dbl_repeat"===t.type||"bar_left_repeat"===t.type||"bar_thin_thick"===t.type||"bar_thick_thin"===t.type,h="bar_left_repeat"===t.type||"bar_thick_thin"===t.type||"bar_thin_thin"===t.type||"bar_dbl_repeat"===t.type,d="bar_left_repeat"===t.type||"bar_dbl_repeat"===t.type;if(o||d){for(var p in this.slurs)this.slurs.hasOwnProperty(p)&&this.slurs[p].setEndX(a);this.startlimitelem=a}if(o&&(a.addRight(new f("dots.dot",s,1,7)),a.addRight(new f("dots.dot",s,1,5)),s+=6),c&&(i=new f(null,s,1,2,{type:"bar",pitch2:10,linewidth:.6}),a.addRight(i)),"bar_invisible"===t.type&&(i=new f(null,s,1,2,{type:"none",pitch2:10,linewidth:.6}),a.addRight(i)),t.decoration&&this.decoration.createDecoration(e,t.decoration,12,l?3:1,a,0,"down",2,t.positioning,this.hasVocals,this.accentAbove),l&&(i=new f(null,s+=4,4,2,{type:"bar",pitch2:10,linewidth:4}),a.addRight(i),s+=5),this.partstartelem&&t.endEnding&&(this.partstartelem.anchor2=i,this.partstartelem=null),h&&(i=new f(null,s+=3,1,2,{type:"bar",pitch2:10,linewidth:.6}),a.addRight(i)),d&&(s+=3,a.addRight(new f("dots.dot",s,1,7)),a.addRight(new f("dots.dot",s,1,5))),t.startEnding&&r){var m=this.getTextSize.calc(t.startEnding,"repeatfont","").width;a.minspacing+=m+10,this.partstartelem=new u(t.startEnding,i,null),e.addOther(this.partstartelem)}return a.extraw-=5,void 0!==t.chord&&x(this.getTextSize,a,t,0,0,0,!1,this.germanAlphabet),a},e.exports=_},2652:function(e,t,r){var n=r(6658),a=r(4331),i=r(5810);function s(e,t,r,s,o,c,l,h,u,d,f,p,m,g,v){for(var b=e.split("\n"),y=b.length-1;y>=0;y--){var x,k=b[y],w=0;s||(k=i(k,g,v));var C=h.calc(k,o,c),T=C.width,S=C.height/a.STEP;switch(t){case"left":w=-(f+=T+7),x=d.averagepitch,u.addExtra(new n(k,w,T+4,x,{type:"text",height:S,dim:l,position:"left"}));break;case"right":w=p+=4,x=d.averagepitch,u.addRight(new n(k,w,T+4,x,{type:"text",height:S,dim:l,position:"right"}));break;case"below":u.addRight(new n(k,0,0,void 0,{type:"text",position:"below",height:S,dim:l,realWidth:T}));break;case"above":u.addRight(new n(k,0,0,void 0,{type:"text",position:"above",height:S,dim:l,realWidth:T}));break;default:if(r){var _=r.y+3*a.STEP;u.addRight(new n(k,w+r.x,0,d.minpitch+_/a.STEP,{position:"relative",type:"text",height:S,dim:l}))}else{var E="above";d.positioning&&d.positioning.chordPosition&&(E=d.positioning.chordPosition),"hidden"!==E&&u.addCentered(new n(k,m/2,T,void 0,{type:"chord",position:E,height:S,dim:l,realWidth:T}))}}}return{roomTaken:f,roomTakenRight:p}}e.exports=function(e,t,r,n,a,i,o,c){for(var l=0;l0?o.top+3:o.bottom-1,f=s>0?o.top+3:o.bottom-3,p=f-2;"bass-8"===e.type&&(d=3,u=0),o.addRight(new i("8",5+u,a.getSymbolWidth("8")*h,d,{scalex:h,scaley:h,top:f,bottom:p}))}}return o}},3923:function(e,t,r){var n=r(1409),a=r(6020),i=r(6658);e.exports=function(e,t){if(e.el_type="keySignature",!e.accidentals||0===e.accidentals.length)return null;var r=new n(e,0,10,"staff-extra key-signature",t);r.isKeySig=!0;var s=0;return e.accidentals.forEach((function(e){var t,n=0;switch(e.acc){case"sharp":t="accidentals.sharp",n=-3;break;case"natural":t="accidentals.nat";break;case"flat":t="accidentals.flat",n=-1.2;break;case"quartersharp":t="accidentals.halfsharp",n=-2.5;break;case"quarterflat":t="accidentals.halfflat",n=-1.2;break;default:t="accidentals.flat"}r.addRight(new i(t,s,a.getSymbolWidth(t),e.verticalPos,{thickness:a.symbolHeightInPitches(t),top:e.verticalPos+a.symbolHeightInPitches(t)+n,bottom:e.verticalPos+n})),s+=a.getSymbolWidth(t)+2}),this),r}},2143:function(e,t,r){var n=r(6020),a=r(6658);e.exports=function(e,t,r,i){i||(i={});var s,o=void 0!==i.dir?i.dir:null,c=void 0!==i.headx?i.headx:0,l=void 0!==i.extrax?i.extrax:0,h=void 0!==i.flag?i.flag:null,u=void 0!==i.dot?i.dot:0,d=void 0!==i.dotshiftx?i.dotshiftx:0,f=void 0!==i.scale?i.scale:1,p=void 0!==i.accidentalSlot?i.accidentalSlot:[],m=void 0!==i.shouldExtendStem&&i.shouldExtendStem,g=void 0===i.printAccidentals||i.printAccidentals,v=r.verticalPos,b=0,y=0,x=0;if(void 0===t)e.addFixed(new a("pitch is undefined",0,0,0,{type:"debug"}));else if(""===t)s=new a(null,0,0,v);else{var k=c;if(r.printer_shift){var w="same"===r.printer_shift?1:0;k="down"===o?-n.getSymbolWidth(t)*f+w:n.getSymbolWidth(t)*f-w}var C={scalex:f,scaley:f,thickness:n.symbolHeightInPitches(t)*f,name:r.name};if((s=new a(t,k,n.getSymbolWidth(t)*f,v,C)).stemDir=o,h){var T=v+("down"===o?-7:7)*f;m&&("down"===o&&T>6&&(T=6),"up"===o&&T<6&&(T=6));var S="down"===o?c:c+s.w-.6;e.addRight(new a(h,S,n.getSymbolWidth(h)*f,T,{scalex:f,scaley:f}))}for(y=s.w+d-2+5*u;u>0;u--){var _=1-Math.abs(v)%2;e.addRight(new a("dots.dot",s.w+d-2+5*u,n.getSymbolWidth("dots.dot"),v+_))}}if(s&&(s.highestVert=r.highestVert),g&&r.accidental){var E;switch(r.accidental){case"quartersharp":E="accidentals.halfsharp";break;case"dblsharp":E="accidentals.dblsharp";break;case"sharp":E="accidentals.sharp";break;case"quarterflat":E="accidentals.halfflat";break;case"flat":E="accidentals.flat";break;case"dblflat":E="accidentals.dblflat";break;case"natural":E="accidentals.nat"}for(var M=!1,N=l,A=0;A=6){p[A][0]=v,N=p[A][1],M=!0;break}!1===M&&(N-=n.getSymbolWidth(E)*f+2,p.push([v,N]),b=n.getSymbolWidth(E)*f+2);var B=n.symbolHeightInPitches(E);e.addExtra(new a(E,N,n.getSymbolWidth(E),v,{scalex:f,scaley:f,top:v+B/2,bottom:v-B/2})),x=n.getSymbolWidth(E)/2}return{notehead:s,accidentalshiftx:b,dotshiftx:y,extraLeft:x}}},2525:function(e,t,r){var n=r(1409),a=r(6020),i=r(6658);e.exports=function(e,t){e.el_type="timeSignature";var r=new n(e,0,10,"staff-extra time-signature",t);if("specified"===e.type)for(var s=0,o=0;o",n)),o&&e.addOther(new a(o.start,o.stop,"<",n)),c&&e.addOther(new i(c.start,c.stop))},l.prototype.createDecoration=function(e,t,r,a,i,l,u,d,f,p,m){f||(f={ornamentPosition:"above",volumePosition:p?"above":"below",dynamicPosition:p?"above":"below"}),function(e,t,r,a){for(var i=0;i9&&d++;var m=n/2;"center"!==s.getSymbolAlign(p)&&(m-=s.getSymbolWidth(p)/2),a.addFixedX(new o(p,m,s.getSymbolWidth(p),d))}if("slide"===t[f]&&a.heads[0]){var g=a.heads[0].pitch,v=new o("",-i-15,0,(g-=2)-1),b=new o("",-i-5,0,g+1);a.addFixedX(v),a.addFixedX(b),e.addOther(new c({anchor1:v,anchor2:b,fixedY:!0}))}}return void 0===d&&(d=r),{above:d,below:a.bottom}}(e,t,r,a,i,l,u,d,m);g.above=Math.max(g.above,this.minTop),g.below=Math.min(g.below,d),function(e,t,r,n,a,i,c,l){function h(e,t){"above"===e?n.above+=t:n.below-=t}function u(e){var t;return"above"===e?(t=n.above)c&&(t=c),t}function d(e,n,a){var i=u(n);r.addFixedX(new o(e,t/2,0,i+2,{type:"decoration",klass:"ornament",thickness:3,anchor:a})),h(n,5)}function f(e,n){var a=t/2;"center"!==s.getSymbolAlign(e)&&(a-=s.getSymbolWidth(e)/2);var i=s.symbolHeightInPitches(e)+1,c=u(n);c="above"===n?c+i/2:c-i/2,r.addFixedX(new o(e,a,s.getSymbolWidth(e),c,{klass:"ornament",thickness:s.symbolHeightInPitches(e),position:n})),h(n,i)}for(var p={"+":"scripts.stopped",open:"scripts.open",snap:"scripts.snap",wedge:"scripts.wedge",thumb:"scripts.thumb",shortphrase:"scripts.shortphrase",mediumphrase:"scripts.mediumphrase",longphrase:"scripts.longphrase",trill:"scripts.trill",roll:"scripts.roll",irishroll:"scripts.roll",marcato:"scripts.umarcato",dmarcato:"scripts.dmarcato",umarcato:"scripts.umarcato",turn:"scripts.turn",uppermordent:"scripts.prall",pralltriller:"scripts.prall",mordent:"scripts.mordent",lowermordent:"scripts.mordent",downbow:"scripts.downbow",upbow:"scripts.upbow",fermata:"scripts.ufermata",invertedfermata:"scripts.dfermata",breath:",",coda:"scripts.coda",segno:"scripts.segno"},m=0;mthis.w&&(this.w=e.dx+e.w),this.right[this.right.length]=e,this._addChild(e)},i.prototype.addFixed=function(e){this._addChild(e)},i.prototype.addFixedX=function(e){this._addChild(e)},i.prototype.addCentered=function(e){var t=e.w/2;-tthis.w&&(this.w=e.dx+t),this.right[this.right.length]=e,this._addChild(e)},i.prototype.setLimit=function(e,t){t[e]&&(this.specialY[e]?this.specialY[e]=Math.max(this.specialY[e],t[e]):this.specialY[e]=t[e])},i.prototype._addChild=function(e){var t=!0;"clef"==this.abcelem.el_type&&"barNumber"==e.type&&(t=!1),e.parent=this,this.children[this.children.length]=e,t&&this.pushTop(e.top),this.pushBottom(e.bottom),this.setLimit("tempoHeightAbove",e),this.setLimit("partHeightAbove",e),this.setLimit("volumeHeightAbove",e),this.setLimit("dynamicHeightAbove",e),this.setLimit("endingHeightAbove",e),this.setLimit("chordHeightAbove",e),this.setLimit("lyricHeightAbove",e),this.setLimit("lyricHeightBelow",e),this.setLimit("chordHeightBelow",e),this.setLimit("volumeHeightBelow",e),this.setLimit("dynamicHeightBelow",e)},i.prototype.pushTop=function(e){void 0!==e&&(void 0===this.top?this.top=e:this.top=Math.max(e,this.top))},i.prototype.pushBottom=function(e){void 0!==e&&(void 0===this.bottom?this.bottom=e:this.bottom=Math.min(e,this.bottom))},i.prototype.setX=function(e){this.x=e;for(var t=0;tthis.max)&&(this.max=e.abcelem.maxpitch))},t.prototype.addBeam=function(e){this.beams.push(e)},t.prototype.setStemDirection=function(){this.average=r(this.total,this.count),this.forceup?this.stemsUp=!0:this.forcedown?this.stemsUp=!1:this.stemsUp=this.average<6,delete this.count,this.total=0},t.prototype.calcDir=function(){this.average=r(this.total,this.elems.length),this.forceup?this.stemsUp=!0:this.forcedown?this.stemsUp=!1:this.stemsUp=this.average<6;for(var e=this.stemsUp?"up":"down",t=0;t0&&this.unalignedWords(e.unalignedWords,n,a,i,s),this.extraText(e,n,a,i,s),e.footer&&r&&this.footer(e.footer,t,n,s)}function s(e,t,r,n,i,s,o){r&&(t&&(r="string"==typeof r?t+r:[{text:t}].concat(r)),a(e,r,"historyfont",i=s?"abcjs-extra-text "+i:"","description",n,{absElemType:"extraText",anchor:"start"},o))}function o(e,t,r,i,s,o,c,l,h,u,d,f){if(r){l=d?"abcjs-extra-text "+l:"";var p=f.calc("A",s,l);if("string"==typeof r)t&&(r=t+"\n"+r),n(e,{marginLeft:i,text:r,font:s,absElemType:"extraText",name:h,"dominant-baseline":"middle",klass:l},f);else{e.push({startGroup:c,klass:l,name:h}),e.push({move:u.info}),t&&(n(e,{marginLeft:i,text:t,font:s,absElemType:"extraText",name:h,"dominant-baseline":"middle"},f),e.push({move:3*p.height/4}));for(var m=0;m0&&this.startVoice.staff.voices[0]===e)},e.exports=t},6891:function(e){e.exports=function(e,t,r,n){this.type="CrescendoElem",this.anchor1=e,this.anchor2=t,this.dir=r,"above"===n?this.dynamicHeightAbove=6:this.dynamicHeightBelow=6,this.pitch=void 0}},3185:function(e){e.exports=function(e,t,r){this.type="DynamicDecoration",this.anchor=e,this.dec=t,"below"===r?this.volumeHeightBelow=6:this.volumeHeightAbove=6,this.pitch=void 0}},8256:function(e){e.exports=function(e,t,r){this.type="EndingElem",this.text=e,this.anchor1=t,this.anchor2=r,this.endingHeightAbove=5,this.pitch=void 0}},3736:function(e){e.exports=function(e,t,r,n,a,i){var s,o=e.text;this.rows=[],t&&this.rows.push({move:t});var c=r.calc("textfont","defined-text");if(""===o)this.rows.push({move:2*c.attr["font-size"]});else if("string"==typeof o)this.rows.push({move:c.attr["font-size"]/2}),this.rows.push({left:n,text:o,font:"textfont",klass:"defined-text",anchor:"start",startChar:e.startChar,endChar:e.endChar,absElemType:"freeText",name:"free-text"}),s=i.calc(o,"textfont","defined-text"),this.rows.push({move:s.height});else if(o){for(var l=0,h=n,u="textfont",d=0;dthis.top&&(this.top=this.pitch2),this.bottom=n,void 0!==this.pitch2&&this.pitch20?this.top+=a.stemHeight:this.bottom+=a.stemHeight),a.dim&&(this.dim=a.dim),a.position&&(this.position=a.position),this.height=a.height?a.height:4,a.top&&(this.top=a.top),a.bottom&&(this.bottom=a.bottom),a.name?this.name=a.name:this.c?this.name=this.c:this.name=this.type,a.realWidth?this.realWidth=a.realWidth:this.realWidth=this.w,this.centerVertically=!1,this.type){case"debug":this.chordHeightAbove=this.height;break;case"lyric":a.position&&"below"===a.position?this.lyricHeightBelow=this.height:this.lyricHeightAbove=this.height;break;case"chord":a.position&&"below"===a.position?this.chordHeightBelow=this.height:this.chordHeightAbove=this.height;break;case"text":void 0===this.pitch?a.position&&"below"===a.position?this.chordHeightBelow=this.height:this.chordHeightAbove=this.height:this.centerVertically=!0;break;case"part":this.partHeightAbove=this.height}};t.prototype.getChordDim=function(){if("debug"===this.type)return null;if(!this.chordHeightAbove&&!this.chordHeightBelow)return null;var e="chord"===this.type?this.realWidth/2:0,t=this.x-e-0;return{left:t,right:t+this.realWidth+0}},t.prototype.invertLane=function(e){void 0===this.lane&&(this.lane=0),this.lane=e-this.lane-1},t.prototype.putChordInLane=function(e){this.lane=e,this.chordHeightAbove?this.chordHeightAbove=1.25*this.height*this.lane:this.chordHeightBelow=1.25*this.height*this.lane},t.prototype.getLane=function(){return void 0===this.lane?0:this.lane},t.prototype.setX=function(e){this.x=e+this.dx},e.exports=t},6994:function(e,t,r){var n=r(1716);e.exports=function(e,t,r,a,i,s,o,c){var l=c.calc("i",r,a);if(""===t)e.push({move:l.height});else{if("string"==typeof t)return void n(e,{marginLeft:s,text:t,font:r,klass:a,marginTop:o.marginTop,anchor:o.anchor,absElemType:o.absElemType,info:o.info,name:i},c);o.marginTop&&e.push({move:o.marginTop});var h=0,u={left:s,anchor:o.anchor,phrases:[]};a&&(u.klass=a),e.push(u);for(var d=0;d0)this.above=!1;else{var e;e=this.anchor1?this.anchor1.pitch:this.anchor2?this.anchor2.pitch:14,this.anchor1&&"down"===this.anchor1.stemDir&&this.anchor2&&"down"===this.anchor2.stemDir?this.above=!0:this.anchor1&&"up"===this.anchor1.stemDir&&this.anchor2&&"up"===this.anchor2.stemDir?this.above=!1:this.anchor1&&this.anchor2?this.above=e>=6:this.anchor1?this.above="down"===this.anchor1.stemDir:this.anchor2?this.above="down"===this.anchor2.stemDir:this.above=e>=6}},t.prototype.calcSlurDirection=function(){if(this.isGrace)this.above=!1;else if(0===this.voiceNumber)this.above=!0;else if(this.voiceNumber>0)this.above=!1;else{var e=!1;this.anchor1&&"down"===this.anchor1.stemDir&&(e=!0),this.anchor2&&"down"===this.anchor2.stemDir&&(e=!0);for(var t=0;te&&(e=this.internalNotes[t].highestVert);e>this.startY&&e>this.endY&&(this.startY=this.endY=e-1)}},t.prototype.getYBounds=function(){var e,t;return this.isTie?(this.calcTieDirection(),this.calcX(10,1e3),this.calcTieY()):(this.calcSlurDirection(),this.calcX(10,1e3),this.calcSlurY()),this.above?e=(t=Math.min(this.startY,this.endY))+3:t=(e=Math.min(this.startY,this.endY))-3,[e,t]},e.exports=t},1134:function(e,t,r){var n=r(1716),a=r(6994);e.exports=function(e,t,r,i,s,o,c,l,h,u){if(this.rows=[],e.header&&o){var d=u.calc("X","headerfont","abcjs-header abcjs-meta-top").height;n(this.rows,{marginLeft:c,text:e.header.left,font:"headerfont",klass:"header meta-top",marginTop:-d,info:t.header,name:"header"},u),n(this.rows,{marginLeft:c+s/2,text:e.header.center,font:"headerfont",klass:"header meta-top",marginTop:-d,anchor:"middle",info:t.header,name:"header"},u),n(this.rows,{marginLeft:c+s,text:e.header.right,font:"headerfont",klass:"header meta-top",marginTop:-d,anchor:"end",info:t.header,name:"header"},u)}o&&this.rows.push({move:l.top});var f=r.titleleft?"start":"middle",p=r.titleleft?c:c+s/2;if(e.title){var m=h?"abcjs-title":"";a(this.rows,e.title,"titlefont",m,"title",p,{marginTop:l.title,anchor:f,absElemType:"title",info:t.title},u)}if(i.length)for(var g=0;g0){var v=!(!e.composer&&!e.origin);m=h?"abcjs-rhythm":"",n(this.rows,{marginLeft:c,text:e.rhythm,font:"infofont",klass:m,absElemType:"rhythm",noMove:v,info:t.rhythm,name:"rhythm"},u)}e.composer&&e.composer,e.origin&&e.origin;var b=e.composer?e.composer:"";e.origin&&("string"==typeof b&&"string"==typeof e.origin?b+=" ("+e.origin+")":"string"==typeof b&&"string"!=typeof e.origin?((b=[{text:b}]).push({text:" ("}),(b=b.concat(e.origin)).push({text:")"})):(b.push({text:" ("}),(b=b.concat(e.origin)).push({text:")"}))),b&&(m=h?"abcjs-composer":"",a(this.rows,b,"composerfont",m,"composer",c+s,{anchor:"end",absElemType:"composer",info:t.composer,ingroup:!0},u))}e.author&&e.author.length>0&&(m=h?"abcjs-author":"",a(this.rows,e.author,"composerfont",m,"author",c+s,{anchor:"end",absElemType:"author",info:t.author},u)),e.partOrder&&e.partOrder.length>0&&(m=h?"abcjs-part-order":"",a(this.rows,e.partOrder,"partsfont",m,"part-order",c,{absElemType:"partOrder",info:t.partOrder,anchor:"start"},u))}},2096:function(e){var t=function(e,t,r){this.type="TripletElem",this.anchor1=t,this.number=e,this.durationClass=("d"+Math.round(1e3*t.parent.durationClass)/1e3).replace(/\./,"-"),this.middleElems=[],this.flatBeams=r.flatBeams};t.prototype.isClosed=function(){return!!this.anchor2},t.prototype.middleNote=function(e){this.middleElems.push(e)},t.prototype.setCloseAnchor=function(e){this.anchor2=e,this.anchor1.parent.beam&&"up"!==this.anchor1.stemDir||(this.endingHeightAbove=4)},e.exports=t},3197:function(e){var t=function(e,t){this.children=[],this.beams=[],this.otherchildren=[],this.w=0,this.duplicate=!1,this.voicenumber=e,this.voicetotal=t,this.bottom=7,this.top=7,this.specialY={tempoHeightAbove:0,partHeightAbove:0,volumeHeightAbove:0,dynamicHeightAbove:0,endingHeightAbove:0,chordHeightAbove:0,lyricHeightAbove:0,lyricHeightBelow:0,chordHeightBelow:0,volumeHeightBelow:0,dynamicHeightBelow:0}};t.prototype.addChild=function(e){if("bar"===e.type){for(var t=!0,r=0;t&&r0&&"TempoElement"===t.children[0].type;t.elemset=[],o.beginGroup(e.paper,e.controller);for(var u=0;u=0&&f.setAttribute("class","abcjs-notehead")}}var p=t.type;if(("note"===t.type||"rest"===t.type)&&(t.counters=e.controller.classes.getCurrent(),p=(p+=" d"+Math.round(1e3*t.durationClass)/1e3).replace(/\./g,"-"),t.abcelem.pitches))for(var m=0;m0?g.classList[0]+" ":"";g.setAttribute("class",v+t.overrideClasses)}if(h)t.startChar=t.abcelem.startChar,t.endChar=t.abcelem.endChar,c.add(t,g,!1,l);else{t.elemset.push(g);var b=!1;"note"!==t.type&&"tabNumber"!==t.type||(b=!0),c.add(t,g,b,l)}}else t.elemset.length>0&&c.add(t,t.elemset[0],"note"===t.type,l);if(t.klass&&s(t.elemset,"mark","","#00ff00"),t.hint&&s(t.elemset,"abcjs-hint","",null),t.abcelem.abselem=t,t.heads&&t.heads.length>0){t.notePositions=[];for(var y=0;y=1&&l(e,e.spacing.staffSeparation,v[v.length-1],y.staffGroup);var x=c(e,y.staffGroup,m,b);x.line=p+b,v.push(x),e.paper.closeGroup()}else y.nonMusic&&(t.shouldAddClasses&&(g.klass="abcjs-non-music"),e.paper.openGroup(g),i(e,y.nonMusic,m),e.paper.closeGroup())}return t.reset(),r.bottomText&&r.bottomText.rows&&r.bottomText.rows.length>0&&(t.shouldAddClasses&&(g.klass="abcjs-meta-bottom"),e.paper.openGroup(g),e.moveY(24),i(e,r.bottomText,m),e.paper.closeGroup()),a(e,s,u,h),{staffgroups:v,selectables:m.getElements()}}},9879:function(e,t,r){var n=r(4777);e.exports=function(e,t,r){void 0===t.pitch&&window.console.error("Dynamic Element y-coordinate not set.");var a=n(e,t.anchor.x,t.pitch,t.dec,{scalex:1,scaley:1,klass:e.controller.classes.generate("decoration dynamics"),fill:e.foregroundColor,stroke:"none",name:"dynamics"});return r.wrapSvgEl({el_type:"dynamicDecoration",startChar:-1,endChar:-1,decoration:t.dec},a),[a]}},5947:function(e,t,r){var n=r(6764),a=r(5759),i=r(6454),s=r(7199);e.exports=function(e,t,r,o,c){void 0===t.pitch&&window.console.error("Ending Element y-coordinate not set.");var l=s(e.calcY(t.pitch)),h="";t.anchor1&&(r=s(t.anchor1.x+t.anchor1.w),h+=n("M %f %f L %f %f ",r,l,r,s(l+20))),t.anchor2&&(o=s(t.anchor2.x),h+=n("M %f %f L %f %f ",o,l,o,s(l+20))),h+=n("M %f %f L %f %f ",r,l,o,l),e.paper.openGroup({klass:e.controller.classes.generate("ending"),"data-name":"ending"}),i(e,{path:h,stroke:e.foregroundColor,fill:e.foregroundColor,"data-name":"line"}),t.anchor1&&a(e,{x:s(r+5),y:s(e.calcY(t.pitch-.5)),text:t.text,type:"repeatfont",klass:"ending",anchor:"start",noClass:!0,name:t.text});var u=e.paper.closeGroup();return c.wrapSvgEl({el_type:"ending",startChar:-1,endChar:-1},u),[u]}},9045:function(e,t,r){var n=r(6764),a=r(6454),i=r(7199);function s(e,t,r){return i(e+r*t)}var o=[[3.5,-4.8]],c=[[1.5,-1],[.3,-.3],[-3.5,3.8]],l=[[-1.5,2]],h=[[3,4],[3,-4]],u=[[-3,4],[-3,-4]];function d(e,t){for(var r="",n=0;n1&&s.indexOf(".")<0){var p=i.isInGroup()?"":o.klass;e.paper.openGroup({"data-name":o.name,klass:p});for(var m=0,g=0;g0?t.linewidth+e.lineThickness:t.linewidth-e.lineThickness;t.graphelem=a(e,t.x,u,o,e.calcY(t.pitch2),"abcjs-stem","stem");break;case"ledger":t.graphelem=i(e,t.x,t.x+t.w,t.pitch,"abcjs-ledger","ledger",.35+e.lineThickness)}return 1!==t.scalex&&t.graphelem&&function(e,t,r,n,a,i){e.setAttributeOnElement(t,{style:"transform:scale("+r+","+n+");transform-origin:"+a+"px "+i+"px;"})}(e.paper,t.graphelem,t.scalex,t.scaley,t.x,o),t.graphelem}},7199:function(e){e.exports=function(e){return parseFloat(e.toFixed(2))}},3524:function(e,t,r){var n=r(5741),a=r(5829);function i(e,t,r){this.elements=[],this.paper=e,this.tuneNumber=r,this.selectTypes=t}i.prototype.getElements=function(){return this.elements},i.prototype.add=function(e,t,r,n){if(this.canSelect(e)){var a;a=void 0===this.selectTypes?{selectable:!1,"data-index":this.elements.length}:{selectable:!0,tabindex:0,"data-index":this.elements.length},this.paper.setAttributeOnElement(t,a);var i={absEl:e,svgEl:t,isDraggable:r};void 0!==n&&(i.staffPos=n),this.elements.push(i)}},i.prototype.canSelect=function(e){return!(!1===this.selectTypes||!e||!e.abcelem||!0!==this.selectTypes&&!(void 0===this.selectTypes?"note"===e.abcelem.el_type||"tabNumber"===e.abcelem.el_type:this.selectTypes.indexOf(e.abcelem.el_type)>=0))},i.prototype.wrapSvgEl=function(e,t){var r={tuneNumber:this.tuneNumber,abcelem:e,elemset:[t],highlight:n,unhighlight:a};this.add(r,t,!1)},e.exports=i},4169:function(e){e.exports=function(e,t){var r=Math.round(e.y),n=(e.controller.width-t)/2,a=n+t,i="M "+n+" "+r+" L "+a+" "+r+" L "+a+" "+(r+1)+" L "+n+" "+(r+1)+" L "+n+" "+r+" z";e.paper.pathToBack({path:i,stroke:"rgba(0,0,0,0)",fill:"rgba(0,0,0,255)",class:e.controller.classes.generate("defined-text")})}},7611:function(e){e.exports=function(e,t,r,n){var a=(t+e.padding.left+e.padding.right)*r,i=(e.y+e.padding.bottom)*r;if(e.isPrint&&(i=Math.max(i,1056)),""!==e.ariaLabel){var s="Sheet Music";e.abctune&&e.abctune.metaText&&e.abctune.metaText.title&&(s+=' for "'+e.abctune.metaText.title+'"'),e.paper.setTitle(s);var o=e.ariaLabel?e.ariaLabel:s;e.paper.setAttribute("aria-label",o)}e.paper.insertStyles(".abcjs-dragging-in-progress text, .abcjs-dragging-in-progress tspan {"+["-webkit-touch-callout: none;","-webkit-user-select: none;","-khtml-user-select: none;","-moz-user-select: none;","-ms-user-select: none;","user-select: none;"].join(" ")+"}");var c={overflow:"hidden"};"resize"===n?e.paper.setResponsiveWidth(a,i):(c.width="",c.height=i+"px",r<1?(c.width=a+"px",e.paper.setSize(a/r,i/r)):e.paper.setSize(a,i)),e.paper.setScale(r),e.paper.setParentStyles(c)}},6764:function(e){function t(e){return t="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},t(e)}e.exports=function(){for(var e,r,n,a,i,s=0,o=arguments[s++],c=[];o;){if(r=/^[^\x25]+/.exec(o))c.push(r[0]);else if(r=/^\x25{2}/.exec(o))c.push("%");else{if(!(r=/^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(o)))throw"Huh ?!";if(null==(e=arguments[r[1]||s++])||null==e)throw"Too few arguments.";if(/[^s]/.test(r[7])&&"number"!=typeof e)throw"Expecting number but found "+t(e);switch(r[7]){case"b":e=e.toString(2);break;case"c":e=String.fromCharCode(e);break;case"d":e=parseInt(e);break;case"e":e=r[6]?e.toExponential(r[6]):e.toExponential();break;case"f":e=r[6]?parseFloat(e).toFixed(r[6]):parseFloat(e);break;case"o":e=e.toString(8);break;case"s":e=(e=String(e))&&r[6]?e.substring(0,r[6]):e;break;case"u":e=Math.abs(e);break;case"x":e=e.toString(16);break;case"X":e=e.toString(16).toUpperCase()}e=/[def]/.test(r[7])&&r[2]&&e>0?"+"+e:e,a=r[3]?"0"==r[3]?"0":r[3][1]:" ",i=r[5]-String(e).length,n=r[5]?str_repeat(a,i):"",c.push(r[4]?e+n:n+e)}o=o.substring(r[0].length)}return c.join("")}},5537:function(e,t,r){var n=r(4331),a=r(129),i=r(3145),s=r(7641),o=r(1547),c=r(3624),l=r(5668);function h(e,t,r,i,s){if(r)for(var o=0;o=0&&v.voices&&u(e,t.voices,v.voices),e.showDebug.indexOf("grid")>=0&&(e.paper.dottedLine({x1:e.padding.left,x2:e.padding.left+e.controller.width,y1:m,y2:m,stroke:"#0000ff"}),o(e,{x:e.padding.left,y:e.calcY(v.originalTop),width:e.controller.width,height:e.calcY(v.originalBottom)-e.calcY(v.originalTop),fill:e.foregroundColor,stroke:e.foregroundColor,"fill-opacity":.1,"stroke-opacity":.1}),d=0,E(v,"chordHeightAbove"),E(v,"chordHeightBelow"),E(v,"dynamicHeightAbove"),E(v,"dynamicHeightBelow"),E(v,"endingHeightAbove"),E(v,"lyricHeightAbove"),E(v,"lyricHeightBelow"),E(v,"partHeightAbove"),E(v,"tempoHeightAbove"),E(v,"volumeHeightAbove"),E(v,"volumeHeightBelow"))),e.moveY(n.STEP,-v.bottom),e.showDebug&&e.showDebug.indexOf("grid")>=0&&e.paper.dottedLine({x1:e.padding.left,x2:e.padding.left+e.controller.width,y1:e.y,y2:e.y,stroke:"#0000aa"})}for(var b=2,y=0,x=0;x6&&(d=0)}}_>1&&(f=t.staffs[0].topLine,p=t.staffs[_-1].bottomLine,c(e,t.startx,.6,f,p,null)),e.y=m}},7865:function(e,t,r){var n=r(6637);e.exports=function(e,t,r,a,i,s,o){var c=e.calcY(a);return n(e,t,r,c,i,s,o)}},7641:function(e,t,r){var n=r(7865);e.exports=function(e,t,r,a,i,s){var o="abcjs-top-line",c=2;i&&(c=i),e.paper.openGroup({prepend:!0,klass:e.controller.classes.generate("abcjs-staff")});var l=0,h=0;if(1===a)n(e,t,r,6,o,null,s+e.lineThickness),l=e.calcY(10),h=e.calcY(2);else for(var u=a-1;u>=0;u--){var d=(u+1)*c;h=e.calcY(d),0===l&&(l=h),n(e,t,r,d,o,null,s+e.lineThickness),o=void 0}return e.paper.closeGroup(),[l,h]}},3987:function(e,t,r){var n=r(2435),a=r(5759);e.exports=function(e,t){var r=t.x;void 0===t.pitch&&window.console.error("Tempo Element y-coordinate not set."),t.tempo.el_type="tempo";var i,s=e.calcY(t.pitch)+2;if(t.tempo.preString){i=a(e,{x:r,y:s,text:t.tempo.preString,type:"tempofont",klass:"abcjs-tempo",anchor:"start",noClass:!0,name:"pre"},!0);var o=e.controller.getTextSize.calc(t.tempo.preString,"tempofont","tempo",i).width;r+=o+o/t.tempo.preString.length}if(t.note){t.note.setX(r);for(var c=0;c.1||(this.scale=void 0),t.staffwidth?(this.staffwidthScreen=t.staffwidth,this.staffwidthPrint=t.staffwidth):(this.staffwidthScreen=740,this.staffwidthPrint=680),this.listeners=[],t.clickListener&&this.addSelectListener(t.clickListener),this.renderer=new i(e),this.renderer.setPaddingOverride(t),t.showDebug&&(this.renderer.showDebug=t.showDebug),t.jazzchords&&(this.jazzchords=t.jazzchords),t.accentAbove&&(this.accentAbove=t.accentAbove),t.germanAlphabet&&(this.germanAlphabet=t.germanAlphabet),t.lineThickness&&(this.lineThickness=t.lineThickness),this.renderer.controller=this,this.renderer.foregroundColor=t.foregroundColor?t.foregroundColor:"currentColor",void 0!==t.ariaLabel&&(this.renderer.ariaLabel=t.ariaLabel),this.renderer.minPadding=t.minPadding?t.minPadding:0,this.reset()};function x(e){for(var t=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=0;r0)for(var o=s.staffGroup.voices[0],c=!1,l=0,h=0;hthis.width+1&&(e.topText=new l(e.metaText,e.metaTextInfo,e.formatting,e.lines,i,this.renderer.isPrint,this.renderer.padding.left,this.renderer.spacing,this.classes.shouldAddClasses,this.getTextSize),e.lines&&e.lines.length>0))for(var s=e.lines.length,o=0;o0)for(var h=c.nonMusic.rows.length,f=0;f0&&c.text[0].center)&&(p.left=i/2+this.renderer.padding.left)}}e.tablatures&&v.layoutTablatures(this.renderer,e);var m=g(this.renderer,this.classes,e,this.width,i,this.responsive,a,this.selectTypes,t,r);if(this.staffgroups=m.staffgroups,this.selectables=m.selectables,this.oneSvgPerLine){var b=this.renderer.paper.svg.parentNode;this.svgs=function(e,t,r,n,a){r||(r="Untitled");var i=t.querySelector("svg");"resize"===n&&(t.style.paddingBottom="");for(var s=i.querySelector("style"),o="resize"===n?i.viewBox.baseVal.width:i.getAttribute("width"),c=t.querySelectorAll("svg > g"),l=0,h=[],u=0;u0&&t.push(e),"abcjs-tab-number"===e)return t.join(" ");if("text instrument-name"===e)return"abcjs-text abcjs-instrument-name";if(null!==this.lineNumber&&t.push("l"+this.lineNumber),null!==this.measureNumber&&t.push("m"+this.measureNumber),null!==this.measureNumber&&t.push("mm"+this.measureTotal()),null!==this.voiceNumber&&t.push("v"+this.voiceNumber),e&&(e.indexOf("note")>=0||e.indexOf("rest")>=0||e.indexOf("lyric")>=0)&&null!==this.noteNumber&&t.push("n"+this.noteNumber),t.length>0){t=(t=t.join(" ")).split(" ");for(var r=0;r0&&(t[r]="abcjs-"+t[r])}return t.join(" ")},e.exports=t},1328:function(e){var t=function(e,t){this.formatting=e,this.classes=t};t.prototype.updateFonts=function(e){e.gchordfont&&(this.formatting.gchordfont=e.gchordfont),e.tripletfont&&(this.formatting.tripletfont=e.tripletfont),e.annotationfont&&(this.formatting.annotationfont=e.annotationfont),e.vocalfont&&(this.formatting.vocalfont=e.vocalfont)},t.prototype.getFamily=function(e){return'"'===e[0]&&'"'===e[e.length-1]?e.substring(1,e.length-1):e},t.prototype.calc=function(e,t){var r;r="string"==typeof e?(r=this.formatting[e])?{face:r.face,size:Math.round(4*r.size/3),decoration:r.decoration,style:r.style,weight:r.weight,box:r.box}:{face:"Arial",size:Math.round(16),decoration:"underline",style:"normal",weight:"normal"}:{face:e.face,size:Math.round(4*e.size/3),decoration:e.decoration,style:e.style,weight:e.weight,box:e.box};var n=this.formatting.fontboxpadding?this.formatting.fontboxpadding:.1;return r.padding=r.size*n,{font:r,attr:{"font-size":r.size,"font-style":r.style,"font-family":this.getFamily(r.face),"font-weight":r.weight,"text-decoration":r.decoration,class:this.classes.generate(t)}}},e.exports=t},9799:function(e){var t=function(e,t){this.getFontAndAttr=e,this.svg=t};t.prototype.updateFonts=function(e){this.getFontAndAttr.updateFonts(e)},t.prototype.attr=function(e,t){return this.getFontAndAttr.calc(e,t)},t.prototype.getFamily=function(e){return'"'===e[0]&&'"'===e[e.length-1]?e.substring(1,e.length-1):e},t.prototype.calc=function(e,t,r,n){var a;a="string"==typeof t?this.attr(t,r):{font:{face:t.face,size:t.size,decoration:t.decoration,style:t.style,weight:t.weight},attr:{"font-size":t.size,"font-style":t.style,"font-family":this.getFamily(t.face),"font-weight":t.weight,"text-decoration":t.decoration,class:this.getFontAndAttr.classes.generate(r)}};var i=this.svg.getTextSize(e,a.attr,n);return a.font.box?{height:i.height+4*a.font.padding,width:i.width+4*a.font.padding}:i},t.prototype.baselineToCenter=function(e,t,r,n,a){return.5*this.calc(e,t,r).height+(a-n-2)*this.attr(t,r).font.size},e.exports=t},2187:function(e){e.exports=function(e,t,r,n){if(e)for(var a=0;a0&&(o.length>0&&" "!==o[o.length-1]&&(o+=" "),o+=t),i.setAttribute("class",o)}}},4331:function(e){var t={FONTEM:360,FONTSIZE:30};t.STEP=93*t.FONTSIZE/720,t.SPACE=10,t.TOPNOTE=15,t.STAVEHEIGHT=100,t.INDENT=50,e.exports=t},8123:function(e){function t(e,t,r,n){if(0===e.indexOf(t)){var a=e.replace(t,""),i=parseInt(a,10);""+i===a&&(r[n]=i)}}e.exports=function(e,r){var n=[];if(e.absEl.elemset){for(var a={},i=0;i=0&&r=0?(a=function(e,t,r){return e.x<=t.offsetX&&e.x+e.width>=t.offsetX&&e.y<=t.offsetY&&e.y+e.height>=t.offsetY||Math.abs(t.layerY/r-t.offsetY)<3?[t.offsetX,t.offsetY]:[t.layerX,t.layerY]}(e.selectables[i].svgEl.getBBox(),t,e.scale),r=a[0],n=a[1]):(a=function(e){var t,r,n=1,a=1,i=e.target.closest("svg"),s=0;return i&&i.viewBox&&i.viewBox.baseVal&&(0!==i.viewBox.baseVal.width&&(n=i.viewBox.baseVal.width/i.clientWidth),0!==i.viewBox.baseVal.height&&(a=i.viewBox.baseVal.height/i.clientHeight),s=i.viewBox.baseVal.y),e.target&&"svg"===e.target.tagName?(t=e.offsetX,r=e.offsetY):(t=e.layerX,r=e.layerY),[t*=n,(r*=a)+s]}(t),i=function(e,t,r){for(var n=9999999,a=-1,i=0;i0;i++){var s=e.selectables[i];if(e.getDim(s),s.dim.leftt&&s.dim.topr)a=i,n=0;else if(s.dim.topr){var o=Math.min(Math.abs(s.dim.left-t),Math.abs(s.dim.right-t));ot){var c=Math.min(Math.abs(s.dim.top-r),Math.abs(s.dim.bottom-r));cMath.abs(t-s.dim.right)?Math.abs(t-s.dim.right):Math.abs(t-s.dim.left),h=Math.abs(r-s.dim.top)>Math.abs(r-s.dim.bottom)?Math.abs(r-s.dim.bottom):Math.abs(r-s.dim.top),u=Math.sqrt(l*l+h*h);u=0&&n<=12?a:-1}(e,r=a[0],n=a[1])),{x:r,y:n,clickedOn:i}}function l(e){if(e&&e.target&&e.touches&&!(e.touches.length<1)){var t=e.target.getBoundingClientRect(),r=e.touches[0].pageX-t.left,n=e.touches[0].pageY-t.top;e.touches[0].offsetX=r,e.touches[0].offsetY=n,e.touches[0].layerX=e.touches[0].pageX,e.touches[0].layerY=e.touches[0].pageY}}function h(e){var t=e;"touchstart"===e.type&&(l(e),e.touches.length>0&&(t=e.touches[0]));var r=c(this,t);r.clickedOn>=0&&("touchstart"===e.type||0===e.button)&&this.selectables[r.clickedOn]&&(this.dragTarget=this.selectables[r.clickedOn],this.dragIndex=r.clickedOn,this.dragMechanism="mouse",this.dragMouseStart={x:r.x,y:r.y},this.dragging&&this.dragTarget.isDraggable&&(function(e,t){if(e){var r=v(e.svg);r[t]=!0,b(e.svg,r)}}(this.renderer.paper,"abcjs-dragging-in-progress"),this.dragTarget.absEl.highlight(void 0,this.dragColor)))}function u(e){var t=e;if("touchmove"===e.type&&(l(e),e.touches.length>0&&(t=e.touches[0])),this.lastTouchMove=e,this.dragTarget&&this.dragging&&this.dragTarget.isDraggable&&"mouse"===this.dragMechanism&&this.dragMouseStart){var r=c(this,t),a=Math.round((r.y-this.dragMouseStart.y)/n.STEP);a!==this.dragYStep&&(this.dragYStep=a,this.dragTarget.svgEl.setAttribute("transform","translate(0,"+a*n.STEP+")"))}}function d(e){var t=e;"touchend"===e.type&&this.lastTouchMove&&(l(this.lastTouchMove),this.lastTouchMove&&this.lastTouchMove.touches&&this.lastTouchMove.touches.length>0&&(t=this.lastTouchMove.touches[0])),this.dragTarget&&(m.bind(this)(),this.dragTarget.absEl&&this.dragTarget.absEl.highlight&&(this.selected=[this.dragTarget.absEl],this.dragTarget.absEl.highlight(void 0,this.selectionColor)),p.bind(this)(this.dragTarget,this.dragYStep,this.selectables.length,this.dragIndex,t),this.dragTarget.svgEl&&this.dragTarget.svgEl.focus&&(this.dragTarget.svgEl.focus(),this.dragTarget=null,this.dragIndex=-1),function(e,t){if(e){var r=v(e.svg);delete r[t],b(e.svg,r)}}(this.renderer.svg,"abcjs-dragging-in-progress"))}function f(e){e>=0&&eo&&ei&&(a=i),a<-i&&(a=-i),a}(x,k,v,w),A=M+Math.floor(N/2),B=M+Math.floor(-N/2),S||(y&&M<6||!y&&M>6)&&(A=6,B=6),[A,B]),f=c(e.stemsUp,r,l);e.addBeam({startX:f[0],endX:f[1],startY:d[0],endY:d[1],dy:t});for(var p=function(e,t,r,n,a){for(var o=[],l=[],h=0;h0&&u.abcelem.beambr&&u.abcelem.beambr<=b+1){l[b].split||(l[b].split=[l[b].x]);var y=c(t,e[h-1],u);l[b].split[l[b].split.length-1]>=y[0]&&(y[0]+=u.w),l[b].split.push(y[0]),l[b].split.push(y[1])}}for(var x=l.length-1;x>=0;x--)if(h===e.length-1||s(e[h+1].abcelem.duration)>-x-4){var k=f,w=p+m*(x+1);l[x].single&&(k=0===h?f+5:f-5,w=i(r.startX,r.startY,r.endX,r.endY,k)+m*(x+1));var C={startX:l[x].x,endX:k,startY:l[x].y,endY:w,dy:a};if(void 0!==l[x].split){var T=l[x].split;C.endX<=T[T.length-1]&&(T[T.length-1]-=u.w),T.push(C.endX),C.split=l[x].split}o.push(C),l=l.slice(0,x)}}}return o}(e.elems,e.stemsUp,e.beams[0],e.isgrace,t),m=0;m0?((a=(r-(n-i*a))/i)*s>50&&(a=50/s),a):null}e.exports=function(e,t,r,i,s,l){var h,u,d=r;for(h=0;hMath.round(d)&&(d=f,s&&(h=-1)))}for(h=0;h=0&&(c.originalTop=c.top,c.originalBottom=c.bottom),i(c,l,"lyricHeightAbove"),i(c,l,"chordHeightAbove",c.specialY.chordLines.above),c.specialY.endingHeightAbove&&(c.specialY.chordHeightAbove?c.top+=2:c.top+=c.specialY.endingHeightAbove+a,l.endingHeightAbove=c.top),c.specialY.dynamicHeightAbove&&c.specialY.volumeHeightAbove?(c.top+=Math.max(c.specialY.dynamicHeightAbove,c.specialY.volumeHeightAbove)+a,l.dynamicHeightAbove=c.top,l.volumeHeightAbove=c.top):(i(c,l,"dynamicHeightAbove"),i(c,l,"volumeHeightAbove")),i(c,l,"partHeightAbove"),i(c,l,"tempoHeightAbove"),c.specialY.lyricHeightBelow&&(c.specialY.lyricHeightBelow+=e.spacing.vocal/n.STEP,l.lyricHeightBelow=c.bottom,c.bottom-=c.specialY.lyricHeightBelow+a),c.specialY.chordHeightBelow){l.chordHeightBelow=c.bottom;var h=c.specialY.chordHeightBelow;c.specialY.chordLines.below&&(h*=c.specialY.chordLines.below),c.bottom-=h+a}c.specialY.volumeHeightBelow&&c.specialY.dynamicHeightBelow?(l.volumeHeightBelow=c.bottom,l.dynamicHeightBelow=c.bottom,c.bottom-=Math.max(c.specialY.volumeHeightBelow,c.specialY.dynamicHeightBelow)+a):c.specialY.volumeHeightBelow?(l.volumeHeightBelow=c.bottom,c.bottom-=c.specialY.volumeHeightBelow+a):c.specialY.dynamicHeightBelow&&(l.dynamicHeightBelow=c.bottom,c.bottom-=c.specialY.dynamicHeightBelow+a),e.showDebug&&e.showDebug.indexOf("box")>=0&&(c.positionY=l);for(var u=0;u0&&(c.top+=f)}c.top+=e.spacing.staffTopMargin/n.STEP,r=2-c.bottom}}},735:function(e,t,r){var n=r(937);function a(e){for(var t=0;t0?0:5e-7)}e.exports=function(e,t,r,s,o){var c,l=0,h=1e3,u=o;s.startx=u;var d,f,p=0;for(r&&console.log("init layout",e),c=0;c1e-7?v.push(s.voices[c]):g.push(s.voices[c]);m=0;var b=0;for(c=0;cu&&(u=n.getNextX(g[c]),m=n.getSpacingUnits(g[c]),b=g[c].spacingduration);l+=m,h=Math.min(h,m),r&&console.log("currentduration: ",p,l,h);var y=void 0;for(c=0;c0){u=w;for(var T=0;Tu&&(u=n.getNextX(s.voices[c]),m=n.getSpacingUnits(s.voices[c]));return function(e){for(var t=0,r=0;r0){var a=n.children.length-1,i=n.children[a];if("bar"===i.abcelem.el_type){var s=i.children[0].x;s>t?t=s:i.children[0].x=t}}}}(s.voices),l+=m,s.setWidth(u),{spacingUnits:l,minSpace:h}}},3294:function(e,t,r){var n=r(3721);function a(e){return e.stemsUp}e.exports=function(e){if(e.anchor1&&e.anchor2){e.hasBeam=!!e.anchor1.parent.beam&&e.anchor1.parent.beam===e.anchor2.parent.beam;var t=e.anchor1.parent.beam;if(!e.hasBeam||t.elems[0]===e.anchor1.parent&&t.elems[t.elems.length-1]===e.anchor2.parent||(e.hasBeam=!1),e.hasBeam){var r=a(t)?e.anchor1.x+e.anchor1.w:e.anchor1.x;e.yTextPos=function(e,t,r){if(0===r.beams.length)return 0;r=r.beams[0];var a=e+(t-e)/2;return n(r.startX,r.startY,r.endX,r.endY,a)}(r,e.anchor2.x,t),e.yTextPos+=a(t)?3:-2,e.xTextPos=(o=r,c=e.anchor2.x,o+(c-o)/2),e.top=e.yTextPos+1,e.bottom=e.yTextPos-2,a(t)&&(e.endingHeightAbove=4)}else{e.startNote=Math.max(e.anchor1.parent.top,9)+4,e.endNote=Math.max(e.anchor2.parent.top,9)+4,"rest"===e.anchor1.parent.type&&"rest"!==e.anchor2.parent.type?e.startNote=e.endNote:"rest"===e.anchor2.parent.type&&"rest"!==e.anchor1.parent.type&&(e.endNote=e.startNote);for(var i=0,s=0;se.startNote||i>e.endNote)&&(e.startNote=i,e.endNote=i),e.flatBeams&&(e.startNote=Math.max(e.startNote,e.endNote),e.endNote=Math.max(e.startNote,e.endNote)),e.yTextPos=e.startNote+(e.endNote-e.startNote)/2,e.xTextPos=e.anchor1.x+(e.anchor2.x+e.anchor2.w-e.anchor1.x)/2,e.top=e.yTextPos+1}}var o,c;delete e.middleElems,delete e.flatBeams}},937:function(e){var t=function(){};t.beginLayout=function(e,t){t.i=0,t.durationindex=0,t.startx=e,t.minx=e,t.nextx=e,t.spacingduration=0},t.layoutEnded=function(e){return e.i>=e.children.length},t.getNextX=function(e){return Math.max(e.minx,e.nextx)},t.getSpacingUnits=function(e){return Math.sqrt(8*e.spacingduration)},t.layoutOneItem=function(e,t,r,n,a){var i=r.children[r.i];if(!i)return 0;var s=e-r.minx,o=r.durationindex+i.duration>0?n:0;if("note"===i.abcelem.el_type&&!i.abcelem.rest&&0!==r.voicenumber&&a){var c=a.children[a.i],l=c&&(i.abcelem.maxpitch<=c.abcelem.maxpitch+1&&i.abcelem.maxpitch>=c.abcelem.minpitch-1||i.abcelem.minpitch<=c.abcelem.maxpitch+1&&i.abcelem.minpitch>=c.abcelem.minpitch-1);if(l&&i.abcelem.minpitch===c.abcelem.minpitch&&i.abcelem.maxpitch===c.abcelem.maxpitch&&c.heads&&c.heads.length>0&&i.heads&&i.heads.length>0&&c.heads[0].c===i.heads[0].c&&(l=!1),l){var h=c.heads&&c.heads.length>0?c.heads[0].realWidth:c.fixed.w;i.adjustedWidth||(i.adjustedWidth=h+i.w),i.w=i.adjustedWidth;for(var u=0;u0&&t.putChordInLane(n),void(e[n]=r.right);e.push(r.right),t.putChordInLane(e.length-1)}}function c(e){for(var t=0,r=0;r=0;r--)(n=e[t].children[r]).chordHeightBelow&&o(i,n)}return(a.length>1||i.length>1)&&function(e,t,r){for(var n=0;n=0};i.prototype.reset=function(){this.paper.clear(),this.y=0,this.abctune=null,this.path=null,this.isPrint=!1,this.lineThickness=0,this.initVerticalSpace()},i.prototype.newTune=function(e){this.abctune=e,this.setVerticalSpace(e.formatting),this.isPrint="print"===e.media,this.setPadding(e)},i.prototype.setLineThickness=function(e){this.lineThickness=e},i.prototype.setPaddingOverride=function(e){this.paddingOverride={top:e.paddingtop,bottom:e.paddingbottom,right:e.paddingright,left:e.paddingleft}},i.prototype.setPadding=function(e){function t(t,r,n,a,i){void 0!==e.formatting[n]?t.padding[r]=e.formatting[n]:void 0!==t.paddingOverride[r]?t.padding[r]=t.paddingOverride[r]:t.isPrint?t.padding[r]=a:t.padding[r]=i}t(this,"top","topmargin",38,15),t(this,"bottom","botmargin",38,15),t(this,"left","leftmargin",68,15),t(this,"right","rightmargin",68,15)},i.prototype.adjustNonScaledItems=function(e){this.padding.top/=e,this.padding.bottom/=e,this.padding.left/=e,this.padding.right/=e,this.abctune.formatting.headerfont.size/=e,this.abctune.formatting.footerfont.size/=e},i.prototype.initVerticalSpace=function(){this.spacing={composer:7.56,graceBefore:8.67,graceInside:10.67,graceAfter:16,info:0,lineSkipFactor:1.1,music:7.56,paragraphSkipFactor:.4,parts:11.33,slurHeight:1,staffSeparation:61.33,staffTopMargin:0,stemHeight:36.67,subtitle:3.78,systemStaffSeparation:48,text:18.9,title:7.56,top:30.24,vocal:0,words:0}},i.prototype.setVerticalSpace=function(e){void 0!==e.staffsep&&(this.spacing.staffSeparation=4*e.staffsep/3),void 0!==e.composerspace&&(this.spacing.composer=4*e.composerspace/3),void 0!==e.partsspace&&(this.spacing.parts=4*e.partsspace/3),void 0!==e.textspace&&(this.spacing.text=4*e.textspace/3),void 0!==e.musicspace&&(this.spacing.music=4*e.musicspace/3),void 0!==e.titlespace&&(this.spacing.title=4*e.titlespace/3),void 0!==e.sysstaffsep&&(this.spacing.systemStaffSeparation=4*e.sysstaffsep/3),void 0!==e.stafftopmargin&&(this.spacing.staffTopMargin=4*e.stafftopmargin/3),void 0!==e.subtitlespace&&(this.spacing.subtitle=4*e.subtitlespace/3),void 0!==e.topspace&&(this.spacing.top=4*e.topspace/3),void 0!==e.vocalspace&&(this.spacing.vocal=4*e.vocalspace/3),void 0!==e.wordsspace&&(this.spacing.words=4*e.wordsspace/3)},i.prototype.calcY=function(e){return this.y-e*n.STEP},i.prototype.moveY=function(e,t){void 0===t&&(t=1),this.y+=e*t},i.prototype.absolutemoveY=function(e){this.y=e},e.exports=i},4101:function(e){var t="http://www.w3.org/2000/svg";function r(e){this.svg=s(),this.currentGroup=[],e.appendChild(this.svg)}function n(e,t,r){var n=r-e;return"M "+e+" "+t+" l "+n+" 0 l 0 1 l "+-n+" 0 z "}function a(e,t,r){var n=r-t;return"M "+e+" "+t+" l 0 "+n+" l 1 0 l 0 "+-n+" z "}r.prototype.clear=function(){if(this.svg){var e=this.svg.parentNode;this.svg=s(),this.currentGroup=[],e&&(e.innerHTML="",e.appendChild(this.svg))}},r.prototype.setTitle=function(e){var t=document.createElement("title"),r=document.createTextNode(e);t.appendChild(r),this.svg.insertBefore(t,this.svg.firstChild)},r.prototype.setResponsiveWidth=function(e,t){if(this.svg.setAttribute("viewBox","0 0 "+e+" "+t),this.svg.setAttribute("preserveAspectRatio","xMinYMin meet"),this.svg.removeAttribute("height"),this.svg.removeAttribute("width"),this.svg.style.display="inline-block",this.svg.style.position="absolute",this.svg.style.top="0",this.svg.style.left="0",this.svg.parentNode){var r=this.svg.parentNode.getAttribute("class");r?r.indexOf("abcjs-container")<0&&this.svg.parentNode.setAttribute("class",r+" abcjs-container"):this.svg.parentNode.setAttribute("class","abcjs-container"),this.svg.parentNode.style.display="inline-block",this.svg.parentNode.style.position="relative",this.svg.parentNode.style.width="100%";var n=t/e*100;this.svg.parentNode.style["padding-bottom"]=n+"%",this.svg.parentNode.style["vertical-align"]="middle",this.svg.parentNode.style.overflow="hidden"}},r.prototype.setSize=function(e,t){this.svg.setAttribute("width",e),this.svg.setAttribute("height",t)},r.prototype.setAttribute=function(e,t){this.svg.setAttribute(e,t)},r.prototype.setScale=function(e){1!==e?(this.svg.style.transform="scale("+e+","+e+")",this.svg.style["-ms-transform"]="scale("+e+","+e+")",this.svg.style["-webkit-transform"]="scale("+e+","+e+")",this.svg.style["transform-origin"]="0 0",this.svg.style["-ms-transform-origin-x"]="0",this.svg.style["-ms-transform-origin-y"]="0",this.svg.style["-webkit-transform-origin-x"]="0",this.svg.style["-webkit-transform-origin-y"]="0"):(this.svg.style.transform="",this.svg.style["-ms-transform"]="",this.svg.style["-webkit-transform"]="")},r.prototype.insertStyles=function(e){var r=document.createElementNS(t,"style");r.textContent=e,this.svg.insertBefore(r,this.svg.firstChild)},r.prototype.setParentStyles=function(e){for(var t in e)e.hasOwnProperty(t)&&this.svg.parentNode&&(this.svg.parentNode.style[t]=e[t]);this.dummySvg&&(document.querySelector("body").removeChild(this.dummySvg),this.dummySvg=null)},r.prototype.rect=function(e){var t=[],r=e.x,i=e.y,s=e.x+e.width,o=e.y+e.height;return t.push(n(r,i,s)),t.push(n(r,o,s)),t.push(a(s,i,o)),t.push(a(r,o,i)),this.path({path:t.join(" "),stroke:"none","data-name":e["data-name"]})},r.prototype.dottedLine=function(e){var r=document.createElementNS(t,"line");r.setAttribute("x1",e.x1),r.setAttribute("x2",e.x2),r.setAttribute("y1",e.y1),r.setAttribute("y2",e.y2),r.setAttribute("stroke",e.stroke),r.setAttribute("stroke-dasharray","5,5"),this.svg.insertBefore(r,this.svg.firstChild)},r.prototype.rectBeneath=function(e){var r=document.createElementNS(t,"rect");r.setAttribute("x",e.x),r.setAttribute("width",e.width),r.setAttribute("y",e.y),r.setAttribute("height",e.height),e.stroke&&r.setAttribute("stroke",e.stroke),e["stroke-opacity"]&&r.setAttribute("stroke-opacity",e["stroke-opacity"]),e.fill&&r.setAttribute("fill",e.fill),e["fill-opacity"]&&r.setAttribute("fill-opacity",e["fill-opacity"]),this.svg.insertBefore(r,this.svg.firstChild)},r.prototype.text=function(e,r,n){var a=document.createElementNS(t,"text");for(var i in a.setAttribute("stroke","none"),r)r.hasOwnProperty(i)&&a.setAttribute(i,r[i]);for(var s=(""+e).split("\n"),o=0;o0?this.currentGroup[0].removeChild(r):this.svg.removeChild(r)),n&&(i[n]=a),a},r.prototype.openGroup=function(e){e=e||{};var r=document.createElementNS(t,"g");return e.klass&&r.setAttribute("class",e.klass),e.fill&&r.setAttribute("fill",e.fill),e.stroke&&r.setAttribute("stroke",e.stroke),e["data-name"]&&r.setAttribute("data-name",e["data-name"]),e.prepend?this.prepend(r):this.append(r),this.currentGroup.unshift(r),r},r.prototype.closeGroup=function(){var e=this.currentGroup.shift();return e&&0===e.children.length?(e.parentElement.removeChild(e),null):e},r.prototype.path=function(e){var r=document.createElementNS(t,"path");for(var n in e)e.hasOwnProperty(n)&&("path"===n?r.setAttributeNS(null,"d",e.path):"klass"===n?r.setAttributeNS(null,"class",e[n]):void 0!==e[n]&&r.setAttributeNS(null,n,e[n]));return this.append(r),r},r.prototype.pathToBack=function(e){var r=document.createElementNS(t,"path");for(var n in e)e.hasOwnProperty(n)&&("path"===n?r.setAttributeNS(null,"d",e.path):"klass"===n?r.setAttributeNS(null,"class",e[n]):r.setAttributeNS(null,n,e[n]));return this.prepend(r),r},r.prototype.lineToBack=function(e){for(var r=document.createElementNS(t,"line"),n=Object.keys(e),a=0;a0?this.currentGroup[0].appendChild(e):this.svg.appendChild(e)},r.prototype.prepend=function(e){this.currentGroup.length>0?this.currentGroup[0].appendChild(e):this.svg.insertBefore(e,this.svg.firstChild)},r.prototype.setAttributeOnElement=function(e,t){for(var r in t)t.hasOwnProperty(r)&&e.setAttributeNS(null,r,t[r])},r.prototype.moveElementToChild=function(e,t){e.appendChild(t)},e.exports=r},1185:function(e){e.exports="6.4.4"}},t={},r=function r(n){var a=t[n];if(void 0!==a)return a.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}(1045),r;var e,t,r}));