/** * VexFlow 1.2.83 built on 2016-09-06. * Copyright (c) 2010 Mohit Muthanna Cheppudira * * http://www.vexflow.com http://github.com/0xfe/vexflow */ !function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports.Vex=b():a.Vex=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var d=c(1),e=c(2),f=c(5),g=c(3),h=c(10),i=c(14),j=c(30),k=c(4),l=c(43),m=c(20),n=c(45),o=c(18),p=c(29),q=c(15),r=c(33),s=c(55),t=c(56),u=c(41),v=c(42),w=c(57),x=c(22),y=c(27),z=c(39),A=c(37),B=c(40),C=c(44),D=c(21),E=c(19),F=c(58),G=c(52),H=c(53),I=c(59),J=c(17),K=c(34),L=c(51),M=c(25),N=c(60),O=c(16),P=c(61),Q=c(62),R=c(63),S=c(64),T=c(65),U=c(8),V=c(35),W=c(50),X=c(66),Y=c(67),Z=c(68),$=c(38),_=c(69),aa=c(70),ba=c(28),ca=c(46),da=c(71),ea=c(72),fa=c(31),ga=c(32),ha=c(73),ia=c(36),ja=c(74),ka=c(54),la=c(9),ma=c(75),na=c(76),oa=c(78),pa=c(77),qa=c(6);d.Vex.Flow=e.Flow,d.Vex.Flow.Element=f.Element,d.Vex.Flow.Fraction=g.Fraction,d.Vex.Flow.Renderer=h.Renderer,d.Vex.Flow.Formatter=i.Formatter,d.Vex.Flow.Music=j.Music,d.Vex.Flow.Glyph=k.Glyph,d.Vex.Flow.Stave=l.Stave,d.Vex.Flow.StaveNote=m.StaveNote,d.Vex.Flow.StaveModifier=n.StaveModifier,d.Vex.Flow.Voice=o.Voice,d.Vex.Flow.Accidental=p.Accidental,d.Vex.Flow.Beam=q.Beam,d.Vex.Flow.StaveTie=r.StaveTie,d.Vex.Flow.TabStave=s.TabStave,d.Vex.Flow.TabNote=t.TabNote,d.Vex.Flow.Bend=u.Bend,d.Vex.Flow.Vibrato=v.Vibrato,d.Vex.Flow.VibratoBracket=w.VibratoBracket,d.Vex.Flow.Note=x.Note,d.Vex.Flow.ModifierContext=y.ModifierContext,d.Vex.Flow.TickContext=z.TickContext,d.Vex.Flow.Articulation=A.Articulation,d.Vex.Flow.Annotation=B.Annotation,d.Vex.Flow.Barline=C.Barline,d.Vex.Flow.NoteHead=D.NoteHead,d.Vex.Flow.StaveConnector=E.StaveConnector,d.Vex.Flow.ClefNote=F.ClefNote,d.Vex.Flow.KeySignature=G.KeySignature,d.Vex.Flow.TimeSignature=H.TimeSignature,d.Vex.Flow.TimeSigNote=I.TimeSigNote,d.Vex.Flow.Stem=J.Stem,d.Vex.Flow.TabTie=K.TabTie,d.Vex.Flow.Clef=L.Clef,d.Vex.Flow.Modifier=M.Modifier,d.Vex.Flow.TabSlide=N.TabSlide,d.Vex.Flow.Tuplet=O.Tuplet,d.Vex.Flow.GraceNote=P.GraceNote,d.Vex.Flow.GraceTabNote=Q.GraceTabNote,d.Vex.Flow.Tuning=R.Tuning,d.Vex.Flow.KeyManager=S.KeyManager,d.Vex.Flow.StaveHairpin=T.StaveHairpin,d.Vex.Flow.BoundingBox=U.BoundingBox,d.Vex.Flow.Stroke=V.Stroke,d.Vex.Flow.TextNote=W.TextNote,d.Vex.Flow.Curve=X.Curve,d.Vex.Flow.TextDynamics=Y.TextDynamics,d.Vex.Flow.StaveLine=Z.StaveLine,d.Vex.Flow.Ornament=$.Ornament,d.Vex.Flow.PedalMarking=_.PedalMarking,d.Vex.Flow.TextBracket=aa.TextBracket,d.Vex.Flow.FretHandFinger=ba.FretHandFinger,d.Vex.Flow.Repetition=ca.Repetition,d.Vex.Flow.BarNote=da.BarNote,d.Vex.Flow.GhostNote=ea.GhostNote,d.Vex.Flow.NoteSubGroup=fa.NoteSubGroup,d.Vex.Flow.GraceNoteGroup=ga.GraceNoteGroup,d.Vex.Flow.Tremolo=ha.Tremolo,d.Vex.Flow.StringNumber=ia.StringNumber,d.Vex.Flow.Crescendo=ja.Crescendo,d.Vex.Flow.Volta=ka.Volta,d.Vex.Flow.Font=la.Font,d.Vex.Flow.System=ma.System,d.Vex.Flow.Factory=na.Factory,d.Vex.Flow.Parser=oa.Parser,d.Vex.Flow.EasyScore=pa.EasyScore,d.Vex.Flow.Registry=qa.Registry,b["default"]=d.Vex,a.exports=b["default"]},function(a,b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function d(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function e(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(b,"__esModule",{value:!0});var f=function(){function a(a,b){for(var c=0;c=b/2?parseInt(a/b,10)*b+b:parseInt(a/b,10)*b},g.MidLine=function(a,b){var c=b+(a-b)/2;return c%2>0&&(c=g.RoundN(10*c,5)/10),c},g.SortAndUnique=function(a,b,c){if(a.length>1){var d=[],e=void 0;a.sort(b);for(var f=0;f=6&&2*m%2===0&&(n=-1);var o="undefined"!=typeof j.int_val?12*k+j.int_val:null,p=j.code,q=j.shift_right;if(g.length>2&&g[2]){var r=g[2].toUpperCase(),s=h.keyProperties.note_glyph[r];s&&(p=s.code,q=s.shift_right)}return{key:i,octave:k,line:m,int_value:o,accidental:j.accidental,code:p,stroke:n,shift_right:q,displaced:!1}},h.keyProperties.note_values={C:{index:0,int_val:0,accidental:null},CN:{index:0,int_val:0,accidental:"n"},"C#":{index:0,int_val:1,accidental:"#"},"C##":{index:0,int_val:2,accidental:"##"},CB:{index:0,int_val:-1,accidental:"b"},CBB:{index:0,int_val:-2,accidental:"bb"},D:{index:1,int_val:2,accidental:null},DN:{index:1,int_val:2,accidental:"n"},"D#":{index:1,int_val:3,accidental:"#"},"D##":{index:1,int_val:4,accidental:"##"},DB:{index:1,int_val:1,accidental:"b"},DBB:{index:1,int_val:0,accidental:"bb"},E:{index:2,int_val:4,accidental:null},EN:{index:2,int_val:4,accidental:"n"},"E#":{index:2,int_val:5,accidental:"#"},"E##":{index:2,int_val:6,accidental:"##"},EB:{index:2,int_val:3,accidental:"b"},EBB:{index:2,int_val:2,accidental:"bb"},F:{index:3,int_val:5,accidental:null},FN:{index:3,int_val:5,accidental:"n"},"F#":{index:3,int_val:6,accidental:"#"},"F##":{index:3,int_val:7,accidental:"##"},FB:{index:3,int_val:4,accidental:"b"},FBB:{index:3,int_val:3,accidental:"bb"},G:{index:4,int_val:7,accidental:null},GN:{index:4,int_val:7,accidental:"n"},"G#":{index:4,int_val:8,accidental:"#"},"G##":{index:4,int_val:9,accidental:"##"},GB:{index:4,int_val:6,accidental:"b"},GBB:{index:4,int_val:5,accidental:"bb"},A:{index:5,int_val:9,accidental:null},AN:{index:5,int_val:9,accidental:"n"},"A#":{index:5,int_val:10,accidental:"#"},"A##":{index:5,int_val:11,accidental:"##"},AB:{index:5,int_val:8,accidental:"b"},ABB:{index:5,int_val:7,accidental:"bb"},B:{index:6,int_val:11,accidental:null},BN:{index:6,int_val:11,accidental:"n"},"B#":{index:6,int_val:12,accidental:"#"},"B##":{index:6,int_val:13,accidental:"##"},BB:{index:6,int_val:10,accidental:"b"},BBB:{index:6,int_val:9,accidental:"bb"},R:{index:6,int_val:9,rest:!0},X:{index:6,accidental:"",octave:4,code:"v3e",shift_right:5.5}},h.keyProperties.note_glyph={D0:{code:"v27",shift_right:-.5},D1:{code:"v2d",shift_right:-.5},D2:{code:"v22",shift_right:-.5},D3:{code:"v70",shift_right:-.5},T0:{code:"v49",shift_right:-2},T1:{code:"v93",shift_right:.5},T2:{code:"v40",shift_right:.5},T3:{code:"v7d",shift_right:.5},X0:{code:"v92",shift_right:-2},X1:{code:"v95",shift_right:-.5},X2:{code:"v7f",shift_right:.5},X3:{code:"v3b",shift_right:-2}},h.integerToNote=function(a){if("undefined"==typeof a)throw new e.Vex.RERR("BadArguments","Undefined integer for integerToNote");if(a<-2)throw new e.Vex.RERR("BadArguments","integerToNote requires integer > -2: "+a);var b=h.integerToNote.table[a];if(!b)throw new e.Vex.RERR("BadArguments","Unknown note value for integer: "+a);return b},h.integerToNote.table={0:"C",1:"C#",2:"D",3:"D#",4:"E",5:"F",6:"F#",7:"G",8:"G#",9:"A",10:"A#",11:"B"},h.tabToGlyph=function(a){var b=arguments.length<=1||void 0===arguments[1]?1:arguments[1],c=null,d=0,e=0;if("X"===a.toString().toUpperCase()){var f=new g.Glyph("v7f",h.DEFAULT_TABLATURE_FONT_SCALE).getMetrics();c="v7f",d=f.width,e=-f.height/2}else d=h.textWidth(a.toString());return{text:a,code:c,getWidth:function(){return d*b},shift_y:e}},h.textWidth=function(a){return 7*a.toString().length},h.articulationCodes=function(a){return h.articulationCodes.articulations[a]},h.articulationCodes.articulations={"a.":{code:"v23",between_lines:!0},av:{code:"v28",between_lines:!0},"a>":{code:"v42",between_lines:!0},"a-":{code:"v25",between_lines:!0},"a^":{code:"va",between_lines:!1},"a+":{code:"v8b",between_lines:!1},ao:{code:"v94",between_lines:!1},ah:{code:"vb9",between_lines:!1},"a@a":{code:"v43",between_lines:!1},"a@u":{code:"v5b",between_lines:!1},"a|":{code:"v75",between_lines:!1},am:{code:"v97",between_lines:!1},"a,":{code:"vb3",between_lines:!1}},h.accidentalCodes=function(a){return h.accidentalCodes.accidentals[a]},h.accidentalCodes.accidentals={"#":{code:"v18",parenRightPaddingAdjustment:-1},"##":{code:"v7f",parenRightPaddingAdjustment:-1},b:{code:"v44",parenRightPaddingAdjustment:-2},bb:{code:"v26",parenRightPaddingAdjustment:-2},n:{code:"v4e",parenRightPaddingAdjustment:-1},"{":{code:"v9c",parenRightPaddingAdjustment:-1},"}":{code:"v84",parenRightPaddingAdjustment:-1},db:{code:"v9e",parenRightPaddingAdjustment:-1},d:{code:"vab",parenRightPaddingAdjustment:0},bbs:{code:"v90",parenRightPaddingAdjustment:-1},"++":{code:"v51",parenRightPaddingAdjustment:-1},"+":{code:"v78",parenRightPaddingAdjustment:-1},"+-":{code:"v8d",parenRightPaddingAdjustment:-1},"++-":{code:"v7a",parenRightPaddingAdjustment:-1},bs:{code:"vb7",parenRightPaddingAdjustment:-1},bss:{code:"v39",parenRightPaddingAdjustment:-1}},h.accidentalColumnsTable={1:{a:[1],b:[1]},2:{a:[1,2]},3:{a:[1,3,2],b:[1,2,1],second_on_bottom:[1,2,3]},4:{a:[1,3,4,2],b:[1,2,3,1],spaced_out_tetrachord:[1,2,1,2]},5:{a:[1,3,5,4,2],b:[1,2,4,3,1],spaced_out_pentachord:[1,2,3,2,1],very_spaced_out_pentachord:[1,2,1,2,1]},6:{a:[1,3,5,6,4,2],b:[1,2,4,5,3,1],spaced_out_hexachord:[1,3,2,1,3,2],very_spaced_out_hexachord:[1,2,1,2,1,2]}},h.ornamentCodes=function(a){return h.ornamentCodes.ornaments[a]},h.ornamentCodes.ornaments={mordent:{code:"v1e"},mordent_inverted:{code:"v45"},turn:{code:"v72"},turn_inverted:{code:"v33"},tr:{code:"v1f"},upprall:{code:"v60"},downprall:{code:"vb4"},prallup:{code:"v6d"},pralldown:{code:"v2c"},upmordent:{code:"v29"},downmordent:{code:"v68"},lineprall:{code:"v20"},prallprall:{code:"v86"}},h.keySignature=function(a){var b=h.keySignature.keySpecs[a];if(!b)throw new e.Vex.RERR("BadKeySignature","Bad key signature spec: '"+a+"'");if(!b.acc)return[];for(var c=h.keySignature.accidentalList(b.acc),d=[],f=0;f0}},{key:"greaterThanEquals",value:function(b){var c=a.__compareB.copy(this);return c.subtract(b),c.numerator>=0}},{key:"lessThan",value:function(a){return!this.greaterThanEquals(a)}},{key:"lessThanEquals",value:function(a){return!this.greaterThan(a)}},{key:"clone",value:function(){return new a(this.numerator,this.denominator)}},{key:"copy",value:function(a){return this.set(a.numerator,a.denominator)}},{key:"quotient",value:function(){return Math.floor(this.numerator/this.denominator)}},{key:"fraction",value:function(){return this.numerator%this.denominator}},{key:"abs",value:function(){return this.denominator=Math.abs(this.denominator),this.numerator=Math.abs(this.numerator),this}},{key:"toString",value:function(){return this.numerator+"/"+this.denominator}},{key:"toSimplifiedString",value:function(){return a.__tmp.copy(this).simplify().toString()}},{key:"toMixedString",value:function(){var b="",c=this.quotient(),d=a.__tmp.copy(this);return c<0?d.abs().fraction():d.fraction(),0!==c?(b+=c,0!==d.numerator&&(b+=" "+d.toSimplifiedString())):b=0===d.numerator?"0":d.toSimplifiedString(),b}},{key:"parse",value:function(a){var b=a.split("/"),c=parseInt(b[0],10),d=b[1]?parseInt(b[1],10):1;return this.set(c,d)}}]),a}();b.Fraction=g,g.__compareA=new g,g.__compareB=new g,g.__tmp=new g},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function g(a,b,c,d,e,f){function g(){return b+a[l++]*d}function h(){return c+a[l++]*e}for(var i=void 0,j=void 0,k=void 0,l=0;l0}var d=b.id,e=b.name,f=b.value,g=b.oldValue;return c(a.INDEXES.concat(["id","class"]),e)?(this.updateIndex({id:d,name:e,value:f,oldValue:g}),this):this}}],[{key:"enableDefaultRegistry",value:function(b){a.defaultRegistry=b}},{key:"getDefaultRegistry",value:function(){return a.defaultRegistry}},{key:"disableDefaultRegistry",value:function(){a.defaultRegistry=null}}]),a}();i.defaultRegistry=null},function(a,b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var d=function(){function a(a,b){for(var c=0;cthis.x2&&(this.x2=a)),null!=b&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=b,this.y2=b),bthis.y2&&(this.y2=b))}},{key:"addX",value:function(a){this.addPoint(a,null)}},{key:"addY",value:function(a){this.addPoint(null,a)}},{key:"addQuadraticCurve",value:function(a,b,c,d,e,f){var g=a+2/3*(c-a),h=b+2/3*(d-b),i=g+1/3*(e-a),j=h+1/3*(f-b);this.addBezierCurve(a,b,g,h,i,j,e,f)}},{key:"addBezierCurve",value:function(a,b,c,d,e,f,g,h){var i=[a,b],j=[c,d],k=[e,f],l=[g,h],m=void 0;this.addPoint(i[0],i[1]),this.addPoint(l[0],l[1]);var n=function(a,b){return Math.pow(1-a,3)*i[b]+3*Math.pow(1-a,2)*a*j[b]+3*(1-a)*Math.pow(a,2)*k[b]+Math.pow(a,3)*l[b]};for(m=0;m<=1;m++){var o=6*i[m]-12*j[m]+6*k[m],p=-3*i[m]+9*j[m]-9*k[m]+3*l[m],q=3*j[m]-3*i[m];if(0!==p){var r=Math.pow(o,2)-4*q*p;if(!(r<0)){var s=(-o+Math.sqrt(r))/(2*p);0=d)||!(h<0?k<=e:k>=e);){var n=f[l++%f.length],o=j+Math.cos(i)*n;j=g<0?Math.max(d,o):Math.min(d,o);var p=k+Math.sin(i)*n;k=h<0?Math.max(e,p):Math.min(e,p),m?a.lineTo(j,k):a.moveTo(j,k),m=!m}a.closePath(),a.stroke()}},{key:"Backends",get:function(){return{CANVAS:1,RAPHAEL:2,SVG:3,VML:4}}},{key:"LineEndType",get:function(){return{NONE:1,UP:2,DOWN:3}}},{key:"USE_CANVAS_PROXY",get:function(){return!1}},{key:"lastContext",get:function(){return j},set:function(a){j=a}}]),e(a,[{key:"resize",value:function(b,c){if(this.backend===a.Backends.CANVAS){if(!this.element.getContext)throw new i.Vex.RERR("BadElement","Can't get canvas context from element: "+this.sel);this.element.width=b,this.element.height=c,this.ctx=a.bolsterCanvasContext(this.element.getContext("2d"))}else this.ctx.resize(b,c);return this}},{key:"getContext",value:function(){return this.ctx}}]),a}()},function(a,b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var d=function(){function a(a,b){for(var c=0;c2*Math.PI;)a-=2*Math.PI;return a}if(d=g(d),e=g(e),d>e){var h=d;d=e,e=h,f=!f}var i=e-d;return i>Math.PI?(this.arcHelper(a,b,c,d,d+i/2,f),this.arcHelper(a,b,c,d+i/2,e,f)):this.arcHelper(a,b,c,d,e,f),this}},{key:"arcHelper",value:function(a,b,c,d,e,f){var g=a+c*Math.cos(d),h=b+c*Math.sin(d),i=a+c*Math.cos(e),j=b+c*Math.sin(e),k=0,l=0;f?(l=1,e-dMath.PI&&(k=1),this.path+="M"+g+","+h+",A"+c+","+c+",0,"+k+","+l+","+i+","+j+"M"+this.pen.x+","+this.pen.y}},{key:"glow",value:function(){var a=this.paper.set();if(this.shadow_attributes.width>0)for(var b=this.shadow_attributes,c=b.width/2,d=1;d<=c;d++)a.push(this.paper.path(this.path).attr({stroke:b.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(b.width/c*d).toFixed(3),opacity:+((b.opacity||.3)/c).toFixed(3),transform:this.attributes.transform,scale:this.attributes.scale}));return a}},{key:"fill",value:function(){var a=this.paper.path(this.path).attr(this.attributes).attr("stroke-width",0);return this.glow(a),this}},{key:"stroke",value:function(){var a=this.lineWidth*(this.state.scale.x+this.state.scale.y)/2,b=this.paper.path(this.path).attr(this.attributes).attr("fill","none").attr("stroke-width",a);return this.glow(b),this}},{key:"closePath",value:function(){return this.path+="Z",this}},{key:"measureText",value:function(a){var b=this.paper.text(0,0,a).attr(this.attributes).attr("fill","none").attr("stroke","none"),c=b.getBBox();return b.remove(),{width:c.width,height:c.height}}},{key:"fillText",value:function(a,b,c){return this.paper.text(b+this.measureText(a).width/2,c-this.state.font_size/(2.25*this.state.scale.y),a).attr(this.attributes),this}},{key:"save",value:function(){return this.state_stack.push({state:{font_family:this.state.font_family},attributes:{font:this.attributes.font,fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}},{key:"restore",value:function(){var a=this.state_stack.pop();return this.state.font_family=a.state.font_family,this.attributes.font=a.attributes.font,this.attributes.fill=a.attributes.fill,this.attributes.stroke=a.attributes.stroke,this.attributes["stroke-width"]=a.attributes["stroke-width"],this.shadow_attributes.width=a.shadow_attributes.width,this.shadow_attributes.color=a.shadow_attributes.color,this}}]),a}()},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0}),b.SVGContext=void 0;var e=function(){function a(a,b){for(var c=0;c2*Math.PI;)a-=2*Math.PI;return a}if(d=g(d),e=g(e),d>e){var h=d;d=e,e=h,f=!f}var i=e-d;return i>Math.PI?(this.arcHelper(a,b,c,d,d+i/2,f),this.arcHelper(a,b,c,d+i/2,e,f)):this.arcHelper(a,b,c,d,e,f),this}},{key:"arcHelper",value:function(a,b,c,d,e,f){var g=a+c*Math.cos(d),h=b+c*Math.sin(d),i=a+c*Math.cos(e),j=b+c*Math.sin(e),k=0,l=0;f?(l=1,e-dMath.PI&&(k=1),this.path+="M"+g+" "+h+" A"+c+" "+c+" 0 "+k+" "+l+" "+i+" "+j+"M"+this.pen.x+" "+this.pen.y}},{key:"closePath",value:function(){return this.path+="Z",this}},{key:"glow",value:function(){if(this.shadow_attributes.width>0)for(var a=this.shadow_attributes,b=a.width/2,c=1;c<=b;c++){var d={stroke:a.color,"stroke-linejoin":"round","stroke-linecap":"round","stroke-width":+(.4*a.width/b*c).toFixed(3),opacity:+((a.opacity||.3)/b).toFixed(3)},e=this.create("path");d.d=this.path,this.applyAttributes(e,d),this.add(e)}return this}},{key:"fill",value:function(a){this.glow();var b=this.create("path");return"undefined"==typeof a&&(a={},f.Vex.Merge(a,this.attributes),a.stroke="none"),a.d=this.path,this.applyAttributes(b,a),this.add(b),this}},{key:"stroke",value:function(){this.glow();var a=this.create("path"),b={};return f.Vex.Merge(b,this.attributes),b.fill="none",b["stroke-width"]=this.lineWidth,b.d=this.path,this.applyAttributes(a,b),this.add(a),this}},{key:"measureText",value:function(a){var b=this.create("text");if("function"!=typeof b.getBBox)return{x:0,y:0,width:0,height:0};b.textContent=a,this.applyAttributes(b,this.attributes),this.svg.appendChild(b);var c=b.getBBox();return this.ie&&""!==a&&"italic"===this.attributes["font-style"]&&(c=this.ieMeasureTextFix(c,a)),this.svg.removeChild(b),c}},{key:"ieMeasureTextFix",value:function(a){var b=Number(this.fontSize),c=1.196,d=1.9598,e=c*b+d,f=a.width-e,g=a.height-1.5,h={x:a.x,y:a.y,width:f,height:g};return h}},{key:"fillText",value:function(a,b,c){var d={};f.Vex.Merge(d,this.attributes),d.stroke="none",d.x=b,d.y=c;var e=this.create("text");e.textContent=a,this.applyAttributes(e,d),this.add(e)}},{key:"save",value:function(){return this.state_stack.push({state:{"font-family":this.state["font-family"],"font-weight":this.state["font-weight"],"font-style":this.state["font-style"],"font-size":this.state["font-size"]},attributes:{"font-family":this.attributes["font-family"],"font-weight":this.attributes["font-weight"],"font-style":this.attributes["font-style"],"font-size":this.attributes["font-size"],fill:this.attributes.fill,stroke:this.attributes.stroke,"stroke-width":this.attributes["stroke-width"],"stroke-dasharray":this.attributes["stroke-dasharray"]},shadow_attributes:{width:this.shadow_attributes.width,color:this.shadow_attributes.color}}),this}},{key:"restore",value:function(){var a=this.state_stack.pop();return this.state["font-family"]=a.state["font-family"],this.state["font-weight"]=a.state["font-weight"],this.state["font-style"]=a.state["font-style"],this.state["font-size"]=a.state["font-size"],this.attributes["font-family"]=a.attributes["font-family"],this.attributes["font-weight"]=a.attributes["font-weight"],this.attributes["font-style"]=a.attributes["font-style"],this.attributes["font-size"]=a.attributes["font-size"],this.attributes.fill=a.attributes.fill,this.attributes.stroke=a.attributes.stroke,this.attributes["stroke-width"]=a.attributes["stroke-width"],this.attributes["stroke-dasharray"]=a.attributes["stroke-dasharray"],this.shadow_attributes.width=a.shadow_attributes.width,this.shadow_attributes.color=a.shadow_attributes.color,this}}]),a}()},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(){for(var a=arguments.length,b=Array(a),c=0;c0&&e0?b.tickContexts.map[g[f-1]]:null,j=f0?d=-Math.min(h.getFormatterMetrics().freedom.right,Math.abs(k)):k<0&&(d=j?Math.min(j.getFormatterMetrics().freedom.right,Math.abs(k)):0);var l=Math.min(5,Math.abs(d));d=d>0?l:-l}),this.evaluate()}},{key:"postFormat",value:function(){var a=function(a){return a.list.forEach(function(b){return a.map[b].postFormat()})};return a(this.modiferContexts),a(this.tickContexts),this}},{key:"joinVoices",value:function(a){return this.createModifierContexts(a),this.hasMinTotalWidth=!1,this}},{key:"format",value:function(a,b,c){var d={align_rests:!1,context:null,stave:null};return j.Vex.Merge(d,c),this.voices=a,this.alignRests(a,d.align_rests),this.createTickContexts(a),this.preFormat(b,d.context,a,d.stave),d.stave&&this.postFormat(),this}},{key:"formatToStave",value:function(a,b,c){var d=b.getNoteEndX()-b.getNoteStartX()-10;e("Formatting voices to width: ",d);var f={context:b.getContext()};return j.Vex.Merge(f,c),this.format(a,d,f)}}]),a}()},function(a,b,c){"use strict";function d(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b=0?o.Stem.DOWN:o.Stem.UP}Object.defineProperty(b,"__esModule",{value:!0}),b.Beam=void 0;var i=function(){function a(a,b){for(var c=0;c=k.Flow.durationToTicks("4"))throw new j.Vex.RuntimeError("BadArguments","Beams can only be applied to notes shorter than a quarter note.");var g=void 0,i=void 0;for(d.stem_direction=o.Stem.UP,g=0;g-1?o.Stem.UP:o.Stem.DOWN}for(g=0;g4?[new m.Fraction(2,e)]:e<=4?[new m.Fraction(1,e)]:[new m.Fraction(1,4)]}},{key:"applyAndGetBeams",value:function(a,c,d){return b.generateBeams(a.getTickables(),{groups:d,stem_direction:c})}},{key:"generateBeams",value:function(a,c){function d(a){return a.reduce(function(a,b){return b.getTicks().clone().add(a)},new m.Fraction(0,1))}function e(){s.length-1>u?u+=1:u=0}function f(){var a=[];t.forEach(function(b){if(a=[],b.shouldIgnoreTicks())return v.push(w),void(w=a);w.push(b);var c=s[u].clone(),f=d(w),g=k.Flow.durationToNumber(b.duration)<8;g&&b.tuplet&&(c.numerator*=2),f.greaterThan(c)?(g||a.push(w.pop()),v.push(w),w=a,e()):f.equals(c)&&(v.push(w),w=a,e())}),w.length>0&&v.push(w)}function g(){return v.filter(function(a){if(a.length>1){var b=!0;return a.forEach(function(a){a.getIntrinsicTicks()>=k.Flow.durationToTicks("4")&&(b=!1)}),b}return!1})}function i(){var a=[];v.forEach(function(b){var d=[];b.forEach(function(b,e,f){var g=0===e||e===f.length-1,h=f[e-1],i=!c.beam_rests&&b.isRest(),j=c.beam_rests&&c.beam_middle_only&&b.isRest()&&g,k=!1;if(c.maintain_stem_directions&&h&&!b.isRest()&&!h.isRest()){var l=h.getStemDirection(),m=b.getStemDirection();k=m!==l}var n=parseInt(b.duration,10)<8,o=i||j||k||n;o?(d.length>0&&a.push(d),d=k?[b]:[]):d.push(b)}),d.length>0&&a.push(d)}),v=a}function l(){v.forEach(function(a){var b=void 0;if(c.maintain_stem_directions){var d=p(a);b=d?d.getStemDirection():o.Stem.UP}else b=c.stem_direction?c.stem_direction:h(a);q(a,b)})}function p(a){for(var b=0;ba?b:a});return b}},{key:"breakSecondaryAt",value:function(a){return this.break_on_indices=a,this}},{key:"getSlopeY",value:function(a,b,c,d){return c+(a-b)*d}},{key:"calculateSlope",value:function(){for(var a=this.notes,b=this.stem_direction,c=this.render_options,d=c.max_slope,e=c.min_slope,f=c.slope_iterations,g=c.slope_cost,h=a[0],i=p(h,a[a.length-1]),j=(d-e)/f,k=Number.MAX_VALUE,l=0,m=0,n=e;n<=d;n+=j){for(var o=0,q=0,r=1;rn)&&(k=n,i=Math.min.apply(Math,d(m.getYs())),j=m.getBeamCount())}var p=h/a.length,q=1.5*e,r=f+j*q,s=i+r*-b;b===o.Stem.DOWN&&ps&&(p=i-r),g?b===o.Stem.DOWN&&p>g?this.render_options.flat_beam_offset=p:b===o.Stem.UP&&p=8&&(l=this.break_on_indices.indexOf(h)!==-1,this.render_options.secondary_break_ticks&&g>=this.render_options.secondary_break_ticks&&(g=0,l=!0));var m=i.getIntrinsicTicks()1,f.point=28,f.y_pos=16,f.x_pos=100,f.width=200,f.location=f.options.location||b.LOCATION_TOP,j.Formatter.AlignRestsToNotes(a,!0,!0),f.resolveGlyphs(),f.attach(),f}return f(b,a),g(b,null,[{key:"LOCATION_TOP",get:function(){return 1}},{key:"LOCATION_BOTTOM",get:function(){return-1}},{key:"NESTING_OFFSET",get:function(){return 15}}]),g(b,[{key:"attach",value:function(){for(var a=0;a=1;)this.num_glyphs.push(new k.Glyph("v"+a%10,this.point)),a=parseInt(a/10,10);for(this.denom_glyphs=[],a=this.notes_occupied;a>=1;)this.denom_glyphs.push(new k.Glyph("v"+a%10,this.point)),a=parseInt(a/10,10)}},{key:"getNestedTupletCount",value:function(){function a(a,b){return a.tupletStack.filter(function(a){return a.location===b}).length}var b=this.location,c=this.notes[0],d=a(c,b),e=a(c,b);return this.notes.forEach(function(c){var f=a(c,b);d=f>d?f:d,e=fe&&(e=i)}}return e+a+c}},{key:"draw",value:function(){var a=this;this.checkContext(),this.setRendered();var c=this.notes[0],d=this.notes[this.notes.length-1];this.bracketed?(this.x_pos=c.getTieLeftX()-5,this.width=d.getTieRightX()-this.x_pos+5):(this.x_pos=c.getStemX(),this.width=d.getStemX()-this.x_pos),this.y_pos=this.getYPosition();var e=function(a,b){return a+b.getMetrics().width},f=this.num_glyphs.reduce(e,0);this.ratioed&&(f=this.denom_glyphs.reduce(e,f),f+=.32*this.point);var g=this.x_pos+this.width/2,h=g-f/2;if(this.bracketed){var i=this.width/2-f/2-5;i>0&&(this.context.fillRect(this.x_pos,this.y_pos,i,1),this.context.fillRect(this.x_pos+this.width/2+f/2+5,this.y_pos,i,1),this.context.fillRect(this.x_pos,this.y_pos+(this.location===b.LOCATION_BOTTOM),1,10*this.location),this.context.fillRect(this.x_pos+this.width,this.y_pos+(this.location===b.LOCATION_BOTTOM),1,10*this.location))}var j=0;if(this.num_glyphs.forEach(function(b){b.render(a.context,h+j,a.y_pos+a.point/3-2),j+=b.getMetrics().width}),this.ratioed){var k=h+j+.16*this.point,l=.06*this.point;this.context.beginPath(),this.context.arc(k,this.y_pos-.08*this.point,l,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),this.context.beginPath(),this.context.arc(k,this.y_pos+.12*this.point,l,0,2*Math.PI,!0),this.context.closePath(),this.context.fill(),j+=.32*this.point,this.denom_glyphs.forEach(function(b){b.render(a.context,h+j,a.y_pos+a.point/3-2),j+=b.getMetrics().width})}}}]),b}(i.Element)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function g(){for(var a=arguments.length,b=Array(a),c=0;c0&&c){var f=e.getBoundingBox();f&&c.mergeWith(f)}e.setContext(a),e.draw()}this.boundingBox=c}}]),b}(i.Element)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function g(a,b,c,d,e){if(b!==m.type.BOLD_DOUBLE_LEFT&&b!==m.type.BOLD_DOUBLE_RIGHT)throw new i.Vex.RERR("InvalidConnector","A REPEAT_BEGIN or REPEAT_END type must be provided.");var f=3,g=3.5,h=2;b===m.type.BOLD_DOUBLE_RIGHT&&(f=-5,g=3),a.fillRect(c+f,d,1,e-d),a.fillRect(c-h,d,g,e-d)}Object.defineProperty(b,"__esModule",{value:!0}),b.StaveConnector=void 0;var h=function(){function a(a,b){for(var c=0;c=b.type.SINGLE_RIGHT&&a<=b.type.NONE&&(this.type=a),this}},{key:"setText",value:function(a,b){return this.texts.push({content:a,options:i.Vex.Merge({shift_x:0,shift_y:0},b)}),this}},{key:"setFont",value:function(a){i.Vex.Merge(this.font,a)}},{key:"setXShift",value:function(a){if("number"!=typeof a)throw i.Vex.RERR("InvalidType","x_shift must be a Number");return this.x_shift=a,this}},{key:"draw",value:function(){var a=this.checkContext();this.setRendered();var c=this.top_stave.getYForLine(0),d=this.bottom_stave.getYForLine(this.bottom_stave.getNumLines()-1)+this.thickness,e=this.width,f=this.top_stave.getX(),h=this.type===b.type.SINGLE_RIGHT||this.type===b.type.BOLD_DOUBLE_RIGHT||this.type===b.type.THIN_DOUBLE;h&&(f=this.top_stave.getX()+this.top_stave.width);var j=d-c;switch(this.type){case b.type.SINGLE:e=1;break;case b.type.SINGLE_LEFT:e=1;break;case b.type.SINGLE_RIGHT:e=1;break;case b.type.DOUBLE:f-=this.width+2;break;case b.type.BRACE:e=12;var k=this.top_stave.getX()-2+this.x_shift,m=c,n=k,o=d,p=k-e,q=m+j/2,r=p-.9*e,s=m+.2*j,t=k+1.1*e,u=q-.135*j,v=t,w=q+.135*j,x=r,y=o-.2*j,z=p-e,A=y,B=k+.4*e,C=q+.135*j,D=B,E=q-.135*j,F=z,G=s;a.beginPath(),a.moveTo(k,m),a.bezierCurveTo(r,s,t,u,p,q),a.bezierCurveTo(v,w,x,y,n,o),a.bezierCurveTo(z,A,B,C,p,q),a.bezierCurveTo(D,E,F,G,k,m),a.fill(),a.stroke();break;case b.type.BRACKET:c-=4,d+=4,j=d-c,l.Glyph.renderGlyph(a,f-5,c-3,40,"v1b",!0),l.Glyph.renderGlyph(a,f-5,d+3,40,"v10",!0),f-=this.width+2;break;case b.type.BOLD_DOUBLE_LEFT:g(a,this.type,f+this.x_shift,c,d);break;case b.type.BOLD_DOUBLE_RIGHT:g(a,this.type,f,c,d);break;case b.type.THIN_DOUBLE:e=1;break;case b.type.NONE:break;default:throw new i.Vex.RERR("InvalidType","The provided StaveConnector.type ("+this.type+") is invalid")}this.type!==b.type.BRACE&&this.type!==b.type.BOLD_DOUBLE_LEFT&&this.type!==b.type.BOLD_DOUBLE_RIGHT&&this.type!==b.type.NONE&&a.fillRect(f,c,e,j),this.type===b.type.THIN_DOUBLE&&a.fillRect(f-3,c,e,j), a.save(),a.lineWidth=2,a.setFont(this.font.family,this.font.size,this.font.weight);for(var H=0;H2?d[1]:null,r=o>2?d[2]:d[1];2===o&&p.stemDirection===-1&&1===r.stemDirection&&(p=d[1],r=d[0]);var s=Math.max(p.voice_shift,r.voice_shift),t=0,u=void 0;if(2===o){var v=p.stemDirection===r.stemDirection?0:.5;return p.stemDirection===r.stemDirection&&p.minLine<=r.maxLine&&(p.isrest||(u=Math.abs(p.line-(r.maxLine+.5)),u=Math.max(u,p.stemMin),p.minLine=p.line-u,p.note.setStemLength(10*u))),p.minLine<=r.maxLine+v&&(p.isrest?h(p,r,1):r.isrest?h(r,p,-1):(t=s,p.stemDirection===r.stemDirection?p.note.setXShift(t+3):r.note.setXShift(t))),!0}if(null!==q&&q.minLine0&&(this.keyProps[b-1].displaced=!0)),a=f,this.keyProps.push(e)}a=-(1/0),this.keyProps.forEach(function(b){b.lineb&&(b=d):d1}},{key:"hasStem",value:function(){return this.glyph.stem}},{key:"hasFlag",value:function(){return j(Object.getPrototypeOf(b.prototype),"hasFlag",this).call(this)&&!this.isRest()}},{key:"getStemX",value:function(){return"r"===this.noteType?this.getCenterGlyphX():j(Object.getPrototypeOf(b.prototype),"getStemX",this).call(this)+t(this)}},{key:"getYForTopText",value:function(a){var b=this.getStemExtents();return Math.min(this.stave.getYForTopText(a),b.topY-this.render_options.annotation_spacing*(a+1))}},{key:"getYForBottomText",value:function(a){var b=this.getStemExtents();return Math.max(this.stave.getYForTopText(a),b.baseY+this.render_options.annotation_spacing*a)}},{key:"setStave",value:function(a){j(Object.getPrototypeOf(b.prototype),"setStave",this).call(this,a);var c=this.note_heads.map(function(b){return b.setStave(a),b.getY()});if(this.setYs(c),this.stem){var d=this.getNoteHeadBounds(),e=d.y_top,f=d.y_bottom;this.stem.setYBounds(e,f)}return this}},{key:"getKeys",value:function(){return this.keys}},{key:"getKeyProps",value:function(){return this.keyProps}},{key:"isDisplaced",value:function(){return this.displaced}},{key:"setNoteDisplaced",value:function(a){return this.displaced=a,this}},{key:"getTieRightX",value:function(){var a=this.getAbsoluteX();return a+=this.getGlyphWidth()+this.x_shift+this.extraRightPx,this.modifierContext&&(a+=this.modifierContext.getExtraRightPx()),a}},{key:"getTieLeftX",value:function(){var a=this.getAbsoluteX();return a+=this.x_shift-this.extraLeftPx}},{key:"getLineForRest",value:function(){var a=this.keyProps[0].line;if(this.keyProps.length>1){var b=this.keyProps[this.keyProps.length-1].line,c=Math.max(a,b),d=Math.min(a,b);a=l.Vex.MidLine(c,d)}return a}},{key:"getModifierStartXY",value:function(a,b){if(!this.preFormatted)throw new l.Vex.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");if(0===this.ys.length)throw new l.Vex.RERR("NoYValues","No Y-Values calculated for this note.");var c=r.Modifier.Position,d=c.ABOVE,e=c.BELOW,f=c.LEFT,g=c.RIGHT,h=0;return a===f?h=-2:a===g?(h=this.getGlyphWidth()+this.x_shift+2,this.stem_direction===o.Stem.UP&&this.hasFlag()&&u(this,b)&&(h+=this.flag.getMetrics().width)):a!==e&&a!==d||(h=this.getGlyphWidth()/2),{x:this.getAbsoluteX()+h,y:this.ys[b]}}},{key:"setStyle",value:function(a){this.note_heads.forEach(function(b){return b.setStyle(a)}),this.stem.setStyle(a)}},{key:"setKeyStyle",value:function(a,b){return this.note_heads[a].setStyle(b),this}},{key:"setKeyLine",value:function(a,b){return this.keyProps[a].line=b,this.note_heads[a].setLine(b),this}},{key:"getKeyLine",value:function(a){return this.keyProps[a].line}},{key:"addToModifierContext",value:function(a){this.setModifierContext(a);for(var b=0;bb)&&(b=g),c=f>c?f:c,d=f=k;--p)n(c.getYForNote(p))}}},{key:"drawModifiers",value:function(){if(!this.context)throw new l.Vex.RERR("NoCanvasContext","Can't draw without a canvas context.");var a=this.context;a.openGroup("modifiers");for(var b=0;b2&&(h=!0),h||(c-=l.Flow.STEM_WIDTH/2*e),a.beginPath(),a.moveTo(c,d+f),a.lineTo(c,d+1),a.lineTo(c+g,d-f),a.lineTo(c+g,d),a.lineTo(c,d+f),a.closePath(),h?a.fill():a.stroke(),l.Flow.durationToFraction(b).equals(.5))for(var i=[-3,-1,g+1,g+3],j=0;j=6){var i=c,j=Math.floor(f);f<0&&j-f===-.5?i-=5:f>6&&j-f===-.5&&(i+=5),"r"!==this.note_type&&a.fillRect(b-this.render_options.stroke_px,i,this.getWidth()+2*this.render_options.stroke_px,1)}if("s"===this.note_type){var k=this.stave.getSpacingBetweenLines();h(a,this.duration,b,c,d,k)}else this.style?(a.save(),this.applyStyle(a),p.Glyph.renderGlyph(a,b,c,e,this.glyph_code),a.restore()):p.Glyph.renderGlyph(a,b,c,e,this.glyph_code)}}]),b}(m.Note)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(b,"__esModule",{value:!0}),b.Note=void 0;var g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol?"symbol":typeof a},h=function(){function a(a,b){for(var c=0;c0){var q=p.space.deviation,r=q>=0?"+":"";a.setFillStyle("red"),a.fillText(r+Math.round(q),h+b.getXShift(),c-10)}a.restore()}},{key:"CATEGORY",get:function(){return"note"}},{key:"STAVEPADDING",get:function(){return 12}}]),h(b,[{key:"getPlayNote",value:function(){return this.playNote}},{key:"setPlayNote",value:function(a){return this.playNote=a,this}},{key:"isRest",value:function(){return!1}},{key:"addStroke",value:function(a,b){return b.setNote(this),b.setIndex(a),this.modifiers.push(b),this.setPreFormatted(!1),this}},{key:"getStave",value:function(){return this.stave}},{key:"setStave",value:function(a){return this.stave=a,this.setYs([a.getYForLine(0)]),this.context=this.stave.context,this}},{key:"getCategory",value:function(){return b.CATEGORY}},{key:"setContext",value:function(a){return this.context=a,this}},{key:"getExtraLeftPx",value:function(){return this.extraLeftPx}},{key:"getExtraRightPx",value:function(){return this.extraRightPx}},{key:"setExtraLeftPx",value:function(a){return this.extraLeftPx=a,this}},{key:"setExtraRightPx",value:function(a){return this.extraRightPx=a,this}},{key:"shouldIgnoreTicks",value:function(){return this.ignore_ticks}},{key:"getLineNumber",value:function(){return 0}},{key:"getLineForRest",value:function(){return 0}},{key:"getGlyph",value:function(){return this.glyph}},{key:"getGlyphWidth",value:function(){return this.glyph.getWidth(this.render_options.glyph_font_scale)}},{key:"setYs",value:function(a){return this.ys=a,this}},{key:"getYs",value:function(){if(0===this.ys.length)throw new i.Vex.RERR("NoYValues","No Y-values calculated for this note.");return this.ys}},{key:"getYForTopText",value:function(a){if(!this.stave)throw new i.Vex.RERR("NoStave","No stave attached to this note.");return this.stave.getYForTopText(a)}},{key:"getBoundingBox",value:function(){return null}},{key:"getVoice",value:function(){if(!this.voice)throw new i.Vex.RERR("NoVoice","Note has no voice.");return this.voice}},{key:"setVoice",value:function(a){return this.voice=a,this.preFormatted=!1,this}},{key:"getTickContext",value:function(){return this.tickContext}},{key:"setTickContext",value:function(a){return this.tickContext=a,this.preFormatted=!1,this}},{key:"getDuration",value:function(){return this.duration}},{key:"isDotted",value:function(){return this.dots>0}},{key:"hasStem",value:function(){return!1}},{key:"getDots",value:function(){return this.dots}},{key:"getNoteType",value:function(){return this.noteType}},{key:"setBeam",value:function(){return this}},{key:"setModifierContext",value:function(a){return this.modifierContext=a,this}},{key:"addModifier",value:function(a){var b=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return a.setNote(this),a.setIndex(b),this.modifiers.push(a),this.setPreFormatted(!1),this}},{key:"getModifierStartXY",value:function(){if(!this.preFormatted)throw new i.Vex.RERR("UnformattedNote","Can't call GetModifierStartXY on an unformatted note");return{x:this.getAbsoluteX(),y:this.ys[0]}}},{key:"getMetrics",value:function(){if(!this.preFormatted)throw new i.Vex.RERR("UnformattedNote","Can't call getMetrics on an unformatted note.");var a=0,b=0;null!=this.modifierContext&&(a=this.modifierContext.state.left_shift,b=this.modifierContext.state.right_shift);var c=this.getWidth();return{width:c,noteWidth:c-a-b-this.extraLeftPx-this.extraRightPx,left_shift:this.x_shift,modLeftPx:a,modRightPx:b,extraLeftPx:this.extraLeftPx,extraRightPx:this.extraRightPx}}},{key:"setWidth",value:function(a){this.width=a}},{key:"getWidth",value:function(){if(!this.preFormatted)throw new i.Vex.RERR("UnformattedNote","Can't call GetWidth on an unformatted note.");return this.width+(this.modifierContext?this.modifierContext.getWidth():0)}},{key:"setXShift",value:function(a){return this.x_shift=a,this}},{key:"getXShift",value:function(){return this.x_shift}},{key:"getX",value:function(){if(!this.tickContext)throw new i.Vex.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");return this.tickContext.getX()+this.x_shift}},{key:"getAbsoluteX",value:function(){if(!this.tickContext)throw new i.Vex.RERR("NoTickContext","Note needs a TickContext assigned for an X-Value");var a=this.tickContext.getX();return this.stave&&(a+=this.stave.getNoteStartX()+this.render_options.stave_padding),this.isCenterAligned()&&(a+=this.getCenterXShift()),a}},{key:"setPreFormatted",value:function(a){if(this.preFormatted=a,this.preFormatted){var b=this.tickContext.getExtraPx();this.left_modPx=Math.max(this.left_modPx,b.left),this.right_modPx=Math.max(this.right_modPx,b.right)}}}]),b}(k.Tickable)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(b,"__esModule",{value:!0}),b.Tickable=void 0;var g=function(){function a(a,b){for(var c=0;cl?k:l,m=v,n=t}return b.right_shift+=l,!0}},{key:"CATEGORY",get:function(){return"dots"}}]),g(b,[{key:"getCategory",value:function(){return b.CATEGORY}},{key:"setNote",value:function(a){this.note=a,"gracenotes"===this.note.getCategory()&&(this.radius*=.5,this.setWidth(3))}},{key:"setDotShiftY",value:function(a){return this.dot_shiftY=a,this}},{key:"draw",value:function(){if(this.checkContext(),this.setRendered(),!this.note||null===this.index)throw new h.Vex.RERR("NoAttachedNote","Can't draw dot without a note and index.");var a=this.note.stave.options.spacing_between_lines_px,b=this.note.getModifierStartXY(this.position,this.index);"tabnotes"===this.note.getCategory()&&(b.y=this.note.getStemExtents().baseY);var c=b.x+this.x_shift+this.width-this.radius,d=b.y+this.y_shift+this.dot_shiftY*a,e=this.context;e.beginPath(),e.arc(c,d,this.radius,0,2*Math.PI,!1),e.fill()}}]),b}(i.Modifier)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(){for(var a=arguments.length,b=Array(a),c=0;ct?y:t):B===i.Modifier.Position.RIGHT&&(C.setXShift(s),y=j+G,u=y>u?y:u),v=D,w=A}return b.left_shift+=t,b.right_shift+=u,!0}},{key:"CATEGORY",get:function(){return"frethandfinger"}}]),g(b,[{key:"getCategory",value:function(){return b.CATEGORY}},{key:"setFretHandFinger",value:function(a){return this.finger=a,this}},{key:"setOffsetX",value:function(a){return this.x_offset=a,this}},{key:"setOffsetY",value:function(a){return this.y_offset=a,this}},{key:"draw",value:function(){if(this.checkContext(),!this.note||null==this.index)throw new h.Vex.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();var a=this.context,b=this.note.getModifierStartXY(this.position,this.index),c=b.x+this.x_shift+this.x_offset,d=b.y+this.y_shift+this.y_offset+5;switch(this.position){case i.Modifier.Position.ABOVE:c-=4,d-=12;break;case i.Modifier.Position.BELOW:c-=2,d+=10;break;case i.Modifier.Position.LEFT:c-=this.width;break;case i.Modifier.Position.RIGHT:c+=1;break;default:throw new h.Vex.RERR("InvalidPostion","The position "+this.position+" does not exist")}a.save(),a.setFont(this.font.family,this.font.size,this.font.weight),a.fillText(""+this.finger,c,d),a.restore()}}]),b}(i.Modifier)},function(a,b,c){"use strict";function d(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);by?B.shift:y,z=B.line}for(var C=0,D=function(a){for(var b=!1,e=a,f=a;f+1=7){for(var q=2,r=!0;r===!0;){r=!1;for(var s=0;s+qp?C:p}else for(o=a;o<=f;o++)p=m.Flow.accidentalColumnsTable[l][n][o-a],x[o].column=p,C=C>p?C:p;a=f,E=a},E=0;EF[a.column]&&(F[a.column]=a.width)});for(var I=1;I0?(d=b.flatLine||b.dblSharpLine?2.5:3,a.dblSharpLine&&(c-=.5)):(d=a.flatLine||a.dblSharpLine?2.5:3,b.dblSharpLine&&(c-=.5));var e=Math.abs(c)-1;if(!k||k&&l){g[h.root]=j;var m=new b(i);a.addAccidental(e,m),d.push(j)}})})})}},{key:"CATEGORY",get:function(){return"accidentals"}}]),j(b,[{key:"reset",value:function(){var a=this.render_options.font_scale;this.glyph=new p.Glyph(this.accidental.code,a),this.glyph.setOriginX(1),this.cautionary&&(this.parenLeft=new p.Glyph(m.Flow.accidentalCodes("{").code,a),this.parenRight=new p.Glyph(m.Flow.accidentalCodes("}").code,a),this.parenLeft.setOriginX(1),this.parenRight.setOriginX(1))}},{key:"getCategory",value:function(){return b.CATEGORY}},{key:"getWidth",value:function(){var a=this.cautionary?q(this.parenLeft)+q(this.parenRight)+this.render_options.parenLeftPadding+this.render_options.parenRightPadding:0;return q(this.glyph)+a}},{key:"setNote",value:function(a){if(!a)throw new k.Vex.RERR("ArgumentError","Bad note value: "+a);this.note=a,"gracenotes"===this.note.getCategory()&&(this.render_options.font_scale=25,this.reset())}},{key:"setAsCautionary",value:function(){return this.cautionary=!0,this.render_options.font_scale=28,this.reset(),this}},{key:"draw",value:function(){var a=this.context,b=this.type,c=this.position,d=this.note,e=this.index,f=this.cautionary,g=this.x_shift,i=this.y_shift,j=this.glyph,l=this.parenLeft,m=this.parenRight,n=this.render_options,o=n.parenLeftPadding,p=n.parenRightPadding;if(this.checkContext(),!d||null==e)throw new k.Vex.RERR("NoAttachedNote","Can't draw accidental without a note and index.");var r=d.getModifierStartXY(c,e),s=r.x+g,t=r.y+i;h("Rendering: ",b,s,t),f?(m.render(a,s,t),s-=q(m),s-=p,s-=this.accidental.parenRightPaddingAdjustment,j.render(a,s,t),s-=q(j),s-=o,l.render(a,s,t)):j.render(a,s,t),this.setRendered()}}]),b}(o.Modifier)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0}),b.Music=void 0;var e=function(){function a(a,b){for(var c=0;c=a.NUM_TONES)}},{key:"isValidIntervalValue",value:function(a){return this.isValidNoteValue(a)}},{key:"getNoteParts",value:function(a){if(!a||a.length<1)throw new f.Vex.RERR("BadArguments","Invalid note name: "+a);if(a.length>3)throw new f.Vex.RERR("BadArguments","Invalid note name: "+a);var b=a.toLowerCase(),c=/^([cdefgab])(b|bb|n|#|##)?$/,d=c.exec(b);if(null!=d){var e=d[1],g=d[2];return{root:e,accidental:g}}throw new f.Vex.RERR("BadArguments","Invalid note name: "+a)}},{key:"getKeyParts",value:function(a){if(!a||a.length<1)throw new f.Vex.RERR("BadArguments","Invalid key: "+a);var b=a.toLowerCase(),c=/^([cdefgab])(b|#)?(mel|harm|m|M)?$/,d=c.exec(b);if(null!=d){var e=d[1],g=d[2],h=d[3];return h||(h="M"),{root:e,accidental:g,type:h}}throw new f.Vex.RERR("BadArguments","Invalid key: "+a)}},{key:"getNoteValue",value:function(b){var c=a.noteValues[b];if(null==c)throw new f.Vex.RERR("BadArguments","Invalid note name: "+b);return c.int_val}},{key:"getIntervalValue",value:function(b){var c=a.intervals[b];if(null==c)throw new f.Vex.RERR("BadArguments","Invalid interval name: ${intervalString}");return c}},{key:"getCanonicalNoteName",value:function(b){if(!this.isValidNoteValue(b))throw new f.Vex.RERR("BadArguments","Invalid note value: "+b);return a.canonical_notes[b]}},{key:"getCanonicalIntervalName",value:function(b){if(!this.isValidIntervalValue(b))throw new f.Vex.RERR("BadArguments","Invalid interval value: "+b);return a.diatonic_intervals[b]}},{key:"getRelativeNoteValue",value:function(b,c,d){if(null==d&&(d=1),1!==d&&d!==-1)throw new f.Vex.RERR("BadArguments","Invalid direction: "+d);var e=(b+d*c)%a.NUM_TONES;return e<0&&(e+=a.NUM_TONES),e}},{key:"getRelativeNoteName",value:function(b,c){var d=this.getNoteParts(b),e=this.getNoteValue(d.root),g=c-e;if(Math.abs(g)>a.NUM_TONES-3){var h=1;g>0&&(h=-1);var i=(c+1+(e+1))%a.NUM_TONES*h;if(Math.abs(i)>2)throw new f.Vex.RERR("BadArguments","Notes not related: "+b+", "+c+")");g=i}if(Math.abs(g)>2)throw new f.Vex.RERR("BadArguments","Notes not related: "+b+", "+c+")");var j=d.root;if(g>0)for(var k=1;k<=g;++k)j+="#";else if(g<0)for(var l=-1;l>=g;--l)j+="b";return j}},{key:"getScaleTones",value:function(a,b){for(var c=[a],d=a,e=0;e1){var a=new n.Beam(this.grace_notes);a.render_options.beam_width=3,a.render_options.partial_beam_length=4,this.beam=a}return this}},{key:"setNote",value:function(a){this.note=a}},{key:"setWidth",value:function(a){this.width=a}},{key:"getWidth",value:function(){return this.width}},{key:"draw",value:function(){function a(a,b){var c=b.getTickContext(),e=c.getExtraPx(),f=c.getX()-e.left-e.extraLeft+d.getSpacingFromNextModifier();a.forEach(function(a){var c=a.getTickContext(),d=c.getX();a.setStave(b.stave),c.setX(f+d)})}var b=this;this.checkContext();var c=this.getNote();if(g("Drawing grace note group for:",c),!c||null===this.index)throw new i.Vex.RuntimeError("NoAttachedNote","Can't draw grace note without a parent note and parent note index.");this.setRendered();var d=this;if(a(this.grace_notes,c,this.width),this.grace_notes.forEach(function(a){a.setContext(b.context).draw()}),this.beam&&this.beam.setContext(this.context).draw(),this.show_slur){var e=this.getNote().getCategory()===q.StaveNote.CATEGORY,f=e?o.StaveTie:p.TabTie;this.slur=new f({last_note:this.grace_notes[0],first_note:c,first_indices:[0],last_indices:[0]}),this.slur.render_options.cp2=12,this.slur.render_options.y_shift=(e?7:5)+this.render_options.slur_y_shift,this.slur.setContext(this.context).draw()}}}]),b}(k.Modifier)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(b,"__esModule",{value:!0}),b.StaveTie=void 0;var g=function(){function a(a,b){for(var c=0;ct?x:t):n===i.Modifier.Position.RIGHT&&(l.setXShift(s),x+=B,u=x>u?x:u),v=y,w=m}return b.left_shift+=t,b.right_shift+=u,!0}},{key:"CATEGORY",get:function(){return"stringnumber"}}]),g(b,[{key:"getCategory",value:function(){return b.CATEGORY}},{key:"getNote",value:function(){return this.note}},{key:"setNote",value:function(a){return this.note=a,this}},{key:"getIndex",value:function(){return this.index}},{key:"setIndex",value:function(a){return this.index=a,this}},{key:"setLineEndType",value:function(a){return a>=j.Renderer.LineEndType.NONE&&a<=j.Renderer.LineEndType.DOWN&&(this.leg=a),this}},{key:"getPosition",value:function(){return this.position}},{key:"setPosition",value:function(a){return a>=i.Modifier.Position.LEFT&&a<=i.Modifier.Position.BELOW&&(this.position=a),this}},{key:"setStringNumber",value:function(a){return this.string_number=a,this}},{key:"setOffsetX",value:function(a){return this.x_offset=a,this}},{key:"setOffsetY",value:function(a){return this.y_offset=a,this}},{key:"setLastNote",value:function(a){return this.last_note=a,this}},{key:"setDashed",value:function(a){return this.dashed=a,this}},{key:"draw",value:function(){var a=this.checkContext();if(!this.note||null==this.index)throw new h.Vex.RERR("NoAttachedNote","Can't draw string number without a note and index.");this.setRendered();var b=this.note.stave.options.spacing_between_lines_px,c=this.note.getModifierStartXY(this.position,this.index),d=c.x+this.x_shift+this.x_offset,e=c.y+this.y_shift+this.y_offset;switch(this.position){case i.Modifier.Position.ABOVE:case i.Modifier.Position.BELOW:var f=this.note.getStemExtents(),g=f.topY,l=f.baseY+2;this.note.stem_direction===k.StaveNote.STEM_DOWN&&(g=f.baseY,l=f.topY-2),e=this.position===i.Modifier.Position.ABOVE?this.note.hasStem()?g-1.75*b:c.y-1.75*b:this.note.hasStem()?l+1.5*b:c.y+1.75*b,e+=this.y_shift+this.y_offset;break;case i.Modifier.Position.LEFT:d-=this.radius/2+5;break;case i.Modifier.Position.RIGHT:d+=this.radius/2+6;break;default:throw new h.Vex.RERR("InvalidPosition","The position "+this.position+" is invalid")}a.save(),a.beginPath(),a.arc(d,e,this.radius,0,2*Math.PI,!1),a.lineWidth=1.5,a.stroke(),a.setFont(this.font.family,this.font.size,this.font.weight);var m=d-a.measureText(this.string_number).width/2;if(a.fillText(""+this.string_number,m,e+4.5),null!=this.last_note){var n=this.last_note.getStemX()-this.note.getX()+5;a.strokeStyle="#000000",a.lineCap="round",a.lineWidth=.6,this.dashed?j.Renderer.drawDashedLine(a,d+10,e,d+n,e,[3,3]):j.Renderer.drawDashedLine(a,d+10,e,d+n,e,[3,0]);var o=void 0,p=void 0;switch(this.leg){case j.Renderer.LineEndType.UP:o=-10,p=this.dashed?[3,3]:[3,0],j.Renderer.drawDashedLine(a,d+n,e,d+n,e+o,p);break;case j.Renderer.LineEndType.DOWN:o=10,p=this.dashed?[3,3]:[3,0],j.Renderer.drawDashedLine(a,d+n,e,d+n,e+o,p)}}a.restore()}}]),b}(i.Modifier)},function(a,b,c){"use strict";function d(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function h(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b=1},v=function(a,b){return u(a,b)?b===r?Math.ceil:Math.floor:Math.round},w=function(a,b,c,d){var e=t(v(b,c),b),f=a&&u(e,c),g=e%1===0;if(f&&g){var h=.5;return e+h*-d}return e},x=function(a,b){var c=a.getStave(),d=a.getStemDirection(),e=a.getStemExtents(),f=e.topY,g=e.baseY;if("stavenotes"===a.getCategory())return a.hasStem()?d===p.Stem.UP?f:g:Math.min.apply(Math,h(a.getYs()));if("tabnotes"===a.getCategory())return a.hasStem()&&d===p.Stem.UP?f:c.getYForTopText(b);throw new l.Vex.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")},y=function(a,b){var c=a.getStave(),d=a.getStemDirection(),e=a.getStemExtents(),f=e.topY,g=e.baseY;if("stavenotes"===a.getCategory())return a.hasStem()?d===p.Stem.UP?g:f:Math.max.apply(Math,h(a.getYs()));if("tabnotes"===a.getCategory())return a.hasStem()?d===p.Stem.UP?c.getYForBottomText(b):f:c.getYForBottomText(b);throw new l.Vex.RERR("UnknownCategory","Only can get the top and bottom ys of stavenotes and tabnotes")},z=function(a,b){var c=b===r&&a.getStemDirection()===p.Stem.UP||b===s&&a.getStemDirection()===p.Stem.DOWN;return"stavenotes"===a.getCategory()?a.hasStem()&&c?.5:1:a.hasStem()&&c?1:0},A=b.Articulation=function(a){function b(a){e(this,b);var c=f(this,Object.getPrototypeOf(b).call(this));if(c.setAttribute("type","Articulation"),c.note=null,c.index=null,c.type=a,c.position=s,c.render_options={font_scale:38},c.articulation=m.Flow.articulationCodes(c.type),!c.articulation)throw new l.Vex.RERR("ArgumentError","Articulation not found: "+c.type);return c.glyph=new o.Glyph(c.articulation.code,c.render_options.font_scale),c.setWidth(c.glyph.getMetrics().width),c}return g(b,a),k(b,null,[{key:"format",value:function(a,b){if(!a||0===a.length)return!1;var c=function(a){return a.getPosition()===r},d=function(a){return a.getPosition()===s},e=.5,f=function(a,b,c){return t(v(b,c),a.glyph.getMetrics().height/10+e)};a.filter(c).forEach(function(a){a.setTextLine(b.top_text_line),b.top_text_line+=f(a,b.top_text_line,r)}),a.filter(d).forEach(function(a){a.setTextLine(b.text_line),b.text_line+=f(a,b.text_line,s)});var g=a.map(function(a){return a.getWidth()}).reduce(function(a,b){return Math.max(b,a)});return b.left_shift+=g/2,b.right_shift+=g/2,!0}},{key:"easyScoreHook",value:function(a,b,c){var d=a.articulations;if(d){var e={staccato:"a.",tenuto:"a-"};d.split(",").map(function(a){return a.trim().split(".")}).map(function(a){var b=j(a,2),d=b[0],f=b[1],g={type:e[d]};return f&&(g.position=n.Modifier.PositionString[f]),c.getFactory().Articulation(g)}).map(function(a){return b.addModifier(0,a)})}}},{key:"CATEGORY",get:function(){return"articulations"}},{key:"INITIAL_OFFSET",get:function(){return-.5}}]),k(b,[{key:"getCategory",value:function(){return b.CATEGORY}},{key:"draw",value:function(){var a,c=this.note,e=this.index,f=this.position,g=this.glyph,h=this.articulation.between_lines,j=this.text_line,k=this.context;if(this.checkContext(),!c||null==e)throw new l.Vex.RERR("NoAttachedNote","Can't draw Articulation without a note and index.");this.setRendered();var m=c.getStave(),n=m.getSpacingBetweenLines(),o="tabnotes"===c.getCategory(),p=c.getModifierStartXY(f,e),q=p.x,t=!h||o,v=z(c,f),A=(a={},d(a,r,function(){g.setOrigin(.5,1);var a=x(c,j)-(j+v)*n;return t?Math.min(m.getYForTopText(b.INITIAL_OFFSET),a):a}),d(a,s,function(){g.setOrigin(.5,0);var a=y(c,j)+(j+v)*n;return t?Math.max(m.getYForBottomText(b.INITIAL_OFFSET),a):a}),a)[f]();if(!o){var B=f===r?-1:1,C=o?c.positions[e].str:c.getKeyProps()[e].line,D=(c.getYs()[e]-A)/n,E=D+C,F=w(h,E,f,B);u(F,f)&&g.setOrigin(.5,.5),A+=Math.abs(F-E)*n*B}i("Rendering articulation at (x: "+q+", y: "+A+")"),g.render(k,q,A)}}]),b}(n.Modifier)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function g(){for(var a=arguments.length,b=Array(a),c=0;c0&&d--;for(var h=0;hc.getWidth()&&(b-=c.getWidth()),b}},{key:"setRepetitionTypeLeft",value:function(a,b){return this.modifiers.push(new m.Repetition(a,this.x,b)),this}},{key:"setRepetitionTypeRight",value:function(a,b){return this.modifiers.push(new m.Repetition(a,this.x,b)),this}},{key:"setVoltaType",value:function(a,b,c){return this.modifiers.push(new u.Volta(a,b,this.x,c)),this}},{key:"setSection",value:function(a,b){return this.modifiers.push(new n.StaveSection(a,this.x,b)),this}},{key:"setTempo",value:function(a,b){return this.modifiers.push(new o.StaveTempo(a,this.x,b)),this}},{key:"setText",value:function(a,b,c){return this.modifiers.push(new p.StaveText(a,b,c)),this}},{key:"getHeight",value:function(){return this.height}},{key:"getSpacingBetweenLines",value:function(){return this.options.spacing_between_lines_px}},{key:"getBoundingBox",value:function(){return new q.BoundingBox(this.x,this.y,this.width,this.getBottomY()-this.y)}},{key:"getBottomY",value:function(){var a=this.options,b=a.spacing_between_lines_px,c=this.getYForLine(a.num_lines)+a.space_below_staff_ln*b;return c}},{key:"getBottomLineY",value:function(){return this.getYForLine(this.options.num_lines)}},{key:"getYForLine",value:function(a){var b=this.options,c=b.spacing_between_lines_px,d=b.space_above_staff_ln,e=this.y+a*c+d*c;return e}},{key:"getLineForY",value:function(a){var b=this.options,c=b.spacing_between_lines_px,d=b.space_above_staff_ln;return(a-this.y)/c-d}},{key:"getYForTopText",value:function(a){var b=a||0;return this.getYForLine(-b-this.options.top_text_position)}},{key:"getYForBottomText",value:function(a){var b=a||0;return this.getYForLine(this.options.bottom_text_position+b)}},{key:"getYForNote",value:function(a){var b=this.options,c=b.spacing_between_lines_px,d=b.space_above_staff_ln,e=this.y+d*c+5*c-a*c;return e}},{key:"getYForGlyphs",value:function(){return this.getYForLine(3)}},{key:"addModifier",value:function(a,b){return void 0!==b&&a.setPosition(b),a.setStave(this),this.formatted=!1,this.modifiers.push(a),this}},{key:"addEndModifier",value:function(a){return this.addModifier(a,l.StaveModifier.Position.END),this}},{key:"setBegBarType",value:function(a){var b=k.Barline.type,c=b.SINGLE,d=b.REPEAT_BEGIN,e=b.NONE;return a!==c&&a!==d&&a!==e||(this.modifiers[0].setType(a),this.formatted=!1),this}},{key:"setEndBarType",value:function(a){return a!==k.Barline.type.REPEAT_BEGIN&&(this.modifiers[1].setType(a),this.formatted=!1),this}},{key:"setClef",value:function(a,b,c,d){void 0===d&&(d=l.StaveModifier.Position.BEGIN),this.clef=a;var e=this.getModifiers(d,r.Clef.CATEGORY);return 0===e.length?this.addClef(a,b,c,d):e[0].setType(a,b,c),this}},{key:"setEndClef",value:function(a,b,c){return this.setClef(a,b,c,l.StaveModifier.Position.END),this}},{key:"setKeySignature",value:function(a,b,c){void 0===c&&(c=l.StaveModifier.Position.BEGIN);var d=this.getModifiers(c,s.KeySignature.CATEGORY);return 0===d.length?this.addKeySignature(a,b,c):d[0].setKeySig(a,b),this}},{key:"setEndKeySignature",value:function(a,b){return this.setKeySignature(a,b,l.StaveModifier.Position.END),this}},{key:"setTimeSignature",value:function(a,b,c){void 0===c&&(c=l.StaveModifier.Position.BEGIN);var d=this.getModifiers(c,t.TimeSignature.CATEGORY);return 0===d.length?this.addTimeSignature(a,b,c):d[0].setTimeSig(a),this}},{key:"setEndTimeSignature",value:function(a,b){return this.setTimeSignature(a,b,l.StaveModifier.Position.END),this}},{key:"addKeySignature",value:function(a,b,c){return this.addModifier(new s.KeySignature(a,b),c),this}},{key:"addClef",value:function(a,b,c,d){return void 0!==d&&d!==l.StaveModifier.Position.BEGIN||(this.clef=a),this.addModifier(new r.Clef(a,b,c),d),this}},{key:"addEndClef",value:function(a,b,c){return this.addClef(a,b,c,l.StaveModifier.Position.END),this}},{key:"addTimeSignature",value:function(a,b,c){return this.addModifier(new t.TimeSignature(a,b),c),this}},{key:"addEndTimeSignature",value:function(a,b){return this.addTimeSignature(a,b,l.StaveModifier.Position.END),this}},{key:"addTrebleGlyph",value:function(){return this.addClef("treble"),this}},{key:"getModifiers",value:function(a,b){return void 0===a?this.modifiers:this.modifiers.filter(function(c){return a===c.getPosition()&&(void 0===b||b===c.getCategory())})}},{key:"sortByCategory",value:function(a,b){for(var c=a.length-1;c>=0;c--)for(var d=0;db[a[d+1].getCategory()]){var e=a[d];a[d]=a[d+1],a[d+1]=e}}},{key:"format",value:function(){var a=this.modifiers[0],b=this.modifiers[1],c=this.getModifiers(l.StaveModifier.Position.BEGIN),d=this.getModifiers(l.StaveModifier.Position.END);this.sortByCategory(c,{barlines:0,clefs:1,keysignatures:2,timesignatures:3}),this.sortByCategory(d,{timesignatures:0,keysignatures:1,barlines:2,clefs:3}),c.length>1&&a.getType()===k.Barline.type.REPEAT_BEGIN&&(c.push(c.splice(0,1)[0]),c.splice(0,0,new k.Barline(k.Barline.type.SINGLE))),d.indexOf(b)>0&&d.splice(0,0,new k.Barline(k.Barline.type.NONE));for(var e=void 0,f=void 0,g=void 0,h=0,i=this.x,j=0;j0){this.context.save(),this.context.setFont(this.font.family,this.font.size,this.font.weight);var g=this.context.measureText(""+this.measure).width;d=this.getYForTopText(0)+3,this.context.fillText(""+this.measure,this.x-g/2,d),this.context.restore()}return this}},{key:"drawVertical",value:function(a,b){this.drawVerticalFixed(this.x+a,b)}},{key:"drawVerticalFixed",value:function(a,b){this.checkContext();var c=this.getYForLine(0),d=this.getYForLine(this.options.num_lines-1);b&&this.context.fillRect(a-3,c,1,d-c+1),this.context.fillRect(a,c,1,d-c+1)}},{key:"drawVerticalBar",value:function(a){this.drawVerticalBarFixed(this.x+a,!1)}},{key:"drawVerticalBarFixed",value:function(a){this.checkContext();var b=this.getYForLine(0),c=this.getYForLine(this.options.num_lines-1);this.context.fillRect(a,b,1,c-b+1)}},{key:"getConfigForLines",value:function(){return this.options.line_config}},{key:"setConfigForLine",value:function(a,b){if(a>=this.options.num_lines||a<0)throw new h.Vex.RERR("StaveConfigError","The line number must be within the range of the number of lines in the Stave.");if(void 0===b.visible)throw new h.Vex.RERR("StaveConfigError","The line configuration object is missing the 'visible' property.");if("boolean"!=typeof b.visible)throw new h.Vex.RERR("StaveConfigError","The line configuration objects 'visible' property must be true or false.");return this.options.line_config[a]=b,this}},{key:"setConfigForLines",value:function(a){if(a.length!==this.options.num_lines)throw new h.Vex.RERR("StaveConfigError","The length of the lines configuration array must match the number of lines in the Stave");for(var b in a)a[b]||(a[b]=this.options.line_config[b]),h.Vex.Merge(this.options.line_config[b],a[b]);return this.options.line_config=a,this}}]),b}(i.Element)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(b,"__esModule",{value:!0}),b.Barline=void 0;var g=function(){function a(a,b){for(var c=0;c=a.line;f=h?g.above:g.below}}this.placeGlyphOnLine(e,this.stave,a.line),this.glyphs.push(e);var j=this.xPositions[this.xPositions.length-1],l=e.getMetrics().width+f;this.xPositions.push(j+l),this.width+=l}},{key:"cancelKey",value:function(a){return this.formatted=!1,this.cancelKeySpec=a,this}},{key:"convertToCancelAccList",value:function(a){var b=i.Flow.keySignature(a),c=this.accList.length>0&&b.length>0&&b[0].type!==this.accList[0].type,d=c?b.length:b.length-this.accList.length;if(!(d<1)){for(var e=[],f=0;f0?this.accList[0].type:null;if(this.alterKeySpec&&this.convertToAlterAccList(this.alterKeySpec),this.accList.length>0){this.convertAccLines(this.stave.clef,a);for(var b=0;b/"');b.forEach(function(b){if(isNaN(Number(b)))throw new i.Vex.RERR("BadTimeSignature","Invalid time spec: "+a+". Must contain two valid numbers.")})};b.TimeSignature=function(a){function b(){var a=arguments.length<=0||void 0===arguments[0]?null:arguments[0],c=arguments.length<=1||void 0===arguments[1]?15:arguments[1];d(this,b);var f=e(this,Object.getPrototypeOf(b).call(this));if(f.setAttribute("type","TimeSignature"),null===a)return e(f);var g=c;return f.point=40,f.topLine=2,f.bottomLine=4,f.setPosition(k.StaveModifier.Position.BEGIN),f.setTimeSig(a),f.setWidth(f.timeSig.glyph.getMetrics().width),f.setPadding(g),f}return f(b,a),h(b,null,[{key:"CATEGORY",get:function(){return"timesignatures"}},{key:"glyphs",get:function(){return{C:{code:"v41",point:40,line:2},"C|":{code:"vb6",point:40,line:2}}}}]),h(b,[{key:"getCategory",value:function(){return b.CATEGORY}},{key:"parseTimeSpec",value:function(a){if("C"===a||"C|"===a){var c=b.glyphs[a],d=c.line,e=c.code,f=c.point;return{line:d,num:!1,glyph:new j.Glyph(e,f)}}l(a);var h=a.split("/").map(function(a){return a.split("")}),i=g(h,2),k=i[0],m=i[1];return{num:!0,glyph:this.makeTimeSignatureGlyph(k,m)}}},{key:"makeTimeSignatureGlyph",value:function(a,b){var c=new j.Glyph("v0",this.point);c.topGlyphs=[],c.botGlyphs=[];for(var d=0,e=0;eh?d:h,n=c.getMetrics().x_min;c.getMetrics=function(){return{x_min:n,x_max:n+m,width:m}};var o=(m-d)/2,p=(m-h)/2,q=this;return c.renderToStave=function(a){for(var b=a+o,c=0;c-1;f?(c.push(d),d=[]):d.push(e)}return d.length>0&&c.push(d),c}function h(a,b,c,d){var e=1!==d,f=d!==-1,g=c.getSpacingBetweenLines(),h=c.getNumLines(),i=[];return b.forEach(function(b){var j=b.indexOf(h)>-1,k=b.indexOf(1)>-1;if(!(e&&k||f&&j)){1===b.length&&b.push(b[0]);var l=[];b.forEach(function(b,e,f){var i=1===b,j=b===h,k=c.getYForLine(b-1);0!==e||i?e!==f.length-1||j||(k+=g/2-1):k-=g/2-1,l.push(k),1===d&&i?l.push(a-2):d===-1&&j&&l.push(a+2)}),i.push(l.sort(function(a,b){return a-b}))}}),i}Object.defineProperty(b,"__esModule",{value:!0}),b.TabNote=void 0;var i=function r(a,b,c){null===a&&(a=Function.prototype);var d=Object.getOwnPropertyDescriptor(a,b);if(void 0===d){var e=Object.getPrototypeOf(a);return null===e?void 0:r(e,b,c)}if("value"in d)return d.value;var f=d.get;if(void 0!==f)return f.call(c)},j=function(){function a(a,b){for(var c=0;cparseInt(h,10)?b.SLIDE_DOWN:b.SLIDE_UP}return f.slide_direction=c,f.render_options.cp1=11,f.render_options.cp2=14,f.render_options.y_shift=.5,f.setFont({font:"Times",size:10,style:"bold italic"}),f.setNotes(a),f}return f(b,a),g(b,null,[{key:"createSlideUp",value:function(a){return new b(a,b.SLIDE_UP)}},{key:"createSlideDown",value:function(a){return new b(a,b.SLIDE_DOWN)}},{key:"SLIDE_UP",get:function(){return 1}},{key:"SLIDE_DOWN",get:function(){return-1}}]),g(b,[{key:"renderTie",value:function(a){if(0===a.first_ys.length||0===a.last_ys.length)throw new h.Vex.RERR("BadArguments","No Y-values to render");var c=this.context,d=a.first_x_px,e=a.first_ys,f=a.last_x_px,g=this.slide_direction;if(g!==b.SLIDE_UP&&g!==b.SLIDE_DOWN)throw new h.Vex.RERR("BadSlide","Invalid slide direction");for(var i=0;ithis.numStrings)throw new f.Vex.RERR("BadArguments","String number must be between 1 and "+this.numStrings+":"+a);return this.tuningValues[b-1]}},{key:"getValueForFret",value:function(a,b){var c=this.getValueForString(b),d=parseInt(a,10);if(d<0)throw new f.Vex.RERR("BadArguments","Fret number must be 0 or higher: "+a);return c+d}},{key:"getNoteForFret",value:function(a,b){var c=this.getValueForFret(a,b),d=Math.floor(c/12),e=c%12;return g.Flow.integerToNote(e)+"/"+d}}]),a}()},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0}),b.KeyManager=void 0;var e=function(){function a(a,b){for(var c=0;ci.y;g.x+=d.getMetrics().modRightPx+f.padding_left,i.x-=e.getMetrics().modLeftPx+f.padding_right;var m=d.getGlyph().getWidth(),n=d.getKeyProps()[b].displaced;n&&1===d.getStemDirection()&&(g.x+=m+f.padding_left);var o=e.getKeyProps()[k].displaced;o&&e.getStemDirection()===-1&&(i.x-=m+f.padding_right),g.y+=l?-3:1,i.y+=l?2:0,h(c,g,i,a.render_options)}),c.restore();var j=c.measureText(this.text).width,k=f.text_justification,m=0;if(k===b.TextJustification.LEFT)m=g.x;else if(k===b.TextJustification.CENTER){var n=i.x-g.x,o=n/2+g.x;m=o-j/2}else k===b.TextJustification.RIGHT&&(m=i.x-j);var p=void 0,q=f.text_position_vertical;return q===b.TextVerticalPosition.TOP?p=d.getStave().getYForTopText():q===b.TextVerticalPosition.BOTTOM&&(p=d.getStave().getYForBottomText(l.Flow.TEXT_HEIGHT_OFFSET_HACK)),c.save(),this.applyFontStyle(),c.fillText(this.text,m,p),c.restore(),this}}]),b}(k.Element)},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function g(){for(var a=arguments.length,b=Array(a),c=0;c3)throw new j.Vex.RERR("InvalidParameter","The style must be one found in PedalMarking.Styles");return this.style=a,this}},{key:"setLine",value:function(a){return this.line=a,this}},{key:"drawBracketed",value:function(){var a=this.context,c=!1,d=void 0,e=void 0,f=this;this.notes.forEach(function(g,i,k){c=!c;var l=g.getAbsoluteX(),m=g.getStave().getYForBottomText(f.line+3);if(l0||b===!0;return!b||e>0||(this.pos=d),h?this.matchSuccess():this.matchFail(d),{success:h,results:c,numMatches:e}}},{key:"expectZeroOrMore",value:function(a){return this.expectOneOrMore(a,!0)}},{key:"expect",value:function(a){e("Evaluating rules:",a);var b=void 0;if(!a)throw new i("Invalid Rule: "+a,a);var c=a.bind(this.grammar)();if(c.token)b=this.matchToken(c.token,c.noSpace===!0),b.success&&(this.pos+=b.incrementPos);else{if(!c.expect)throw new i("Bad grammar! No `token` or `expect` property",c);b=c.oneOrMore?this.expectOneOrMore(c):c.zeroOrMore?this.expectZeroOrMore(c):this.expectOne(c)}return b.matches=[],b.results&&b.results.forEach(function(a){return b.matches.push(f(a))}),c.run&&b.success&&c.run(b),b}}]),a}()}])}); //# sourceMappingURL=vexflow-min.js.map