// abc2svg - ABC to SVG translator
// @source: https://chiselapp.com/user/moinejf/repository/abc2svg
// Copyright (C) 2014-2025 Jean-François Moine - LGPL3+
// commit [a5c7a50620]
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(u){var y=0;return function(){return y<u.length?{done:!1,value:u[y++]}:{done:!0}}};$jscomp.arrayIterator=function(u){return{next:$jscomp.arrayIteratorImpl(u)}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(u,y,E){u!=Array.prototype&&u!=Object.prototype&&(u[y]=E.value)};$jscomp.getGlobal=function(u){u=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,u];for(var y=0;y<u.length;++y){var E=u[y];if(E&&E.Math==Math)return E}return globalThis};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(u,y){this.$jscomp$symbol$id_=u;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:y})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function u(E){if(this instanceof u)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(E||"")+"_"+y++,E)}var y=0;return u}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var u=$jscomp.global.Symbol.iterator;u||(u=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[u]&&$jscomp.defineProperty(Array.prototype,u,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var u=$jscomp.global.Symbol.asyncIterator;u||(u=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(u){$jscomp.initSymbolIterator();u={next:u};u[$jscomp.global.Symbol.iterator]=function(){return this};return u};
$jscomp.iteratorFromArray=function(u,y){$jscomp.initSymbolIterator();u instanceof String&&(u+="");var E=0,w={next:function(){if(E<u.length){var F=E++;return{value:y(F,u[F]),done:!1}}w.next=function(){return{done:!0,value:void 0}};return w.next()}};w[Symbol.iterator]=function(){return w};return w};
$jscomp.polyfill=function(u,y,E,w){if(y){E=$jscomp.global;u=u.split(".");for(w=0;w<u.length-1;w++){var F=u[w];F in E||(E[F]={});E=E[F]}u=u[u.length-1];w=E[u];y=y(w);y!=w&&null!=y&&$jscomp.defineProperty(E,u,{configurable:!0,writable:!0,value:y})}};$jscomp.polyfill("Array.prototype.keys",function(u){return u?u:function(){return $jscomp.iteratorFromArray(this,function(u){return u})}},"es6","es3");if("undefined"==typeof abc2svg)var abc2svg={};
abc2svg.C={BLEN:1536,BAR:0,CLEF:1,CUSTOS:2,SM:3,GRACE:4,KEY:5,METER:6,MREST:7,NOTE:8,PART:9,REST:10,SPACE:11,STAVES:12,STBRK:13,TEMPO:14,BLOCK:16,REMARK:17,FULL:0,EMPTY:1,OVAL:2,OVALBARS:3,SQUARE:4,SL_ABOVE:1,SL_BELOW:2,SL_AUTO:3,SL_HIDDEN:4,SL_DOTTED:8,SL_ALI_MSK:112,SL_ALIGN:16,SL_CENTER:32,SL_CLOSE:64};abc2svg.sym_name="bar clef custos smark grace key meter Zrest note part rest yspace staves Break tempo  block remark".split(" ");
abc2svg.keys=[new Int8Array([-1,-1,-1,-1,-1,-1,-1]),new Int8Array([-1,-1,-1,0,-1,-1,-1]),new Int8Array([0,-1,-1,0,-1,-1,-1]),new Int8Array([0,-1,-1,0,0,-1,-1]),new Int8Array([0,0,-1,0,0,-1,-1]),new Int8Array([0,0,-1,0,0,0,-1]),new Int8Array([0,0,0,0,0,0,-1]),new Int8Array([0,0,0,0,0,0,0]),new Int8Array([0,0,0,1,0,0,0]),new Int8Array([1,0,0,1,0,0,0]),new Int8Array([1,0,0,1,1,0,0]),new Int8Array([1,1,0,1,1,0,0]),new Int8Array([1,1,0,1,1,1,0]),new Int8Array([1,1,1,1,1,1,0]),new Int8Array([1,1,1,1,1,
1,1])];abc2svg.p_b40=new Int8Array([2,8,14,19,25,31,37]);abc2svg.b40_p=new Int8Array([0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6]);abc2svg.b40_a=new Int8Array([-2,-1,0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2,-2,-1,0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2]);abc2svg.b40_m=new Int8Array([-2,-1,0,1,2,0,0,1,2,3,4,0,2,3,4,5,6,3,4,5,6,7,0,5,6,7,8,9,0,7,8,9,10,11,0,9,10,11,12,13]);
abc2svg.b40l5=new Int8Array([-14,-7,0,7,14,0,-12,-5,2,9,16,0,-10,-3,4,11,18,-15,-8,-1,6,13,0,-13,-6,1,8,15,0,-11,-4,3,10,17,0,-9,-2,5,12,19]);abc2svg.isb40=new Int8Array([0,1,6,7,12,17,18,23,24,29,30,35]);abc2svg.pab40=function(u,y){u+=19;u=40*(u/7|0)+abc2svg.p_b40[u%7];y&&3!=y&&(u+=y);return u};abc2svg.b40p=function(u){return 7*(u/40|0)+abc2svg.b40_p[u%40]-19};abc2svg.b40a=function(u){return abc2svg.b40_a[u%40]};abc2svg.b40m=function(u){return 12*(u/40|0)+abc2svg.b40_m[u%40]};
abc2svg.ch_alias={maj:"",min:"m","-":"m","\u00b0":"dim","+":"aug","+5":"aug",maj7:"M7","\u03947":"M7","\u0394":"M7",min7:"m7","-7":"m7","\u00f87":"m7b5","\u00b07":"dim7","min+7":"m+7",aug7:"+7","7+5":"+7","7#5":"+7",sus:"sus4","7sus":"7sus4"};abc2svg.font_tb=[];abc2svg.font_st={};abc2svg.hdn={};abc2svg.ft_w={thin:100,extralight:200,light:300,regular:400,medium:500,semi:600,demi:600,semibold:600,demibold:600,bold:700,extrabold:800,ultrabold:800,black:900,heavy:900};abc2svg.ft_re=/-?Thin|-?Extra Light|-?Light|-?Regular|-?Medium|-?[DS]emi|-?[DS]emi[ -]?Bold|-?Bold|-?Extra[ -]?Bold|-?Ultra[ -]?Bold|-?Black|-?Heavy\//i;
abc2svg.lypre=/^\d.+\.|^[\d-]+\.?|^\w+:|^\(|^\)/;abc2svg.rat=function(u,y){for(var E,w,F=0,v=0,Ka=1,Q=1;0!=y;)w=y,E=u/y|0,y=u%y,u=w,w=F+E*Ka,F=Ka,Ka=w,w=Q+E*v,Q=v,v=w;return[Ka,v]};abc2svg.pitcmp=function(u,y){return u.pit-y.pit};
abc2svg.Abc=function(u){function y(a,b){if(!a)return a;var c=new a.constructor,d;for(d in a)a.hasOwnProperty(d)&&(c[d]=b&&"object"==typeof a[d]?y(a[d],b-1):a[d]);return c}function E(a,b,c,d){var e,f;if(u.errbld){switch(a){case 0:a="warn";break;case 1:a="error";break;default:a="fatal"}u.errbld(a,b,c,d)}else{if(void 0!=d&&0<=d){for(e=f=0;;){var g=r.file.indexOf("\n",e);if(0>g||g>d)break;f++;e=g+1}e=d-e}d="";c&&(d=c,f&&(d+=":"+(f+1)+":"+(e+1)),d+=" ");switch(a){case 0:d+="Warning: ";break;case 1:d+=
"Error: ";break;default:d+="Internal bug: "}u.errmsg(d+b,f,e)}}function w(a,b,c,d,e,f,g){var h;if(!(a<p.quiet)){if(b){if(b.err)return;b.err=!0}u.textrans&&(h=u.textrans[c])&&(c=h);3<arguments.length&&(c=c.replace(/\$./g,function(a){switch(a){case "$1":return d;case "$2":return e;case "$3":return f;default:return g}}));b&&b.fname?E(a,c,b.fname,b.istart):E(a,c)}}function F(){this.index=0;F.prototype.char=function(){return this.buffer[this.index]};F.prototype.next_char=function(){return this.buffer[++this.index]};
F.prototype.get_int=function(){for(var a=0,b=this.buffer[this.index];"0"<=b&&"9">=b;)a=10*a+Number(b),b=this.next_char();return a}}function v(a,b,c,d,e,f){w(a,{fname:r.fname,istart:r.istart+r.line.index},b,c,d,e,f)}function Ka(a){eval('"use strict";\n'+a)}function Q(a,b,c,d){a=x[a];var e=c/2|0;c=(c+d)/2|0;0>e&&(e=0,0>c&&(c=0));c>=Qa&&(c=Qa-1,e>c&&(e=c));if(b)for(b=a.top[e++];e<=c;)b<a.top[e]&&(b=a.top[e]),e++;else for(b=a.bot[e++];e<=c;)b>a.bot[e]&&(b=a.bot[e]),e++;return b}function Y(a,b,c,d,e){a=
x[a];var f=c/2|0;c=(c+d)/2|0;0>f&&(f=0,0>c&&(c=0));c>=Qa&&(c=Qa-1,f>c&&(f=c));if(b)for(;f<=c;)a.top[f]<e&&(a.top[f]=e),f++;else for(;f<=c;)a.bot[f]>e&&(a.bot[f]=e),f++}function af(a){function b(){for(var b,c=a.ix;0<--c&&(b=ha[c],b&&b.s==f););for(;;){c++;b=ha[c];if(!b||b.s!=f)break;if(b!=a&&!(e^b.up)&&6==b.dd.func){m-=b.dd.wl;break}}}if(!a.ldst){var c=a.dd,d=a.prev,e=a.start.up,f=a.s,g=f.st,h=a.start.s,k=h.x;d&&(k=d.s.x+a.dd.wl+2,d.val-=d.dd.wr,8>d.val&&(d.val=8));a.st=g;a.up=e;(function(){for(var b,
c=a.start,d=c.s,f=c.ix;0<=--f&&(b=ha[f],b&&b.s==d););for(;;){f++;b=ha[f];if(!b||b.s!=d)break;if(b!=c&&!(e^b.up||"trill"!=b.dd.name&&6!=b.dd.func)){k+=b.dd.wr+2;break}}})();if(a.defl.noen){var m=a.x-k;20>m&&(k=a.x-20-3,m=20)}else m=f.x-k-4,b(a),20>m&&(m=20);var n=Q(g,e,k-c.wl,m);if(e){var q=x[h.st].topbar+2;n<q&&(n=q)}else q=x[h.st].botbar-2,n>q&&(n=q),n-=c.h;if(d)if(e)n<d.y&&(n=d.y);else if(n>=d.y)n=d.y;else{do d.y=n,d=d.prev;while(d)}a.lden=!1;a.has_val=!0;a.val=m;a.x=k;a.y=n;n=e?n+c.h:n-c.hd;Y(g,
e,k,m,n);e?h.ymx=f.ymx=n:h.ymn=f.ymn=n}}function Nb(a){if(!a.ldst)if(a.start)af(a);else{var b=a.up,c=a.s,d=a.dd,e=a.x,f=d.wl+d.wr;switch(d.glyph){case "lphr":case "mphr":case "sphr":case "short":case "tick":c.type==m.BAR&&(c.invis=1);case "brth":case "caes":var g=x[c.st].topbar+2+d.hd;if(!c.invis){"brth"==d.glyph&&g<c.ymx&&(g=c.ymx);for(c=c.ts_next;c&&!c.seqst;c=c.ts_next);e+=.45*((c?c.x:la)-e)}a.x=e;a.y=g;return}c.nhd&&(e+=c.notes[0<=c.stem?0:c.nhd].shhd);switch(d.ty){case "@":case "<":case ">":g=
a.y}if(void 0==g)if(b)g=Q(c.st,!0,e-d.wl,f)+d.hd,a.y>g&&(g=a.y),c.ymx=g+d.h;else{g=Q(c.st,!1,e-d.wl,f)-d.h;a.y<g&&(g=a.y);if("fermata"==d.name||"accent"==d.glyph||"roll"==d.glyph)a.inv=1;c.ymn=g-d.hd}5<d.wr&&e>la-d.wr&&(a.x=e=la-d.wr);b?Y(c.st,1,e-d.wl,f,g+d.h):Y(c.st,0,e-d.wl,f,g-d.hd);a.y=g}}function vc(a,b){b||(b=a);var c,d;(d=Ob[b])||(/\d[()]$/.test(b)?d=Ob[b.replace(/\d/,"")]:/^\d$/.test(b)&&(d="3 fng 5,5 3 3 "+b));if(d)if(c=d.match(/(\d+)\s+(.+?)\s+([0-9.,]+)\s+([0-9.]+)\s+([0-9.]+)/)){var e=
Number(c[1]),f=c[3],g=parseFloat(c[4]),h=parseFloat(c[5]);if(isNaN(e))w(1,null,"%%deco: bad C function value '$1'",c[1]);else if(10<e&&(32>e||45<e))w(1,null,"%%deco: bad C function index '$1'",e);else{if(0<f.indexOf(",")){f=f.split(",");var k=f[1];f=f[0]}else k=0;if(50<f||80<g||80<h)w(1,null,"%%deco: abnormal h/wl/wr value '$1'",d);else{b=wb[a];b||(b={name:a},wb[a]=b);b.func=0==a.indexOf("head-")?9:e;b.glyph=c[2];b.h=Number(f);b.hd=Number(k);b.wl=g;b.wr=h;if(c=d.replace(c[0],"").trim()){'"'==c[0]&&
(c=c.slice(1,-1));if("@"==c[0]){d=c.match(/^@([0-9.-]+),([0-9.-]+);?/);if(!d){w(1,null,"%%deco: bad position '$1'",c);return}b.dx=+d[1];b.dy=+d[2];c=c.replace(d[0],"")}b.str=c}6==b.func&&void 0==b.str&&(b.str=a);d=a.slice(-1);if("("==d||")"==d&&0>a.indexOf("("))if(b.str=null,a=a.slice(0,-1)+("("==d?")":"("),a=wb[a])"("==d?(b.dd_en=a,a.dd_st=b):(b.dd_st=a,a.dd_en=b);return b}}}else w(1,null,"Invalid decoration '$1'",a);else p.decoerr&&w(1,null,"Unknown decoration '$1'",a)}function Cd(a,b,c){var d=
pb[a],e=a.slice(0,-1)+("("==a.slice(-1)?")":"(");d?w(1,b,"Conflict on !$1!",a):(c.tie_ty&&(l.tie_s=null),c.s=b,(d=pb[e])?(")"==a.slice(-1)&&(d=c,c=pb[e]),pb[e]=null,c.midi!=d.midi||c.s.time+c.dur!=d.s.time?w(1,b,"Bad tie"):(c.tie_ty||(c.tie_ty=m.SL_AUTO),c.tie_e=d,d.tie_s=c,c.s.ti1=d.s.ti2=!0)):pb[a]=c)}function Dd(a){var b,c=wb[a];if(c)return c;if(0<="<>^_@".indexOf(a[0])&&!/^([>^]|[<>]\d?[()])$/.test(a)){var d=a[0];"@"==d&&(d=(b=a.match(/@([-\d]+),([-\d]+)/))?b[0]:"");c=vc(a,a.replace(d,""))}else c=
vc(a);if(c)return d&&("@"==d[0]&&(c.x=Number(b[1]),c.y=Number(b[2]),d="@"),c.ty=d),c}function dc(a,b){function c(){var c,d=b;if(a.type!=m.NOTE)return 1;for(;d&&d.type!=m.NOTE;)d=d.prev;if(!d)return 1;for(c=0;c<d.a_dd.length;c++)if(d.a_dd[c].name==f.name)return a.fg||(a.fg=[]),a.fg.push({ty:1,s:d,nm:f.name}),d.fg||(d.fg=[]),d.fg.push({ty:0,s:a,nm:f.name}),0;return 1}for(var d,e,f,g,h,k;;){g=ma.shift();if(!g)break;if(f=Dd(g)){switch(f.func){case 0:if(a.type==m.BAR&&"dot"==g){a.bar_dotted=!0;continue}case 1:"|"==
f.glyph[0]&&(a.decstm=f.h);case 2:if(!a.notes){w(1,a,G.must_note_rest,g);continue}break;case 3:if(k&&"fng"==f.glyph)for(d=0;5>=d;d++)Ob[d.toString()]="5 fng 5,5 3 3 "+d,wb[d.toString()]&&(wb[d.toString()].func=5);break;case 4:case 5:if(d=g.match(/1?[85]([vm])([ab])([()])/))e="v"==d[1]?1:2,"b"==d[2]&&(e=-e),a.ottava||(a.ottava=[]),a.ottava["("==d[3]?0:1]=e,oa.ottava=1;break;case 8:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}d=a.notes[a.nhd];d.a_dd||(d.a_dd=[]);d.a_dd.push(f);continue;case 9:if(!a.notes){w(1,
a,G.must_note_rest,g);continue}for(e=0;e<=a.nhd;e++)d=a.notes[e],d.invis=!0,d.a_dd||(d.a_dd=[]),d.a_dd.push(f);continue;case 10:if(a.notes)for(e=0;e<=a.nhd;e++)a.notes[e].color=g;else a.color=g;break;case 32:a.invis=!0;break;case 33:if(a.type!=m.BAR){w(1,a,"!beamon! must be on a bar");continue}a.beam_on=!0;break;case 34:if(a.type!=m.NOTE||!b||b.type!=m.NOTE||a.dur!=b.dur){w(1,a,"!$1! must be on the last of a couple of notes",g);continue}a.trem2=!0;a.beam_end=!0;a.beam_st=!1;b.beam_st=!0;b.beam_end=
!1;a.ntrem=b.ntrem=Number(g[4]);for(e=0;e<=a.nhd;e++)a.notes[e].dur*=2;for(e=0;e<=b.nhd;e++)b.notes[e].dur*=2;break;case 35:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}a.xstem=!0;break;case 36:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}"1"==g[6]?a.beam_br1=!0:a.beam_br2=!0;break;case 37:a.rbstop=1;break;case 38:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}a.trem1=!0;a.ntrem=g.length;break;case 39:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}a.feathered_beam="a"==g[5]?1:-1;break;
case 40:a.stemless=!0;break;case 41:a.rbstop=2;break;case 42:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}if(!a.notes[0].acc)continue;g="sacc"+a.notes[0].acc.toString();f=wb[g];if(!f&&(f=vc(g),!f)){w(1,a,G.bad_val,"!editorial!");continue}delete a.notes[0].acc;l.acc[a.notes[0].pit+19]=0;break;case 43:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}e=l.acc[a.notes[0].pit+19];if(a.notes[0].acc||!e)continue;h=1;break;case 44:if(a.type!=m.NOTE){w(1,a,G.must_note,g);continue}Cd(g,a,a.notes[0]);continue;
case 45:k=1;continue}if(k&&"fng"==f.glyph&&(k=0,c())){w(1,a,"!$1! must be on the last of a couple of notes",g);continue}a.a_dd||(a.a_dd=[]);a.a_dd.push(f)}}h&&(ma.push("cacc"+e),Fc(a,a.notes[0]))}function Fc(a,b){for(var c,d;;){c=ma.shift();if(!c)break;if(d=Dd(c)){switch(d.func){case 1:case 3:case 8:break;default:w(1,a,"Cannot have !$1! on a head",c);continue;case 9:b.invis=!0;break;case 32:b.invis=!0;continue;case 10:b.color=c;continue;case 40:a.stemless=!0;continue;case 44:Cd(c,a,b);continue}b.a_dd||
(b.a_dd=[]);b.a_dd.push(d)}}}function $c(a,b){var c,d=b,e=a.wr,f=a.a_dd,g=f.length;for(c=0;c<g;c++){var h=f[c];switch(h.func){case 1:case 2:12>d&&(d=12);break;case 3:switch(h.glyph){case "brth":case "lphr":case "mphr":case "sphr":20>a.wr&&(a.wr=20);break;default:var k=h.wl+2;d<k&&(d=k)}default:switch(h.ty){case "<":k=b+h.wl+h.wr+6;d<k&&(d=k);break;case ">":k=e+h.wl+h.wr+6,a.wr<k&&(a.wr=k)}}}return d}function bf(){function a(a){var b=a.x-a.wl,c=ha.length;for(a=0;a<c;a++){var d=ha[a];d.ix=a;d.s.x=d.x=
b;d.defl.nost=!0}}function b(a){if(!a.invis||!a.play){if(a.a_dd){var b,c=a.a_dd.length;void 0==a.y&&(a.y=0);for(b=0;b<c;b++){var d=a.a_dd[b];var e=a.x;var O=a.y;switch(d.func){default:if(10<=d.func)continue;var n=0;break;case 3:case 4:case 5:n=a.pos.orn;break;case 6:n=a.pos.dyn}switch(d.ty){case "^":n=n&-8|m.SL_ABOVE;break;case "_":n=n&-8|m.SL_BELOW;break;case "<":case ">":n=n&7|m.SL_CLOSE;"<"==d.ty?(e-=d.wr+8,a.notes[0].acc&&(e-=8)):e+=d.wl+8;O=3*(a.notes[0].pit-18)-(d.h-d.hd)/2;break;case "@":e+=
d.x,O+=d.y}if((n&7)!=m.SL_HIDDEN){e={s:a,dd:d,st:a.st,ix:ha.length,defl:{},x:e,y:O};n&&(e.pos=n);O=0;if("^"==d.ty)O=1;else if("_"!=d.ty)switch(d.func){case 0:O=a.multi?0<a.multi:0>a.stem;break;case 3:case 5:a:{switch(n&7){case m.SL_ABOVE:O=1;break a;case m.SL_BELOW:O=0;break a}O=0<a.multi||!a.second}break;case 6:a:{switch(n&7){case m.SL_ABOVE:O=!0;break a;case m.SL_BELOW:O=!1;break a}O=a.multi?0<a.multi:a.p_v.have_ly?(a.pos.voc&7)!=m.SL_ABOVE:!1}}e.up=O;0<=d.name.indexOf("inverted")&&(e.inv=1);a.type!=
m.BAR||d.ty||(e.x-=a.wl/2-2);ha.push(e);d.dd_en?e.ldst=!0:d.dd_st&&(e.lden=!0,e.defl.nost=!0);if(Ed[d.func])Ed[d.func](e)}}}if(a.notes)for(d=0;d<a.notes.length;d++)if(a.notes[d].a_dd){e=a;O=d;var q=e.notes[O],l=q.a_dd.length,z=e.x;for(n=0;n<l;n++)b=q.a_dd[n],c={s:e,dd:b,st:e.st,m:O,ix:0,defl:{},x:z,y:3*(q.pit-18)-(b.h-b.hd)/2},b.ty?"@"==b.ty?(c.x+=b.x,c.y+=b.y):(c.y-=(b.h-b.hd)/2,"<"==b.ty?(c.x-=b.wr+8,e.notes[O].acc&&(z-=8)):">"==b.ty&&(c.x+=b.wl+8)):(q.shhd&&(c.x+=q.shhd*B.scale),q.shac&&(c.x-=
q.shac),8!=b.func&&(c.x-=b.wl+b.wr+3)),ha.push(c),b.dd_en?c.ldst=!0:b.dd_st&&(c.lden=!0,c.defl.nost=!0)}}}var c,d;for(c=M;c;c=c.ts_next){switch(c.type){case m.CLEF:case m.KEY:case m.METER:continue}break}for(ha.length&&a(c);c;c=c.ts_next){switch(c.type){case m.BAR:case m.MREST:case m.NOTE:case m.REST:case m.SPACE:break;case m.GRACE:for(d=c.extra;d;d=d.next)b(d);break;default:continue}b(c)}(function(){var a,b=ha.length;for(a=0;a<b;a++){var c=ha[a];if(c.ldst){var d=c.dd;var k=d.dd_en;var m=c.s;var n=
m.v;for(d=a+1;d<b;d++){var q=ha[d];if(!q.start&&q.dd==k&&q.s.v==n)break}if(d==b)for(n=m.st,d=a+1;d<b&&(q=ha[d],q.start||q.dd!=k||q.s.st!=n);d++);d==b&&(q={s:m,st:c.st,dd:k,ix:ha.length-1,x:la-6,y:m.y,cont:!0,lden:!0,defl:{noen:!0}},q.x<m.x+10&&(q.x=m.x+10),void 0!=c.m&&(q.m=c.m),ha.push(q));q.start=c;q.defl.nost=c.defl.nost;for(d=a;0<=--d;)if(c=ha[d],c.start){if(c.s.time<m.time)break;if(c.dd.name==q.dd.name){q.prev=c;break}}}}for(a=0;a<b;a++)q=ha[a],q.lden&&!q.start&&(m=q.s,c={s:Fd(m),st:q.st,dd:q.dd.dd_st,
ix:ha.length-1,y:m.y,ldst:!0},c.x=c.s.x+c.s.wr,void 0!=q.m&&(c.m=q.m),ha.push(c),q.start=c)})()}function cf(){var a,b=ha.length;for(a=0;a<b;a++){var c=ha[a];var d=c.dd;d=d.func;if(Gd[d]&&void 0==c.m)Gd[d](c)}}function df(){var a,b;var c=Array(V+1);var d=ha.length;for(a=0;a<=V;a++)c[a]={ymin:0,ymax:0};for(a=0;a<d;a++){var e=ha[a];(b=e.dd)&&ad[b.func]&&void 0==e.m&&"<"!=b.ty&&">"!=b.ty&&"@"!=b.ty&&(ad[b.func](e),6==b.func&&!b.dd_en&&((e.pos&m.SL_ALI_MSK)==m.SL_ALIGN||0==(e.pos&m.SL_ALI_MSK)&&0<e.s.fmt.dynalign)&&
(e.up?e.y>c[e.st].ymax&&(c[e.st].ymax=e.y):e.y<c[e.st].ymin&&(c[e.st].ymin=e.y)))}for(a=0;a<d;a++)if(e=ha[a],b=e.dd)if("@"==b.ty){var f=e.y;0<f?(f=f+b.h+2,f>x[e.st].ann_top&&(x[e.st].ann_top=f)):(f=f-b.hd-2,f<x[e.st].ann_bot&&(x[e.st].ann_bot=f))}else if(6==b.func&&"<"!=b.ty&&">"!=b.ty&&!b.dd_en){var g=e.val||b.wl+b.wr;(e.pos&m.SL_ALI_MSK)==m.SL_ALIGN||0==(e.pos&m.SL_ALI_MSK)&&0<e.s.fmt.dynalign?(f=e.up?c[e.st].ymax:c[e.st].ymin,e.y=f):f=e.y;f=e.up?f+b.h:f-b.hd;Y(e.st,e.up,e.x,g,f)}for(a=0;a<d;a++)e=
ha[a],(b=e.dd)&&!b.dd_en&&"ped"==b.name.slice(0,3)&&(g=e.val||10,e.y=Q(e.st,0,e.x,g)-(b.dd_st&&p.pedline?10:b.h),Y(e.st,0,e.x,g,e.y));ef();for(a=0;a<C.length;a++)if(c=C[a],!c.second&&c.sym&&!c.ignore){e=void 0;var h;b=c;c=x[b.st].topbar+15;for(f=b.sym;f;f=f.next)if(f.type==m.BAR&&f.rbstart&&!f.norepbra){if(!f.next)break;e||(e=f,T("repeat"));for(h=f;f.next&&(f=f.next,!f.rbstop););d=h.x;h.xsh&&(d+=h.xsh);g=Q(b.st,!0,d,f.x-d)+2;c<g&&(c=g);2==h.rbstart&&(g=Q(b.st,!0,d,3)+10,c<g&&(c=g));2==f.rbstop&&(g=
Q(b.st,!0,f.x-3,3)+10,c<g&&(c=g));h.text&&(g=ua(h.text),g=Q(b.st,!0,d+4,g[0])+g[1],c<g&&(c=g));f.rbstart&&(f=f.prev)}if(f=e)for(La(b.st,!0),g=c*x[b.st].staffscale;f;f=f.next)if(f.rbstart&&!f.norepbra){for(h=f;f.next&&(f=f.next,!f.rbstop););if(h==f)break;d=h.x;h.xsh&&(d+=h.xsh);0<p.measurenb&f.bar_num&&f.bar_num%p.measurenb&&(d+=6);e=f.type!=m.BAR?f.rbstop?0:f.x-la+4:1<f.bar_type.length&&"[]"!=f.bar_type||"]"==f.bar_type?0<h.st&&!(K.staves[h.st-1].flags&64)?f.wl:":"==f.bar_type.slice(-1)?12:":"!=f.bar_type[0]?
0:8:f.rbstop&&!f.rbstart?0:8;e=f.x-d-e;f.next||f.rbstop||b.bar_start||(b.bar_start=bd(f),b.bar_start.bar_type="",b.bar_start.rbstart=1);h.text&&na(d+4,g-A.curfont.size,h.text);ib(d,g);2==h.rbstart&&(D+="m0 10v-10");D+="h"+e.toFixed(1);2==f.rbstop&&(D+="v10");D+='"/>\n';Y(h.st,!0,d,e,c+2);f.rbstart&&(f=f.prev)}}}function ff(){var a;var b=K;for(a=0;a<=V&&!b.st_print[a];a++);if(!(a>V)){La(a);if(1!=x[a].staffscale){var c=Ma("measure").size;xb("measurefont","* "+(c/x[a].staffscale).toString())}T("measure");
var d=yb("0")*A.curfont.swfac;var e=M;var f=A.nbar;if(1<f)if(0==p.measurenb){var g=!0;var h=Q(a,!0,0,20);h<x[a].topbar+14&&(h=x[a].topbar+14);na(0,h-.2*A.curfont.size,f.toString());Y(a,!0,0,20,h+A.curfont.size+2)}else if(0==f%p.measurenb){for(;;e=e.ts_next){switch(e.type){case m.CLEF:case m.KEY:case m.METER:case m.STBRK:continue}break}if(e.type!=m.BAR||!e.bar_num){g=!0;var k=d;10<=f&&(k*=100<=f?3:2);A.curfont.pad&&(k+=2*A.curfont.pad);b=(e.prev?e.prev.x+e.prev.wr/2:e.x-e.wl)-k;h=Q(a,!0,b,k)+5;h<x[a].topbar+
6&&(h=x[a].topbar+6);h+=A.curfont.pad;na(b,h-.2*A.curfont.size,f.toString());h+=A.curfont.size+A.curfont.pad;Y(a,!0,b,k,h)}}for(;e;e=e.ts_next){switch(e.type){case m.STAVES:b=e.sy;for(a=0;a<V&&!b.st_print[a];a++);La(a);continue;default:continue;case m.BAR:if(!e.bar_num||1>=e.bar_num)continue}f=e.bar_num;0!=p.measurenb&&0==f%p.measurenb&&e.next&&!e.bar_mrep&&(g||(g=!0),k=d,10<=f&&(k*=100<=f?3:2),A.curfont.pad&&(k+=2*A.curfont.pad),b=e.x,h=Q(a,!0,b,k),h<x[a].topbar+6&&(h=x[a].topbar+6),e.next.type==
m.NOTE&&(0<e.next.stem?h<e.next.ys-A.curfont.size&&(h=e.next.ys-A.curfont.size):h<e.next.y&&(h=e.next.y)),h+=2+A.curfont.pad,na(b,h-.2*A.curfont.size,f.toString()),h+=A.curfont.size+A.curfont.pad,Y(a,!0,b,k,h))}A.nbar=f;c&&xb("measurefont","* "+c.toString())}}function gf(){var a,b,c;var d=K;for(c=0;c<=V&&!d.st_print[c];c++);if(!(c>V)){La(c,1);var e=x[c].topbar+2,f=0,g=1,h=-100;for(d=M;d;d=d.ts_next)if((a=d.part)&&!a.invis){if(!k){var k=d;T("parts");var O=A.curfont.size+2+2*A.curfont.pad}void 0==a.x&&
(a.x=d.x-10);var n=a.text;p.partname&&(a.ntxt=n=Hd(n)[2]);var q=ua(n)[0];a=Q(c,!0,a.x,q+3);e<a&&(e=a)}if(k)for(Ra(-1),e*=x[c].staffscale,d=k;d;d=d.ts_next)if((a=d.part)&&!a.invis){n=a.ntxt||a.text;q=ua(n)[0];if(u.anno_start||u.anno_stop)a.wl=0,a.wr=q,a.ymn=e,a.ymx=a.ymn+O,pa(a);na(a.x,e+A.curfont.pad+.22*A.curfont.size,n);Y(c,1,a.x,q+3,(e+O)/x[c].staffscale);Pb(a)}e=x[c].topbar+6;for(d=M;d;d=d.ts_next)d.type!=m.TEMPO||d.invis||(b||(b=d),q=d.tempo_wh[0],a=Q(c,!0,d.x-16,q),a>e&&(e=a),h>=d.x-16&&!(f&
g>>1)&&(f|=g),g<<=1,h=d.x-16+q);if(b)for(Ra(-1),T("tempo"),e=(e+2)*x[c].staffscale,d=b;d;d=d.ts_next)if(d.type==m.TEMPO&&!d.invis){q=d.tempo_wh[0];O=d.tempo_wh[1];a=e;f&1&&(a+=O);if(u.anno_start||u.anno_stop)d.wl=16,d.wr=q-16,d.ymn=a,d.ymx=d.ymn+14,pa(d);k=void 0;b=d;g=d.x-16;h=a;T("tempo");A.curfont.box&&(A.curfont.box=!1,k=b.tempo_wh[1]+2);D+='<text class="'+Ib(A.curfont)+'" x="';$a(g,'" y="',h+.22*A.curfont.size);D+='">'+b.tempo_str+"</text>\n";k&&(A.curfont.box=!0,D+='<rect class="stroke" x="',
$a(g-2,'" y="',h+k-1),D+='" width="'+(b.tempo_wh[0]+4).toFixed(1)+'" height="'+k.toFixed(1)+'"/>\n');b.invis=!0;Pb(d);Y(c,1,d.x-16,q,(a+O+2)/x[c].staffscale);f>>=1}}}function hf(a,b,c,d){function e(a){return 6*Math.round((a+12)/6)-12-a}var f=a?3.5:5;a=a?1.8:3.2;if(0<b){b=d-(c-1)*f-a;if(26<b)return 0;c=d}else{c=d+(c-1)*f+a;if(-2>c)return 0;b=d}d=e(c-.25);b=e(b+.25);return d*d>b*b?b:d}function Id(a){var b;a=y(a);a.invis=!0;delete a.extra;delete a.text;delete a.a_gch;delete a.a_ly;delete a.a_dd;delete a.tp;
a.notes=y(a.notes);for(b=0;b<=a.nhd;b++){var c=a.notes[b]=y(a.notes[b]);delete c.a_dd}return a}function Jd(a){function b(a,b,c,d,e,f){var g=e.s1,k=g.nflags;g.ntrem&&(k-=g.ntrem);g.trem2&&f>k&&(g.dur>=m.BLEN/2?(a=g.x+6,b=e.s2.x-6):g.dur<m.BLEN/4&&(f=b-a,16>f?(a+=f/4,b-=f/4):(a+=5,b-=6)));c=e.a*a+e.b-c;b=(b-a)/B.scale;e=e.a*b*B.stsc;ib(a,c,!0);D+="l"+b.toFixed(1)+" "+(-e).toFixed(1)+"v"+d.toFixed(1)+"l"+(-b).toFixed(1)+" "+e.toFixed(1)+'z"/>\n'}var c,d,e,f,g=0,h=a.s1,k=a.s2;pa(h,"beam");if(h.grace){var O=
3.5;var n=3.2;var q=.29;var l=1.8}else O=5,n=7,q=.34,l=3.2;l/=B.scale;var z=h.stem;h.stem!=k.stem&&h.nflags>k.nflags&&(z=k.stem);0>z&&(l=-l);b(h.xs-q,k.xs+q,0,l,a,1);var t=0;for(c=h;c.type==m.NOTE&&c.stem!=z&&(c.ys=a.a*c.xs+a.b-x[c.st].y+O*(c.nflags-1)*c.stem-l),c!=k;c=c.next);h.feathered_beam&&(t=O/(k.xs-h.xs),0<h.feathered_beam?(t=-t,O=t*h.xs):O=t*k.xs,t*=z);q=0;for(d=2;d<=a.nflags;d++)for(q+=O,0!=t&&(a.a+=t),c=h;;c=c.next){if(!(c.type!=m.NOTE||c.nflags<d))if(c.trem1&&d>c.nflags-c.ntrem){var p=
c.dur>=m.BLEN/2?c.x:c.xs;b(p-5,p+5,(q+2.5)*z,l,a,d)}else{for(e=c;c!=k;){var r=c.next;if(r.type==m.NOTE||r.type==m.REST)if(r.trem1){if(r.nflags-r.ntrem<d)break}else if(r.nflags<d)break;if(r.beam_br1||r.beam_br2&&2<d)break;c=r}for(f=c;f.type!=m.NOTE;)f=f.prev;p=e.xs;var u=q*z;if(e==f){if(e==h)p+=n;else if(e==k)p-=n;else if(e.beam_br1||e.beam_br2&&2<d)p+=n;else{for(r=e.next;r.type!=m.NOTE;)r=r.next;if(r.beam_br1||r.beam_br2&&2<d)p-=n;else{for(e=e.prev;e.type!=m.NOTE;)e=e.prev;p=e.nflags<r.nflags||e.nflags==
r.nflags&&e.dots<r.dots?p+n:p-n}}e.stem!=z&&(g-=O,u=g*z,e.ys=a.a*e.xs+a.b-x[e.st].y-l)}else if(e.stem==f.stem&&e.stem!=z)for(g-=O,u=g*z,c=e;c.type==m.NOTE&&(c.ys=a.a*c.xs+a.b-x[c.st].y-l),c!=f;c=c.next);b(p,f.xs,u,l,a,d)}if(c==k)break}h.tmp?Na(h):k.tmp&&Na(k);Pb(h,"beam")}function Kd(a){function b(a,b,c){for(var d,e;!K.st_print[b];){if(K.staves[b].flags&c)return;b++}for(d=e=b;;){K.st_print[d]&&(e=d);if(K.staves[d].flags&c)break;d++}b=x[b].y+x[b].topbar*x[b].staffscale;e=x[e].y+x[e].botbar*x[e].staffscale;
c&514?(a+=wc-6,c=wa-e,b=(b-e)/24,D+='<text transform="translate('+a.toFixed(1)+","+c.toFixed(1)+") scale(2.5,"+b.toFixed(2)+')">'+xc.brace.c+"</text>\n"):(a+=wc-5,c=wa-b-3,b=b-e+2,D+='<path d="m'+a.toFixed(1)+" "+c.toFixed(1)+"\n\tc10.5 1 12 -4.5 12 -3.5c0 1 -3.5 5.5 -8.5 5.5\n\tv"+b.toFixed(1)+'\n\tc5 0 8.5 4.5 8.5 5.5c0 1 -1.5 -4.5 -12 -3.5"/>\n')}var c,d,e=K.nstaff;for(c=d=0;;c++){var f=K.staves[c].flags;f&5&&d++;if(K.st_print[c])break;f&10&&d--;if(c==e)break}for(f=e;f>c&&!K.st_print[f];f--);if(c!=
f||0!=d)for(d=x[f].y+x[f].botbar*x[f].staffscale,c=x[c].y+x[c].topbar*x[c].staffscale-d,ib(a,d),D+="v"+(-c).toFixed(1)+'"/>\n',c=0;c<=e;c++)f=K.staves[c].flags,f&1&&b(a,c,2),f&4&&b(a,c,8),f&256&&b(a-6,c,512),f&1024&&b(a-6,c,2048)}function Ld(a){if(a.a_meter){var b;var c=x[a.st];var d=c.y;"|||||"!=c.stafflines&&(d+=(c.topbar+c.botbar)/2-12);for(c=0;c<a.a_meter.length;c++){var e=a.a_meter[c];var f=a.x+a.x_meter[c];var g=d+(e.bot?18:12);if(!a.a_meter[c+1]||"|"!=a.a_meter[c+1].top&&"."!=a.a_meter[c+1].top){R(f,
g,"mtr"+e.top[0]);if(1<e.top.length){var h=0;for(b=f;;){switch(e.top[h]){case "(":case ")":f+=4;break;case "1":f+=8;break;case " ":f+=4;break;case "+":f+=2;default:f+=10}if(++h>=e.top.length)break;R(f,g,"mtr"+e.top[h])}f=(b+f)/2-5}e.bot&&(e.bot[1]?(1==e.bot[0]?(b=f-4,f+=4):(b=f-5,f+=5),R(b,d+6,"mtr"+e.bot[0]),R(f,d+6,"mtr"+e.bot[1])):R(f,d+6,"mtr"+e.bot[0]))}else R(f,g,"mtr"+e.top[0]+a.a_meter[c+1].top),c++}}}function cd(a,b,c){if("object"==typeof c){var d=c[0],e=c[1];var f=d+"_"+e;c=Md[f];c||(c=
abc2svg.rat(Math.abs(d),e),e=c[1],c=(0>d?-c[0]:c[0]).toString(),1!=e&&(c+="_"+e),Md[f]=c)}R(a,b,"acc"+c)}function jb(a,b,c,d,e){var f;0<=b?(f=a.hlu[b])||(f=a.hlu[b]=[]):(f=a.hld[-b])||(f=a.hld[-b]=[]);for(a=0;a<f.length&&!(c>=f[a][0]);a++);a==f.length?f.push([c,d,e]):c>f[a][0]?f.splice(++a,0,[c,d,e]):(d<f[a][1]&&(f[a][1]=d),e>f[a][2]&&(f[a][2]=e))}function Nd(a,b,c){b-=3;10>c?R(a-4,b,"mtr"+c):(R(a-10,b,"mtr"+(c/10|0)),R(a-2,b,"mtr"+c%10))}function jf(a){var b;a.nflags=a.dur<2*m.BLEN?-2:a.dur<4*m.BLEN?
-3:-4;a.dots=0;for(b=a.ts_next;b.time!=a.time+a.dur&&b.ts_next;)b=b.ts_next;var c=b.x-b.wl;for(b=a;!b.seqst;)b=b.ts_prev;b=b.ts_prev;c=(c+b.x+b.wr)/2;if(a.a_dd){b=c-a.x;var d,e=ha.length;for(d=0;d<e;d++){var f=ha[d];f.s==a&&(f.x+=b)}}a.x=c}function kf(a){var b,c,d=a;for(b=a.extra;b.next;)b=b.next;var e=b;if(c=(0<=b.stem||0>a.multi)&&28>=b.notes[0].pit||16>b.notes[0].pit){var f=127;for(b=a.extra;b;b=b.next)b.y<f&&(f=b.y,e=b);b=e.x;f=e.y-5;a.extra!=e&&(b-=4,f+=1);a=a.next;var g=a.x-1;0>a.stem&&-2<a.nflags&&
(g-=4);var h=3*(a.notes[0].pit-18)-5;var k=.4*(g-b);3<k&&(k=3);var m=k;var n=.2;var q=.8;f>h+7?(b=e.x-1,f+=.5,h+=6.5,g=a.x-5.5,k=.8*(f-h),m=.2*(f-h),n=0):h>f+4&&(h=f+4,b=e.x+2,f=e.y-4)}else{f=-127;for(b=a.extra;b;b=b.next)b.y>f&&(f=b.y,e=b);b=e.x;f=e.y+5;a.extra!=e&&(b-=4,--f);a=a.next;g=a.x-1;0<=a.stem&&-2<a.nflags&&(g-=2);h=3*(a.notes[a.nhd].pit-18)+5;k=.4*(b-g);-3>k&&(k=-3);m=k;n=.2;q=.8;f<h-7?(b=e.x-1,f-=.5,h-=6.5,g=a.x-5.5,k=.8*(f-h),m=.2*(f-h),n=0):h<f-4&&(h=f-4,b=e.x+2,f=e.y+4)}d.slur={x0:b,
y0:f,x1:n*g+(1-n)*b-b,y1:f-n*h-(1-n)*f+k,x2:q*g+(1-q)*b-b,y2:f-q*h-(1-q)*f+m,x3:g-b,y3:f-h};f-=d.slur.y1;b=d.extra;c?f<b.ymn&&(b.ymn=f):f>b.ymx&&(b.ymx=f)}function Qb(a,b){var c,d=Array(a.nhd+1);var e=a.notes[0>a.stem?a.nhd:0];var f=a.x,g=a.x+e.shhd*B.scale;var h=x[a.st].y+3*(e.pit-18);e=x[a.st].y;if(a.dots){for(c=0;c<=a.nhd;c++){var k=3*(a.notes[c].pit-18);0==k%6&&(k=a.dot_low?k-3:k+3);d[c]=k}for(c=0;c<a.nhd;c++)if(!(d[c+1]>d[c])){for(k=c;0<k&&!(d[k]>d[k-1]+6);)k--;if(3*(a.notes[k].pit-18)-d[k]<
d[c+1]-3*(a.notes[c+1].pit-18))for(;k<=c;)d[k++]-=6;else d[c+1]=d[c]+6}}a.stemless?a.xstem&&(k=a.ts_prev,c=(0<k.stem?k.y:k.ys)-a.y,c+=x[k.st].y-e,dd(g,h,c)):(c=a.ys-a.y,k=a.nflags,a.ntrem&&(k-=a.ntrem),!b||0>=k?(0<a.nflags&&(c=0<=a.stem?c-1:c+1),dd(g,h,c,a.grace)):dd(g,h,c,a.grace,k,a.fmt.straightflags));if(b&&a.trem1){b=a.ntrem||0;c=3*(a.notes[0<a.stem?a.nhd:0].pit-18);a.head==m.FULL||a.head==m.EMPTY?(f+=(a.grace?2.3:3.5)*a.stem,c=0<a.stem?c+(6+5.4*b):c-11.4):c=0<a.stem?c+(5+5.4*b):c-10.4;c/=a.p_v.scale;
for(ea('<path d="mX Y\n\t',f-4.5,e+c);;){D+="l9 -3v3l-9 3z";if(0>=--b)break;D+="m0 5.4"}D+='"/>\n'}for(e=0;e<=a.nhd;e++){var O=void 0,n=void 0;h=a;var q=e;var l=d;c=!1;k=h.notes[q];var z=x[h.st].y,t=h.x,p=3*(k.pit-18),r=t+k.shhd*B.scale,u=p+z;if(k.dur==h.dur){var v=h.head;b=h.dots;f=h.nflags}else g=ec(h,k.dur),v=g[0],b=g[1],f=g[2];if(!k.invis)if(k.map&&k.map[0])(n=k.map[0][v])||(n=k.map[0][k.map[0].length-1]),g=n.indexOf("/"),0<=g&&(n=0<=h.stem?n.slice(0,g):n.slice(g+1));else if(h.type==m.CUSTOS)n=
"custos";else switch(v){case m.OVAL:n="HD";break;case m.OVALBARS:if(h.head!=m.SQUARE){n="HDD";break}case m.SQUARE:-4<f?n="breve":(n="longa",O=0<h.stem);va||!h.next||h.next.type!=m.BAR||h.next.next||(b=0);r+=1;break;case m.EMPTY:n="Hd";break;default:n="hd"}void 0!=k.color&&(c=fb(k.color));if(n){if(h.grace||O)h.grace?zb(r,u,0,.66,0):zb(r,u,0,1,-1),r=u=0;U.psxygl(r,u,n)||R(r,u,n);(h.grace||O)&&Ab()}if(b&&(h.dots||k.dur!=h.dur))for(v=t+(6.6+h.xmx)*B.scale,void 0==l[q]&&(l[q]=3*(h.notes[q].pit-18),0==
(h.notes[q].pit&1)&&(l[q]+=3)),q=l[q]+z,g=k.dur/12>>5-f-b;0<b--;)R(v,q,g&1<<b?"dot":"dot+"),v+=3.5;k.acc&&(t-=k.shac*B.scale,h.grace?(zb(t,p+z,0,.75),cd(0,0,k.acc),Ab()):cd(t,p+z,k.acc));0!=c&&fb(c)}}function Fd(a){for(;a.prev;)if(a=a.prev,a.rbstart)return a;for(a=a.p_v.sym;a.type!=m.CLEF;)a=a.ts_prev;a.next&&a.next.type==m.KEY&&(a=a.next);return a.next&&a.next.type==m.METER?a.next:a}function lf(a,b){var c;if(a.grace&&0<a.stem)return-1;var d=a.multi?a.multi:b.multi?b.multi:0;if(d)return d;for(;;a=
a.next){if(a.type==m.NOTE){if(!a.stemless){if(0>a.stem)return 1;var e=!0}22>a.notes[0].pit&&(c=!0)}if(a.time==b.time)break}return e||c?-1:1}function Od(a,b,c,d,e,f,g){var h=.3;var k=d-b;0>k&&(k=-k);var m=c-a;40<m&&.7>k/m&&(h=.3+.002*(m-40),.7<h&&(h=.7));var n=.5*(a+c);k=.5*(b+d);var q=a+.45*(n+h*(a-n)-a);var l=b+.45*(k+h*(b-k)+f-b);n=c+.45*(n+h*(c-n)-c);h=d+.45*(k+h*(d-k)+f-d);k=2*e;f=.2+.001*m;.6<f&&(f=.6);f*=e;m*=.03;D=g?D+'<path class="stroke" stroke-dasharray="5,5" d="M':D+'<path d="M';$a(a," ",
b);D+="c"+((q-a)/B.scale).toFixed(1)+" "+(b-l).toFixed(1)+" "+((n-a)/B.scale).toFixed(1)+" "+(b-h).toFixed(1)+" "+((c-a)/B.scale).toFixed(1)+" "+(b-d).toFixed(1);g||(D+="\n\tv"+(-f).toFixed(1)+"c"+((n-m-c)/B.scale).toFixed(1)+" "+(d+f-h-k).toFixed(1)+" "+((q+m-c)/B.scale).toFixed(1)+" "+(d+f-l-k).toFixed(1)+" "+((a-c)/B.scale).toFixed(1)+" "+(d-b).toFixed(1));D+='"/>\n'}function ed(a,b,c){var d,e,f,g=b.ty,h=(g&7)==m.SL_ABOVE?1:-1;var k=a.length;var O=k-1;var n=b.nts;var q=a[0];var l=a[O];var z=1;
La(q.st);for(d=1;d<k;d++){var t=a[d];if(t.type==m.NOTE||t.type==m.REST)z++,t.st==q.st||e||(e=t)}if(e&&!c){A.a_sl||(A.a_sl=[]);var p=24+q.fmt.sysstaffsep;e.st>q.st&&(p=-p);for(d=0;d<k;d++)if(t=a[d],t.st==q.st)t.dur&&(f=t);else if(t=y(t),a[d]==e&&(e=t),a[d]=t,t.dur)if(t.notes=y(t.notes),t.notes[0]=y(t.notes[0]),b.ty&m.SL_CENTER){if(t.st!=f.st){b.ty=b.ty&-8|(f.st<t.st?m.SL_BELOW:m.SL_ABOVE);var r=q.ymn;p=l.ymx;if(t.st<f.st){for(g=1;g<d;g++)f=a[g],f.ymn<r&&(r=f.ymn);for(g=d;g<O;g++)f=a[g],f.ymx>p&&(p=
f.ymx)}else{for(g=1;g<d;g++)f=a[g],f.ymx>p&&(p=f.ymx);for(g=d;g<O;g++)f=a[g],f.ymn<r&&(r=f.ymn)}p+=r;f=t}t.y=p-t.y;t.notes[0].pit=(t.y/3|0)+18;t.ys=p-t.ys;n=t.ymx;t.ymx=p-t.ymn;t.ymn=p-n;t.stem=-t.stem}else t.notes[0].pit+=p/3|0,t.ys+=p,t.y+=p,t.ymx+=p,t.ymn+=p;g=q.st>e.st?"/":"\\";g=b.ty&m.SL_CENTER?g+g:q.st==l.st?"/"==g?"/\\":"\\/":g+(0<h?"+":"-");h=D;D="";ed(a,b,1);A.a_sl.push([q,e,g,D]);D=h}else{e=q.x;q.notes&&q.notes[0].shhd&&(e+=q.notes[0].shhd);k=l.x;l.notes&&(k+=l.notes[0].shhd);if(n){var u=
3*(n.pit-18)+2*h;e+=3}else u=0<h?q.ymx+2:q.ymn-2,q.type==m.NOTE&&(0<h?0<q.stem?(e+=5,q.beam_end&&-1<=q.nflags&&!q.in_tuplet?0<q.nflags?(e+=2,u=q.ys-3):u=q.ys-6:u=q.ys+3):u=q.y+8:0>q.stem?(--e,l.grace?u=q.y-8:q.beam_end&&-1<=q.nflags&&(!q.in_tuplet||q.ys<u+3)?0<q.nflags?(e+=2,u=q.ys+3):u=q.ys+6:u=q.ys-3):u=q.y-5);if(b.nte){var v=3*(b.nte.pit-18)+2*h;k-=3}else v=0<h?l.ymx+2:l.ymn-2,l.type==m.NOTE&&(0<h?0<l.stem?(k+=1,v=l.beam_st&&-1<=l.nflags&&!l.in_tuplet?l.ys-6:l.ys+3):v=l.y+8:0>l.stem?(k-=5,v=l.beam_st&&
-1<=l.nflags&&!l.in_tuplet?l.ys+6:l.ys-3):v=l.y-5);q.type!=m.NOTE&&(u=v+1.2*h,e=q.x+.5*q.wr,e>k-12&&(e=k-12));l.type!=m.NOTE&&(v=q.type==m.NOTE?u+1.2*h:u,q!=l&&(k=l.x-.3*l.wl));3<=z&&(t=a[1],t.type!=m.BAR&&t.x<e+48&&(0<h?(n=t.ymx-2,u<n&&(u=n)):(n=t.ymn+2,u>n&&(u=n))),t=a[O-1],t.type!=m.BAR&&t.x>k-48&&(0<h?(n=t.ymx-2,v<n&&(v=n)):(n=t.ymn+2,v>n&&(v=n))));f=(v-u)/(k-e);if(.7<f||-.7>f)f=.7<f?.7:-.7,0<f*h?u=v-f*(k-e):v=u+f*(k-e);n=v-u;8<n?n=8:-8>n&&(n=-8);r=n;0>r&&(r=-r);p=.5*r;d=.3*n;0<n*h?(k-=p,v-=d):
(e+=p,u+=d);q.grace&&(e=q.x-1.15);l.grace&&(k=l.x+1.15);p=0;f=(v-u)/(k-e);if(q!=l&&q.v==l.v){l=u-f*e;for(d=1;d<O;d++)switch(t=a[d],t.type){case m.NOTE:case m.REST:0<h?(n=3*(t.notes[t.nhd].pit-18)+6,n<t.ymx&&(n=t.ymx),n-=f*t.x+l,n>p&&(p=n)):(n=3*(t.notes[0].pit-18)-6,n>t.ymn&&(n=t.ymn),n-=f*t.x+l,n<p&&(p=n));break;case m.GRACE:for(t=t.extra;t;t=t.next)0<h?(n=t.ymx,n-=f*t.x+l,n>p&&(p=n)):(n=t.ymn,n-=f*t.x+l,n<p&&(p=n))}u+=.45*p;v+=.45*p;p*=.65}z=3<z?(.08*(k-e)+12)*h:(.03*(k-e)+8)*h;0<h?(z<3*p&&(z=3*
p),40<z&&(z=40)):(z>3*p&&(z=3*p),-40>z&&(z=-40));n=v-u;0>n&&(n=-n);0<h?z<.8*n&&(z=.8*n):z>-.8*n&&(z=-.8*n);z*=q.fmt.slurheight;Od(e,u,k,v,h,z,g&m.SL_DOTTED);f=(v-u)/(k-e);l=u-f*e;l=0<z?l+(3*Math.sqrt(z)-2):l-(3*Math.sqrt(-z)-2);for(d=0;d<=O;d++)t=a[d],t.st==q.st&&t.type!=m.BAR&&(n=f*t.x+l,t.ymx<n?t.ymx=n:t.ymn>n&&(t.ymn=n),c||(d==O?(p=k,b.nte&&(p-=5)):p=t.x+t.wr,0!=d&&(e=t.x),d&&d!=O||(n-=z/3),p-=e-t.wl,Y(q.st,0<h,e-t.wl,p,n)))}}function Gc(a,b){for(var c,d,e,f;;){if(!a||a==b){if(!c||!(a=c.next)||
a==b)break;c=null}if(a.type==m.GRACE)c=a,a=a.extra;else{if(a.sls){e=a.sls;a.sls=null;f=[];for(d=0;d<e.length;d++){var g,h;var k=a;var l=e[d],n=[];var q=l.se;if(b&&q.time>b.time)k=void 0;else{switch(l.loc){case "i":k=Fd(k);break;case "o":for(g=c||k;g.ts_next;g=g.ts_next);for(q=g;g;g=g.ts_prev){if(g.v==k.v){q=g;break}g.st==k.st&&(q=g);if(g.ts_prev.time!=q.time)break}}if(k.p_v.s_next&&q.time>=va.time){if(q.time==va.time)if(q.grace)for(g=va;g&&g.time==q.time;g=g.ts_next){if(g.type==m.GRACE){g=null;break}}else for(g=
va;g.time==q.time;g=g.ts_next){if(g==q){g=null;break}}else g=null;if(!g){k.p_v.sls.push(l);for(q=k.p_v.s_next.prev;q.next;)q=q.next;l=Object.create(l)}}switch(l.ty&7){case m.SL_ABOVE:g=1;break;case m.SL_BELOW:g=-1;break;default:g=k.v!=q.v?1:lf(k,q),l.ty&=-8,l.ty|=0<g?m.SL_ABOVE:m.SL_BELOW}g=K.voices[k.v]&&K.voices[q.v]?0<g*(K.voices[k.v].range<=K.voices[q.v].range?1:-1)?k.v:q.v:k.v>q.v?k.v:q.v;if(!c||q.grace&&k.v==q.v&&k.time==q.time)n.push(k),k=k.grace?k.next:k.ts_next;else{do n.push(k),k=k.next;
while(k);k=c.next}if(q.grace){if(!k.grace){for(h=q;h.prev;)h=h.prev;for(;;){k.v==g&&n.push(k);if(k.extra==h)break;k=k.ts_next}k=h}for(;;){n.push(k);if(k==q)break;k=k.next}}else for(;k;){k.v==g&&n.push(k);if(k==q)break;k=k.ts_next}for(q=1;q<n.length-1;q++)k=n[q],k.sls&&Gc(k,b),k.tp&&fd(k);ed(n,l);k=1}k||f.push(e[d])}f.length&&(a.sls=f)}a=a.next}}}function fd(a){var b,c,d,e,f=a.tp.shift();a.tp.length||delete a.tp;var g=e=a.st;for(b=a;b;b=b.next){switch(b.type){case m.GRACE:if(!b.sl1)continue;for(d=
b.extra;d;d=d.next)d.sls&&Gc(d);default:continue;case m.NOTE:case m.REST:}b.sls&&Gc(b);b.st<g?(e=g,g=b.st):b.st>e&&(e=b.st);b.tp&&fd(b);if(b.tpe)break}b&&b.tpe--;if(1!=f.f[0])if(b){d=f.f[3];if(!d){for(c=a;c&&!c.stem;)c=c.next;d=c&&0>c.stem?m.SL_BELOW:m.SL_ABOVE}La(d==m.SL_ABOVE?g:e);if(a==b||2==f.f[1])var h=!0;else if(1==f.f[1])h=!0,ed([a,b],{ty:d});else if(2!=f.f[0]&&a.type==m.NOTE&&b.type==m.NOTE){h=!0;for(c=a;;c=c.next){if(c.type!=m.NOTE&&c.type!=m.REST){if(c.type==m.GRACE||c.type==m.SPACE)continue;
h=!1;break}if(c==b)break;if(c.beam_end){h=!1;break}}if(h&&!a.beam_st&&!a.beam_br1&&!a.beam_br2)for(c=a.prev;c;c=c.prev)if(c.type==m.NOTE||c.type==m.REST){c.nflags>=a.nflags&&(h=!1);break}if(h&&!b.beam_end)for(c=b.next;c;c=c.next)if(c.type==m.NOTE||c.type==m.REST){!c.beam_br1&&!c.beam_br2&&c.nflags>=b.nflags&&(h=!1);break}}if(h){if(1!=f.f[2]){T("tuplet");h=(b.x+a.x)/2;var k=d==m.SL_ABOVE?Q(g,1,h-4,8):Q(e,0,h-4,8)-A.curfont.size;0<a.stem*b.stem&&(h=0<a.stem?h+4:h-4);var l=k+.22*A.curfont.size;0==f.f[2]?
na(h,l,f.p.toString(),"c"):na(h,l,f.p+":"+f.q,"c");for(c=a;!(c.x>=h);c=c.next);d==m.SL_ABOVE?(k+=A.curfont.size,c.ymx<k&&(c.ymx=k),Y(g,1,h-3,6,k)):(c.ymn>k&&(c.ymn=k),Y(e,0,h-3,6,k))}}else{var n=a.x-4;if(b.dur>b.prev.dur){c=b.next;if(!c||c.time!=b.time+b.dur)for(c=b.ts_next;c&&!(c.seqst&&c.time>=b.time+b.dur);c=c.ts_next);var q=c?c.x-c.wl-5:la-6}else q=b.x+4,h=0<=b.stem?0:b.nhd,0<b.notes[h].shhd&&(q+=b.notes[h].shhd),b.st==g&&0<b.stem&&(q+=3.5);if(d==m.SL_ABOVE){if(a.st>=b.st){0<a.stem&&(n+=3);k=
Q(a.st,1,n-4,8);var p=k>x[a.st].topbar+2?k:x[a.st].topbar+2}else p=x[a.st].topbar+2;if(b.st>=a.st){k=Q(b.st,1,q-4,8);var z=k>x[b.st].topbar+2?k:x[b.st].topbar+2}else z=x[b.st].topbar+2;h=.5*(n+q);k=.5*(p+z);var t=(z-p)/(q-n);p=3*(b.notes[b.nhd].pit-a.notes[a.nhd].pit)/(q-n);0<p?0>t?t=0:t>p&&(t=p):0<t?t=0:t<p&&(t=p);t=a.fmt.beamslope*t/(a.fmt.beamslope+Math.abs(t));t*t<.1*.1&&(t=0);z=0;for(c=a;c.dur&&c.st==g&&(l=k+(c.x-h)*t,p=Q(g,1,c.x-4,8)+2,p-l>z&&(z=p-l)),c!=b;c=c.next);k+=z;p=k+t*(n-h);z=k+t*(q-
h);k+=6;for(c=a;c.st==g&&(l=k+(c.x-h)*t,c.ymx<l&&(c.ymx=l),Y(g,1,c.x-3,6,l)),c!=b;c=c.next);}else{a.st<=b.st?(k=Q(a.st,0,n-4,8),p=-2>k?k:-2):p=-2;b.st<=a.st?(0>b.stem&&(q-=3),k=Q(b.st,0,q-4,8),z=-2>k?k:-2):z=-2;h=.5*(n+q);k=.5*(p+z);t=(z-p)/(q-n);p=3*(b.notes[0].pit-a.notes[0].pit)/(q-n);0<p?(0>t?t=0:t>p&&(t=p),.35<t&&(t=.35)):(0<t?t=0:t<p&&(t=p),-.35>t&&(t=-.35));t*t<.1*.1&&(t=0);z=0;for(c=a;c.dur&&c.st==e&&(l=k+(c.x-h)*t,p=Q(e,0,c.x-4,8),p-l<z&&(z=p-l)),c!=b;c=c.next);k+=z-8;p=k+t*(n-h);z=k+t*(q-
h);k-=2;for(c=a;c.st==e&&(l=k+(c.x-h)*t,c.ymn>l&&(c.ymn=l),Y(e,0,c.x-3,6,l)),c!=b;c=c.next);}1==f.f[2]?(g=z-p,e=d==m.SL_ABOVE?-3:3,l=(q-n)/B.scale,D+='<path class="stroke" d="m',$a(n," ",p+4+e),D+="v"+e.toFixed(1)+"l"+l.toFixed(1)+" "+(-g).toFixed(1)+"v"+(-e).toFixed(1)+'"/>\n'):(a=n,b=p,n=q-n,q=z-p,p=d==m.SL_ABOVE,z=0==f.f[2]?f.p.toString():f.p+":"+f.q,f=10*z.length,c=p?-3:3,T("tuplet"),na(a+n/2,b+q/2-.1*A.curfont.size,z,"c"),n/=B.scale,p||(b+=6),D+='<path class="stroke" d="m',$a(a," ",b),p=n-f+
1,f=0<q?f+q/8:f-q/8,D+="v"+c.toFixed(1)+"m"+n.toFixed(1)+" "+(-q).toFixed(1)+"v"+(-c).toFixed(1)+'"/>\n<path class="stroke" stroke-dasharray="'+(p/2).toFixed(1)+" "+f.toFixed(1)+'" d="m',$a(a," ",b-c),D+="l"+n.toFixed(1)+" "+(-q).toFixed(1)+'"/>\n',d==m.SL_ABOVE?Y(g,1,h-3,6,l+2):Y(e,0,h-3,6,l))}}else w(1,a,"No end of tuplet in this music line")}function yc(a,b,c){var d,e=2==c?a.pit:b.pit,f=(a.tie_ty&7)==m.SL_ABOVE?1:-1,g=a.s,h=g.st,k=b.s,l=k.x,n=a.shhd;for(d=0;d<g.nhd&&g.notes[d]!=a;d++);0<f?d<g.nhd&&
e+1==g.notes[d+1].pit&&g.notes[d+1].shhd>n&&(n=g.notes[d+1].shhd):0<d&&e==g.notes[d-1].pit+1&&g.notes[d-1].shhd>n&&(n=g.notes[d-1].shhd);var q=g.x+n;if(2!=c){for(d=0;d<k.nhd&&k.notes[d]!=b;d++);n=k.notes[d].shhd;0<f?d<k.nhd&&e+1==k.notes[d+1].pit&&k.notes[d+1].shhd<n&&(n=k.notes[d+1].shhd):0<d&&e==k.notes[d-1].pit+1&&k.notes[d-1].shhd<n&&(n=k.notes[d-1].shhd);l+=n}switch(c){default:if(e<b.pit||0>f)e=a.pit;break;case 3:f=-f;case 1:q=k.prev?k.prev.x+k.wr:g.x;g.st!=k.st&&(h=k.st);q+=.4*(l-q);q>l-20&&
(q=l-20);break;case 2:l=g.next?g.next.x:la,l!=la&&(l-=.4*(l-q)),l<q+16&&(l=q+16)}20<l-q?(q+=3.5,l-=3.5):(q+=1.5,l-=1.5);!g.dots||a.pit&1||!(0<f&&!g.dot_low||0>f&&g.dot_low)||(q+=5);b=x[h].y+3*(e-18)+.8*f;Od(q,b,l,b,f,(.15*(l-q)+14)*f*g.fmt.tieheight,a.tie_ty&m.SL_DOTTED)}function mf(){function a(a,b){var c=la/Qa,d=a.x/c|0,e=b.x/c|0,f=(a.ys-b.ys)/(a.xs-b.xs);b=a.ys-a.xs*f;var g=x[a.st];c*=f;if(0<a.stem)for(;d<=e;)a=c*d+b,g.top[d]<a&&(g.top[d]=a),d++;else for(;d<=e;)a=c*d+b,g.bot[d]>a&&(g.bot[d]=a),
d++}var b,c,d,e=D;D="";Qa=Math.ceil(la/2);for(b=0;b<=V;b++){var f=x[b];f.top=new Float32Array(Qa);f.bot=new Float32Array(Qa);for(c=0;c<Qa;c++)f.top[c]=0,f.bot[c]=24}for(c=0;c<C.length;c++){var g={};var h=!0;b=C[c];for(f=b.sym;f;f=f.next)switch(f.type){case m.GRACE:for(d=f.extra;d;d=d.next)d.beam_st&&!d.beam_end&&(U.calculate_beam(g,d),g.s2&&a(d,g.s2));f.p_v.ckey.k_bagpipe||!f.fmt.graceslurs||f.gr_shift||f.sl1||f.ti1||!f.next||f.next.type!=m.NOTE||kf(f)}for(f=b.sym;f;f=f.next)switch(f.type){case m.NOTE:if(f.beam_st&&
!f.beam_end||h&&!f.beam_st)h=!1,U.calculate_beam(g,f),g.s2&&a(f,g.s2)}}nf();bf();for(f=M;f;f=f.ts_next)if(!f.invis){switch(f.type){case m.GRACE:for(d=f.extra;d;d=d.next)Y(f.st,!0,d.x-2,4,d.ymx+1),Y(f.st,!1,d.x-2,4,d.ymn-5);continue;case m.MREST:Y(f.st,!0,f.x+16,32,f.ymx+2);continue;default:Y(f.st,!0,f.x-f.wl,f.wl+f.wr,f.ymx+2),Y(f.st,!1,f.x-f.wl,f.wl+f.wr,f.ymn-2);case m.PART:case m.TEMPO:case m.STAVES:continue;case m.NOTE:}0<f.stem?(f.stemless?(b=-5,c=10):f.beam_st?(b=3,c=f.beam_end?4:10):(b=-8,
c=f.beam_end?11:16),Y(f.st,!0,f.x+b,c,f.ymx),c=f.ymn,f.notes[0].acc&&c>3*(f.notes[0].pit-18)-9&&(c=3*(f.notes[0].pit-18)-9),Y(f.st,!1,f.x-f.wl,f.wl+f.wr,c)):(Y(f.st,!0,f.x-f.wl,f.wl+f.wr,f.ymx),f.stemless?(b=-5,c=10):f.beam_st?(b=-6,c=f.beam_end?4:10):(b=-8,c=f.beam_end?5:16),b+=f.notes[0].shhd,Y(f.st,!1,f.x+b,c,f.ymn));f.notes[f.nhd].acc&&(c=3*(f.notes[f.nhd].pit-18)+(-1==f.notes[f.nhd].acc?11:10),Y(f.st,!0,f.x-10,10,c));f.notes[0].acc&&(c=3*(f.notes[0].pit-18)-(-1==f.notes[0].acc?5:10),Y(f.st,!1,
f.x-10,10,c))}cf();for(c=0;c<C.length;c++)if(b=C[c],f=b.sym)for(fb(f.color),b=b.st;f;f=f.next)f.play||(f.tp&&fd(f),(f.sls||f.sl1)&&Gc(f));fb();for(b=0;b<=V;b++)for(f=x[b],d=f.topbar+2,g=f.botbar-2,c=0;c<Qa;c++)d>f.top[c]&&(f.top[c]=d),g<f.bot[c]&&(f.bot[c]=g);0<=p.measurenb&&ff();La(-1);for(c=0;c<C.length;c++)if(b=C[c],b.have_ly){of();break}df();gf();La(-1);D=e}function pf(a,b){var c,d,e,f=[];if(A.vnt){for(c=b.length;0<=--c&&!b[c];);if(!(0>c)){for(d=0;d<C.length;d++){var g=C[d];K.voices[d]&&(c=K.voices[d].st,
b[c]&&(e=1==A.vnt?g.nm:g.snm))&&(delete g.new_name,f[c]=f[c]?f[c]+("\n"+e):e)}if(f.length){T("voice");var h=A.curfont.size;var k=h/2;a=.5*-a;for(c=0;c<f.length;c++)if(f[c])for(g=f[c].split("\n"),d=x[c].y+.5*x[c].topbar*x[c].staffscale+k*(g.length-2)+.22*h,K.staves[c].flags&1&&c+1<x.length&&K.staves[c+1].flags&2&&!f[c+1]&&(d-=.5*(x[c].y-x[c+1].y)),b=0;b<g.length;b++)e=g[b],na(a,d,e,"c"),d-=h}}}}function qf(){var a,b;var c=K;var d=va?va.fmt:p;for(b=0;b<C.length;b++){var e=C[b];1!=e.scale&&(e.scale_str=
'transform="scale('+e.scale+')"')}for(b=0;b<=V&&!A.st_print[b];b++);var f=0;if(b>V)return f;var g=x[b];for(a=0;a<Qa;a++){var h=g.top[a];f<h&&(f=h)}f*=g.staffscale;var k=M.fmt.staffsep/2+g.topbar*g.staffscale;f<k&&(f=k);f<g.ann_top&&(f=g.ann_top);g.y=-f;for(e=0;e<b;e++)x[e].y=-f;if(!A.st_print[b])return f;a=c.staves[e];for(b++;b<=V;b++)if(A.st_print[b]){g=x[b];k=a.sep||d.sysstaffsep;var m=a.maxsep||d.maxsysstaffsep;var n=0;if(g.staffscale==x[e].staffscale){for(a=0;a<Qa;a++)h=g.top[a]-x[e].bot[a],n<
h&&(n=h);n*=g.staffscale}else for(a=0;a<Qa;a++)h=g.top[a]*g.staffscale-x[e].bot[a]*x[e].staffscale,n<h&&(n=h);k+=g.topbar*g.staffscale;n<k&&(n=k);m+=g.topbar*g.staffscale;n>m&&(n=m);f+=n;for(g.y=-f;!A.st_print[++e];)x[e].y=-f;for(;!(a=c.staves[e]);)c=c.next}for(a=c=0;a<Qa;a++)h=x[e].bot[a],c>h&&(c=h);c>g.ann_bot&&(c=g.ann_bot);c*=x[e].staffscale;for(b=0;b<=V;b++)g=x[b],n=g.y,1!=g.staffscale&&(g.scale_str='transform="translate(0,'+(wa-n).toFixed(1)+") scale("+g.staffscale+')"');if(0==c){for(b=V;0<=
b&&!A.st_print[b];b--);if(0>b)return f}n=-c;k=.5*d.staffsep;n<k&&(n=k);m=.5*d.maxstaffsep;n>m&&(n=m);return f+n}function rf(a){function b(){var a,b,c;for(a=c=0;a<=K.nstaff;a++)if(0>h[a])l[a]=n[a]=0;else{var d=x[a].staffscale;var e=K.staves[a].stafflines;var f=e.length;for(b=0;b<f&&("."==e[b]||"-"==e[b]);b++);l[a]=x[a].y+6*(b==f-1?f-2:b>=f-2?f-3:b)*d;c||(c=x[a].y+6*(b==f?f+1:b>=f-2?f:f-1)*d);n[a]=c-l[a];q[a]=f-b&&(f-1-b||2);if("."!=e[f-1])for(x[a].hll=17+2*b,b==f&&(x[a].hll-=2),x[a].hlmap=c=new Int8Array(2*
(f-b+1)+2),d=1;b<f;b++,d+=2)switch(e[b]){case "|":case "[":case "'":c[d-1]=1,c[d]=1,c[d+1]=1}c=K.staves[a].flags&64?0:l[a]}if(b=r.length)for(;0<=--b&&(f=r[b],a=f[0].st,f[1]>l[a]&&(f[1]=l[a]),f[2]<n[a]&&(f[2]=n[a]),f[3]<q[a]&&(f[3]=q[a]),!f[0].seqst););}function c(a,b,c){var d,e,f=0,g="",k={"|":"slW","[":"slthW","'":"sltnW",":":"sldW"},h=K.staves[a].stafflines,m=h.length,n=6*x[a].staffscale;if(/[\[|':]/.test(h))if(c-=b,Ra(-1),Rb&&Rb.st_l==h&&1==x[a].staffscale&&Rb.st_w==(c|0))R(b,x[a].y,"stdef"+p.fullsvg);
else{for(d=0;d<m;d++,f-=n)if("."!=h[d]){for(e=0;d<m;d++,f-=n,e-=n){switch(h[d]){case ".":case "-":continue;case l:g+="m-"+c.toFixed(1)+" "+e.toFixed(2)+"h"+c.toFixed(1);e=0;continue}void 0!=l&&(g+='"/>\n');var l=h[d];g+='<path class="'+k[l]+'" d="m0 '+f+"h"+c.toFixed(1);e=0}g+='"/>'}f=x[a].y;!Rb&&c>Jb()-10&&1==x[a].staffscale?(Rb={st_l:h,st_w:c|0},d="stdef"+p.fullsvg,0>g.indexOf("<path",1)?kb[d]=g.replace("path",'path id="'+d+'"'):kb[d]='<g id="'+d+'">\n'+g+"\n</g>",R(b,f,d)):ea('<g transform="translate(X, Y)">\n'+
g+"\n</g>\n",b,f)}}function d(a){var b=K.staves[a.st].stafflines,c=x[a.st],d=5-a.nflags,e=a.x;a=a.y;if(!(6>d)){7==d&&12==a&&2>=b.length&&(a-=6);a/=6;switch(d){default:switch(b[a+1]){case "|":case "[":case "'":case ":":break;default:jb(c,a+1,e,-7,7)}9==d&&a--;break;case 7:a++;case 6:}switch(b[a]){case "|":case "[":case "'":case ":":break;default:jb(c,a,e,-7,7)}}}function e(a,b){var c=b.time;do b=b.ts_next;while(b.st!=a);for(;b.prev&&b.prev.time>=c;)b=b.prev;return b.bar_type?b.x:b.x-b.wl}var f,g,h=
[],k=[],l=[],n=[],q=[],r=[],z="",t="";for(g=0;g<=V;g++)k[g]=K.st_print[g],h[g]=k[g]?0:-1;b();Kd(0);for(f=M;f;f=f.ts_next)switch(f.type){case m.STAVES:var u=f.sy;for(g=0;g<=V;g++){var v=h[g];if(0>v)u.st_print[g]&&(h[g]=e(g,f),k[g]=!0);else if(!u.st_print[g]||!K.staves[g]||u.staves[g].stafflines!=K.staves[g].stafflines){if(f.ts_prev.bar_type){var w=f.ts_prev.x;u.staves[g].stafflines.length>K.staves[g].stafflines.length&&(w-=f.ts_prev.wl-4)}else w=(f.ts_prev.x+f.x)/2,h[g]=-1;c(g,v,w);h[g]=u.st_print[g]?
w:-1}}K=u;b();continue;case m.BAR:if(f.invis||!f.bar_type||!K.st_print[f.st])break;if(f.second&&(!f.ts_prev||f.ts_prev.type==m.BAR&&f.ts_prev.st==f.st))break;r.push([f,l[f.st],n[f.st],q[f.st]]);break;case m.STBRK:if(K.voices[f.v]&&0==K.voices[f.v].range&&14<f.xmx&&f.next&&f.next.type==m.CLEF){for(v=g=0;v<C.length;v++)K.voices[v]&&0<K.voices[v].range&&g++;for(w=f.ts_next;w&&w.type==m.STBRK;w=w.ts_next)g--;0==g&&Kd(f.x)}g=f.st;v=h[g];0<=v&&(w=f.prev)&&(w=w.type==m.BAR?w.x:f.x-f.xmx,v>=w||(c(g,v,w),
h[g]=f.x));break;case m.GRACE:for(w=f.extra;w;w=w.next)U.draw_hl(w);break;case m.NOTE:f.invis||U.draw_hl(f);break;case m.REST:(f.fmr||f.rep_nb&&0<=f.rep_nb)&&jf(f),f.invis||d(f)}for(g=0;g<=V;g++)v=h[g],0>v||v>=la||c(g,v,la);sf();(function(){var a,b=r.length;for(a=0;a<b;a++){var c=r[a];var d,e,f=c[0],g=c[1],h=c[2],k=c[3],n=f.bar_type,l=f.st,q=x[l],O=3<=k?6*k:6*(4-k),p=f.x;0!=l&&f.ts_prev&&f.ts_prev.type!=m.BAR&&(h=O*q.staffscale);f.ymx=f.ymn+h;Ra(-1);pa(f);f.color&&fb(f.color);c=g+O/2;if(f.bar_mrep){Ra(l);
if(1==f.bar_mrep){for(d=f.prev;d.type!=m.REST;d=d.prev);R(d.x,c,"mrep")}else R(p,c,"mrep2"),f.v==K.top_voice&&Nd(p,c+q.topbar,f.bar_mrep);Ra(-1)}"||:"==n&&(n="[|:");for(e=n.length;0<=--e;){switch(n[e]){case "|":f.bar_dotted?(d=9>=O/6?[0,0,4,3.6,4.8,4.3,4,4.7,4.4,4.9][O/6]:5,ea('<path class="bW" stroke-dasharray="A,A" d="MX YvG"/>\n',p,g,d*q.staffscale,-h)):f.color?ea('<path class="bW" d="MX YvF"/>\n',p,g,-h):z+="M"+gb(p).toFixed(1)+" "+U.sy(g).toFixed(1)+"v"+(-h).toFixed(1);break;default:p-=3;f.color?
ea('<path class="bthW" d="MX YvF"/>\n',p+1.5,g,-h):t+="M"+gb(p+1.5).toFixed(1)+" "+U.sy(g).toFixed(1)+"v"+(-h).toFixed(1);break;case ":":p-=2,Ra(l),k&1?(R(p,c+6,"rdot"),R(p,c-6,"rdot")):R(p,c-12,"rdots"),Ra(-1)}p-=3}fb();Pb(f)}Ra(-1);z&&(D+='<path class="bW" d="'+z+'"/>\n');t&&(D+='<path class="bthW" d="'+t+'"/>\n')})();pf(a,k)}function nf(){var a,b,c,d;for(a=0;a<C.length;a++){var e=C[a];if(e=e.sym)if(e=e.next){var f=void 0;for(d=e;d;d=d.next)if(d.ti1){var g=b=0;var h=128;for(c=0;c<=d.nhd;c++)d.notes[c].tie_ty&&
(b++,128>h&&d.notes[c].pit<=h+1&&g++,h=d.notes[c].pit,f=d.notes[c].tie_e);h=f&&0>d.stem*f.stem?22<=h?m.SL_ABOVE:m.SL_BELOW:d.multi?0<d.multi?m.SL_ABOVE:m.SL_BELOW:0>d.stem?m.SL_ABOVE:m.SL_BELOW;if(d.multi)for(c=0;c<=d.nhd;c++)g=d.notes[c].tie_ty,(g&7)==m.SL_AUTO&&(d.notes[c].tie_ty=g&m.SL_DOTTED|h);else if(1>=b)for(c=0;c<=d.nhd;c++){if(g=d.notes[c].tie_ty){(g&7)==m.SL_AUTO&&(d.notes[c].tie_ty=g&m.SL_DOTTED|h);break}}else if(g){h=128;for(c=0;c<=d.nhd;c++)if(d.notes[c].tie_ty){if(128>h&&d.notes[c].pit<=
h+1){b=c;break}h=d.notes[c].pit}h=m.SL_BELOW;for(c=0;c<=d.nhd;c++)if(g=d.notes[c].tie_ty)b==c&&(h=m.SL_ABOVE),(g&7)==m.SL_AUTO&&(d.notes[c].tie_ty=g&m.SL_DOTTED|h)}else if(b&1)for(b=(b-1)/2,h=m.SL_BELOW,c=0;c<=d.nhd;c++){if(g=d.notes[c].tie_ty)0==b&&22<=d.notes[c].pit&&(h=m.SL_ABOVE),(g&7)==m.SL_AUTO&&(d.notes[c].tie_ty=g&m.SL_DOTTED|h),0==b--&&(h=m.SL_ABOVE)}else for(b/=2,h=m.SL_BELOW,c=0;c<=d.nhd;c++)if(g=d.notes[c].tie_ty)(g&7)==m.SL_AUTO&&(d.notes[c].tie_ty=g&m.SL_DOTTED|h),0==--b&&(h=m.SL_ABOVE)}for(;e;e=
e.next)if(e.ti1&&(20>e.notes[0].pit&&e.notes[0].tie_ty&&(e.notes[0].tie_ty&7)==m.SL_BELOW||24<e.notes[e.nhd].pit&&e.notes[e.nhd].tie_ty&&(e.notes[e.nhd].tie_ty&7)==m.SL_ABOVE)){for(f=e.next;f&&f.type!=m.NOTE;)f=f.next;if(f){if(f.st!=e.st)continue;b=f.x-e.x-10}else b=la-e.x-10;d=100>b?9:300>b?12:16;24<e.notes[e.nhd].pit&&(c=3*(e.notes[e.nhd].pit-18)+d,e.ymx<c&&(e.ymx=c),f&&f.ymx<c&&(f.ymx=c),Y(e.st,!0,e.x+5,b,c));20>e.notes[0].pit&&(c=3*(e.notes[0].pit-18)-d,e.ymn>c&&(e.ymn=c),f&&f.ymn>c&&(f.ymn=c),
Y(e.st,!1,e.x+5,b,c))}}}}function Bb(a){return!a||!/^(0|n|f)/i.test(a)}function gd(a){var b=Pd[a.fname||a.name];b||(b=1.1);a.swfac=a.size*b}function xb(a,b){var c;if("-"==a[a.length-2]){var d=a[a.length-1];if("1">d||"9"<d)return;a="u"+d+"font"}var e={};if(d=b.match(/\s+(no)?box(\s|$)/))d[1]?(e.box=!1,e.pad=0):(e.box=!0,e.pad=2.5),b=b.replace(d[0],d[2]);if(d=b.match(/\s+padding=([\d.]+)(\s|$)/))e.pad=d[1]?+d[1]:0,b=b.replace(d[0],d[2]);if(d=b.match(/\s+class=(.*?)(\s|$)/))e.class=d[1],b=b.replace(d[0],
d[2]);if(d=b.match(/\s+wadj=(.*?)(\s|$)/)){if("undefined"==typeof document)switch(d[1]){case "none":e.wadj="";break;case "space":e.wadj="spacing";break;case "glyph":e.wadj="spacingAndGlyphs";break;default:v(1,G.bad_val,"%%"+a)}b=b.replace(d[0],d[2])}if(d=b.match(/\s+([0-9.]+|\*)$/))"*"!=d[1]&&(e.size=+d[1]),b=b.replace(d[0],"");if("u"==b[0]&&"url("==b.slice(0,4)||"l"==b[0]&&"local("==b.slice(0,6)){d=b.indexOf(")",1);if(0>d){v(1,"No end of url in font family");return}e.src=b.slice(0,d+1);e.fid=abc2svg.font_tb.length;
abc2svg.font_tb.push(e);e.name="ft"+e.fid;b=b.replace(e.src,"")}if(d=b.match(/[- ]?[nN]ormal/))e.normal=!0,b=b.replace(d[0],"");if(d=b.match(abc2svg.ft_re))e.weight=abc2svg.ft_w[d[0].replace(/[ -]/,"").toLowerCase()],b=b.replace(d[0],"");if(d=b.match(/[- ]?[iI]talic/))e.style="italic",b=b.replace(d[0],"");if(d=b.match(/[- ]?[oO]blique/))e.style="oblique",b=b.replace(d[0],"");e.src||(b=b.trim(),"*"==b&&(b=""),b=b.replace(/Times-Roman|Times/,"serif").replace("Helvetica","sans-serif").replace("Courier",
"monospace").replace("music",p.musicfont.name),0<b.indexOf("Fig")&&(e.figb=!0));b&&!e.name&&(e.name=b);e.size&&gd(e);if(!e.name||!e.size){b=p[a];for(c in b)if(b.hasOwnProperty(c)&&void 0==e[c])switch(c){case "fid":case "used":case "src":break;case "style":case "weight":if(e.normal)break;default:e[c]=b[c]}e.swfac||gd(e)}void 0==e.pad&&(e.pad=0);e.fname=e.name;700<=e.weight&&(e.fname+="Bold");p[a]=e}function ab(a){a=a.toLowerCase().match(/(-?[\d.]+)(.*)/);if(!a)return NaN;a[1]=+a[1];switch(a[2]){case "cm":return 37.8*
a[1];case "in":return 96*a[1];case "pt":return a[1]/.75;case "px":case "":return a[1]}return NaN}function Qd(a){var b=a.indexOf(" ");0<b&&(a=a.slice(0,b));return tf[a]}function Rd(a,b){a=a.slice(0,3);"ste"==a&&(a="stm");Sb("pos",'"'+a+" "+b+'"')}function Sb(a,b){a=[a+"=",b];3>r.state?fc(l?l.id:"*",a):l?Sd(a):fc("*",a)}function lb(){ba.chg&&(ba.chg=!1,ba.lm=p.leftmargin-p.printmargin,0>ba.lm&&(ba.lm=0),ba.rm=p.rightmargin-p.printmargin,0>ba.rm&&(ba.rm=0),ba.width=p.pagewidth-2*p.printmargin,100>ba.width-
ba.lm-ba.rm&&(w(0,void 0,"Bad staff width"),ba.width=ba.lm+ba.rm+150),wc=ba.lm/p.scale)}function Td(a){var b=a.name,c="";a.weight&&(c+=a.weight+" ");a.style&&(c+=a.style+" ");0>b.indexOf('"')&&0<b.indexOf(" ")&&(b='"'+b+'"');return c+a.size.toFixed(1)+"px "+b}function Ud(a){return"font:"+Td(a)}function Ib(a){var b="f"+a.fid+p.fullsvg;a.class&&(b+=" "+a.class);a.box&&(b+=" box");return b}function bb(a){a.used||(a.used=!0,void 0==a.fid&&(a.fid=abc2svg.font_tb.length,abc2svg.font_tb.push(a),a.swfac||
gd(a),a.pad||(a.pad=0)),a.cw_tb||(a.cw_tb=a.name?0<a.name.indexOf("ans")?Vd:0<a.name.indexOf("ono")?uf:vf:Vd),hd(".f"+a.fid+(p.fullsvg||"")+"{"+Ud(a)+"}"),a.src&&hd("@font-face{\n font-family:"+a.name+";\n src:"+a.src+"}"),a==p.musicfont&&hd(".f"+a.fid+(p.fullsvg||"")+" text,tspan{white-space:pre}"),Kb.text&&!Kb.used&&0<=a.name.indexOf("text")&&(mb+=Kb.text,Kb.used=1))}function Ma(a){a+="font";var b=p[a];if(!b)return v(1,"Unknown font $1",a),A.curfont;if(!b.name||!b.size){a=Object.create(A.deffont);
b.name&&(a.name=b.name);b.normal&&(a.weight&&(a.weight=null),a.style&&(a.style=null));b.weight&&(a.weight=b.weight);b.style&&(a.style=b.style);b.src&&(a.src=b.src);b.size&&(a.size=b.size);var c=Td(a);b.class&&(a.class=b.class,c+=" "+b.class);b=abc2svg.font_st[c];if(void 0!=b)return abc2svg.font_tb[b];abc2svg.font_st[c]=abc2svg.font_tb.length;a.fid=a.used=void 0;b=a}bb(b);return b}function Hc(a,b){var c,d,e="";for(c=0;;){var f=a.indexOf("\\",c);if(0>f)break;e+=a.slice(c,f);c=a[++f];if(!c)return e+
"\\";switch(c){case "0":case "2":if("0"!=a[f+1])break;if(d=wf[a[f+2]]){e+=d;c=f+3;continue}break;case "u":c=Number("0x"+a.slice(f+1,f+5));if(isNaN(c)||32>c){e+=a[++f]+"\u0306";c=f+1;continue}c=String.fromCharCode(c);if("\\"==c){f+=4;break}e+=c;c=f+5;continue;case "t":e+="\t";c=f+1;continue;case "n":e+="\n";c=f+1;continue;default:if(d=xf[a.slice(f,f+2)]){e+=d;c=f+2;continue}if((d=a[f+1])&&/[A-Za-z]/.test(d))switch(c){case "`":e+=d+"\u0300";c=f+2;continue;case "'":e+=d+"\u0301";c=f+2;continue;case "^":e+=
d+"\u0302";c=f+2;continue;case "~":e+=d+"\u0303";c=f+2;continue;case "=":e+=d+"\u0304";c=f+2;continue;case "_":e+=d+"\u0305";c=f+2;continue;case ".":e+=d+"\u0307";c=f+2;continue;case '"':e+=d+"\u0308";c=f+2;continue;case "o":e+=d+"\u030a";c=f+2;continue;case "H":e+=d+"\u030b";c=f+2;continue;case "v":e+=d+"\u030c";c=f+2;continue;case "c":e+=d+"\u0327";c=f+2;continue;case ";":e+=d+"\u0328";c=f+2;continue}}"w"==b&&(e+="\\");e+=c;c=f+1}return e+a.slice(c)}function yf(a){var b;if(u.read_file)if(2<Cb)v(1,
"Too many include levels");else if(b=u.read_file(a)){Cb++;var c=y(r);id(a,b);c.state=r.state;c.ckey=r.ckey;r=c;Cb--}else v(1,"Cannot read file '$1'",a);else v(1,"No read_file support")}function id(a,b,c,d){function e(){var a=b.indexOf("K:",c);if(0>a)return!1;a=b.indexOf("\n",a);if(r.select.test(b.slice(r.bol,a)))return!0;var e=/\n\w*\n/;e.lastIndex=a;I=e.exec(b)?e.lastIndex:d;return!1}function f(a,b){if(!a)return a;var c=a.indexOf("%");if(0==c)return"";0<c&&(a=a.replace(/([^\\])%.*/,"$1").replace(/\\%/g,
"%"));a=a.replace(/\s+$/,"");return b&&0<=a.indexOf("\\")?Hc(a,b):a}function g(a,e){var f,g="";e||(e=b.indexOf("\n\n",c));0>e&&(e=d);if("object"!=typeof a){"b"!=a[0]&&"a"!=a[0]&&"+"!=a[0]&&"*"!=a[0]&&(a="b"+a);"<"!=a[1]&&(a=a[0]+"<pre>");for(f=a.match(/<\/?[^>]*>/g);;){var h=f.pop();if(!h)break;"/"==h[1]||"/>"==h.slice(-2)?f.pop():g+="</"+h.slice(1)}p.show_source=a=[a,g]}h=a[0].slice(1)+Wd(b.slice(c,e))+a[1];Z.src="+"==a[0][0]&&Z.src?Z.src+h:h}function h(){r.bol=c;var a;ma.length&&(v(1,"Decoration(s) without symbol: $1",
ma),ma=[]);r.tp&&(v(1,"No end of tuplet"),(a=r.tps)&&delete a.tp,delete r.tp);fa&&(v(1,"No end of voice overlay"),Tb(fa.bar?"|":")"));U.voice_adj();a:{var b,d;a=C.length;var e=[],f=[];var g=K;for(d=0;d<a;d++){var h=C[d].sym;e[d]=h;if(g.voices[d]&&(f[g.voices[d].range]=d,!l&&h)){var k=h.fmt;var n=C[d];var l={type:m.STAVES,fname:r.fname,dur:0,v:d,p_v:n,time:0,st:0,sy:g,next:h,fmt:k,seqst:!0}}}if(l){n.sym=M=h=l;h.next?h.next.prev=h:n.last_sym=h;if(h=oa.tempo)h.v=d=n.v,h.p_v=n,h.st=0,h.time=0,h.prev=
l,h.next=l.next,h.next?h.next.prev=h:n.last_sym=h,h.prev.next=h,h.fmt=k,oa.tempo=null,e[d]=h;if(1==a)for(h=M,h.ts_next=h.next;;){h=h.next;if(!h)break a;if(h.time!=h.prev.time||Sa[h.prev.type])h.seqst=1;if(h.type==m.PART){if(h.prev.next=h.prev.ts_next=h.next)h.next.part=h,h.next.prev=h.prev,h.soln&&(h.next.soln=1),h.seqst&&(h.next.seqst=1)}else h.ts_prev=h.prev,h.ts_next=h.next}for(;;){if(q){g=q;var q=null;for(d=f.length=0;d<a;d++)g.voices[d]&&(f[g.voices[d].range]=d)}n=k=1E7;for(b=0;;){d=f[b++];if(void 0==
d)break;!(h=e[d])||h.time>k||(g=Sa[h.type],h.type==m.GRACE&&h.next&&h.next.type==m.BAR&&(g=5),h.time<k?(k=h.time,n=g):g<n&&(n=g))}if(127<n)break;if(6==n){b=void 0;d=h=void 0;for(g=0;;){var O=f[g++];if(void 0==O)break;if((h=e[O])&&h.bar_type&&!h.invis&&h.time==k)if(d){if(h.bar_type!=d)break;if(h.text&&!b&&"|"==d){b=h.text;break}}else d=h.bar_type,h.text&&"|"==d&&(b=h.text)}if(void 0!=O)if("::"==d||":|"==d||b)for(g=0,d=b?"|":"::";;){O=f[g++];if(void 0==O)break;!(h=e[O])||h.invis||h.bar_type!=d||"|"==
d&&!h.text||(b=y(h),"::"==d?(h.bar_type=":|",b.bar_type="|:"):(delete h.text,delete h.rbstart,b.bar_type="[",b.invis=1,b.xsh=0),b.next=h.next,b.next&&(b.next.prev=b),b.prev=h,h.next=b)}else w(1,h,"Different bars $1 and $2",d+(b||""),h.bar_type+(h.text||""))}for(b=0;;){d=f[b++];if(void 0==d)break;if((h=e[d])&&h.time==k&&(g=Sa[h.type],h.type==m.GRACE&&h.next&&h.next.type==m.BAR&&(g=5),g==n))if(g||h.type!=m.PART){h.type==m.STAVES&&(q=h.sy);if(t){var t=0;h.seqst=!0}h.ts_prev=l;l=l.ts_next=h;e[d]=h.next}else if(h.prev?
h.prev.next=h.next:h.p_v.sym=h.next,e[d]=h.next)h.next.part=h,h.next.prev=h.prev,h.soln&&(h.next.soln=1)}n&&(t=1)}}}if(M){for(l=0;l<C.length;l++)C[l].key||(C[l].key=r.ckey);u.anno_start&&(pa=zf);u.anno_stop&&(Pb=Af);U.set_bar_num();L.P&&(M.parts=L.P);u.get_abcmodel&&u.get_abcmodel(M,C,abc2svg.sym_name,L);u.img_out&&U.output_music()}lb();L.W&&Bf(L.W);t=p.infoname.split("\n");q=t.length;for(l=0;l<q;l++)if(a=t[l][0],!(0>p.writefields.indexOf(a))&&(a=L[a])){if(!z){var z=!0;T("history");ra(p.textspace);
var I=A.curfont.size*p.lineskipfac}f=t[l].slice(2);'"'==f[0]&&(f=f.slice(1,-1));ra(I);e=ua(f);na(0,.22*e[1],f,null,null,e);k=e[0];a=a.split("\n");na(k,.22*e[1],a[0]);for(f=1;f<a.length;f++)a[f]?(ra(I),na(k,.22*e[1],a[f])):ra(A.curfont.size*p.parskipfac);ra(I*p.parskipfac);bb(A.curfont)}r.state=0;nb();M&&(jd.push([M,C,L,p]),M=null);p=Z.cfmt;L=Z.info;Da=Z.char_tb;oa=Z.glovar;Lb=Z.maps;gc=Z.mac;hc=Z.maci;r.tune_v_opts=null;r.scores=null;r.ufmt=!1;delete r.pq;Xd();ba.chg=!0;lb();p.show_source&&(u.img_out("</div>"),
"a"==p.show_source[0][0]&&u.img_out(Z.src))}function k(a,c){if("end"!=a){c?(r.tune_v_opts||(r.tune_v_opts={}),c=r.tune_v_opts):(r.voice_opts||(r.voice_opts={}),c=r.voice_opts);for(c[a]=[];;){var d=++I;if("%"!=b[d])break;I=b.indexOf("\n",I);if(b[d+1]==t){d+=2;sa=0>I?b.slice(d):b.slice(d,I);n=sa.match(/\S+/);switch(n[0]){default:c[a].push(f(sa,!0));continue;case "score":case "staves":case "tune":case "voice":d-=2}break}}I=r.eol=d-1}}function l(){var a,d=b.indexOf("K:",c);d=b.indexOf("\n",d);var e=b.slice(r.bol,
d);for(d in r.tune_opts)if(r.tune_opts.hasOwnProperty(d)&&(new RegExp(d)).test(e)){var f=r.tune_opts[d];for(a=0;a<f.t_opts.length;a++){var g=f.t_opts[a];switch(g.match(/\S+/)[0]){case "score":case "staves":r.scores||(r.scores=[]);r.scores.push(g);break;default:U.do_pscom(g)}}if(f=f.v_opts)for(a in f)f.hasOwnProperty(a)&&(r.tune_v_opts||(r.tune_v_opts={}),r.tune_v_opts[a]=r.tune_v_opts[a]?r.tune_v_opts[a].concat(f[a]):f[a])}}var n,q="\n";if(abc2svg.mhooks)for(z in abc2svg.mhooks)Yd[z]||(Yd[z]=1,abc2svg.mhooks[z](U));
r.file=b;r.fname=a;void 0==c&&(c=0);d||(d=b.length);for("%abc-"==b.slice(c,c+5)&&(p["abc-version"]=/[1-9.]+/.exec(b.slice(c+5,c+10)));c<d;c=r.eol+1){var I=b.indexOf("\n",c);if(0>I||I>d)I=d;for(r.eol=I;;){I--;switch(b[I]){case " ":case "\t":continue}break}I++;if(I==c)1==r.state?(r.istart=c,v(1,"Empty line in tune header - ignored")):2<=r.state&&(h(),r.state=0,r.select&&(I=b.indexOf("\nX:",r.eol),0>I&&(I=d),r.eol=I));else{r.istart=r.bol=c;r.iend=I;r.line.index=0;var z=b[c];var t=b[c+1];if("I"==z&&":"==
t||"%"==z){if("%"==z&&0>r.prefix.indexOf(t))continue;if("a"==b[c+2]&&"b"==b[c+3]&&"c"==b[c+4]&&" "==b[c+5])c+=6,z=b[c],t=b[c+1];else var x=!0}if(x){x=!1;c+=2;var sa=b.slice(c,I);if((n=sa.match(/([^\s]+)\s*(.*)/))&&"%"!=n[1][0]){switch(n[1]){case "abcm2ps":case "ss-pref":r.prefix=n[2];continue;case "abc-include":yf(f(n[2]));continue}if("begin"==n[1].slice(0,5)){a=n[1].substr(5);var D="\n"+z+t+"end"+a;z=b.indexOf(D,I);0>z?(v(1,"No $1 after %%$2",D.slice(1),n[1]),r.eol=d):(U.do_begin_end(a,f(n[2]),b.slice(I+
1,z).replace(/\n%[^%].*$/gm,"").replace(/^%%/gm,"")),r.eol=b.indexOf("\n",z+6),0>r.eol&&(r.eol=d))}else{switch(n[1]){case "show_source":a=f(n[2]);switch(a[0]){case "*":z=b.indexOf("\n"+z+t+"show_source",I),c-=2,g(a,z),u.img_out(Z.src);case "0":a="";default:p[n[1]]=a}continue;case "select":if(0!=r.state){v(1,G.not_in_tune,"%%select");continue}z=f(n[2]);'"'==z[0]&&(z=z.slice(1,-1));if(!z){delete r.select;continue}z=z.replace(/\(/g,"\\(");z=z.replace(/\)/g,"\\)");r.select=new RegExp(z,"m");continue;
case "tune":if(0!=r.state){v(1,G.not_in_tune,"%%tune");continue}z=f(n[2]);if(!z){r.tune_opts={};continue}if("end"==z)continue;r.tune_opts||(r.tune_opts={});for(r.tune_opts[z]=z={t_opts:[]};;){c=I;if("%"!=b[c+1])break;I=b.indexOf("\n",I+1);if(b[c+2]==t){sa=b.slice(c+3,0>I?void 0:I);n=sa.match(/([^\s]+)\s*(.*)/);switch(n[1]){case "tune":break;case "voice":k(f(n[2],!0),!0);continue;default:z.t_opts.push(f(sa,!0));continue}break}}r.tune_v_opts&&(z.v_opts=r.tune_v_opts,r.tune_v_opts=null);r.eol=c;continue;
case "voice":if(0!=r.state){v(1,G.not_in_tune,"%%voice");continue}z=f(n[2]);if(!z){r.voice_opts=null;continue}k(z);continue}U.do_pscom(f(sa,!0))}}}else if(":"==t&&/[A-Za-z+]/.test(z)){for(c+=2;;){switch(b[c]){case " ":case "\t":c++;continue}break}if("+"==z){if(!F){v(1,"+: without previous info field");continue}q=" ";z=F}sa=f(b.slice(c,I),z);switch(z){case "X":if(0!=r.state){v(1,G.ignored,z);continue}if(r.select&&!e()){I=b.indexOf("\nX:",r.eol);0>I&&(I=d);r.eol=I;continue}Z.cfmt=y(p);Z.info=y(L,2);
Z.char_tb=y(Da);Z.glovar=y(oa);Z.maps=y(Lb,1);Z.mac=y(gc);Z.maci=y(hc);p.show_source&&(c-=2,g(p.show_source),"b"==p.show_source[0][0]&&u.img_out(Z.src),u.img_out('<div class="source">'));L.X=sa;r.state=1;r.tune_opts&&l();continue;case "T":switch(r.state){case 0:continue;case 1:case 2:sa=Cf(sa,L.T);L.T=void 0==L.T?sa:L.T+("\n"+sa);continue}z=Va("title");z.text=sa;continue;case "K":switch(r.state){case 0:continue;case 1:L.K=sa}kd(z,sa);continue;case "W":if(0==r.state||0>p.writefields.indexOf(z))break;
L.W=void 0==L.W?sa:L.W+(q+sa);break;case "m":if(2<=r.state){v(1,G.ignored,z);continue}n=sa.match(/(.*?)[= ]+(.*)/);if(!n||!n[2]){v(1,G.bad_val,"m:");continue}gc[n[1]]=n[2];hc[n[1][0]]=!0;break;case "s":if(3!=r.state||0>p.writefields.indexOf(z))break;Df(sa," "==q);break;case "w":if(3!=r.state||0>p.writefields.indexOf(z))break;Ef(sa," "==q);break;case "|":if(2>r.state)continue;r.line.buffer=sa;Zd();continue;default:if(0<="ABCDFGHNOSZ".indexOf(z)){if(2<=r.state){v(1,G.ignored,z);continue}L[z]=L[z]?L[z]+
(q+sa):sa}else{kd(z,sa);continue}}q="\n";var F=z}else F=void 0,2>r.state||(r.line.buffer=f(b.slice(c,I)),r.line.buffer&&Zd())}}Cb||(1==r.state&&(v(1,"End of file in tune header"),$d("C")),2<=r.state&&h(),Z.src&&"+"==p.show_source[0]&&(u.img_out(Z.src),Z.src=null),r.state=0)}function ec(a,b){var c=abc2svg.hdn[b];if(c)return c;var d=0,e=b;0!=e%12&&w(1,a,"Invalid note duration $1",e);(e/=12)||w(1,a,"Note too short");for(c=5;e&&!(e&1);e>>=1,c--);for(e>>=1;0<e>>d;)d++;c-=d;if(0<=c)a=m.FULL;else switch(c){default:w(1,
a,"Note too long"),c=-4;case -4:a=m.SQUARE;break;case -3:a=a.fmt.squarebreve?m.SQUARE:m.OVALBARS;break;case -2:a=m.OVAL;break;case -1:a=m.EMPTY}return abc2svg.hdn[b]=c=[a,d,c]}function ae(a){var b,c=a.stem;if(b=a.nhd){var d=.74*Ic[a.head];a.grace&&(d*=.6);if(0<=c){var e=1;var f=b+1;b=a.notes[0].pit}else d=-d,e=b-1,f=-1,b=a.notes[b].pit;for(var g=!1,h=0;e!=f;e+=c){var k=a.notes[e].pit-b;b=a.notes[e].pit;if(!k){if(g){k=a.notes[e].shhd=a.notes[e-c].shhd+d;h<k&&(h=k);continue}if(e+c!=f&&b+c==a.notes[e+
c].pit){a.notes[e].shhd=-d;h<-d&&(h=-d);continue}}0>k&&(k=-k);if(3<k||2<=k&&a.head!=m.SQUARE)g=!1;else if(g=!g)a.notes[e].shhd=d,h<d&&(h=d)}a.xmx=h}}function be(a,b){var c,d,e,f,g=a.length;for(c=g-1;0<=--c;)if((f=a[c].shhd)&&!(0<f)){f=(b||(a[c].s?Ic[a[c].s.head]:9))-f;var h=a[c].pit;for(d=g;0<=--d;)if(a[d].acc){var k=a[d].pit;if(k<h-3)break;!(k>h+3)&&a[d].shac<f&&(a[d].shac=f)}}for(d=g;0<=--d;)if(a[d].acc){k=a[d].pit;var m=a[d].shac;m||(m=a[d].shhd,c=b||Ic[a[d].s.head],m=0>m?c-m:c);break}if(!(0>d)){for(e=
0;e<d;e++)if(a[e].acc){h=a[e].pit;var n=a[e].shac;n||(n=a[e].shhd,c=b||Ic[a[e].s.head],n=0>n?c-n:c);break}if(d==e)a[d].shac=m;else{if(k>h+4)m>n&&(n=m),a[d].shac=a[e].shac=n;else{a[d].shac=m;if(a[d].pit!=a[e].pit||a[d].acc!=a[e].acc)m+=7;a[e].shac=n=m}n+=7;for(c=d;--c>e;)if(b=a[c].acc){f=a[c].shac;f<n&&(f=n);h=a[c].pit;for(d=g;--d>c;)a[d].acc&&(k=a[d].pit,!(k>=h+4&&(k>h+4||0>b||0>a[d].acc))&&f>a[d].shac-6&&(m=a[d].shac+7,m>f&&(f=m)));a[c].shac=f}}}}function Uc(a,b){a.next=b;a.prev=b.prev;a.prev?a.prev.next=
a:a.p_v.sym=a;b.prev=a}function ic(a,b){(a.ts_next=b)?(a.ts_prev=b.ts_prev,a.ts_prev&&(a.ts_prev.ts_next=a),b.ts_prev=a):(w(2,a,"Bad linkage"),a.ts_prev=null);a.seqst=!a.ts_prev||a.time!=a.ts_prev.time||Sa[a.ts_prev.type]!=Sa[a.type]&&!!Sa[a.ts_prev.type];b&&!b.seqst&&(b.seqst=b.time!=a.time||Sa[a.type]!=Sa[b.type]&&!!Sa[a.type],b.seqst&&(a=b.wl,U.set_width(b),b.a_ly&&ld(b),b.shrink?b.shrink+=b.wl-a:(b.shrink=b.wl,b.prev&&(b.shrink+=b.prev.wr)),b.space=0))}function Na(a){a.next&&(a.next.prev=a.prev);
a.prev?a.prev.next=a.next:a.p_v.sym=a.next;a.ts_next&&(a.seqst?a.ts_next.seqst?(a.ts_next.shrink+=a.shrink,a.ts_next.space+=a.space):(a.ts_next.seqst=!0,a.ts_next.shrink=a.shrink,a.ts_next.space=a.space):a.ts_next.seqst&&a.ts_prev&&a.ts_prev.seqst&&!Sa[a.ts_prev.type]&&(a.ts_next.seqst=!1,a.shrink=a.ts_next.shrink,a.space=a.ts_next.space),a.ts_next.ts_prev=a.ts_prev);a.ts_prev&&(a.ts_prev.ts_next=a.ts_next);M==a&&(M=a.ts_next);va==a&&(va=a.ts_next)}function ce(a,b,c){var d=a.p_v,e=a.st;a.type==m.BAR&&
a.prev&&a.prev.type==m.BAR&&":"!=a.prev.bar_type[0]&&(a=a.prev);d.last_sym=a.prev;d.last_sym||(d.sym=null);d.time=a.time;d=de(d,m.CLEF);d.next=a;a.prev=d;d.clef_type=b;d.clef_line=c;d.st=e;d.clef_small=!0;delete d.second;d.notes=[];d.notes[0]={pit:a.notes[0].pit};for(d.nhd=0;!a.seqst;)a=a.ts_prev;ic(d,a);a.soln&&(d.soln=!0,delete a.soln);return d}function ee(a,b,c){var d,e=0;for(d=0;d<a.a_gch.length;d++){var f=a.a_gch[d];switch(f.type){case "<":f=f.text.wh[0]+b;f>c&&(c=f);break;case ">":f=f.text.wh[0]+
a.wr,f>e&&(e=f)}}a.wr<e&&(a.wr=e);return c}function fe(a,b){md>=m.BLEN/2?b=md>=m.BLEN?b/4:b/2:!a.next&&b>=m.BLEN&&(b/=2);a=b>=m.BLEN/4?b<m.BLEN/2?5:b<m.BLEN?6:b<2*m.BLEN?7:b<4*m.BLEN?8:9:b>=m.BLEN/8?4:b>=m.BLEN/16?3:b>=m.BLEN/32?2:b>=m.BLEN/64?1:0;var c=b-(m.BLEN/16/8<<a);var d=p.spatab[a];c&&(0>c?d=p.spatab[0]*b/(m.BLEN/16/8):(9<=a&&(a=8),d+=(p.spatab[a+1]-p.spatab[a])*c/(m.BLEN/16/8<<a)));return d}function Ff(a,b){var c;var d=a.time-b;if(!d){switch(a.type){case m.MREST:return a.wl}return 0}if(a.ts_prev.type==
m.MREST)return 71;for(c=fe(a,d);!a.dur;){switch(a.type){case m.BAR:return a.next||(c*=.9),.9*c-3;case m.CLEF:return c-a.wl-a.wr;case m.BLOCK:case m.REMARK:case m.STAVES:case m.TEMPO:a=a.ts_next;if(!a)return c;continue;case m.NOTE:break;default:return c}break}if(d<=m.BLEN/4)for(d=a;d;){if(!d.beam_st){c*=.9;break}d=d.ts_next;if(!d||d.seqst)break}if(-1<=a.nflags&&0<a.stem){var e=!0;for(d=a.ts_prev;d&&d.time==b;d=d.ts_prev)if(d.type==m.NOTE&&(-1>d.nflags||0<d.stem)){e=!1;break}if(e){for(d=a.ts_next;d&&
d.time==a.time;d=d.ts_next)if(d.type==m.NOTE&&(-1>d.nflags||0>d.stem)){e=!1;break}e&&(c*=.9)}}return c}function ge(a,b){for(var c=a.time,d=b.time-c,e=fe(a,d),f=a,g=0;f=f.ts_next,f.seqst&&(g+=f.space,f.bar_type&&(g+=10)),f!=b;);for(e=(e+g)/2/d;a=a.ts_next,a.seqst&&(a.space=e*(a.time-c),c=a.time),a!=b;);}function bd(a){return{type:m.BAR,bar_type:"|",fname:a.fname,istart:a.istart,iend:a.iend,v:a.v,p_v:a.p_v,st:a.st,dur:0,time:a.time+(a.dur||0),nhd:0,notes:[{pit:a.notes?a.notes[0].pit:22}],seqst:!0,invis:!0,
prev:a,fmt:a.fmt}}function he(a){for(var b,c,d,e,f=M,g=f,h=0,k=[],l=[],n=h,q=f.time;;){e=0;do!f.a_gch&&!f.a_ly||c||(c=f),U.set_width(f),b=f.st,void 0==k[b]&&(k[b]=0),void 0==l[b]&&(l[b]=0),f.prev&&f.prev.st!=b&&(k[b]=k[f.prev.st],l[b]=l[f.prev.st]),b=k[b]+l[b]+f.wl,b>n&&(n=b),f.dur&&f.dur!=f.notes[0].dur&&(e=1),f=f.ts_next;while(f&&!f.seqst);g.shrink=n-h;g.space=g.ts_prev?Ff(g,q):0;0==g.space&&g.ts_prev&&g.ts_prev.type==m.SPACE&&g.ts_prev.seqst&&(g.space=g.ts_prev.space/=2);if(e){if(!a)break;d||(d=
g)}else d&&d.v==g.v&&(ge(d,g),d=null);g.shrink||(g.type!=m.CLEF||g.ts_prev.bar_type?(g.shrink=g.wl,n+=g.wl):(delete g.seqst,g.time=q));q=g.time;if(!f)break;f=g;do l[f.st]=0,f=f.ts_next;while(!f.seqst);h=n;do b=g.st,k[b]=h,g.wr>l[b]&&(l[b]=g.wr),g=g.ts_next;while(!g.seqst)}d&&ge(d,g);if(c){a=c;var p;f=e=0;for(T("vocal");a;a=a.ts_next)if(a.seqst&&(e+=a.shrink,f++),a.a_ly&&ld(a),a.a_gch)for(d=0;d<a.a_gch.length;d++)if(c=a.a_gch[d],!("g"!=c.type||0>c.y)){if(p&&p>e+c.x)for(a.prev&&a.prev.seqst&&a.prev.type==
m.BAR&&f--,p=(p-e-c.x)/f;;){var z=z.ts_next;z.shrink&&(z.shrink+=p);if(z==a||z.type==m.BAR)break}z=a;p=c.text.wh[0];e=f=0;break}}}function Ub(a){var b=y(a);b.prev.next=a.ts_prev=a.prev=b.ts_prev.ts_next=b;b.next=b.ts_next=a;a.seqst=!1;a.invis=a.play=!0;b.type=m.REST;delete b.in_tuplet;delete b.tp;delete b.a_dd;delete b.a_gch;delete b.sls;return b}function Gf(a){var b,c,d,e=a.repeat_n,f=a.repeat_k,g=a.st,h=a.v;a.repeat_n=0;if(0>e){var k=e=-e;for(c=a.prev;c;c=c.prev)if(!c.dur){if(c.type==m.BAR){w(1,
c,"Bar in repeat sequence");return}}else if(0>=--k)break;if(c){var l=a.time-c.time;k=f*e;for(b=a;b;b=b.next)if(!b.dur){if(b.type==m.BAR){w(1,b,"Bar in repeat sequence");return}}else if(0>=--k)break;if(b&&b.next){for(b=a.prev;b!=c;b=b.prev)if(b.type==m.NOTE){b.beam_end=!0;break}for(d=f;0<=--d;){k=e;a.dur&&k--;for(b=a.ts_next;0<k;)b.st==g&&(b.invis=b.play=!0,b.seqst&&b.ts_next.seqst&&(b.seqst=!1),b.v==h&&b.dur&&k--),b=b.ts_next;a=Ub(a);a.dur=a.notes[0].dur=l;a.rep_nb=-1;a.beam_st=!0;U.set_width(a);
a.head=m.SQUARE;for(a=b;a&&(a.st!=g||a.v!=h||!a.dur);a=a.ts_next);}}else w(1,a,G.not_enough_n)}else w(1,a,G.not_enough_n)}else{k=e;for(b=a.prev.prev;b&&(b.type!=m.BAR&&b.time!=M.time||!(0>=--k));b=b.prev);if(b){l=a.time-b.time;k=1==e?f:e;for(b=a;b&&!(b.type==m.BAR&&0>=--k);b=b.next);if(b){k=f;if(2==e&&1<k){b=b.next;if(!b){w(1,a,G.not_enough_m);return}b.repeat_n=e;b.repeat_k=--k}l/=e;if(2==e){for(b=a.ts_next;;b=b.ts_next)if(b.st==g)if(b.type==m.BAR){if(b.v==h)break}else b.invis=b.play=!0,b.seqst&&
b.ts_next.seqst&&(b.seqst=!1);c=Ub(a);c.dur=c.notes[0].dur=l;c.invis=!0;b.bar_mrep=2;c=b.next;for(b=c.ts_next;;b=b.ts_next)if(b.st==g)if(b.type==m.BAR){if(b.v==h)break}else b.dur&&(b.invis=b.play=!0,b.seqst&&b.ts_next.seqst&&(b.seqst=!1));c=Ub(c);c.dur=c.notes[0].dur=l;c.invis=!0;U.set_width(c)}else for(c=a,d=f;0<=--d;){for(b=c.ts_next;;b=b.ts_next)if(b.st==g)if(b.type==m.BAR){if(b.v==h)break}else b.dur&&(b.invis=b.play=!0,b.seqst&&b.ts_next.seqst&&(b.seqst=!1));c=Ub(c);c.dur=c.notes[0].dur=l;c.beam_st=
!0;if(1==f){c.rep_nb=1;break}c.rep_nb=f-d+1;c=b.next}}else w(1,a,G.not_enough_m)}else w(1,a,G.not_enough_m)}}function Vc(a){function b(a){if(p.custos&&1==C.length)a:{for(var b=a,c,d=b;d.type!=m.NOTE;)if(d=d.next,!d)break a;c=b.p_v;c.last_sym=b.prev;c.time=b.time;c=de(c,m.CUSTOS);c.next=b;b.prev=c;c.wl=0;c.wr=4;ic(c,b);c.shrink=b.shrink;12>c.shrink&&(c.shrink=12);c.space=d.space;c.head=m.FULL;c.stem=d.stem;c.nhd=d.nhd;c.notes=[];for(b=0;b<d.notes.length;b++)c.notes[b]={pit:d.notes[b].pit,shhd:0,dur:m.BLEN/
4};c.stemless=!0}a.nl=!0;a=a.ts_prev;a.type!=m.BAR&&(a.type!=m.KEY||a.k_sf||a.k_old_sf||a.k_a_acc||!a.prev||!a.prev.bar_type?(d=bd(a),b=a.ts_next,d.wl=0,d.wr=0,d.ts_prev=a,d.next=a.next,d.ts_next=a.ts_next,a.next&&(a.next.prev=d),a.ts_next.ts_prev=d,a.next=a.ts_next=d,d.shrink=b.shrink,b.shrink=b.wl+10,d.space=.9*b.space-3):Na(a))}var c;a=function(a){function b(a){a=a.bar_type.match(/(:*)([^:]*)(:*)/);a[3]?a[1]?(q=a[2].length/2|0,l=a[1]+"|"+a[2].slice(0,q),n=a[2].slice(q)+"|"+a[3]):(l="||",n="[|"+
a[3]):(l=a[1]+a[2],n="[")}function c(a,b,c){var d;for(d=b.ts_prev;d.time==a.time;d=d.ts_prev)if(d.v==a.v){if(d.bar_type){if("|"!=d.bar_type)return;var e=d;break}if(!f)var f=d.next}if(!e){e=y(a);f||(f=a);e.next=f;e.prev=f.prev;e.prev&&(e.prev.next=e);f.prev=e;e.ts_prev=b.ts_prev;e.ts_prev.ts_next=e;e.ts_next=b;b.ts_prev=e;a==c&&(e.seqst=1);if(e.seqst){for(a=e.ts_next;!a.seqst;a=a.ts_next);e.shrink=a.shrink;a.shrink=e.wr+a.wl;e.space=a.space;a.space=0}delete e.part}e.bar_type="||"}var d,e,l,n,q;for(d=
a;d&&d.time==a.time;){if(d.bar_type&&":"==d.bar_type.slice(-1)){var p=d;break}d=d.ts_next}if(p){for(d=p;c(p,a,d),p=p.ts_next,p&&!p.seqst;);return a}for(d=a;d.ts_prev&&d.ts_prev.time==a.time;)d=d.ts_prev,d.bar_type?e=d:!e&&d.type==m.GRACE&&d.seqst&&(a=d);if(!e||!e.bar_type||":"!=e.bar_type.slice(-1)&&!e.text)return a;for(a=e;a.time==e.time;a=a.ts_prev){switch(a.ts_prev.type){case m.KEY:case m.METER:case m.TEMPO:case m.STAVES:case m.STBRK:continue}break}for(d=e;;){b(e);p=y(e);p.bar_type=l;e.bar_type=
n;p.ts_prev=a.ts_prev;p.ts_prev.ts_next=p;p.ts_next=a;a.ts_prev=p;e==d&&(p.seqst=1);p.next=e;p.prev&&(p.prev.next=p);e.prev=p;e.rbstop&&(p.rbstop=e.rbstop);e.text&&(e.invis=1,delete e.xsh,delete p.text,delete p.rbstart);delete p.part;delete e.a_dd;delete e.a_gch;do e=e.ts_next;while(!e.seqst&&!e.bar_type);if(e.seqst)break}return a}(a);(function(a){var b,c,d;for(c=a;c&&c.time==a.time;c=c.ts_next){switch(c.type){case m.KEY:if(!c.fmt.keywarn||c.invis)continue;for(b=a.ts_prev;b&&b.type==m.METER;b=b.ts_prev);
case m.METER:if(c.type==m.METER){if(!a.fmt.timewarn)continue;b=a.ts_prev}case m.CLEF:if(!c.prev)continue;if(c.type==m.CLEF){if(c.clef_none)break;for(b=a.ts_prev;b;b=b.ts_prev){switch(b.type){case m.BAR:if(":"==b.bar_type[0])break;case m.KEY:case m.METER:continue}break}}var e=y(c);ic(e,b.ts_next);for(b=e;b=b.ts_next,b.v!=c.v;);Uc(e,b);if(e.seqst){U.set_width(e);e.shrink=e.wl;var l=e.ts_prev;for(d=0;;){l.wr>d&&(d=l.wr);if(l.seqst)break;l=l.ts_prev}e.shrink+=d;e.space=0;for(l=e;!l.ts_next.seqst;)l=l.ts_next;
for(d=0;l.wl>d&&(d=l.wl),l=l.ts_next,!l.seqst;);l.shrink=e.wr+d}delete e.part;continue}if(Sa[c.type])break}})(a);if(a.ts_prev.type!=m.STAVES)return b(a),a;for(a=a.ts_prev;a&&(!a.seqst||a.type==m.CLEF);a=a.ts_prev);var d=0;for(c=a.type;;a=a.ts_next){if(!a)return a;if(a.type!=c){c=a.type;if(0>d)break;switch(a.type){case m.STAVES:if(!a.ts_prev)return;if(a.ts_prev.type==m.BAR)break;for(;a.ts_next&&(!Sa[a.ts_next.type]||a.ts_next.type==m.CLEF);)a=a.ts_next;if(!a.ts_next||a.ts_next.type!=m.BAR)continue;
a=a.ts_next;case m.BAR:if(d)break;d=1;continue;case m.STBRK:a.stbrk_forced?d=-1:Na(a);continue;case m.CLEF:if(d)break;continue;default:if(!d||a.prev&&a.prev.type==m.GRACE)continue}break}}b(a);return a}function ie(){var a=C[0];U.set_width(a.clef);U.set_width(a.ckey);U.set_width(a.meter);return[a.clef.wl+a.clef.wr+a.ckey.wl+a.ckey.wr,a.meter.wl+a.meter.wr]}function je(a,b){for(var c,d,e=0,f=0,g=1-a.fmt.maxshrink;a!=b;)a.seqst&&(c=a.shrink,f+=c,e=(d=a.space)<c?e+c:e+(c*a.fmt.maxshrink+d*g),a.x=e),a=
a.ts_next;b&&(f+=b.wr);return[e,f]}function Jc(a){switch(a.type){case m.CLEF:a.y=6*(a.clef_line-1);if(a.second||a.invis){a.ymx=a.ymn=12;break}switch(a.clef_type){default:a.ymx=a.y+25;a.ymn=a.y-14;break;case "c":a.ymx=a.y+12;a.ymn=a.y-11;break;case "b":a.ymx=a.y+4,a.ymn=a.y-11}a.clef_small&&(a.ymx-=3,a.ymn+=2);24>a.ymx&&(a.ymx=24);0<a.ymn&&(a.ymn=0);a.clef_octave&&(0<a.clef_octave?a.ymx+=4:a.ymn-=4);break;case m.KEY:a.ymx=2<a.k_sf?34:0<a.k_sf?30:26;a.ymn=-2;break;default:a.ymx=24,a.ymn=0}}function Hf(){function a(a,
b){var c,d;switch(a.type){case m.REST:if(1==C.length)break;case m.NOTE:if(!a.p_v.ckey.k_drum)for(d=a.nhd;0<=d;d--){var e=a.notes[d];e.opit||(e.opit=e.pit);e.pit+=b}break;case m.GRACE:for(c=a.extra;c;c=c.next)if(!a.p_v.ckey.k_drum)for(d=0;d<=c.nhd;d++)e=c.notes[d],e.opit||(e.opit=e.pit),e.pit+=b}}function b(a){for(var b=a.a_dd.length;0<=--b;)a.a_dd[b].name.match(/1?[85][vm][ab]/)&&a.a_dd.splice(b,1)}var c,d,e,f=new Int8Array(V+1);for(c=M;c;c=c.ts_next){var g=c.st;if(e=c.ottava){if(e[0]){if(f[g]&&!e[1]){a(c,
f[g]);b(c);continue}}else if(!f[g]){b(c);continue}for(d=c;d&&!d.seqst;)d=d.ts_prev;if(d)for(;d!=c;)d.st==g&&(e[1]&&a(d,-f[g]),e[0]&&a(d,7*-e[0])),d=d.ts_next;f[g]=e[0]?7*-e[0]:0}f[g]&&a(c,f[g])}}function ke(a,b,c){var d;var e=14;var f=18;for(d=b;d&&(d.type!=m.STAVES||d==b);d=d.ts_next)if(d.st==a)if(d.type!=m.NOTE){if(d.type==m.CLEF){if("a"!=d.clef_type)break;Na(d)}}else d.notes[0].pit<f&&(f=d.notes[0].pit),d.notes[d.nhd].pit>e&&(e=d.notes[d.nhd].pit);if(19<=f||13<=f&&"b"!=c)return"t";if(13>=e||19>=
e&&"t"!=c)return"b";"a"==c&&(c=16<=(e+f)/2?"t":"b");f=c;var g=d,h=null;for(d=b;d!=g&&(d.type!=m.STAVES||d==b);d=d.ts_next)if(d.st==a&&d.type==m.NOTE){var k=d.time;if("t"==f){if(12<d.notes[0].pit||20<d.notes[d.nhd].pit){if(20<d.notes[0].pit||20<d.notes[d.nhd].pit)h=d;continue}if((e=d.ts_prev)&&e.time==k&&e.st==a&&e.type==m.NOTE&&19<=e.notes[0].pit)continue;if((e=d.ts_next)&&e.st==a&&e.time==k&&e.type==m.NOTE&&19<=e.notes[0].pit)continue}else{if(12>=d.notes[0].pit||20>d.notes[d.nhd].pit){if(12>=d.notes[d.nhd].pit||
12>=d.notes[0].pit)h=d;continue}if((e=d.ts_prev)&&e.time==k&&e.st==a&&e.type==m.NOTE&&13>=e.notes[0].pit)continue;if((e=d.ts_next)&&e.st==a&&e.time==k&&e.type==m.NOTE&&13>=e.notes[0].pit)continue}if(h){k=d;for(e=d.ts_prev;e!=h;e=e.ts_prev)if(e.st==a){if(e.type==m.BAR){k=":"!=e.bar_type[0]?e:e.next;break}e.type==m.NOTE&&e.beam_st&&!e.p_v.second&&(k=e)}k.time==h.time?h=d:(h=d,f="t"==f?"b":"t",e=ce(k,f,"t"==f?2:4),e.clef_auto=!0)}else f=c="t"==f?"b":"t",h=d}return c}function If(){function a(a){return 0<
a?6*Math.ceil(a/6):6*-Math.ceil(-a/6)}function b(){var b=h.dots?15:10;h.notes[0].shhd=b;h.xmx=b;k=(k+g.d)/2;k=a(k);h.y+=k;h.ymx+=k;h.ymn+=k;g.d=0}var c,d,e=[],f=K;for(c=M;c;c=c.ts_next)if(!c.invis){switch(c.type){case m.STAVES:f=c.sy;default:continue;case m.REST:if(c.invis||!c.multi)continue;var g=e[c.v];if(!g)e[c.v]=g={d:0};else if(g.d){var h=g.s;var k=a(g.d);h.y+=k;h.ymx+=k;h.ymn+=k;g.d=0}k=0<c.multi?0:24;c.prev&&c.prev.type==m.NOTE?k=c.next&&c.next.type==m.NOTE?(c.prev.y+c.next.y)/2:c.prev.y:c.next&&
c.next.type==m.NOTE?k=c.next.y:c.prev&&c.prev.type==m.REST&&(k=c.prev.y);0<c.multi?12<=k&&(g.d=k-c.y):12>=k&&(g.d=k-c.y);g.s=c;g.st=c.st;g.end_time=c.time+c.dur;c.fmr&&(g.end_time-=.3*c.p_v.wmeasure);if(c.seqst)continue;h=c.ts_prev;if(h.st!=c.st||h.invis)continue;k=h.ymn;e[h.v]&&e[h.v].d&&e[h.v]>=c.time&&(k+=e[h.v].d);if(c.ymx<=k)continue;if(h.type==m.NOTE){g.d=k-c.ymx;break}h.type==m.REST&&18>h.y&&6<=c.y&&(g.d=(k-c.ymx)/2);break;case m.NOTE:if(c.invis||!c.multi)continue}for(d=0;d<e.length;d++)if((g=
e[d])&&g.st==c.st&&d!=c.v&&!(g.end_time<=c.time)){h=g.s;if(f.voices[d].range>f.voices[c.v].range){if(h.ymx+g.d<=c.ymn)continue;k=c.ymn-h.ymx;c.type==m.REST?(e[c.v]||(e[c.v]={d:0}),6>e[c.v].d&&(e[c.v].d=6),k=-6):(k/=2,h.fmr&&(k-=6));if(g.d){if(0<g.d){b();continue}if(k>=g.d)continue}}else{if(h.ymn+g.d>=c.ymx)continue;k=c.ymx-h.ymn;c.type==m.REST&&h==c.ts_prev&&c.y==h.y?(e[c.v]||(e[c.v]={d:0}),-6<e[c.v].d&&(e[c.v].d=-6),k=6):h.time<c.time&&(k=c.ymx-h.y);if(g.d){if(0>g.d){b();continue}if(k<=g.d)continue}}g.d=
k}}for(d=0;d<e.length;d++)(g=e[d])&&g.d&&(h=g.s,k=a(g.d),h.y+=k,h.ymx+=k,h.ymn+=k)}function Kc(a,b,c){a.p_v=b;a.v=b.v;a.st=b.st;a.time=c.time;b.last_sym&&(a.next=b.last_sym.next,a.next&&(a.next.prev=a),b.last_sym.next=a,a.prev=b.last_sym);b.last_sym=a;ic(a,c)}function Jf(){var a,b,c=C.length,d=M.fmt;for(b=0;b<c;b++)if(K.voices[b]){var e=C[b];e.st=K.voices[b].st;e.second=K.voices[b].second;for(a=e.last_sym=e.sym;a&&a.time==M.time;a=a.next){switch(a.type){case m.CLEF:case m.KEY:case m.METER:switch(a.type){case m.CLEF:x[a.st].clef=
a;break;case m.KEY:a.p_v.ckey=a;break;case m.METER:a.p_v.meter=a,Wc=0<=p.writefields.indexOf("M")&&a.a_meter.length}a.part&&(a.next.part=a.part);Na(a);case m.TEMPO:case m.BLOCK:case m.REMARK:continue}break}}var f=M;for(b=0;b<c;b++)if(e=C[b],K.voices[b]&&(!K.voices[b].second||e.bar_start)){var g=K.voices[b].st;x[g]&&x[g].clef&&(a=y(x[g].clef),a.v=b,a.p_v=e,a.st=g,a.time=M.time,a.prev=null,a.next=e.sym,a.next&&(a.next.prev=a),e.sym=e.last_sym=a,a.ts_next=f,a.ts_prev=f?f.ts_prev:null,a.ts_prev?(a.ts_prev.ts_next=
a,delete a.seqst):M=a,f&&(f.ts_prev=a),delete a.clef_small,delete a.part,a.second=K.voices[b].second,K.st_print[g]?a.clef_none||delete a.invis:a.invis=!0,a.fmt=d)}for(b=0;b<c;b++)K.voices[b]&&!K.voices[b].second&&K.st_print[K.voices[b].st]&&(e=C[b],g=e.ckey,g.k_sf||g.k_a_acc)&&(a=y(g),Kc(a,e,f),delete a.invis,delete a.part,a.k_old_sf=g.k_sf,a.fmt=d);if(Wc){for(b=0;b<c;b++)e=C[b],g=e.meter,K.voices[b]&&!K.voices[b].second&&K.st_print[K.voices[b].st]&&(a=y(g),Kc(a,e,f),delete a.part,a.fmt=d);Wc=!1}for(b=
0;b<c;b++)e=C[b],e.sls.length&&(a={type:m.BAR,fname:f.fname,bar_type:"|",dur:0,multi:0,invis:!0,sls:e.sls,fmt:d},Kc(a,e,f),e.sls=[]);for(b=0;b<c;b++){e=C[b];g=e.bar_start;e.bar_start=null;for(a=f;a&&a.time==f.time;a=a.ts_next)if(a.rbstop){g=null;break}g&&K.voices[b]&&K.st_print[K.voices[b].st]&&(e.last_sym.type==m.BAR?e.last_sym.rbstop||(e.last_sym.rbstart=1):(Kc(g,e,f),g.fmt=d))}U.set_pitch(f);a=M;a.seqst=!0;for(a=f;a.ts_next&&!a.ts_next.seqst;a=a.ts_next);if(a.ts_next&&a.ts_next.type!=m.CLEF&&!a.tp&&
!a.ts_next.a_ly)for(a=a.ts_next;a.ts_next&&!a.ts_next.seqst;a=a.ts_next);g=a.ts_next;a.ts_next=null;he();a.ts_next=g}function Kf(a){function b(a){a.prev.trem2=!0;a.prev.head=++a.head;0<--a.nflags?a.nflags+=a.ntrem:(-2>=a.nflags&&(a.stemless=!0,a.prev.stemless=!0),a.nflags=a.ntrem);a.prev.nflags=a.nflags}var c,d,e=!0,f=127;for(c=a.sym;c;c=c.next)if(c.type==m.NOTE){f=c.notes[0].pit;break}for(c=a.sym;c;c=c.next){c.a_gch&&U.gch_build(c);switch(c.type){case m.MREST:e=!0;break;case m.BAR:if(d=c.fmt.bardef[c.bar_type])c.bar_type=
d;c.beam_on||(e=!0);c.next||!c.prev||c.invis||c.prev.head!=m.OVALBARS||(c.prev.head=m.SQUARE);break;case m.GRACE:for(a=c.extra;a;a=a.next)a.notes.sort(abc2svg.pitcmp),d=ec(a,a.dur_orig),a.head=d[0],a.dots=d[1],a.nflags=d[2],!a.trem2||a.next&&!a.next.trem2||b(a);break;case m.NOTE:case m.REST:if(d=ec(c,c.dur_orig),c.head=d[0],c.dots=d[1],c.nflags=d[2],-2>=c.nflags&&(c.stemless=!0),c.xstem&&(c.nflags=0),c.trem1&&(c.nflags=0<c.nflags?c.nflags+c.ntrem:c.ntrem),!c.next||!c.next.trem2)if(c.trem2)b(c);else{a=
c.nflags;c.ntrem&&(a-=c.ntrem);c.type==m.REST&&c.beam_end&&!c.beam_on&&(e=!0);if(e||0>=a){if(g){g.beam_end=!0;var g=null}if(0>=a)c.beam_st=c.beam_end=!0;else if(c.type==m.NOTE||c.beam_on)c.beam_st=!0,e=!1}c.beam_end&&(e=!0);if(c.type==m.NOTE||c.beam_on)g=c}}if(c.type==m.NOTE)for(c.nhd&&c.notes.sort(abc2svg.pitcmp),f=c.notes[0].pit,a=c.prev;a&&a.type==m.REST;a=a.prev)a.notes[0].pit=f;else c.notes||(c.notes=[],c.notes[0]={},c.nhd=0),c.notes[0].pit=f}g&&(g.beam_end=!0)}function Lf(){function a(a,b){var c=
0;for(a+="\n";;){var d=a.indexOf("\n",c);if(0>d)break;c=ua(a.slice(c,d))[0]+12;c>b&&(b=c);if(0>d)break;c=d+1}return b}var b,c=K,d=[0,0,0],e=C.length;for(b=0;b<e;b++){var f=C[b];var g=f.nm;f=f.snm;if((g||f)&&!h){T("voice");var h=A.deffont}g&&(g=a(g,d[1]),g>d[1]&&(d[1]=g));f&&(g=a(f,d[2]),g>d[2]&&(d[2]=g))}for(g=0;c;){for(b=0;b<=c.nstaff;b++){if(c.staves[b].flags&1280){g=12;break}c.staves[b].flags&5&&(g=6)}if(12==g)break;c=c.next}d[0]=g;d[1]+=g;d[2]+=g;return d}function Mf(a,b){var c,d,e,f=a.fmt.shiftunison||
0;if(3<=f||(d=a.dur)>=m.BLEN||(e=b.dur)>=m.BLEN||a.stemless&&b.stemless||a.dots!=b.dots&&(f&1||0!=a.dots*b.dots)||0<a.stem*b.stem)return!1;var g=c=0;if(a.notes[0].pit>b.notes[0].pit){if(0>a.stem)return!1;for(;b.notes[c].pit!=a.notes[0].pit;)if(++c>b.nhd)return!1}else if(a.notes[0].pit<b.notes[0].pit){if(0>b.stem)return!1;for(;b.notes[0].pit!=a.notes[g].pit;)if(++g>a.nhd)return!1}if(b.notes[c].acc!=a.notes[g].acc)return!1;var h=g;var k=c;var l=a.notes[g].shhd;var n=b.notes[c].shhd;do{g++;c++;if(g>
a.nhd)break;if(c>b.nhd)break;if(b.notes[c].acc!=a.notes[g].acc)return!1;l<a.notes[g].shhd&&(l=a.notes[g].shhd);n<b.notes[c].shhd&&(n=b.notes[c].shhd)}while(b.notes[c].pit==a.notes[g].pit);if(g<=a.nhd){if(c<=b.nhd||0<b.stem)return!1}else if(c<=b.nhd&&0<a.stem)return!1;var q=g;g=c;c=0;if(d!=e)if(d<e&&(d=e,e=a.dur),d<m.BLEN/2)b.dots?c=2:a.dots&&(c=1);else if(e<m.BLEN/4){if(f&2)return!1;c=b.dur>=m.BLEN/2?2:1}else return!1;c||(c=a.p_v.scale<b.p_v.scale?2:1);if(1==c){for(c=k;c<g;c++)b.notes[c].invis=!0,
delete b.notes[c].acc;for(c=0;c<=b.nhd;c++)b.notes[c].shhd+=l}else{for(g=h;g<q;g++)a.notes[g].invis=!0,delete a.notes[g].acc;for(g=0;g<=a.nhd;g++)a.notes[g].shhd+=n}a.dots==b.dots&&(b.dots=0);return!0}function nd(a){var b,c=Xc[a.head],d=c,e=[];for(b=0;96>b;b++)e.push(-100);if(-2<a.nflags){if(0<a.stem){d=-d;b=2*a.notes[0].pit;var f=2*(Math.ceil((a.ymx-2)/3)+18)}else b=2*(Math.ceil((a.ymn+2)/3)+18),f=2*a.notes[a.nhd].pit;0>b&&(b=0);for(96<=f&&(f=95);b<=f;)e[b++]=d}var g=a.notes[0<a.stem?0:a.nhd].shhd;
for(f=0;f<=a.nhd;f++)d=-a.notes[f].shhd+c+g,b=2*a.notes[f].pit,0>b?b=0:95<=b&&(b=94),d>e[b]&&(e[b]=d),a.head!=m.SQUARE&&--d,d>e[b-1]&&(e[b-1]=d),d>e[b+1]&&(e[b+1]=d);return e}function od(a){var b,c=Xc[a.head],d=c,e=0<a.nflags&&a.beam_st&&a.beam_end,f=[];for(b=0;96>b;b++)f.push(-100);if(-2<a.nflags){if(0>a.stem){d=-d;b=2*(Math.ceil((a.ymn+2)/3)+18);var g=2*a.notes[a.nhd].pit;var h=b+4}else b=2*a.notes[0].pit,g=2*(Math.ceil((a.ymx-2)/3)+18);0>b&&(b=0);for(96<g&&(g=96);b<g;)f[b++]=d}if(e)if(0<a.stem)for(b=
0==a.xmx?2*a.notes[a.nhd].pit:2*a.notes[0].pit,b+=4,0>b&&(b=0);96>b&&b<=g-4;b++)f[b]=11;else for(b=h,0>b&&(b=0);96>b&&b<=2*a.notes[0].pit-4;b++)f[b]=3.5;h=a.notes[0<a.stem?0:a.nhd].shhd;for(g=0;g<=a.nhd;g++)d=a.notes[g].shhd+c-h,b=2*a.notes[g].pit,0>b?b=0:95<=b&&(b=94),d>f[b]&&(f[b]=d),a.head!=m.SQUARE&&--d,d>f[b-1]&&(f[b-1]=d),d>f[b+1]&&(f[b+1]=d);return f}function Nf(){function a(a){var b=x[a],c=f.staves[a];b||(b=x[a]={});b.y=0;b.stafflines=c.stafflines;b.staffscale=c.staffscale;b.ann_top=b.ann_bot=
0}function b(){var a,b,c=f.staves.length;for(a=0;a<c;a++)if(f.staves[a].flags&257){var d=0;for(b=a;a<c;){d|=h[a]?1:2;if(f.staves[a].flags&514)break;a++}if(3==d)for(;b<=a;)h[b]=!0,e[b++]=!0}}var c,d,e=[],f=K;if(M.type==m.STAVES){var g=M;M=M.ts_next;M.ts_prev=null;g.seqst&&(M.seqst=!0);if(g.p_v.sym=g.next)g.next.prev=null}V=f.nstaff;for(c=0;c<=V;c++)a(c);var h=new Uint8Array(V+1);for(g=M;g&&!g.nl;g=g.ts_next){switch(g.type){case m.STAVES:b();f.st_print=h;for(f=g.sy;V<f.nstaff;)a(++V);h=new Uint8Array(V+
1);continue;case m.BLOCK:g.play?g.ts_next&&g.ts_next.shrink&&(g.ts_next.shrink=0):(Yc.push(g),Na(g));continue}c=g.st;if(c>V){switch(g.type){case m.CLEF:x[c].clef=g;break;case m.KEY:g.p_v.ckey=g;break;case m.METER:g.p_v.meter=g}Na(g)}else if(!h[c]){switch(g.type){default:continue;case m.BAR:if(g.bar_mrep||1<f.staves[c].staffnonote)break;continue;case m.GRACE:break;case m.NOTE:case m.REST:case m.SPACE:case m.MREST:if(!(1<f.staves[c].staffnonote)){if(g.invis)continue;if(!f.staves[c].staffnonote&&g.type!=
m.NOTE)continue}}e[c]=h[c]=!0}}va=g;b();f.st_print=h;(function(){var a,b;for(a=0;a<=V;a++){var c=x[a];c.hlu=[];c.hld=[];var d=c.stafflines.length;c.topbar=6*(d-1);for(b=0;b<d-1;b++){switch(c.stafflines[b]){case ".":case "-":continue}break}c.botbar=6*b;b>=d-2&&("."!=c.stafflines[b]?(c.botbar-=6,c.topbar+=6):(c.botbar-=12,c.topbar+=12))}})();if(va){g=va;delete g.nl;c=g.ts_prev;c.ts_next=null;var k=C.length;for(d=0;d<k;d++){var l=C[d];if(l.sym&&l.sym.time<=va.time){for(g=c;g;g=g.ts_prev)if(g.v==d){l.s_next=
g.next;g.next=null;break}if(g)continue}l.s_next=l.sym;l.sym=null}}Jf();A.st_print=e}function le(){for(var a=M,b=a.time;a;a=a.ts_next){if(a.time!=b){lb();return}switch(a.type){case m.NOTE:case m.REST:case m.MREST:case m.SPACE:lb();return;default:continue;case m.STAVES:K=a.sy;continue;case m.BLOCK:if(a.play)continue;U.block_gen(a)}Na(a);a.p_v.s_next==a&&(a.p_v.s_next=a.next)}M=null}function Wa(a){a.fname=r.fname;a.istart=r.istart;a.iend=r.iend}function me(a){var b={type:m.CLEF,clef_line:2,clef_type:"t",
v:l.v,p_v:l,time:l.time,dur:0,clef_small:1},c=1;Wa(b);switch(a[0]){case '"':c=a.indexOf('"',1);b.clef_name=a.slice(1,c);c++;break;case "a":if("u"==a[1]){b.clef_type="a";b.clef_auto=!0;c=4;break}c=4;case "C":b.clef_type="c";b.clef_line=3;break;case "b":c=4;case "F":b.clef_type="b";b.clef_line=4;break;case "n":c=4;b.invis=!0;b.clef_none=1;break;case "t":if("e"==a[1]){b.clef_type="c";b.clef_line=4;break}c=6;case "G":break;case "p":c=4;case "P":b.clef_type="p";b.clef_line=3;break;default:v(1,"Unknown clef '$1'",
a);return}"1"<=a[c]&&"9">=a[c]&&(b.clef_line=+a[c],c++);delete l.snd_oct;if("8"!=a[c+1]&&"1"!=a[c+1])return b;switch(a[c]){case "^":b.clef_oct_transp=!0;case "+":b.clef_octave="8"==a[c+1]?7:14;b.clef_oct_transp||(l.snd_oct=8==a[c+1]?12:24);break;case "_":b.clef_oct_transp=!0;case "-":b.clef_octave="8"==a[c+1]?-7:-14,b.clef_oct_transp||(l.snd_oct=8==a[c+1]?-12:-24)}return b}function Db(a,b){var c;var d=new F;d.buffer=a;var e=[];for(a=0;2>a;a++)if(c=d.buffer[d.index]?jc(d):null){if("object"==typeof c.acc){v(1,
G.bad_transp);return}e[a]=abc2svg.pab40(c.pit,c.acc)}else{if(1!=a||!b){v(1,G.bad_transp);return}e[a]=242}return e[1]-e[0]}function ne(a){var b;if(b=a.match(/(.)[=\s]*(\[I:.+\]|".+"|!.+!)$/)){a=b[1];var c=b[2];"\\"==a[0]&&("t"==a[1]?a="\t":a[1]||(a=" "));b=a.charCodeAt(0);if(128<=b)v(1,G.not_ascii);else{switch(Da[b][0]){case "0":case "d":case "i":case " ":break;case '"':case "!":case "[":if(1<Da[b].length)break;default:v(1,"Bad user character '$1'",a);return}switch(c){case "!beambreak!":c=" ";break;
case "!ignore!":c="i";break;case "!nil!":case "!none!":c="d"}Da[b]=c}}else v(1,'Lack of starting [, ! or " in U: / %%user')}function Of(a){if(a){if(/^[\]\[|.':-]+$/.test(a))return a.replace(/\]/g,"[");a=+a;switch(a){case 0:return"...";case 1:return"..|";case 2:return".||";case 3:return".|||"}if(!(isNaN(a)||0>a||16<a))return"||||||||||||||||".slice(0,a)}}function Va(a){a={type:m.BLOCK,subtype:a,dur:0};ja(a);return a}function Sd(a){l.init||(l.init=!0,L.V&&(L.V[l.id]&&(a=L.V[l.id].concat(a)),L.V["*"]&&
(a=L.V["*"].concat(a))));a.length&&U.set_vp(a)}function fc(a,b){b.length&&(L.V||(L.V={}),L.V[a]?Array.prototype.push.apply(L.V[a],b):L.V[a]=b)}function Pf(a){var b={type:m.METER,dur:0,a_meter:[]};var c={},d=0,e=0,f;Wa(b);if(0==a.indexOf("none")){e=4;var g=1}else for(g=0;e<a.length&&"="!=a[e];){switch(a[e]){case "C":c.top=a[e++];if(!d)var h=d=4;break;case "c":case "o":c.top=a[e++];if(!d)switch(d="c"==a[e-1]?2:3,h=4,a[e]){case "|":h/=2;break;case ".":d*=3,h*=2}break;case ".":case "|":d=0;c.top=a[e++];
break;case "(":if("("==a[e+1]){var k=!0;c.top=a[e++];b.a_meter.push(c);c={}}for(f=e+1;f<a.length&&")"!=a[f]&&"/"!=a[f];)f++;if(")"==a[f]&&"/"==a[f+1]){e++;continue}case ")":k="("==a[e];c.top=a[e++];b.a_meter.push(c);c={};continue;default:if("0">=a[e]||"9"<a[e]){v(1,"Bad char '$1' in M:",a[e]);return}h=2;for(c.top=a[e++];;){for(;"0"<=a[e]&&"9">=a[e];)c.top+=a[e++];if(")"==a[e]){if("/"!=a[e+1])break;e++}if("/"==a[e]){e++;if("0">=a[e]||"9"<a[e]){v(1,"Bad char '$1' in M:",a[e]);return}for(c.bot=a[e++];"0"<=
a[e]&&"9">=a[e];)c.bot+=a[e++];break}if(" "!=a[e]&&"+"!=a[e])break;if(e>=a.length||"("==a[e+1])break;c.top+=a[e++]}d=eval(c.top.replace(/ /g,"+"))}k||(c.bot&&(h=+c.bot),g+=d*m.BLEN/h);b.a_meter.push(c);for(c={};" "==a[e];)e++;"+"==a[e]&&(c.top=a[e++],b.a_meter.push(c),c={})}if("="==a[e]){g=a.substring(++e).match(/^(\d+)\/(\d+)$/);if(!g){v(1,"Bad duration '$1' in M:",a.substring(e));return}g=m.BLEN*g[1]/g[2]}if(g)if(b.wmeasure=g,0>p.writefields.indexOf("M")&&(b.a_meter=[]),3!=r.state){if(L.M=a,oa.meter=
b,r.state)for(oa.ulen||(oa.ulen=1>=g||g>=3*m.BLEN/4?m.BLEN/8:m.BLEN/16),a=0;a<C.length;a++)C[a].meter=b,C[a].wmeasure=g}else for(l.wmeasure=g,pd()?l.meter=b:ja(b),b=l.voice_down;b;b=b.voice_down)b.wmeasure=g;else v(1,G.bad_val,"M:")}function oe(a,b){var c;if(l.v==H.top_voice)ja(a);else if(C[H.top_voice].time==a.time){var d=l;l=C[H.top_voice];ja(a);l=d}else if(C[H.top_voice].time>a.time)for(d=C[H.top_voice],c=d.sym;;c=c.next){if(c.time>=a.time){Wa(a);a.fmt=p;a.next=c;(a.prev=c.prev)?a.prev.next=a:
d.sym=a;c.prev=a;a.v=c.v;a.p_v=d;a.st=d.st;break}}else Wa(a),a.fmt=p,r.pq_d||(r.pq_d=[]),r.pq_d.push(a);r.pq||(r.pq={});r.pq[b]=a.time}function Qf(a){function b(a){var b;if((b=a.match(/(\d+)\/(\d+)/))&&(a=+b[2])&&!isNaN(a)&&!(a&a-1)&&(b=+b[1],!isNaN(b)))return m.BLEN*b/a;v(1,"Invalid note duration $1",e)}var c=a,d={type:m.TEMPO,dur:0};Wa(d);0>p.writefields.indexOf("Q")&&(d.invis=!0);if('"'==a[0]){var e=a.match(/"([^"]*)"/);if(!e){v(1,"Unterminated string in Q:");return}d.tempo_str1=e[1];a=a.slice(e[0].length).replace(/^\s+/,
"")}if('"'==a.slice(-1)){var f=a.indexOf('"');d.tempo_str2=a.slice(f+1,-1);a=a.slice(0,f).replace(/\s+$/,"")}f=a.indexOf("=");if(0<f){var g=a.slice(0,f).split(/\s+/);for(a=a.slice(f+1).replace(/^\s+/,"");;){e=g.shift();if(!e)break;f=b(e);if(!f)return;d.tempo_notes||(d.tempo_notes=[]);d.tempo_notes.push(f)}"ca. "==a.slice(0,4)&&(d.tempo_ca="ca. ",a=a.slice(4));f=a.indexOf("/");if(0<f){f=b(a);if(!f)return;d.new_beat=f}else if(d.tempo=+a,!d.tempo||isNaN(d.tempo)){v(1,"Bad tempo value");return}}2>r.state||
!l.time&&!oa.tempo?(L.Q=c,oa.tempo=d):(oa.tempo||v(0,"No previous tempo"),d.time=l.time,a="Q"+(d.tempo_str1?"S":"")+d.time,r.pq&&r.pq[a]==d.time||oe(d,a))}function kd(a,b){if(l&&l.ignore)switch(a){default:return;case "P":case "Q":case "V":}switch(a){case "I":U.do_pscom(b);break;case "L":if(a=b.match(/^1\/(\d+)(=(\d+)\/(\d+))?$/)){var c=+a[1];if(!c||0!=(c&c-1))break;c=m.BLEN/c;var d=a[2]?(d=+a[4])?+a[3]/d*m.BLEN:0:c}else"auto"==b&&(c=d=-1);if(!d){v(1,"Bad L: value");break}1>=r.state?oa.ulen=c:(l.ulen=
c,l.dur_fact=d/c);break;case "M":Pf(b);break;case "U":ne(b);break;case "P":if(!r.state)break;if(1==r.state){L.P=b;break}c={type:m.PART,text:b,time:l.time};if(L.P){d=r.pq&&r.pq[b];if(d==c.time)break;if(null!=d){v(1,"Misplaced P:");break}}0>p.writefields.indexOf("P")&&(c.invis=1);oe(c,b);break;case "Q":if(!r.state)break;Qf(b);break;case "V":qd(b);3==r.state&&(l.ignore=!H.voices[l.v]);break;case "K":if(!r.state)break;$d(b);break;case "N":case "R":L[a]=L[a]?L[a]+("\n"+b):b;break;case "r":if(!u.keep_remark||
3!=r.state)break;c={type:m.REMARK,text:b,dur:0};ja(c);break;default:v(0,"'$1:' line ignored",a)}}function pe(){var a,b=r.line,c={type:m.BAR,fname:r.fname,istart:r.bol+b.index,dur:0,multi:0};fa&&fa.bar&&Tb("|");oa.new_nbar&&(c.bar_num=oa.new_nbar,oa.new_nbar=0);for(a=b.char();;){var d=b.next_char();switch(d){case "|":case "[":case "]":case ":":a+=d;continue}break}":"==a[0]&&(":"==a?(a="|",c.bar_dotted=!0):c.rbstop=2);Ia&&Vb(c);ma.length&&dc(c);"["!=a.slice(-1)||/[0-9" ]/.test(d)||(a=a.slice(0,-1),
b.index--,d="[");if("0"<d&&"9">=d)for(c.text=d;;){d=b.next_char();if(0>"0123456789,.-".indexOf(d))break;c.text+=d}else if('"'==d&&"["==a.slice(-1))for(c.text="";;){d=b.next_char();if(!d){v(1,"No end of repeat string");return}if('"'==d){b.index++;break}c.text+=d}"]"==a[0]&&(c.rbstop=2,1!=a.length?a=a.slice(1):c.invis=!0);c.iend=r.bol+b.index;c.text&&"["==a.slice(-1)&&"["!=a&&(a=a.slice(0,-1));":"==a.slice(-1)&&(c.rbstop=1,c.text&&(v(1,"Variant ending on a left repeat bar"),delete c.text),l.tie_s_rep=
null);c.text&&(c.rbstart=c.rbstop=2,"1"==c.text[0]?(l.tie_s_rep=l.tie_s,l.acc_tie?l.acc_tie_rep=l.acc_tie.slice():l.acc_tie_rep&&(l.acc_tie_rep=null)):(l.tie_s=l.tie_s_rep,l.acc_tie_rep&&(l.acc_tie=l.acc_tie_rep.slice())),l.norepbra&&!l.second&&(c.norepbra=1));if(0>l.ulen){var e;if((d=l.last_sym)&&d.type!=m.MREST&&d.type!=m.BAR){for(;d.type!=m.BAR&&d.prev;)d=d.prev;b=d.time;var f=l.wmeasure/(l.time-b);if(1!=f){for(;d;d=d.next)if(d.time=b,d.dur&&!d.grace&&(d.dur*=f,d.dur_orig*=f,b+=d.dur,d.type==m.NOTE||
d.type==m.REST))for(e=0;e<=d.nhd;e++)d.notes[e].dur*=f;l.time=c.time=b}}}if(!("["!=a&&"|:"!=a||l.eoln||c.a_gch||c.invis)&&(d=l.last_sym)&&d.type==m.BAR){if("["==a&&!d.text||c.norepbra){c.text&&(d.text=c.text,!l.st||c.norepbra||H.staves[l.st-1].flags&64||(d.xsh=4));c.norepbra&&(d.norepbra=1);c.rbstart&&(d.rbstart=c.rbstart);c.rbstop&&(d.rbstop=c.rbstop);return}if("|:"==a)switch(d.bar_type){case ":|":d.bar_type="::";d.rbstop=2;return}}switch(a){case "[":case "[]":case "[|]":c.invis=!0;a=c.rbstart?"[":
"[]";break;case ":|:":case ":||:":a="::";break;case "||":if("2.2"<=p["abc-version"])break;case "[|":case "|]":c.rbstop=2}c.bar_type=a;l.lyric_restart||(l.lyric_restart=c);l.sym_restart||(l.sym_restart=c);ja(c);c.st=l.st;!(c.text&&0<c.st)||c.norepbra||H.staves[c.st-1].flags&64||"["==a||(c.xsh=4);c.bar_dotted||c.invis||(l.acc=[])}function kc(a){if(!a)return[];a=a.match(/[^\s"=]+=?|"[^"]*"/g);return a?a:(v(1,"Unterminated string"),[])}function lc(a){Wb.lastIndex=a.index;var b=Wb.exec(a.buffer);if(!b[0])return[1,
1];var c=b[1]||1;var d=b[3]||1;b[3]||(d*=1<<b[2].length);a.index=Wb.lastIndex;return[+c,+d]}function jc(a){var b=a.char();switch(b){case "^":b=a.next_char();if("^"==b){var c=2;b=a.next_char()}else c=1;break;case "=":c=3;b=a.next_char();break;case "_":b=a.next_char(),"_"==b?(c=-2,b=a.next_char()):c=-1}if(1==c||-1==c)if("1"<=b&&"9">=b||"/"==b){var d=lc(a);0>c&&(d[0]=-d[0]);p.nedo&&1==d[1]&&(d[0]*=12,d[1]*=p.nedo);c=d;b=a.char()}d=qb.indexOf(b)+16;b=a.next_char();if(16>d)v(1,"'$1' is not a note",a.buffer[a.index-
1]);else{for(;"'"==b;)d+=7,b=a.next_char();for(;","==b;)d-=7,b=a.next_char();a={pit:d,shhd:0,shac:0};c&&(a.acc=c);return a}}function rd(a,b,c,d){var e=qe(b.pit,c),f=Lb[a.map];if(f&&function(){if(f[e])return 1;e="o"+e.replace(/[',]+/,"");if(f[e])return 1;var d=(d=abc2svg.keys[a.ckey.k_sf+7][(b.pit+75)%7])||3!=c?c:0;e="k"+"__ _  ^ ^^ =".split(" ")[d+2]+qb[(b.pit+75-11*a.ckey.k_sf)%7];if(f[e])return 1;e=e.replace(/[_=^]/g,"");if(f[e])return 1;d=a.ckey.k_sf+[0,2,4,-1,1,3,-2][a.ckey.k_mode];-7>d?d+=7:
7<d&&(d-=7);d=(d=abc2svg.keys[d+7][(b.pit+75)%7])&&3==c?-d:d||c?c-d:3;e="t"+"__ _ = ^ ^^ ".split(" ")[d+2]+qb[(b.pit+75-a.ckey.k_mode-11*a.ckey.k_sf)%7];if(f[e])return 1;e=e.replace(/[_=^]/g,"");if(f[e])return 1;e="*";return f[e]}())if(f=f[e],d)f[1]&&f[1].notrp&&(b.notrp=1);else if(f[1]&&!b.map&&(b.pit=f[1].pit,b.acc=f[1].acc,f[1].notrp&&(b.notrp=1,b.noplay=1)),b.map=f,f[2]&&(b.color=f[2]),e=f[3])b.midi=re(e.pit+19,e.acc)}function mc(){var a=r.line,b=0;ma.length&&"dot"==ma[ma.length-1]&&(b=m.SL_DOTTED,
ma.pop());switch(a.next_char()){case "'":return a.index++,b+m.SL_ABOVE;case ",":return a.index++,b+m.SL_BELOW;case "?":return a.index++,b+m.SL_CENTER}return b+m.SL_AUTO}function se(a,b){var c;for(c=l.sls.length;0<=--c;){var d=l.sls[c];if(d.ss!=a){l.sls.splice(c,1);d.se=a;b&&(d.nte=b);c=d.ss;c.sls||(c.sls=[]);c.sls.push(d);d.grace&&(d.grace.sl1=!0);return}}for(c=a.prev;c;c=c.prev)if(c.type==m.BAR&&":"==c.bar_type[0]&&c.text){c.sls||(c.sls=[]);c.sls.push({ty:m.SL_AUTO,ss:c,se:a});b&&(c.sls[c.sls.length-
1].nte=b);return}a.sls||(a.sls=[]);a.sls.push({ty:m.SL_AUTO,se:a,loc:"i"});b&&(a.sls[a.sls.length-1].nte=b)}function re(a,b){var c=[0,2,4,5,7,9,11][a%7],d=12*(a/7|0);l.snd_oct&&(d+=l.snd_oct);3==b&&(b=0);if(b)if("object"==typeof b){var e=b[0]/b[1];if(100==b[1])return c+d+e}else e=b;else return p.temper?p.temper[abc2svg.p_b40[a%7]]+d:c+d;if(p.nedo){c=p.temper[abc2svg.p_b40[a%7]];if("object"!=typeof b)return a=abc2svg.p_b40[a%7]+b,a=p.temper[a],0<e?a<c&&(a+=12):a>c&&(a-=12),a+d;if(b[1]==p.nedo)return a=
abc2svg.p_b40[a%7],p.temper[a]+d+e}else if(!p.temper)return c+(d+e);c=p.temper[abc2svg.p_b40[a%7]];0<e?(a=p.temper[(abc2svg.p_b40[a%7]+1)%40],a<c&&(a+=12)):(a=p.temper[(abc2svg.p_b40[a%7]+39)%40],a>c&&(a-=12),e=-e);return c+d+(a-c)*e}function te(){for(var a,b=r.line,c=b.index,d="";;){a=b.next_char();if(!a){b.index=c;v(1,"No end of decoration");return}if("!"==a)break;d+=a}ma.push(d)}function Zd(){function a(a){for(var b="";0>a;)a+=7,b+=",";for(;14<=a;)a-=7,b+="'";return qb[a]+b}function b(b,c){if(void 0==
c)return b;var d,e="",f=b.length;for(d=0;d<f;d++){var g=b[d];e="h"<=g&&"z">=g?e+a(c+g.charCodeAt(0)-110):e+g}return e}function c(u){for(var z,t,w,I;;){z=n.char();if(!z)break;if(!u&&hc[z]){I=void 0;for(w in gc)if(gc.hasOwnProperty(w)&&w[0]==z){if(0>w.indexOf("n")){if(n.buffer.indexOf(w,n.index)!=n.index)continue;n.index+=w.length}else{a:{t=void 0;var x=w;var y=1;for(I=n.index+1;y<x.length;y++,I++)if(x[y]!=n.buffer[I]){if("n"!=x[y]){I=void 0;break a}t=qb.indexOf(n.buffer[I]);if(0>t){I=void 0;break a}for(;"'"==
n.buffer[I+1];)t+=7,I++;for(;","==n.buffer[I+1];)t-=7,I++}n.index=I;I=t}if(void 0==I)continue}var A=w;t=gc[w];y=n;x=r.istart;r.line=n=new F;r.istart+=y.index;if(0>p.writefields.indexOf("m")){n.buffer=A.replace("n",a(I));A=l.last_sym;var C=l.time;c(!0);A||(A=l.sym);for(A=A.next;A;A=A.next)A.noplay=!0;var D=l.time;var B=l;l=ue(B.id+"-p");H.voices[l.v]||(l.second=!0,H.voices[l.v]={st:B.st,second:!0,range:l.v});l.time=C;A=l.last_sym;r.line=n=new F;r.istart+=y.index;n.buffer=b(t,I);c(!0);l.time!=D&&v(1,
"Bad length of the macro sequence");A||(A=l.sym);for(;A;A=A.next)A.invis=A.play=!0;l=B}else n.buffer=b(t,I),c(!0);r.line=n=y;r.istart=x;I=1;break}if(I)continue}t=z.charCodeAt(0);if(128<=t){v(1,G.not_ascii);n.index++;break}t=Da[t];switch(t[0]){case " ":if(t=l.last_note)t.beam_end=!0,d&&(d.gr_shift=!0);break;case "\n":if(p.barsperstaff)break;l.eoln=!0;break;case "&":if(d){v(1,G.bad_grace);break}z=n.next_char();if(")"==z){Tb(z);break}Tb("&");continue;case "(":z=n.next_char();if("0"<z&&"9">=z){if(d){v(1,
G.bad_grace);break}t=n.get_int();I=Rf[t];y=t;z=n.char();if(":"==z&&(z=n.next_char(),"0"<z&&"9">=z&&(I=n.get_int(),z=n.char()),":"==z))if(z=n.next_char(),"0"<z&&"9">=z)y=n.get_int(),n.char();else{v(1,"Invalid 'r' in tuplet");continue}if(0==I||void 0==I)I=0==l.wmeasure%9?3:2;0>k&&(k=h.length);h.push({p:t,q:I,r:y,ro:y,f:l.tup||p.tuplets});continue}if("&"==z){if(d){v(1,G.bad_grace);break}Tb("(");break}n.index--;O.push(mc());continue;case ")":if(t=l.last_sym)switch(t.type){case m.SPACE:t.notes||(t.notes=
[],t.notes[0]={});case m.NOTE:case m.REST:break;case m.GRACE:for(t=t.extra;t.next;t=t.next);break;default:t=null}if(!t){v(1,G.bad_char,z);break}se(t);break;case "!":1<t.length?ma.push(t.slice(1,-1)):te();break;case '"':if(d){v(1,G.bad_grace);break}ve(t);break;case "[":if(1<t.length){U.do_pscom(t.slice(3,-1));break}I=n.buffer[n.index+1];if(0<='|[]: "'.indexOf(I)||"1"<=I&&"9">=I){if(d){v(1,G.bar_grace);break}pe();continue}if(":"==n.buffer[n.index+2]){if(d){v(1,G.bad_grace);break}z=n.buffer.indexOf("]",
n.index+1);if(0>z){v(1,"Lack of ']'");break}t=n.buffer.slice(n.index+3,z).trim();r.istart=r.bol+n.index;r.iend=r.bol+ ++z;n.index=0;kd(I,t);n.index=z;continue}case "n":t=U.new_note(d,O);if(!t)continue;if(d||!t.notes)continue;if(0<=k)t.tp=h.slice(k),k=-1,q&&(t.tp[0].s=q),q=t;else if(!q)continue;w=h[h.length-1];if(0<--w.r)continue;for(;;){t=q;I=t.time;y=l.time-I;x=w.q/w.p*y;for(l.time=I+x;;){t.in_tuplet=!0;t.grace||(t.time=I,t.dur&&(z=Math.round(t.dur*x/y),y-=t.dur,t.dur=z,x-=t.dur,I+=t.dur));if(!t.next){t.tpe?
t.tpe++:t.tpe=1;break}t=t.next}z=w.ro;w.s&&(q=w.s);h.pop();if(!h.length){q=null;break}w=h[h.length-1];w.r-=z;if(0<w.r)break}continue;case "<":if(!l.last_note){v(1,"No note before '<'");break}if(d){v(1,"Cannot have a broken rhythm in grace notes");break}for(I="<"==z?1:-1;"<"==z||">"==z;)I*=2,z=n.next_char();l.brk_rhythm=I;continue;case "i":break;case "{":if(d){v(1,"'{' in grace note");break}e=l.last_note;l.last_note=null;f=ma;ma=[];d={type:m.GRACE,fname:r.fname,istart:r.bol+n.index,dur:0,multi:0};
l.color&&(d.color=l.color);switch(l.pos.gst&7){case m.SL_ABOVE:d.stem=1;break;case m.SL_BELOW:d.stem=-1;break;case m.SL_HIDDEN:d.stem=2}ja(d);z=n.next_char();if("/"==z){d.sappo=!0;break}continue;case "|":if(d){v(1,G.bar_grace);break}pe();continue;case "}":if(l.ignore){d=null;break}t=l.last_note;if(!d||!t){v(1,G.bad_char,z);break}ma.length&&v(1,"Decoration ignored");d.extra=d.next;d.extra.prev=null;d.next=null;l.last_sym=d;d=null;if(!t.prev&&!l.ckey.k_bagpipe){for(z=0;z<=t.nhd;z++)t.notes[z].dur*=
2;t.dur*=2;t.dur_orig*=2}l.last_note=e;ma=f;break;case "\\":if(!n.buffer[n.index+1]){g=!0;break}default:v(1,G.bad_char,z)}n.index++}}var d,e,f,g,h=[],k=-1,O=[],n=r.line;if(3==r.state){if(r.tp){h=r.tp;k=r.tpn;var q=r.tps;r.tp=null}c();h.length&&(r.tp=h,r.tps=q,r.tpn=k);O.length&&v(1,"Start of slur without note");d&&(v(1,"No end of grace note sequence"),l.last_sym=d.prev,l.last_note=e,d.prev&&(d.prev.next=null));g||p.barsperstaff||fa||"\n"!=Da[10]||(l.eoln=!0);l.eoln&&p.breakoneoln&&l.last_note&&(l.last_note.beam_end=
!0)}}function yb(a,b){a=a.charCodeAt(0);if(128<=a){if(768<=a&&880>a)return 0;a=97}return(b||A.curfont).cw_tb[a]}function Wd(a){return a.replace(/<|>|&[^&\s]*?;|&/g,function(a){switch(a){case "<":return"&lt;";case ">":return"&gt;";case "&":return"&amp;"}return a})}function nc(a){function b(a,b){return'<tspan\n\tclass="'+(a.class&&a.name==b.name&&a.size==b.size&&a.weight==b.weight&&a.style==b.style?a.class:Ib(a))+'">'}if("object"==typeof a)return a;var c,d=A.deffont,e=A.curfont,f="";e!=d&&(f=b(e,d));
f+=a.replace(/<|>|&[^&\s]*?;|&|\$./g,function(a){switch(a){case "<":return"&lt;";case ">":return"&gt;";case "&":return"&amp;";default:if("$"==a[0]){if("0"==a[1])c=A.deffont;else if("1"<=a[1]&&"9">=a[1])c=Ma("u"+a[1]);else break;a="";if(c!=e&&(e!=d&&(a="</tspan>"),e=c,e!=d))return a+b(e,d)}}return a});e!=d&&(f+="</tspan>");f=new String(f);abc2svg.el?ua(f):f.wh=ua(a);A.curfont=e;return f}function T(a){"string"==typeof a&&(a=Ma(a));A.curfont=A.deffont=a}function na(a,b,c,d,e,f){f||(f=c.wh||ua(c));if(p.singleline||
p.trimsvg){var g=f[0];switch(d){case "c":g=f[0]/2;break;case "j":g=e;break;case "r":g=0}ba.wx<a+g&&(ba.wx=a+g)}D+='<text class="'+Ib(A.deffont);"j"!=d&&5<c.length&&A.deffont.wadj&&(D+='" lengthAdjust="'+A.deffont.wadj+'" textLength="'+f[0].toFixed(1));D+='" x="';$a(a,'" y="',b);switch(d){case "c":D+='" text-anchor="middle">';break;case "j":D+='" textLength="'+e.toFixed(1)+'">';break;case "r":D+='" text-anchor="end">';break;default:D+='">'}D+=nc(c);D+="</text>\n"}function Cf(a,b){if(p.titletrim){var c=
a.lastIndexOf(", ");if(0>c||"A">a[c+2]||"Z"<a[c+2])c=0;else if(1==p.titletrim){if(c<a.length-7||0<=a.indexOf(" ",c+3))c=0}else c<a.length-p.titletrim-2&&(c=0);c&&(a=a.slice(c+2).trim()+" "+a.slice(0,c))}!b&&0<=p.writefields.indexOf("X")&&(a=L.X+".  "+a);return p.titlecaps?a.toUpperCase():a}function Jb(){ba.chg&&lb();return(ba.width-ba.lm-ba.rm-2)/p.scale}function sd(a,b){if(a){lb();b?(T("subtitle"),b=p.subtitlespace):(T("title"),b=p.titlespace);var c=ua(a);c[1]+=2*A.curfont.pad;ra(c[1]+b+A.curfont.pad);
b=A.curfont.pad+.22*c[1];p.titleleft?na(0,b,a,null,null,c):na(Jb()/2,b,a,"c",null,c)}}function we(a,b,c,d,e){if(!c){if(!d)return;c=d;d=null}d?na(a,b,c+" ("+d+")",e):na(a,b,c,e)}function td(a,b){if("s"!=b){lb();var c=Jb(),d=A.curfont.size,e=d*p.lineskipfac;d*=p.parskipfac;var f,g,h;switch(b){default:var k=A.curfont;switch(b){case "c":c/=2;break;case "r":c-=k.pad;break;default:c=k.pad}for(f=0;;){var m=a.indexOf("\n",f);if(m==f){ra(d);nb();for(bb(A.curfont);"\n"==a[m+1];)ra(e),m++;if(m==a.length)break}else{f=
0>m?a.slice(f):a.slice(f,m);var l=ua(f);ra(l[1]*p.lineskipfac+2*k.pad);na(c,k.pad+.2*l[1],f,b);if(0>m)break}f=m+1}ra(d);nb();break;case "f":case "j":for(f=0;;){m=a.indexOf("\n\n",f);var q=0>m?a.slice(f):a.slice(f,m);q=q.split(/\s+/);for(f=g=h=k=0;f<q.length;f++)l=ua(q[f]+"\u00a0"),g+=l[0],g>=c&&(ra(k*p.lineskipfac),na(0,.2*l[1],q.slice(h,f).join(" "),b,c,[g-l[0],l[1]]),h=f,g=l[0],k=0),l[1]>k&&(k=l[1]);0!=g&&(ra(k*p.lineskipfac),na(0,.2*l[1],q.slice(h).join(" ")));ra(d);nb();if(0>m)break;for(;"\n"==
a[m+2];)ra(e),m++;if(m==a.length)break;bb(A.curfont);f=m+2}}}}function Bf(a){function b(a,b){var c=0,d=0;"$"==a[0]&&"0"<=a[1]&&"9">=a[1]&&(A.curfont="0"==a[1]?A.deffont:Ma("u"+a[1]),a=a.slice(2));if("0"<=a[c]&&"9">=a[c]||"."==a[c+1]){for(;c<a.length&&(c++," "!=a[c]&&":"!=a[c-1]&&"."!=a[c-1]););for(d=c;" "==a[c];)c++}var e=.22*A.curfont.size;0!=d&&na(b,e,a.slice(0,d),"r");c<a.length&&na(b+5,e,a.slice(c),"l")}var c,d;var e=0;var f=1;a=a.split("\n");var g=a.length;for(c=0;c<g;c++){var h=a[c];if(!h){for(;c+
1<g&&!a[c+1];)c++;f++}else if(h.length>e){e=h.length;var k=c}}if(void 0!=k){T("words");ra(p.wordsspace);Xb();e=Jb()/2;var m=ua(a[k])[0];k=d=0;if(m<e){var l=f>>1;for(c=0;c<g;c++)if(h=a[c],!h){for(0>=--l&&(k=c);c+1<g&&!a[c+1];)c++;if(0>=l){d=c+1;break}}f>>=1}if(d){var q=(e-m)/2+10;l=q+e}else l=e-m/2+10;var r=!0;for(c=0;c<k||d<g;c++,d++)ra(p.lineskipfac*A.curfont.size),c<k&&((h=a[c])?b(h,q):bb(A.curfont)),d<g&&((h=a[d])?b(h,l):0==--f&&(c<k?f++:d<g-1&&(l=e-m/2+10,Xb()))),a[c+1]||a[d+1]?r=!0:r&&(Xb(),
r=!1)}}function xe(){var a,b="";for(a=0;a<L.P.length;a++)a&&(b+=" "),b+=Hd(L.P[a])[1];return b}function Hd(a){var b;if(p.partname){var c=p.partname.split("\n");for(b=0;b<c.length;b++)if(c[b][0]==a){var d=c[b].match(/.\s+(\S+)\s*(.+)?/);break}}if(!d)return[0,a,a];d[2]||(d[2]=d[1]);'"'==d[2][0]&&(d[2]=d[2].slice(1,-1));return d}function ye(a){return a.replace(/./g,function(a){return(a=xc["mtr"+a])?a.c:0})}function ze(a){var b,c;if(!ud[a])if(ud[a]=!0,c=kb[a]){for(b=0;;){a=c.indexOf('xlink:href="#',b);
if(0>a)break;a+=13;b=c.indexOf('"',a);ze(c.slice(a,b))}Yb+="\n"+c}else w(1,null,"Unknown glyph: '$1'",a)}function Ae(a){var b=0;for(a=a.replace(/\x3c!--.*?--\x3e/g,"");;){var c=a.indexOf("<",b);if(0>c)break;var d=a.indexOf('id="',c);if(0>d)break;d+=4;b=a.indexOf('"',d);if(0>b)break;var e=a.slice(d,b);b=a.indexOf(">",b);if(0>b)break;if("/"==a[b-1])b++;else{d=a.indexOf(" ",c);if(0>d)break;d=a.slice(c+1,d);b=a.indexOf("</"+d+">",b);if(0>b)break;b+=3+d.length}"<filter"==a.substr(c,7)?vd+=a.slice(c,b)+
"\n":kb[e]=a.slice(c,b)}}function wd(){B.started&&(B.started=!1,oc(),D+="</g>\n");if(1!=B.scale||B.color)oc(),D+="<g ",1!=B.scale&&(D=0>B.st?D+C[B.v].scale_str:0>B.v?D+x[B.st].scale_str:D+('transform="translate(0,'+(wa-B.dy).toFixed(1)+") scale("+B.scale+')"')),B.color&&(1!=B.scale&&(D+=" "),D+='color="'+B.color+'"'),D+=">\n",B.started=!0}function fb(a){if(a!=B.color){var b=B.color;B.color=a;wd();return b}}function Ra(a){a!=B.st&&1!=B.scale&&(B.scale=1);var b=0<=a?x[a].staffscale:1;var c=0<=a&&1!=
b?x[a].y:wa;if(b!=B.scale||c!=B.dy||B.st!=a||1!=B.vsc)B.stsc=B.scale=b,B.vsc=1,B.dy=c,B.st=a,B.v=-1,wd()}function Zb(a){var b=wa,c=1==x[a.st].staffscale?-1:a.st,d=a.p_v.scale;0<=c&&(d*=x[c].staffscale,b=x[c].y);if(d!=B.scale||B.dy!=b)B.scale=d,B.vsc=a.p_v.scale,B.dy=b,B.st=c,B.v=a.v,wd()}function La(a,b){D&&(B.started&&(B.started=!1,oc(),D+="</g>\n"),0>B.st?x[0].output+=D:1==B.scale?x[B.st].output+=D:x[B.st].sc_out+=D,D="");B.scale=0>a?1:b?1:x[a].staffscale;B.st=a;B.dy=0}function Be(a,b,c){if(void 0!=
a.istart){var d=a.type,e=a.ymx-a.ymn+4,f=a.wl||2,g=a.wr||2;a.grace&&(d=m.GRACE);c(b||abc2svg.sym_name[d],a.istart,a.iend,a.x-f-2,x[a.st].y+a.ymn+e-2,f+g+4,e,a)}}function zf(a,b){Be(a,b,u.anno_start)}function Af(a,b){Be(a,b,u.anno_stop)}function Lc(){}function ea(a,b,c,d,e){b=gb(b);c=pc(c);D+=a.replace(/X|Y|A|B|F|G/g,function(a){switch(a){case "X":return b.toFixed(1);case "Y":return c.toFixed(1);case "A":return d;case "B":return e;case "F":return d.toFixed(1);default:return e.toFixed(1)}})}function zb(a,
b,c,d,e){oc();ea('<g transform="translate(X,Y',a,b);c&&(D+=") rotate("+c.toFixed(2));d&&(D+=") scale("+d,e&&(D+=", "+e));D+=')">\n';B.g++}function Ab(){oc();B.g--;D+="</g>\n"}function gb(a){return B.g?a:(a+wc)/B.scale}function pc(a){return B.g?-a:1==B.scale?wa-a:0<=B.v?(B.dy-a)/B.vsc:B.dy-a}function $a(a,b,c){a=gb(a);c=pc(c);D+=a.toFixed(1)+b+c.toFixed(1)}function ib(a,b,c){c?ea('<path d="mX Y',a,b):ea('<path class="stroke" d="mX Y',a,b)}function sf(){function a(a,b){var d,e,h,k=a.length;if(k)for(e=
0;e<k;e++)if((d=a[e])&&d.length){var m=gb(d[0][0]);D+='<path class="stroke" stroke-width="1" d="M'+m.toFixed(1)+" "+pc(c.y+b*e).toFixed(1);for(h=0;;){var l=d.shift();if(!l)break;var q=gb(l[0]);D+="m"+(q-m+l[1]-h).toFixed(2)+" 0h"+(-l[1]+l[2]).toFixed(2);m=q;h=l[2]}D+='"/>\n'}}var b;for(b=0;b<=V;b++){var c=x[b];c.hlu&&(Ra(b),a(c.hlu,6),a(c.hld,-6))}}function oc(){var a=[];if(Ca[0].length){for(;;){var b=Ca[0].shift();if(void 0==b)break;a.push(b.toFixed(1))}D+='<text x="'+a.join(",");for(a=[];;){b=Ca[1].shift();
if(void 0==b)break;a.push(b.toFixed(1))}D+='"\ny="'+a.join(",");D+='"\n>'+Ca[2]+"</text>\n";Ca[2]=""}if(Ca[3].length){for(D+='<path class="sW" d="';;){b=Ca[3].shift();if(void 0==b)break;D+="M"+b.toFixed(1)+" "+Ca[3].shift().toFixed(1)+"v"+Ca[3].shift().toFixed(1)}D+='"/>\n'}}function R(a,b,c){if(kb[c])ze(c),ea('<use x="X" y="Y" xlink:href="#A"/>\n',a,b,c);else{var d=xc[c];d?(a+=d.x*B.scale,b-=d.y,d.sc?ea('<text transform="translate(X,Y) scale(A)">B</text>\n',a,b,d.sc,d.c):(Ca[0].push(gb(a)),Ca[1].push(pc(b)),
Ca[2]+=d.c)):"nil"!=c&&w(1,null,"no definition of $1",c)}}function Ce(a,b,c){var d=25+3*(c/20|0);var e=15<c?(c-15)/d|0:0;ea('<path class="stroke" stroke-width="1.2"\n\tstroke-dasharray="5,A"\n\td="mX YhB"/>\n',a+(c-d*e-5)/2,b+4,Math.round((d-5)/B.scale),d*e+5)}function dd(a,b,c,d,e,f){var g=d?2.3:3.5,h=-c;0>c&&(g=-g);a+=g*B.scale;0<=B.v&&(h/=C[B.v].scale);Ca[3].push(gb(a));Ca[3].push(pc(b));Ca[3].push(h);if(e){b+=c;if(0<c)if(f)if(D+='<path d="',d)for(;0<=--e;)ea("MX Yl3 1.5 0 2 -3 -1.5z\n",a,b),b-=
3;else for(;0<=--e;)ea("MX Yl7 3.2 0 3.2 -7 -3.2z\n",a,b),b-=5.4;else if(d)if(D+='<path d="',1==e)ea("MX Yc0.6 3.4 5.6 3.8 3 10\n\t1.2 -4.4 -1.4 -7 -3 -7\n",a,b);else for(;0<=--e;)ea("MX Yc1 3.2 5.6 2.8 3.2 8\n\t1.4 -4.8 -2.4 -5.4 -3.2 -5.2\n",a,b),b-=3.5;else{R(a,b,"flu"+e);return}else if(f){if(D+='<path d="',!d)for(;0<=--e;)ea("MX Yl7 -3.2 0 -3.2 -7 3.2z\n",a,b),b+=5.4}else if(d)if(D+='<path d="',1==e)ea("MX Yc0.6 -3.4 5.6 -3.8 3 -10\n\t1.2 4.4 -1.4 7 -3 7\n",a,b);else for(;0<=--e;)ea("MX Yc1 -3.2 5.6 -2.8 3.2 -8\n\t1.4 4.8 -2.4 5.4 -3.2 5.2\n",
a,b),b+=3.5;else{R(a,b,"fld"+e);return}D+='"/>\n'}}function qc(a,b,c){ea('<path class="stroke" stroke-width="0.8" d="mX YhF"/>\n',a,b+1,c)}function De(a,b,c){var d=c.dd.glyph;if("fng"==d)ea('<text x="X" y="Y" style="font-size:14px">A</text>\n',a-2,b+1,ye(c.dd.str));else{if("@"==d)d="at";else if(!/^[A-Za-z][A-Za-z\-_]*$/.test(d)){w(1,c.s,"No function for decoration '$1'",c.dd.name);return}var e=rc[d];e?e.style&&(Eb+="\n."+d+"{"+e.style+"}",delete e.style):e=rc.crdc;a+=e.dx;b+=e.dy;ea('<text x="X" y="Y" class="A"B>',
a,b,d,e.anchor||"");T("annotation");D+=nc(c.dd.str);D+="</text>\n"}}function Ee(a,b,c){zb(a,b,270);a=0;for(c=Math.ceil(c/6);0<=--c;)R(a,6,"ltr"),a+=6;Ab()}function Fe(a,b,c){b+=4;for(c=Math.ceil(c/6);0<=--c;)R(a,b,"ltr"),a+=6}function xd(a,b,c,d,e){if(Ge[c])Ge[c](a,b,d,e);else w(1,null,"No function for decoration '$1'",c)}function He(a,b,c,d){c=ec(b,c);switch(c[0]){case m.OVAL:b="\ueca2";break;case m.EMPTY:b="\ueca3";break;default:switch(c[2]){case 2:b="\ueca9";break;case 1:b="\ueca7";break;default:b=
"\ueca5"}}a.push('<tspan\nclass="'+Ib(p.musicfont)+'" style="font-size:'+(1.3*A.curfont.size).toFixed(1)+'px"'+d+">"+b+"</tspan>"+(c[1]?"\u2009.":""));return c[1]?2:1}function ra(a){wa+=a}function Ie(){mb="";if(p.fullsvg){ud={};for(var a=0;a<abc2svg.font_tb.length;a++)abc2svg.font_tb[a].used=0;Kb.used=0}else Eb=vd=""}function Xb(){if(!da&&u.img_out&&0!=wa){var a=va?va.fmt:p;var b=Math.ceil(a.trimsvg||1==a.singleline?p.leftmargin+ba.wx*p.scale+p.rightmargin+2:ba.width),c='<svg xmlns="http://www.w3.org/2000/svg" version="1.1"\n\txmlns:xlink="http://www.w3.org/1999/xlink"\n\tfill="currentColor" stroke-width=".7"',
d="";oc();p.fgcolor&&(c+=' color="'+p.fgcolor+'"');a=Ma("music");c+=' class="'+Ib(a)+" tune"+jd.length+'"\n';wa*=p.scale;c=void 0!=u.imagesize?c+u.imagesize:c+(' width="'+b+'px" height="'+wa.toFixed(2)+'px"');c+=' viewBox="0 0 '+b+" "+wa.toFixed(2)+'">\n';c+=vd;p.bgcolor&&(c+='<rect width="100%" height="100%" fill="'+p.bgcolor+'"/>\n');if(Eb||mb)c+="<style>"+mb+Eb+"\n</style>\n";Yb&&(c+="<defs>"+Yb+"\n</defs>\n");1!=p.scale&&(c+='<g class="g" transform="scale('+p.scale+')">\n',d="</g>\n");Je&&Je.ps_flush(!0);
1==r.state&&u.page_format&&!Ta&&(Ta=1);if(0<Ta)u.img_out(1==Ta?'<div class="nobrk">':'<div class="nobrk newpage">'),Ta=-1;else if(0>Ta&&p.splittune){var e=1;Ta=0}u.img_out(c+D+d+"</svg>");e&&u.img_out("</div>");D="";Ie();Yb="";wa=0;ba.wx=0}}function nb(){Xb();0>Ta&&!r.state&&(u.img_out("</div>"),Ta=0)}function Sf(){function a(a,b){b=new RegExp(b);if(b.test(l.id)||b.test(l.nm))for(b=0;b<a.length;b++)U.do_pscom(a[b])}var b;if(r.voice_opts)for(b in r.voice_opts)r.voice_opts.hasOwnProperty(b)&&a(r.voice_opts[b],
b);if(r.tune_v_opts)for(b in r.tune_v_opts)r.tune_v_opts.hasOwnProperty(b)&&a(r.tune_v_opts[b],b)}function ja(a){var b=l.time;a.fname||Wa(a);l.ignore?a.bar_type&&(l.last_bar=a):(a.prev=l.last_sym)?l.last_sym.next=a:l.sym=a;l.last_sym=a;a.v=l.v;a.p_v=l;a.st=l.cst;a.time=b;a.dur&&!a.grace&&(l.time+=a.dur);r.ufmt=!0;a.fmt=p;a.pos=l.pos;l.second&&(a.second=!0);l.floating&&(a.floating=!0);l.eoln&&(a.soln=!0,l.eoln=!1)}function de(a,b){b={type:b,dur:0};var c=l;l=a;ja(b);l=c;a=b.prev;a||(a=b.next);a&&(b.fname=
a.fname,b.istart=a.istart,b.iend=a.iend);return b}function Ke(a){var b={voices:[],staves:[],top_voice:0};if(a)K=H=b;else{for(a=0;a<C.length;a++)if(H.voices[a]){var c=H.voices[a].st;c=H.staves[c];var d=C[a];c.staffnonote=d.staffnonote;d.staffscale&&(c.staffscale=d.staffscale)}for(c=0;c<H.staves.length;c++)b.staves[c]=y(H.staves[c]),b.staves[c].flags=0;H=H.next=b}}function qe(a,b){var c="";if(b)if("object"!=typeof b)c="__ _  ^ ^^ =".split(" ")[b+2];else{var d=b[0];0<d?c+="^":(c+="_",d=-d);c+=d+"/"+
b[1]}c+=qb[(a+75)%7];for(d=a;23<=d;d-=7)c+="'";for(d=a;16>d;d+=7)c+=",";return c}function Le(a){if("0"==a[0])return 0;if(0<="123456789-+".indexOf(a[0])){var b=parseInt(a);if(isNaN(b)||-36>b||36<b)v(1,G.bad_transp);else return b+=36,b=40*((b/12|0)-3)+abc2svg.isb40[b%12],"b"==a.slice(-1)&&(b+=4),b}}function Me(){var a=l.ckey;var b=a.time||0;if(!a.k_bagpipe&&!a.k_drum){var c=(l.score|0)+(l.shift|0)+(p.transp|0);if((l.tr_sco|0)==c)a.k_sf=l.ckey.k_sf;else{pd()?l.key=a:l.time!=b&&(a=y(a.orig||a),l.new||
(a.k_old_sf=l.ckey.k_sf),ja(a));l.ckey=a;p.transp&&l.shift&&v(0,"Mix of old and new transposition syntaxes");l.tr_sco=c;c=abc2svg.b40l5[(c+202)%40]+a.orig.k_sf;-7>c?(c+=12,l.tr_sco-=4):7<c&&(c-=12,l.tr_sco+=4);a.k_none||(a.k_sf=c);for(b=0;40>b&&abc2svg.b40l5[b]!=c;b++);a.k_b40=b;if(a.k_a_acc){var d=b-a.orig.k_b40;var e=[];for(c=0;c<a.k_a_acc.length;c++)b=abc2svg.pab40(a.k_a_acc[c].pit,a.k_a_acc[c].acc)+d,e[c]={pit:abc2svg.b40p(b),acc:abc2svg.b40a(b)||3};a.k_a_acc=e}}}}function Tf(a){var b,c=0;for(b=
0;b<C.length;b++)if(C[b].time>c){var d=C[b];c=d.time}if(!(a.time>=c)){b=l;c-=a.time;c={type:m.MREST,stem:0,multi:0,nhd:0,xmx:0,frm:1,dur:c,dur_orig:c,nmes:c/a.wmeasure,notes:[{pit:18,dur:c}],tacet:a.tacet};var e={type:m.BAR,bar_type:"|",dur:0,multi:0};d.last_sym.bar_type&&(e.bar_type=d.last_sym.bar_type);oa.mrest_p=1;l=a;ja(c);ja(e);l=b}}function ue(a){var b;for(b=0;b<C.length;b++){var c=C[b];if(c.id==a)return c}c=y(l);c.v=C.length;c.id=a;c.sym=c.last_sym=null;c.key=y(l.key);c.sls=[];delete c.nm;
delete c.snm;delete c.new_name;delete c.lyric_restart;delete c.lyric_cont;delete c.sym_restart;delete c.sym_cont;delete c.have_ly;delete c.tie_s;C.push(c);return c}function Tb(a){if("|"==a||")"==a)if(l.last_note)if(l.last_note.beam_end=!0,fa){l.time!=fa.p_voice.time&&(l.ignore||v(1,"Wrong duration in voice overlay"),l.time>fa.p_voice.time&&(fa.p_voice.time=l.time));l.acc=[];a=fa.p_voice;var b=l.last_sym;if(b.type==m.SPACE&&a.last_sym.type!=m.SPACE){b.p_v=a;for(b.v=b.p_v.v;b.prev.type==m.SPACE;)b=
b.prev,b.p_v=a,b.v=b.p_v.v;var c=b.prev;c.next=null;b.prev=a.last_sym;b.prev.next=b;a.last_sym=l.last_sym;l.last_sym=c}l=a;fa=null}else v(1,"Erroneous end of voice overlay");else v(1,G.nonote_vo),fa&&(l=fa.p_voice,fa=null);else if("("==a)fa?v(1,"Voice overlay already started"):fa={p_voice:l,time:l.time};else if(l.last_note){l.last_note.beam_end=!0;a=l.voice_down;if(!a){a=ue(l.id+"o");l.voice_down=a;a.time=0;a.second=!0;a.last_note=null;var d=a.v;if(H.voices[l.v]){H.voices[d]={st:l.st,second:!0};b=
H.voices[l.v].range;for(c=0;c<H.voices.length;c++)H.voices[c]&&H.voices[c].range>b&&H.voices[c].range++;H.voices[d].range=b+1}}a.ulen=l.ulen;a.dur_fact=l.dur_fact;a.acc=[];if(fa)l!=fa.p_voice&&l.time!=fa.p_voice.time&&(v(1,"Wrong duration in voice overlay"),l.time>fa.p_voice.time&&(fa.p_voice.time=l.time));else{c=a.time;if(l.ignore)b=l.last_bar;else for(b=l.last_sym;b&&!(b.type==m.BAR||b.time<=c);b=b.prev);fa={bar:b&&b.bar_type?b.bar_type:"|",p_voice:l,time:b?b.time:l.time}}a.time=fa.time;l=a}else v(1,
G.nonote_vo)}function pd(){var a;if(l.time)return!1;if(!l.last_sym)return!0;for(a=l.last_sym;a;a=a.prev)if(Sa[a.type])return!1;return!0}function Ne(a){if("p"==a.clef_type){var b=l.ckey;b.k_drum=1;b.k_sf=0;b.k_b40=2;b.k_map=abc2svg.keys[7];l.key||(l.key=b)}if(!l.time&&pd())l.clef=a,a.fmt=p;else{if(a.clef_none)b=null;else for(b=l.last_sym;b&&b.time==l.time&&!Sa[b.type];b=b.prev);if(b&&b.time==l.time&&void 0!=b.k_sf){var c=b;b=b.prev}b&&b.time==l.time&&b.bar_type&&":"!=b.bar_type[0]&&(c=b);c?(b=l.last_sym,
l.last_sym=c.prev,ja(a),a.next=c,c.prev=a,l.last_sym=b,a.soln&&(delete a.soln,l.eoln=!0)):ja(a)}}function $d(a){a:{var b="FCGDAEB".indexOf(a[0])-1;var c=0;var d={type:m.KEY,dur:0};Wa(d);var e=1;if(-1>b)switch(a[0]){case "H":var f=!0;if("p"!=a[1].toLowerCase()){v(1,"Unknown bagpipe-like key");break}d.k_bagpipe=a[1];b="P"==a[1]?0:2;e++;p.temper||(p.temper=new Float32Array([11.62,12.55,1.66,2.37,3.49,0,1.66,2.37,3.49,4.41,5.53,0,3.49,4.41,5.53,6.63,7.35,4.41,5.53,6.63,7.35,8.19,0,6.63,7.35,8.19,9.39,
10.51,0,8.19,9.39,10.51,11.62,12.55,0,10.51,11.62,12.55,1.66,1.66]));break;case "P":v(1,"K:P is deprecated");b=0;f=d.k_drum=!0;break;case "n":if(0==a.indexOf("none")){b=0;d.k_none=!0;e=4;break}default:d.k_map=[];d.k_mode=0;a=[d,kc(a)];break a}if(!f){switch(a[e]){case "#":b+=7;e++;break;case "b":b-=7,e++}a=a.slice(e).trim();switch(a.slice(0,3).toLowerCase()){default:if("m"!=a[0]||" "!=a[1]&&"\t"!=a[1]&&"\n"!=a[1]){f=!0;break}case "aeo":case "m":case "min":b-=3;c=5;break;case "dor":b-=2;c=1;break;case "ion":case "maj":break;
case "loc":b-=5;c=6;break;case "lyd":b+=1;c=3;break;case "mix":--b;c=4;break;case "phr":b-=4,c=2}f||(a=a.replace(/\w+\s*/,""));0==a.indexOf("exp ")&&((a=a.replace(/\w+\s*/,""))||v(1,"No accidental after 'exp'"),d.exp=1);f=a[0];if("^"==f||"_"==f||"="==f){d.k_a_acc=[];e=new F;e.buffer=a;do{f=jc(e);if(!f)break;d.k_a_acc.push(f);for(f=a[e.index];" "==f;)f=a[++e.index]}while("^"==f||"_"==f||"="==f);a=a.slice(e.index)}else d.exp&&0==a.indexOf("none")&&(b=0,a=a.replace(/\w+\s*/,""))}if(-7>b||7<b)v(1,"Key with double sharps/flats"),
b=7<b?b-12:b+12;d.k_sf=b;d.k_map=d.k_bagpipe&&!b?abc2svg.keys[9]:abc2svg.keys[b+7];if(d.k_a_acc)for(d.k_map=Array.prototype.slice.call(d.k_map),e=d.k_a_acc.length;0<=--e;)f=d.k_a_acc[e],d.k_map[(f.pit+19)%7]=f.acc;d.k_mode=c;d.k_b40=[1,24,7,30,13,36,19,2,25,8,31,14,37,20,3][b+7];a=[d,kc(a)]}b=a[0];c=void 0==b.k_sf&&!b.k_a_acc;a=a[1];c?b.invis=1:b.orig=b;if(1==r.state){r.ckey=b;c&&(b.k_sf=0,b.k_none=!0,b.k_map=abc2svg.keys[7]);for(c=0;c<C.length;c++)d=C[c],d.ckey=y(b);a.length&&(fc("*",a),a=[]);oa.ulen||
(oa.ulen=m.BLEN/8);lb();ra(p.topspace);U.tunhd();nb();oa.new_nbar?(A.nbar=oa.new_nbar,oa.new_nbar=0):A.nbar=1;r.state=3;for(b=0;b<C.length;b++)c=C[b],c.ulen=oa.ulen,r.ckey.k_bagpipe&&!c.pos.stm&&(c.pos=y(c.pos),c.pos.stm&=-8,c.pos.stm|=m.SL_BELOW);if(0>Xa)for(b=C.length,H.nstaff=V=b-1;0<=--b;)c=C[b],delete c.new,c.st=c.cst=b,H.voices[b]={st:b,range:b},H.staves[b]={stafflines:c.stafflines||"|||||",staffscale:1}}else c||(l.tr_sco&&(l.tr_sco=void 0),b.k_old_sf=l.ckey.k_sf,l.ckey=b,ja(b));if(!l)if(C.length)l=
C[0>Xa?0:H.top_voice];else{l=sc("1");var g=1}if(d=l.clone)l.clone=null;qd(l.id+" "+a.join(" "));d&&(l.clone=d);g&&(l.default=1)}function sc(a){var b,c=C[0],d=C.length;if(1==d&&c.default&&(delete c.default,!c.time))return c.id=a,c.init=0,c;for(b=0;b<d;b++)if(c=C[b],c.id==a)return c;c={v:b,id:a,time:0<=Xa?Xa:0,new:!0,pos:{},scale:1,ulen:oa.ulen,dur_fact:1,meter:y(oa.meter),wmeasure:oa.meter.wmeasure,staffnonote:1,clef:{type:m.CLEF,clef_auto:!0,clef_type:"a",time:0},acc:[],sls:[],hy_st:0};C.push(c);
3==r.state&&(c.ckey=y(r.ckey),c.ckey.k_bagpipe&&!c.pos.stm&&(c.pos=y(c.pos),c.pos.stm&=-8,c.pos.stm|=m.SL_BELOW));return c}function Xd(){V=-1;C=[];l=null;Ke(!0);Xa=-1;A={};ha=[];pb={}}function Ya(){var a=l.clone;var b=a.vs,c=a.a,d=a.bol,e=r.bol,f=r,g=r.file;delete l.clone;"["==g[e-1]&&e--;Cb++;for(a=0;a<b.length;a++)r=Object.create(f),r.line=Object.create(f.line),qd(b[a]+" "+c.join(" ")),id(r.fname,g,d,e);Cb--;r=f}function qd(a){var b=kc(a),c=b.shift();if(c)if(l&&l.clone&&Ya(),a=0<c.indexOf(",")?
c.split(","):[c],2>r.state)for(;;){c=a.shift();if(!c)break;b.length&&fc(c,b);"*"!=c&&1==r.state&&(l=sc(c))}else if("*"==c)v(1,"Cannot have V:* in tune body");else{l=sc(a[0]);1<a.length&&(a.shift(),l.clone={vs:a,a:b.slice(0),bol:r.iend},"]"!=r.file[l.clone.bol-1]&&l.clone.bol++);Sd(b);Me();a=l.v;if(l.new)if(delete l.new,0>Xa)l.st=l.cst=++V,H.nstaff=V,H.voices[a]={st:V,range:a},H.staves[V]={stafflines:l.stafflines||"|||||",staffscale:1};else if(!H.voices[a]){l.ignore=1;return}!l.filtered&&H.voices[a]&&
(r.voice_opts||r.tune_v_opts)&&(l.filtered=!0,Sf())}}function Df(a,b){var c;if(!l.ignore){if(b){if(b=l.sym_cont,!b){v(1,"+: symbol line without music");return}}else if(l.sym_restart&&(l.sym_start=l.sym_restart,l.sym_restart=null),b=l.sym_start,b||(b=l.sym),!b){v(1,"s: without music");return}for(c=0;;){for(;" "==a[c]||"\t"==a[c];)c++;var d=a[c];if(!d)break;switch(d){case "|":for(;b&&b.type!=m.BAR;)b=b.next;if(!b){v(1,"Not enough measure bars for symbol line");return}b=b.next;c++;continue;case "!":case '"':var e=
++c;c=a.indexOf(d,e);if(0>c){v(1,"!"==d?"No end of decoration":"No end of chord symbol/annotation");c=a.length;continue}var f=a.slice(e-1,c+1);break;case "*":break;default:f=d.charCodeAt(0);if(128>f&&(f=Da[f],1<f.length&&("!"==f[0]||'"'==f[0]))){d=f[0];break}v(1,G.bad_char,d)}for(;b&&b.type!=m.NOTE;)b=b.next;if(!b){v(1,"Too many elements in symbol line");return}switch(d){case "!":ma.push(f.slice(1,-1));dc(b,b.prev);break;case '"':r.line.index=e+2,ve(f),Ia&&Vb(b)}b=b.next;c++}l.sym_cont=b}}function Ef(a,
b){var c;if(!l.ignore){(l.pos.voc&7)!=m.SL_HIDDEN&&(l.have_ly=!0);if(b){b=l.lyric_cont;if(!b){v(1,"+: lyric without music");return}if("~"==a[0]){for(;!b.a_ly;)b=b.prev;var d=b.a_ly[l.lyric_line];a=d.t.replace(/ /g,"~")+a}var e=Ma("vocal");A.deffont!=e&&(A.curfont==A.deffont&&(A.curfont=e),A.deffont=e)}else if(T("vocal"),l.lyric_restart?(l.lyric_start=b=l.lyric_restart,l.lyric_restart=null,l.lyric_line=0):(l.lyric_line++,b=l.lyric_start),b||(b=l.sym),!b){v(1,"w: without music");return}e=0;for(c=A.curfont;;){for(;" "==
a[e]||"\t"==a[e];)e++;if(!a[e])break;var f=0;var g=r.istart+e+2;switch(a[e]){case "|":for(;b&&b.type!=m.BAR;)b=b.next;if(!b){v(1,"Not enough measure bars for lyric line");return}b=b.next;e++;continue;case "-":case "_":d=a[e];f="-"==a[e]?2:3;break;case "*":d="";break;default:for(d="";a[e];){switch(a[e]){case "_":case "*":case "|":e--;case " ":case "\t":break;case "~":d+=" ";e++;continue;case "-":f=1;break;case "\\":if(!a[++e])continue;d+=a[e++];continue;case "$":d+=a[e++];var h=a[e];"0"==h?A.curfont=
A.deffont:"1"<=h&&"9">=h&&(A.curfont=Ma("u"+h));default:d+=a[e++];continue}break}}for(;b&&b.type!=m.NOTE;)b=b.next;if(!b){v(1,"Too many words in lyric line");return}d&&(b.pos.voc&7)!=m.SL_HIDDEN&&(d={t:d,font:c,istart:g,iend:g+d.length},f&&(d.ln=f),b.a_ly||(b.a_ly=[]),b.a_ly[l.lyric_line]=d,c=A.curfont);b=b.next;e++}l.lyric_cont=b}}function ld(a){var b,c,d,e=a,f=0,g=0,h=0,k=0,l=a.a_ly,n=0;for(d=a.ts_next;d;d=d.ts_next){d.seqst&&(k+=d.shrink,h++);if(d.bar_type){k+=3;break}if(d.a_ly){for(b=d.a_ly.length;0<=
--b&&(!(c=d.a_ly[b])||c.ln&&!(2>c.ln)););if(0<=b)break}}for(b=0;b<l.length;b++)if(c=l[b]){A.curfont=c.font;c.t=nc(c.t);var q=c.t.replace(/<[^>]*>/g,"");if(2<=c.ln)c.shift=0;else{var p=yb(" ")*c.font.swfac;var z=c.t.wh[0];var t=abc2svg.lypre.exec(q);if(a.type==m.GRACE)var r=a.wl;else t?(t=t[0],"("==q[0]?t=p:(T(c.font),t=" "==q[t.length]||":"==t.slice(-1)?ua(q.slice(0,t.length))[0]:.2*z),r=.4*(z-t),14<r&&(r=14),r+=t,"0"<=q[0]&&"9">=q[0]&&r>n&&(n=r)):(r=.4*z,14<r&&(r=14));c.shift=r;r>g&&(g=r);z+=1.5*
p;z-=r;z>f&&(f=z)}}for(;!e.seqst;)e=e.ts_prev;e.ts_prev&&e.ts_prev.bar_type&&(g-=4);e.wl<g&&(e.shrink+=g-e.wl,e.wl=g);k-=6;if(k<f&&d)for(k=(f-k)/h,a=a.ts_next;;){a.seqst&&(a.shrink+=k,e.wr+=k,e=a);if(a==d)break;a=a.ts_next}if(0<n)for(b=0;b<l.length;b++)(c=l[b])&&"0"<=c.t[0]&&"9">=c.t[0]&&(c.shift=n)}function Oe(a,b,c){var d,e,f;if(a.hy_st&1<<b){var g=!0;a.hy_st&=~(1<<b)}for(d=a.sym;d.type==m.CLEF||d.type==m.KEY||d.type==m.METER;d=d.next);var h=d.prev?d.prev.x:M.x;for(f=0;d;d=d.next)if(e=d.a_ly?d.a_ly[b]:
null){e.font!=A.curfont&&(A.curfont=e.font);var k=e.t;var l=e.ln||0;var n=k.wh[0];var q=e.shift;g&&(3==l?l=2:2>l&&(Ce(h,c,d.x-q-h),g=!1,h=d.x+d.wr));if(p&&3!=l){qc(h+3,c,f-h+3);var p=!1;h=d.x+d.wr}if(2<=l)0==f&&h>d.x-18&&(h=d.x-18),2==l?g=!0:p=!0,f=d.x-q;else{f=d.x-q;l&&(g=!0);if(u.anno_start||u.anno_stop){var r={p_v:d.p_v,st:d.st,istart:e.istart,iend:e.iend,ts_prev:d,ts_next:d.ts_next,x:f,y:c,ymn:c,ymx:c+A.curfont.size,wl:0,wr:n};pa(r,"lyrics")}na(f,c,k);Pb(r,"lyrics");h=f+n}}else switch(d.type){case m.REST:case m.MREST:p&&
(qc(h+3,c,f-h),p=!1,h=d.x+d.wr)}g&&(f=la-10,f<h+10&&(f=h+10),Ce(h,c,f-h),a.s_next&&a.s_next.fmt.hyphencont&&(a.hy_st|=1<<b));for(a.s_next;d;d=d.next)if(d.type==m.NOTE){if(!d.a_ly)break;(e=d.a_ly[b])&&3==e.ln&&(p=!0,f=la-15,f<h+12&&(f=h+12));break}p&&qc(h+3,c,f-h+3)}function Pe(a,b,c,d,e){var f=x[a.st].staffscale;T("vocal");if(0<e){d>-M.fmt.vocalspace&&(d=-M.fmt.vocalspace);d*=f;for(e=0;e<b;e++)d-=1.1*c[e],Oe(a,e,d+.22*c[e]);return d/f}e=x[a.st].topbar+M.fmt.vocalspace;d<e&&(d=e);d*=f;for(e=b;0<=--e;)Oe(a,
e,d+.22*c[e]),d+=1.1*c[e];return d/f}function of(){var a,b,c,d,e,f=Array(V+1),g=C.length,h=Array(g),k=Array(g),l=Array(g),n=Array(g),q=0,p=0,r=-1;for(b=0;b<g;b++){var t=C[b];if(t.sym){t.st!=r&&(p=q=0,r=t.st);var u=0;if(t.have_ly)for(h[b]||(h[b]=[]),a=t.sym;a;a=a.next){if(d=a.a_ly){var v=a.x;var w=10;for(c=0;c<d.length;c++)if(e=d[c]){v-=e.shift;w=e.t.wh[0];break}c=Q(t.st,1,v,w);q<c&&(q=c);c=Q(t.st,0,v,w);for(p>c&&(p=c);u<d.length;)h[b][u++]=0;for(c=0;c<d.length;c++)(e=d[c])&&(!h[b][c]||e.t.wh[1]>h[b][c])&&
(h[b][c]=e.t.wh[1])}}else c=Q(t.st,1,0,la),q<c&&(q=c),c=Q(t.st,0,0,la),p>c&&(p=c);f[r]||(f[r]={});f[r].top=q;f[r].bot=p;k[b]=u;0!=u&&(l[b]=t.pos.voc?(t.pos.voc&7)==m.SL_ABOVE:C[b+1]&&C[b+1].st==r&&C[b+1].have_ly?!0:!1,l[b]?f[r].a=!0:f[r].b=!0)}}for(b=c=0;b<g;b++)t=C[b],t.sym&&t.have_ly&&(l[b]?n[c++]=b:(r=t.st,La(r,!0),0<k[b]&&(f[r].bot=Pe(t,k[b],h[b],f[r].bot,1))));for(;0<=--c;)b=n[c],t=C[b],r=t.st,La(r,!0),f[r].top=Pe(t,k[b],h[b],f[r].top,-1);for(b=0;b<g;b++)if(t=C[b],t.sym){r=t.st;if(f[r].a)for(q=
f[r].top+2,a=t.sym;a;a=a.next)a.a_ly&&Y(r,1,a.x-2,10,q);if(f[r].b)if(p=f[r].bot-2,0<k[t.v])for(a=t.sym;a;a=a.next)a.a_ly&&Y(r,0,a.x-2,10,p);else Y(r,0,0,la,p)}}function ve(a){function b(){for(var a="";;){p=h[c++];if(0>"1234567890.-".indexOf(p))return parseFloat(a);a+=p}}var c,d=Ma("annotation"),e=d.size;var f=r.line;var g=r.bol+f.index;if(1<a.length){var h=a.slice(1,-1);var k=g+1}else{for(c=++f.index;;){a=f.buffer.indexOf('"',c);if(0>a){v(1,"No end of chord symbol/annotation");return}if("\\"!=f.buffer[a-
1]||"\\"==f.buffer[a-2])break;c=a+1}h=Hc(f.buffer.slice(f.index,a));f.index=a;k=r.bol+f.index+1}d.pad&&(e+=d.pad);c=0;for(a="g";;){var p=h[c];if(!p)break;f={text:"",istart:g,iend:k,font:d};switch(p){case "@":a=p;c++;var n=b();if(","!=p){v(1,"',' lacking in annotation '@x,y'");var q=0}else q=b()," "!=p&&c--;f.x=n;f.y=q;break;case "^":f.pos=m.SL_ABOVE;case "_":"_"==p&&(f.pos=m.SL_BELOW);case "<":case ">":c++;a=p;break;default:switch(a){case "g":f.font=Ma("gchord");f.pos=l.pos.gch||m.SL_ABOVE;break;
case "^":f.pos=m.SL_ABOVE;break;case "_":f.pos=m.SL_BELOW;break;case "@":f.x=n,q-=e,f.y=q}}for(f.type=a;;){p=h[c];if(!p)break;switch(p){default:f.text+=p;c++;continue;case "&":for(;;){f.text+=p;p=h[++c];switch(p){default:continue;case ";":case void 0:case "\\":}break}if(";"==p){c++;f.text+=p;continue}case "\n":case ";":}c++;break}f.otext=f.text;Ia||(Ia=[]);Ia.push(f)}}function yd(a,b){var c,d=a.split("/");b=abc2svg.b40l5[(b+202)%40];for(c=0;c<d.length;c++){a=d[c];var e=a.search(/[A-G]/);if(!(0>e)){var f=
e+1;var g="FCGDAEB".indexOf(a[e])-1;if("#"==a[f]||"\u266f"==a[f])g+=7,f++;else if("b"==a[f]||"\u266d"==a[f])g-=7,f++;g+=b;d[c]=a.slice(0,e)+"FCGDAEB"[(g+22)%7]+(13<=g?"##":6<=g?"#":-9>=g?"bb":-2>=g?"b":"")+a.slice(f)}}return d.join("/")}function Vb(a){var b;if(a.type==m.BAR)for(b=0;b<Ia.length;b++)"g"==Ia[b].type&&(w(1,a,"There cannot be chord symbols on measure bars"),Ia.splice(b));if(l.tr_sco||l.tr_snd)for(b=0;b<Ia.length;b++){var c=Ia[b];"g"==c.type&&(l.tr_snd40&&(c.otext=yd(c.text,l.tr_snd40)),
l.tr_sco&&(c.text=yd(c.text,l.tr_sco)))}a.a_gch=a.a_gch?a.a_gch.concat(Ia):Ia;Ia=null}function ef(){function a(a){var b,c,e;for(c=d;c;c=c.ts_next)if(b=c.a_gch){var f=b.length-a-1;if(b=b[f]){if(b.pos==m.SL_ABOVE){var g=c.x+b.x;(e=b.text.wh[0])&&g+e>la&&(g=la-e);e=Q(c.st,1,g,e);"g"==b.type&&e<k[c.st].yup&&(e=k[c.st].yup)}else if(b.pos==m.SL_BELOW||b.pos==m.SL_HIDDEN)continue;else g=c.x+b.x,e=b.y;U.draw_gchord(f,c,g,e)}}}function b(a){for(var b,c,e,f=d;f;f=f.ts_next)(b=f.a_gch)&&(b=b[a])&&b.pos==m.SL_BELOW&&
(c=f.x+b.x,(e=b.text.wh[0])&&c+e>la&&(c=la-e),e=Q(f.st,0,c,e)-2,"g"==b.type&&e>k[f.st].ydn&&(e=k[f.st].ydn),U.draw_gchord(a,f,c,e))}var c,d,e,f,g,h=0,k=Array(V+1);for(f=0;f<=V;f++)k[f]={ydn:x[f].botbar-3,yup:x[f].topbar+4};for(c=M;c;c=c.ts_next)if(e=c.a_gch)for(d||(d=c),f=e.length,f>h&&(h=f);0<=--f;)if("g"==e[f].type){e=e[f];f=c.x+e.x;(g=e.text.wh[0])&&f+g>la&&(f=la-g);e.pos==m.SL_ABOVE?(e=Q(c.st,!0,f,g),e>k[c.st].yup&&(k[c.st].yup=e)):e.pos==m.SL_BELOW&&(e=Q(c.st,!1,f,g)-2,e<k[c.st].ydn&&(k[c.st].ydn=
e));break}if(d)for(La(-1),f=0;f<h;f++)a(f),b(f)}var m=abc2svg.C,Qa,G={bad_char:"Bad character '$1'",bad_grace:"Bad character in grace note sequence",bad_transp:"Bad transpose value",bad_val:"Bad value in $1",bar_grace:"Cannot have a bar in grace notes",ignored:"$1: inside tune - ignored",misplaced:"Misplaced '$1' in %%score",must_note:"!$1! must be on a note",must_note_rest:"!$1! must be on a note or a rest",nonote_vo:"No note in voice overlay",not_ascii:"Not an ASCII character",not_enough_n:"Not enough notes/rests for %%repeat",
not_enough_m:"Not enough measures for %%repeat",not_enough_p:"Not enough parameters in %%map",not_in_tune:"Cannot have '$1' inside a tune",notransp:"Cannot transpose with a temperament"},U=this,oa={meter:{type:m.METER,wmeasure:1,a_meter:[]}},L={},r={ctx:{},prefix:"%",state:0,ottava:[],line:new F},jd=[],Je,wb={},ha,pb,Ob={dot:"0 stc 6 .7 1",tenuto:"0 emb 6 4 3",slide:"1 sld 5,5 7 1",arpeggio:"2 arp 12 10 3",roll:"3 roll 5,4 5 6",lowermordent:"3 lmrd 6,5 4 6",uppermordent:"3 umrd 6,5 4 6",trill:"3 trl 14 5 8",
upbow:"3 upb 12,2 3 7",downbow:"3 dnb 8,2 4 6",gmark:"3 grm 7 4 6",wedge:"0 wedge 8 1.5 1",longphrase:"5 lphr 0 1 16",mediumphrase:"5 mphr 0 1 16",shortphrase:"5 sphr 0 1 16",turnx:"3 turnx 7,2.5 5 6",invertedturn:"3 turn 7,2 5 6",plus:"3 dplus 8,2 2 4","+":"3 dplus 8,2 2 4",">":"5 accent 3.5,3.5 4 4",accent:"5 accent 3.5,3.5 4 4",emphasis:"5 accent 3.5,3.5 4 4",marcato:"3 marcato 9 5 5","^":"3 marcato 9 5 5",mordent:"3 lmrd 6,5 4 6",open:"3 opend 8 3 3",snap:"3 snap 10 3 3",thumb:"3 thumb 10 3 3",
turn:"3 turn 7,2.5 5 6","trill(":"5 ltr 8 0 0","trill)":"5 ltr 8 0 0","8va(":"5 8va 12 6 6","8va)":"5 8va 12 6 6","8vb(":"4 8vb 10,5 6 6","8vb)":"4 8vb 10,5 6 6","15ma(":"5 15ma 12 9 9","15ma)":"5 15ma 12 9 9","15mb(":"4 15mb 12 9 9","15mb)":"4 15mb 12 9 9",breath:"5 brth 0 1 16",caesura:"5 caes 0 1 20",short:"5 short 0 1 16",tick:"5 tick 0 1 16",coda:"5 coda 22,5 10 10",dacapo:"5 dacs 16 20 20 Da Capo",dacoda:"5 dacs 16 20 20 Da Coda","D.C.":"5 dcap 16,3 6 6","D.S.":"5 dsgn 16,3 6 6","D.C.alcoda":"5 dacs 16 32 32 D.C. al Coda",
"D.S.alcoda":"5 dacs 16 32 32 D.S. al Coda","D.C.alfine":"5 dacs 16 32 32 D.C. al Fine","D.S.alfine":"5 dacs 16 32 32 D.S. al Fine",fermata:"5 hld 12 7.5 7.5",fine:"5 dacs 16 12 12 Fine",invertedfermata:"7 hld 12 8 8",segno:"5 sgno 22,2 5 5",f:"6 f 12,5 3 4",ff:"6 ff 12,5 8 5",fff:"6 fff 12,5 11 9",ffff:"6 ffff 12,5 15 12",mf:"6 mf 12,5 8 10",mp:"6 mp 12,5 9 10",p:"6 p 12,5 3 6",pp:"6 pp 12,5 8 9",ppp:"6 ppp 12,5 14 11",pppp:"6 pppp 12,5 14 17",pralltriller:"3 umrd 6,5 4 6",sfz:"6 sfz 12,5 9 9",ped:"6 ped 9 6 10",
"ped-up":"6 pedoff 9 4 4","ped(":"7 lped 14 1 1","ped)":"7 lped 14 1 1","crescendo(":"6 cresc 15,2 0 0","crescendo)":"6 cresc 15,2 0 0","<(":"6 cresc 15,2 0 0","<)":"6 cresc 15,2 0 0","diminuendo(":"6 dim 15,2 0 0","diminuendo)":"6 dim 15,2 0 0",">(":"6 dim 15,2 0 0",">)":"6 dim 15,2 0 0","-(":"8 gliss 0 0 0","-)":"8 gliss 0 0 0","~(":"8 glisq 0 0 0","~)":"8 glisq 0 0 0",invisible:"32 0 0 0 0",beamon:"33 0 0 0 0",trem1:"34 0 0 0 0",trem2:"34 0 0 0 0",trem3:"34 0 0 0 0",trem4:"34 0 0 0 0",xstem:"35 0 0 0 0",
beambr1:"36 0 0 0 0",beambr2:"36 0 0 0 0",rbstop:"37 0 0 0 0","/":"38 0 0 6 6","//":"38 0 0 6 6","///":"38 0 0 6 6","beam-accel":"39 0 0 0 0","beam-rall":"39 0 0 0 0",stemless:"40 0 0 0 0",rbend:"41 0 0 0 0",editorial:"42 0 0 0 0","sacc-1":"3 sacc-1 6,4 4 4",sacc3:"3 sacc3 6,5 4 4",sacc1:"3 sacc1 6,4 4 4",courtesy:"43 0 0 0 0","cacc-1":"3 cacc-1 0 0 0",cacc3:"3 cacc3 0 0 0",cacc1:"3 cacc1 0 0 0","tie(":"44 0 0 0 0","tie)":"44 0 0 0 0",fg:"45 0 0 0 0"},Ed=[function(a){var b=a.up,c=a.s,d=a.dd;var e=
b?c.ymx:c.ymn;0<e&&24>e&&(e=6*((e+9)/6|0)-6);b?(e=27<c.ys&&"d"==d.name[0]&&"dot"==c.a_dd[0].name&&0<c.stem&&0<=c.nflags&&c.beam_st&&c.beam_end?e-6:e+d.hd,c.ymx<e+d.h&&(c.ymx=e+d.h)):"w"==d.name[0]?(a.inv=!0,e-=d.h,c.ymn=e):(e-=d.h,c.ymn=e-d.hd);a.x-=d.wl;a.y=e;c.type==m.NOTE&&(a.x+=c.notes[0<=c.stem?0:c.nhd].shhd)},function(a){var b=a.s;if(null!=b.decstm)if(0<=a.s.stem){if(-1<=b.nflags){var c=3.5;var d=b.ys;1<b.nflags&&(d-=4*(b.nflags-1))}else c=0,d=b.y+21;a.y=(d+3*(b.notes[b.nhd].pit-18))/2}else a.rotpi=
1,-1<=b.nflags?(c=-3.5,d=b.ys,1<b.nflags&&(d+=4*(b.nflags-1))):(c=0,d=b.y-21),a.y=(d+3*(b.notes[0].pit-18))/2;else if(c=-5,a.y=3*(b.notes[0].pit-18),"sld"==a.dd.glyph)for(c=-10,d=0;d<=b.nhd;d++){if(b.notes[d].acc)var e=-7-b.notes[d].shac;else switch(e=-10+b.notes[d].shhd,b.head){case m.SQUARE:e-=3.5;break;case m.OVALBARS:case m.OVAL:e-=2}e<c&&(c=e)}a.x+=c;0>a.y&&Y(b.st,0,a.x,a.dd.wl,a.y-a.dd.h)},function(a){var b,c=a.s,d=a.dd,e=d.wr;if(c.type==m.NOTE)for(b=0;b<=c.nhd;b++){if(c.notes[b].acc)var f=
c.notes[b].shac;else switch(f=1-c.notes[b].shhd,c.head){case m.SQUARE:f+=3.5;break;case m.OVALBARS:case m.OVAL:f+=2}f>e&&(e=f)}f=3*(c.notes[c.nhd].pit-c.notes[0].pit)+4;b=d.h;f<b&&(f=b);a.has_val=!0;a.val=f;a.x-=e;a.y=3*((c.notes[0].pit+c.notes[c.nhd].pit)/2-18)-f/2-3}],Gd=[null,null,null,null,Nb],ad=[null,null,null,Nb,null,Nb,Nb,Nb];Abc.prototype.draw_all_deco=function(){if(ha.length){var a,b,c=[],d=[];var e=V;for(b=x[e].y;0<=--e;){var f=x[e].y;d[e]=.5*(b+24+f);b=f}for(;;){var g=ha.shift();if(!g)break;
if((a=g.dd)&&!a.dd_en){var h=g.s;var k=a.glyph;b=k.indexOf("/");0<b&&(k=0<=h.stem?k.slice(0,b):k.slice(b+1));ad[a.func]?Ra(h.st):Zb(h);e=g.st;if(x[e].topbar){var l=g.x+(a.dx||0);b=g.y+x[e].y+(a.dy||0);if(6==a.func&&((g.pos&m.SL_ALI_MSK)==m.SL_CENTER||0==(g.pos&m.SL_ALI_MSK)&&!h.fmt.dynalign)&&(g.up&&0<e||!g.up&&e<V)){var n=g.up?d[--e]:d[e++];n-=.5*a.h;if(g.up&&b<n||!g.up&&b>n)if(f=Q(e,!g.up,g.x,g.val)+x[e].y,g.up&&(f-=a.h),g.up&&f>n||!g.up&&f<n)b=n,1!=B.scale&&(b+=B.dy/2)}if(u.deco&&(e=u.deco[k])&&
"function"==typeof e){e.call(U,l,b,g);continue}if(!U.psdeco(l,b,g)){pa(h,"deco");g.inv?(b=b+a.h-a.hd,zb(l,b,0,1,-1),l=b=0):g.rotpi&&(zb(l,b,180),l=b=0);if(g.has_val)2!=a.func||0>B.st?xd(l,b,k,g.val/B.scale,g.defl):xd(l,b,k,g.val,g.defl),g.cont&&c.push(g.start);else if(void 0==a.str||xc[a.glyph]||kb[a.glyph])if(g.lden){var p;a=l;l=g.dd.glyph;k=g.start;if(Qe[l]){e=g.s.p_v;if(g.defl.noen){for(p=e.s_next;p&&!p.dur;)p=p.next;if(p)for(n=0;n<=p.nhd;n++)if(f=p.notes[n],f.a_dd)for(e=0;e<f.a_dd.length;e++)if(f.a_dd[e].name==
g.dd.name){b=3*(f.pit-18)+x[g.s.st].y;break}a+=8}else if(g.defl.nost){for(p=e.s_prev;p&&!p.dur;)p=p.prev;if(p)for(n=0;n<=p.nhd;n++)if(f=p.notes[n],f.a_dd)for(e=0;e<f.a_dd.length;e++)if(f.a_dd[e].name==k.dd.name){k.y=3*(f.pit-18);break}k.x-=8}Qe[l](a,b,g)}else w(1,null,"No function for decoration '$1'",l)}else R(l,b,k);else{if(h.fg)a:{e=k=void 0;var r;for(f=h.fg.length;0<=--f&&(e=h.fg[f],e.nm!=a.name););if(!(0>f))if(e.ty)1==e.ty&&qc(l-19,b,12);else{f=l+7;for(r=0;r<ha.length;r++)if(n=ha[r],n.s==e.s&&
n.dd.name==a.name){for(p=0;p<n.s.fg.length&&(k=n.s.fg[p],k.nm!=e.nm);p++);if(k.nm==e.nm){k.ty=2;ib(f,b+1);D+="l"+(n.x-7-f).toFixed(1)+" "+(b-n.y-x[h.st].y).toFixed(1)+'" stroke-width=".7"/>\n';break a}}qc(f,b,12)}}De(l,b,g)}B.g&&Ab();Pb(h,"deco")}}}}ha=c}};var Rb,$b=[],Uf=[[16,16,14,12,10,10],[14,14,10,9,9,9]];Abc.prototype.calculate_beam=function(a,b){var c,d,e,f,g,h;if(!b.beam_st){var k=Id(b);Uc(k,b);ic(k,b);k.x-=12;k.x>b.prev.x+12&&(k.x=b.prev.x+12);k.beam_st=!0;delete k.beam_end;k.tmp=!0;delete k.sls;
b=k}var l=d=0;var n=e=!1;var p=b.st;var r=b.v;var u=b.grace?2.3:3.5;for(c=b;c.type!=m.NOTE||(c.nflags>d&&(d=c.nflags),l++,c.st!=p&&(n=!0),c.stem!=b.stem&&(e=!0),f||c.invis||c.stemless&&!c.trem2||(f=!0),!c.beam_end);c=c.next)if(!c.next){for(;c.type!=m.NOTE;c=c.prev);k=Id(c);k.next=c.next;k.next&&(k.next.prev=k);c.next=k;k.prev=c;k.ts_next=c.ts_next;k.ts_next&&(k.ts_next.ts_prev=k);c.ts_next=k;k.ts_prev=c;delete k.beam_st;k.beam_end=!0;k.tmp=!0;delete k.sls;k.x+=12;k.x<la-12&&(k.x=la-12);c=k;l++;break}if(!f)return!1;
a.s2=c;if(0==x[p].y){if(n)return!1}else if(!n)return a.s1=b,a.a=(b.ys-c.ys)/(b.xs-c.xs),a.b=b.ys-b.xs*a.a+x[p].y,a.nflags=d,!0;var t=b;var v=100;var w=0;for(k=b;k.type!=m.NOTE||(1==(h=k.p_v.scale)&&(h=x[k.st].staffscale),0<=k.stem?(f=u+k.notes[0].shhd,k.notes[k.nhd].midi>w&&(w=k.notes[k.nhd].midi,t=k)):(f=-u+k.notes[k.nhd].shhd,k.notes[0].midi<v&&(v=k.notes[0].midi,t=k)),k.xs=k.x+f*h,k!=c);k=k.next);k.grace&&b.fmt.flatbeams?g=0:!e&&3<=l&&t!=b&&t!=c&&(g=0);f=b.ys+x[p].y;void 0==g&&(e&&b.stem!=c.stem&&
b.st==c.st&&(f-=5*b.stem,c.ys-=5*c.stem),g=(c.ys+x[c.st].y-f)/(c.xs-b.xs));0!=g&&(g=b.fmt.beamslope*g/(b.fmt.beamslope+Math.abs(g)),-.04<g&&.04>g&&(g=0));l=(f+c.ys+x[c.st].y)/2-g*(c.xs+b.xs)/2;u=0;k=b;if(e){for(r=1;;){if(k.stem!=b.stem&&(1==k.nflags||k.beam_br1||k.beam_br2)){r=0;break}if(k==c)break;k=k.next}r=r?(b.nflags+c.nflags)*(b.nflags>=c.nflags?b.stem:c.stem)/4:-(b.nflags*b.stem+c.nflags*c.stem)/2;l+=((b.grace?3.5:5)*r+3.2*b.stem)/2}else if(b.grace)for(;f=g*k.xs+l-x[k.st].y,w=13,w=0<k.stem?
w-(f-3*(k.notes[k.nhd].pit-18)):w+(f-3*(k.notes[0].pit-18)),w+=3*(k.nflags-1),w>u&&(u=w),k!=c;k=k.next);else{for(v=3.2+5*(d-1);k.ts_prev&&k.ts_prev.type==m.NOTE&&k.ts_prev.time==k.time&&k.ts_prev.x>b.xs;)k=k.ts_prev;for(;k&&k.time<=c.time;k=k.ts_next)if(!(k.type!=m.NOTE||k.invis||k.st!=p&&k.v!=r)){f=k.v==r?k.xs:k.x;f=g*f+l-x[k.st].y;if(k.v==r)w=Uf[0==k.nhd?0:1][k.nflags],0<k.stem?(26<k.notes[k.nhd].pit&&(w-=2,28<k.notes[k.nhd].pit&&(w-=2)),w-=f-3*(k.notes[k.nhd].pit-18)):(18>k.notes[0].pit&&(w-=2,
16>k.notes[0].pit&&(w-=2)),w-=3*(k.notes[0].pit-18)-f),w+=3.2+5*(k.nflags-1);else{if(0<b.stem)if(0<k.stem){if(k.ymn>f+4||k.ymx<f-v-2)continue;w=k.v>r?k.ymx-f:k.ymn+8-f}else w=k.ymx-f;else if(0>k.stem){if(k.ymx<f-4||k.ymn>f-v-2)continue;w=k.v<r?f-k.ymn:f-k.ymx+8}else w=f-k.ymn;w+=2+v}w>u&&(u=w)}}0<u&&(l+=b.stem*u);if(!n&&!e)for(k=b.next;;k=k.next){switch(k.type){case m.REST:if(!k.multi)break;n=k.ts_next;if(!n||n.st!=p||n.type!=m.NOTE&&n.type!=m.REST)break;if(k.invis)break;case m.CLEF:f=g*k.x+l;0<b.stem?
(f=k.ymx-f+3.2+5*(d-1)+2,0<f&&(l+=f)):(f=k.ymn-f-3.2-5*(d-1)-2,0>f&&(l+=f));break;case m.GRACE:for(n=k.extra;n;n=n.next)f=g*n.x+l,0<b.stem?(f=n.ymx-f+3.2+5*(d-1),0<f&&(l+=f)):(f=n.ymn-f-3.2-5*(d-1),0>f&&(l+=f))}if(k==c)break}0==g&&(l+=hf(b.grace,b.stem,d,l-x[p].y));for(k=b;;k=k.next){switch(k.type){case m.NOTE:k.ys=g*k.xs+l-x[k.st].y;0<k.stem?k.ymx=k.ys+2.5:k.ymn=k.ys-2.5;break;case m.REST:f=g*k.x+l-x[k.st].y;n=3.2+5*(d-1)+(k.head!=m.FULL?4:9);if(0<b.stem){if(f-=n,0==b.multi&&12<f&&(f=12),k.y<=f)break}else if(f+=
n,0==b.multi&&12>f&&(f=12),k.y>=f)break;k.head!=m.FULL&&(f=6*((f+3+12)/6|0)-12);k.y=f}if(k==c)break}if(0==x[p].y)return!1;a.s1=b;a.a=g;a.b=l;a.nflags=d;return!0};var Md={};Abc.prototype.draw_hl=function(a){var b,c,d=[],e=a.st,f=x[e];if(f.hll&&!a.invis){for(b=0;b<=a.nhd;b++){var g=a.notes[b];f.hlmap[g.pit-f.hll]||d.push([g.pit-18,g.shhd*a.p_v.scale])}if(c=d.length){e=K.staves[e].stafflines;var h=e.length-1,k=h,m=(f.hll-17)/2,l=m,p=(a.grace?4:1.3*Re[a.head])*a.p_v.scale;g=a.notes[0>a.stem?a.nhd:0];
var r=g.shhd;for(b=0;b<d.length;b++){var u=d[b][0];g=(d[b][1]<r?d[b][1]:r)-p;var t=(d[b][1]>r?d[b][1]:r)+p;u<2*m?(++u<2*l&&(l=u>>1),c--):u>2*h&&(k=u>>1,c--);jb(f,u>>1,a.x,g,t)}g=r-p;for(t=r+p;++l<m;)jb(f,l,a.x,g,t);for(;--k>h;)jb(f,k,a.x,g,t);if(c){b=l;for(c=k;b>m&&"-"==e[b];)b--;for(;c<h&&"-"==e[c];)c++;for(;b<c;b++)"-"==e[b]&&jb(f,b,a.x,g,t)}}}};var Se=new Int8Array([24,9,15,21,6,12,18]),Te=new Int8Array([12,18,24,9,15,21,6]),Ue=new Int8Array([-9,12,-9,-9,12,-9]),Ve=new Int8Array([12,-9,12,-9,12,
-9]),We=new Int8Array([9,-12,9,-12,9,-12]),Xe=new Int8Array([-12,9,-12,9,-12,9]);Abc.prototype.draw_keysig=function(a,b){var c=b.k_old_sf,d=x[b.st].y,e,f=b.k_y_clef;var g=b.k_a_acc;f&1&&(f+=7);for(f/=2;0>f;)f+=7;f%=7;if(g&&!b.exp){var h=b.k_sf,k;var m=[];var l=[];if(0<h)for(e=0;e<h;e++)m[e]=1,l[e]=[26,23,27,24,21,25,22][e];else for(e=0;e<-h;e++)m[e]=-1,l[e]=[22,25,21,24,20,23,26][e];var p=g.length;for(h=0;h<p;h++){var r=g[h];for(k=0;k<e;k++)if(l[k]==r.pit){m[k]=r.acc;break}k==e&&(m[k]=r.acc,l[k]=
r.pit,e++)}for(h=0;h<e;h++)(r=g[h])||(r=g[h]={}),r.acc=m[h],r.pit=l[h]}if(!g){if(b.fmt.cancelkey||0==b.k_sf)if(0==b.k_sf||0>c*b.k_sf){m=Se[f];g=9<m?Ue:Ve;for(e=0;e<c;e++)R(a,d+m,"acc3"),m+=g[e],a+=5.5;m=Te[f];g=18>m?We:Xe;for(e=0;e>c;e--)R(a,d+m,"acc3"),m+=g[-e],a+=5.5;0!=b.k_sf&&(a+=3)}if(0<b.k_sf){m=Se[f];g=9<m?Ue:Ve;for(e=0;e<b.k_sf;e++)R(a,d+m,"acc1"),m+=g[e],a+=5.5;if(b.fmt.cancelkey&&e<c)for(a+=2;e<c;e++)R(a,d+m,"acc3"),m+=g[e],a+=5.5;"p"==b.k_bagpipe&&(R(a,d+27,"acc3"),a+=5.5)}if(0>b.k_sf){m=
Te[f];g=18>m?We:Xe;for(e=0;e>b.k_sf;e--)R(a,d+m,"acc-1"),m+=g[-e],a+=5.5;if(b.fmt.cancelkey&&e>c)for(a+=2;e>c;e--)R(a,d+m,"acc3"),m+=g[-e],a+=5.5}}else if(g.length)for(f=g[0].acc,l=100,h=[{}],e=0;e<g.length;e++){c=g[e];for(m=3*(b.k_y_clef+c.pit-18);-3>m;)m+=21;for(;27<m;)m-=21;0!=e&&(m>l+18||m<l-18)?a-=5.5:c.acc!=f&&(a+=3);f=c.acc;h[0].pit=m/3+18;l=m;cd(a,d+m,c.acc);a+=5.5}};var Vf="r128 r64 r32 r16 r8 r4 r2 r1 r0 r00".split(" ");Abc.prototype.draw_symbols=function(a){var b={},c;for(c=a.sym;c;c=c.next){if(c.invis)switch(c.type){case m.CLEF:c.time>=
x[c.st].clef.time&&(x[c.st].clef=c);continue;case m.KEY:a.ckey=c;default:continue;case m.NOTE:}var d=c.st;var e=c.x;fb(c.color);switch(c.type){case m.NOTE:Zb(c);c.beam_st&&!c.beam_end&&U.calculate_beam(b,c)&&Jd(b);c.invis||(pa(c),Qb(c,!b.s2),$b.push(c));c==b.s2&&(b.s2=null);break;case m.REST:if(!A.st_print[d])break;var f=c;var g=x[f.st];var h=g.y,k=f.x;f.notes[0].shhd&&(k+=f.notes[0].shhd*B.scale);if(f.rep_nb)Ra(f.st),pa(f),h="|||||"==g.stafflines?h+12:h+(g.topbar+g.botbar)/2,0>f.rep_nb?R(k,h,"srep"):
(R(k,h,"mrep"),2<f.rep_nb&&f.v==K.top_voice&&0<f.fmt.measrepnb&&!(f.rep_nb%f.fmt.measrepnb)&&Nd(k,h+g.topbar,f.rep_nb));else{Zb(f);pa(f);f.notes[0].color&&fb(f.notes[0].color);e=f.y;d=5-f.nflags;7==d&&12==e&&2>=g.stafflines.length&&(e-=6);f.notes[0].invis||R(k,e+h,Vf[d]);if(f.dots)for(k+=8,e+=h+3,g=f.dots,d=f.dur_orig/12>>5-f.nflags-g;0<g--;)R(k,e,d&1<<g?"dot":"dot+"),k+=3.5;fb()}$b.push(f);break;case m.BAR:break;case m.CLEF:if(c.time>=x[d].clef.time){if(c.x==x[d].clef.x&&c.v!=x[d].clef.v)break;x[d].clef=
c}if(!A.st_print[d])break;fb();Ra(d);pa(c);d=x[d].y;c.clef_name?R(e,d+c.y,c.clef_name):c.clef_small?R(e,d+c.y,"s"+c.clef_type+"clef"):R(e,d+c.y,c.clef_type+"clef");c.clef_octave&&(0<c.clef_octave?(d+=c.ymx+1,c.clef_small&&(d-=2)):d+=c.ymn-2,R(e-2,d,7==c.clef_octave||-7==c.clef_octave?"oct":"oct2"));$b.push(c);break;case m.METER:a.meter=c;if(c.second||!x[c.st].topbar)break;fb();Ra(c.st);pa(c);Ld(c);$b.push(c);break;case m.KEY:a.ckey=c;if(c.second||!x[c.st].topbar)break;fb();Ra(c.st);pa(c);U.draw_keysig(e,
c);$b.push(c);break;case m.MREST:e=c;k=x[e.st];d=k.y+(k.topbar+k.botbar)/2;f=e.nmes.toString();Zb(e);for(h=e;!h.seqst;)h=h.ts_prev;for(h=h.ts_prev;!h.seqst;)h=h.ts_prev;g=h.x+20;h=e.ts_next;h.staff!=e.staff&&(h=e.next);h=h.x-20;e.x=(g+h)/2;pa(e);if(!p.oldmrest||e.nmes>p.oldmrest)ea('<path d="mX Y',g+.6,d-2.7),D+="v2.7h-1.4v-10.8h1.4v2.7h"+((h-g-2.8)/B.scale).toFixed(1)+'v-2.7h1.4v10.8h-1.4v-2.7z"/>\n';else{g=e.x;k=k.y+12;h=e.nmes;var l=h>>2;h&3&&(l++,h&1&&l++);for(g-=3*(l-1);4<=h;)R(g,k,"r00"),h-=
4,g+=6;2<=h&&(R(g,k,"r0"),h-=2,g+=6);h&&R(g+2,k,"r1")}e.tacet?ea('<text x ="X" y="Y" style="font-size:12px;font-weight:700" text-anchor="middle">A</text>\n',e.x,d+18,e.tacet):ea('<text x ="X" y="Y" text-anchor="middle">A</text>\n',e.x,d+22,ye(f));$b.push(e);break;case m.GRACE:Zb(c);e=c;f={};for(d=e.extra;;){d.beam_st&&!d.beam_end&&U.calculate_beam(f,d)&&Jd(f);pa(d);Qb(d,!f.s2);d==f.s2&&(f.s2=null);$b.push(e);if(!d.next)break;d=d.next}e.sappo&&(d=e.extra,d.next?(k=.5*(d.next.x-d.x)+4,f=.5*(d.ys+d.next.ys)-
d.y,f=0<d.stem?f-1:f+1):(k=9,f=0<d.stem?5:-5),h=d.notes[0>d.stem?0:d.nhd],g=d.x,h=x[d.st].y+3*(h.pit-18),0<d.stem?(--g,h+=4):(g-=5,h-=4),ea('<path class="stroke" d="mX YlF G"/>\n',g,h,k,-f));if(d=e.slur)pa(e,"slur"),ib(d.x0,d.y0+x[e.st].y),D+="c"+d.x1.toFixed(1)+" "+d.y1.toFixed(1)+" "+d.x2.toFixed(1)+" "+d.y2.toFixed(1)+" "+d.x3.toFixed(1)+" "+d.y3.toFixed(1)+'"/>\n',Pb(e,"slur");break;case m.SPACE:case m.STBRK:break;case m.CUSTOS:Zb(c);Qb(c,0);break;case m.BLOCK:case m.REMARK:case m.STAVES:case m.TEMPO:break;
default:w(2,c,"draw_symbols - Cannot draw symbol "+c.type)}}Zb(a.sym)};var Pd={serif:1,serifBold:1,"sans-serif":1,"sans-serifBold":1,Palatino:1.1,monospace:1},Kb={},Ye={},p={"abc-version":"1",annotationfont:{name:"text,sans-serif",size:12},aligncomposer:1,beamslope:.4,bardef:{"[":"","[]":"","|:":"[|:","|::":"[|::","|:::":"[|:::",":|":":|]","::|":"::|]",":::|":":::|]","::":":][:"},breaklimit:.7,breakoneoln:!0,cancelkey:!0,composerfont:{name:"text,serif",style:"italic",size:14},composerspace:6,decoerr:!0,
dynalign:!0,footerfont:{name:"text,serif",size:16},fullsvg:"",gchordfont:{name:"text,sans-serif",size:12},gracespace:new Float32Array([6,8,11]),graceslurs:!0,headerfont:{name:"text,serif",size:16},historyfont:{name:"text,serif",size:16},hyphencont:!0,indent:0,infofont:{name:"text,serif",style:"italic",size:14},infoname:'R "Rhythm: "\nB "Book: "\nS "Source: "\nD "Discography: "\nN "Notes: "\nZ "Transcription: "\nH "History: "',infospace:0,keywarn:!0,leftmargin:1.4*37.8,lineskipfac:1.1,linewarn:!0,
maxshrink:.65,maxstaffsep:2E3,maxsysstaffsep:2E3,measrepnb:1,measurefont:{name:"text,serif",style:"italic",size:10},measurenb:-1,musicfont:{name:"music",src:'url("data:application/octet-stream;base64, ") format("truetype")',
size:24},musicspace:6,partsfont:{name:"text,serif",size:15},parskipfac:.4,partsspace:8,pagewidth:793.8,"propagate-accidentals":"o",printmargin:0,rightmargin:1.4*37.8,rbmax:4,rbmin:2,repeatfont:{name:"text,serif",size:9},scale:1,slurheight:1,spatab:new Float32Array([10.2,13.3,17.3,22.48,29.2,38,49.4,64.2,83.5,108.5]),staffsep:46,stemheight:21,stretchlast:.25,stretchstaff:!0,subtitlefont:{name:"text,serif",size:16},subtitlespace:3,sysstaffsep:34,systnames:-1,systvoices:3,tempofont:{name:"text,serif",
weight:"bold",size:12},textfont:{name:"text,serif",size:16},textspace:14,tieheight:1,titlefont:{name:"text,serif",size:20},titlespace:6,titletrim:!0,topspace:22,tuplets:[0,0,0,0],tupletfont:{name:"text,serif",style:"italic",size:10},vocalfont:{name:"text,serif",weight:"bold",size:13},vocalspace:10,voicefont:{name:"text,serif",weight:"bold",size:13},writefields:"CMOPQsTWw",wordsfont:{name:"text,serif",size:16},wordsspace:5,"writeout-accidentals":"n"},Ze={bardef:!0,barsperstaff:!0,beamslope:!0,breaklimit:!0,
bstemdown:!0,cancelkey:!0,dynalign:!0,flatbeams:!0,gracespace:!0,hyphencont:!0,keywarn:!0,maxshrink:!0,maxstaffsep:!0,measrepnb:!0,rbmax:!0,rbmin:!0,shiftunison:!0,slurheight:!0,squarebreve:!0,staffsep:!0,systvoices:1,stemheight:!0,stretchlast:!0,stretchstaff:!0,tieheight:!0,timewarn:!0,trimsvg:1,vocalspace:!0},tf={align:"j",center:"c",fill:"f",justify:"j",obeylines:"l",ragged:"f",right:"r",skip:"s",0:"l",1:"j",2:"f",3:"c",4:"s",5:"r"},zd={above:m.SL_ABOVE,auto:0,below:m.SL_BELOW,down:m.SL_BELOW,
hidden:m.SL_HIDDEN,opposite:m.SL_HIDDEN,under:m.SL_BELOW,up:m.SL_ABOVE};Abc.prototype.set_format=function(a,b){if(/.+font(-[\d])?$/.test(a))"soundfont"==a?p.soundfont=b:xb(a,b);else{Ze[a]&&r.ufmt&&(p=Object.create(p));switch(a){case "aligncomposer":case "barsperstaff":case "infoline":case "measurenb":case "rbmax":case "rbmin":case "measrepnb":case "shiftunison":case "systnames":case "systvoices":var c=parseInt(b);if(isNaN(c)){v(1,"Bad integer value");break}if("systnames"==a){switch(c){case -1:c=3;
break;case 1:c=2;break;case 2:c=1}a="systvoices"}p[a]=c;break;case "abc-version":case "bgcolor":case "fgcolor":case "propagate-accidentals":case "writeout-accidentals":p[a]=b;break;case "beamslope":case "breaklimit":case "lineskipfac":case "maxshrink":case "pagescale":case "parskipfac":case "scale":case "slurheight":case "stemheight":case "tieheight":var d=+b;if(isNaN(d)||!b||0>d){v(1,G.bad_val,"%%"+a);break}switch(a){case "scale":d/=.75;case "pagescale":.1>d&&(d=.1),a="scale",ba.chg=!0}p[a]=d;break;
case "annotationbox":case "gchordbox":case "measurebox":case "partsbox":xb(a.replace("box","font"),"* * "+(Bb(b)?"box":"nobox"));break;case "altchord":case "bstemdown":case "breakoneoln":case "cancelkey":case "checkbars":case "contbarnb":case "custos":case "decoerr":case "flatbeams":case "graceslurs":case "graceword":case "hyphencont":case "keywarn":case "linewarn":case "squarebreve":case "splittune":case "straightflags":case "stretchstaff":case "timewarn":case "titlecaps":case "titleleft":case "trimsvg":p[a]=
Bb(b);break;case "dblrepbar":b=":: "+b;case "bardef":c=b.split(/\s+/);2!=c.length?v(1,G.bad_val,"%%bardef"):(r.ufmt&&(p.bardef=Object.create(p.bardef)),p.bardef[c[0]]=c[1]);break;case "chordalias":c=b.split(/\s+/);c.length?abc2svg.ch_alias[c[0]]=c[1]||"":v(1,G.bad_val,"%%chordalias");break;case "composerspace":case "indent":case "infospace":case "maxstaffsep":case "maxsysstaffsep":case "musicspace":case "partsspace":case "staffsep":case "subtitlespace":case "sysstaffsep":case "textspace":case "titlespace":case "topspace":case "vocalspace":case "wordsspace":d=
ab(b);isNaN(d)||0>d?v(1,G.bad_val,"%%"+a):p[a]=d;break;case "page-format":u.page_format=Bb(b);break;case "print-leftmargin":v(0,"$1 is deprecated - use %%printmargin instead","%%"+a),a="printmargin";case "printmargin":case "leftmargin":case "pagewidth":case "rightmargin":d=ab(b);if(isNaN(d)){v(1,G.bad_val,"%%"+a);break}p[a]=d;ba.chg=!0;break;case "concert-score":"play"!=p.sound&&(p.sound="concert");break;case "writefields":var e=b.split(/\s+/);if(Bb(e[1]))for(b=0;b<e[0].length;b++)d=e[0][b],0>p.writefields.indexOf(d)&&
(p.writefields+=d);else for(b=0;b<e[0].length;b++)d=e[0][b],0<=p.writefields.indexOf(d)&&(p.writefields=p.writefields.replace(d,""));break;case "volume":a="dynamic";case "dynamic":case "gchord":case "gstemdir":case "ornament":case "stemdir":case "vocal":Rd(a,b);break;case "font":d=kc(b);1>=d.length||(b=+d[d.length-1],isNaN(b)||.5>=b?v(1,"Bad scale value in %%font"):Pd[d[0]]=b);break;case "fullsvg":if(0!=r.state){v(1,G.not_in_tune,"%%fullsvg");break}p[a]=b;break;case "gracespace":c=b.split(/\s+/);
for(b=0;3>b;b++)if(isNaN(+c[b])){v(1,G.bad_val,"%%gracespace");break}r.ufmt&&(p[a]=new Float32Array(3));for(b=0;3>b;b++)p[a][b]=+c[b];break;case "tuplets":c=b.split(/\s+/);(d=c[3])&&(d=zd[d]);d&&(c[3]=d);l?l.tup=c:p[a]=c;break;case "infoname":case "partname":a:{d=a;e=p[d]?p[d].split("\n"):"";c=b[0];for(var f=0;f<e.length;f++)if(e[f][0]==c){1==b.length?e.splice(f,1):e[f]=b;p[d]=e.join("\n");break a}p[d]=p[d]?p[d]+("\n"+b):b}break;case "notespacingfactor":if(c=b.match(/([.\d]+)[,\s]*(\d+)?/))d=+c[1],
isNaN(d)||1>d||2<d?d=0:c[2]?(e=+c[2],isNaN(d)&&(d=0)):e=p.spatab[5];if(!d){v(1,G.bad_val,"%%"+a);break}p[a]=b;p.spatab=new Float32Array(10);b=5;do p.spatab[b]=e,e/=d;while(0<=--b);b=5;for(e=p.spatab[b];++b<p.spatab.length;)e*=d,p.spatab[b]=e;break;case "play":p.sound="play";break;case "pos":a=b.match(/(\w*)\s+(.*)/);if(!a||!a[2]){v(1,"Error in %%pos");break}if("tup"==a[1].slice(0,3)&&l){l.tup=l.tup?Object.create(l.tup):p.tuplets;c=zd[a[2]];switch(c){case m.SL_ABOVE:l.tup[3]=1;break;case m.SL_BELOW:l.tup[3]=
2;break;case m.SL_HIDDEN:l.tup[2]=1}break}"vol"==a[1].slice(0,3)&&(a[1]="dyn");Rd(a[1],a[2]);break;case "sounding-score":"play"!=p.sound&&(p.sound="sounding");break;case "staffwidth":c=ab(b);if(isNaN(c)){v(1,G.bad_val,"%%"+a);break}if(100>c){v(1,"%%staffwidth too small");break}c=p.pagewidth-c-p.leftmargin;if(2>c){v(1,"%%staffwidth too big");break}p.rightmargin=c;ba.chg=!0;break;case "textoption":p[a]=Qd(b);break;case "dynalign":case "quiet":case "singleline":case "stretchlast":case "titletrim":c=
""==b?1:+b;isNaN(c)&&(c=+Bb(b));if("t"==a[1]&&(0>c||1<c)){v(1,G.bad_val,"%%"+a);break}p[a]=c;break;case "combinevoices":v(1,"%%combinevoices is deprecated - use %%voicecombine instead");break;case "voicemap":Sb("map",b);break;case "voicescale":Sb("scale",b);break;case "unsizedsvg":Bb(b)?u.imagesize="":delete u.imagesize;break;case "rbdbstop":(c=Bb(b))&&"2.2"<=p["abc-version"]?p["abc-version"]="1":!c&&"2.2">p["abc-version"]&&(p["abc-version"]="2.2");break;default:r.state||(p[a]=b)}Ze[a]&&r.ufmt&&(r.ufmt=
!1)}};Abc.prototype.style_font=Ud;var Z={},gc={},hc={},Yd={},xf={"=D":"\u0110","=H":"\u0126","=T":"\u0166","=d":"\u0111","=h":"\u0127","=t":"\u0167","/O":"\u00d8","/o":"\u00f8","/L":"\u0141","/l":"\u0142",vL:"\u013d",vl:"\u013e",vd:"\u010f",".i":"\u0131",AA:"\u00c5",aa:"\u00e5",AE:"\u00c6",ae:"\u00e6",DH:"\u00d0",dh:"\u00f0",OE:"\u0152",oe:"\u0153",ss:"\u00df",TH:"\u00de",th:"\u00fe"},wf={1:"\u266f",2:"\u266d",3:"\u266e",4:"&#x1d12a;",5:"&#x1d12b;"},Cb=0;Abc.prototype.tosvg=id;var A,x,V,va,la,Wc,
Zc,md,Ic=new Float32Array([9.5,9.5,13,16,16]),Re=new Float32Array([4.7,5,6,7.2,7.5]),Xc=new Float32Array([2.5,3,4.5,6,6.5]);Abc.prototype.set_width=function(a){var b,c,d,e;if(a.play)a.wl=a.wr=0;else{switch(a.type){case m.NOTE:case m.REST:a.wr=e=a.invis?0:Re[a.head];0<a.xmx&&(a.wr+=a.xmx+4);for(b=a.prev;b&&!Sa[b.type];b=b.prev);if(b)switch(b.type){case m.BAR:case m.CLEF:case m.KEY:case m.METER:e+=3;break;case m.STBRK:e+=8;break;case m.NOTE:0>a.stem*b.stem&&(e+=0>a.stem?3:-3)}for(c=d=0;c<=a.nhd;c++){var f=
a.notes[c];var g=f.shhd;0>g&&e<-g+5&&(e=-g+5);(g=f.acc)&&(!b||b.type!=m.NOTE||0<=b.stem&&b.notes[0].pit<f.pit+4||0>b.stem&&b.notes[b.nhd].pit>f.pit-4)&&(g=f.shac+("object"==typeof g?5.5:3.5),b&&0>b.stem&&b.notes[b.nhd].pit>f.pit+4&&(g-=5),e<g&&(e=g));if(f.a_dd){var h=0,k=f.a_dd.length;for(g=0;g<k;g++){var l=f.a_dd[g];l=l.wl+l.wr;f.shac&&(l+=f.shac);l>h&&(h=l)}g=h;d<g&&(d=g)}}e+=d;if(b)switch(b.type){case m.BAR:case m.CLEF:case m.KEY:case m.METER:e-=3}a.a_dd&&(e=$c(a,e));a.beam_st&&a.beam_end&&0<a.stem&&
0<a.nflags&&a.wr<a.xmx+9&&(a.wr=a.xmx+9);if(a.dots){if(void 0==a.wl)switch(a.head){case m.SQUARE:case m.OVALBARS:a.xmx+=3;break;case m.OVAL:a.xmx+=1}a.wr<a.xmx+8&&(a.wr=a.xmx+8);2<=a.dots&&(a.wr+=3.5*(a.dots-1))}a.trem2&&a.beam_end&&20>e&&(e=20);f=e;if(b)switch(b.type){case m.NOTE:(27<a.y&&27<b.y||-3>a.y&&-3>b.y)&&6>f&&(f=6);b.tie&&14>f&&(f=14);break;case m.CLEF:if(b.second||b.clef_small)break;case m.KEY:a.a_gch&&(f+=4);case m.METER:f+=3}a.a_gch&&(f=ee(a,e,f));a.wl=a.prev&&a.prev.type==m.GRACE?e-
4.5:f;return;case m.SPACE:g=a.width/2;a.wr=g;a.a_gch&&(g=ee(a,g,g));a.a_dd&&(g=$c(a,g));a.wl=g;return;case m.BAR:c=a.bar_type;switch(c){case "|":d=5;break;case "[":d=0;break;default:d=2+2.8*c.length;for(b=0;b<c.length;b++)switch(c[b]){case "[":case "]":d+=1;case ":":d+=2}":"==c[0]&&a.prev&&a.prev.dots&&(d+=4)}a.wl=d;a.wr=a.next&&a.next.type!=m.METER?7:5;a.invis&&(a.wl=a.wr=2);(b=a.prev)&&b.type==m.GRACE&&(a.wl-=6);for(;b;b=b.prev)if(Sa[b.type]){b.type==m.STBRK&&(a.wl-=12);break}a.a_dd&&(a.wl=$c(a,
a.wl));a.text&&4>a.text.length&&a.next&&a.next.a_gch&&(T("repeat"),a.wr+=ua(a.text)[0]+2);0<p.measurenb&&a.bar_num&&!(a.bar_num%p.measurenb)&&(a.wr+=4);return;case m.CLEF:if(a.invis){a.wl=a.wr=1;return}if(a.prev&&a.prev.type==m.STBRK){a.wl=6;a.wr=13;delete a.clef_small;return}a.wl=a.clef_small?11:12;a.wr=a.clef_small?8:13;return;case m.KEY:if(a.invis)break;a.wl=0;f=3;c=a.k_sf;e=a.k_old_sf&&(a.fmt.cancelkey||0==c)?a.k_old_sf:0;0<=c*e?(0>c&&(c=-c),0>e&&(e=-e),e>c&&(c=e)):(c-=e,0>c&&(c=-c),f+=3);"p"==
a.k_bagpipe&&c++;if(a.k_a_acc)for(e=a.k_a_acc.length,c=a.exp?e:c+e,e&&(d=a.k_a_acc[0].acc),b=1;b<e;b++)g=a.k_a_acc[b],g.pit>a.k_a_acc[b-1].pit+6||g.pit<a.k_a_acc[b-1].pit-6?c--:g.acc!=d&&(f+=3),d=g.acc;if(!c)break;a.wr=5.5*c+f;a.prev&&!a.prev.bar_type&&(a.wl+=2);return;case m.METER:a.x_meter=[];if(!a.a_meter.length)break;for(b=f=0;b<a.a_meter.length;b++)switch(e=a.a_meter[b],e.top[0]){case "C":case "c":case "o":a.x_meter[b]=f;f+=14;break;default:d=0;e=!e.bot||e.top.length>e.bot.length?e.top:e.bot;
for(c=0;c<e.length;c++)switch(e[c]){case "(":f+=2;d+=6;break;case ")":f-=2;d+=6;break;case "1":d+=6;break;case " ":d+=2;case ".":case "|":break;default:d+=12}a.x_meter[b]=f;f+=d}a.wl=1;a.wr=f+4;return;case m.MREST:a.wl=6;a.wr=66;return;case m.GRACE:if(a.invis)break;e=a.fmt.gracespace[0];d=a.fmt.gracespace[1];c=a.fmt.gracespace[2];b=a.extra;a.prev&&a.prev.type==m.BAR&&(e-=3);for(b.beam_st=!0;;b=b.next){ae(b);be(b.notes,6.5);g=0;for(f=b.nhd;0<=f;f--)b.notes[f].shac-2>g&&(g=b.notes[f].shac-2);e+=g;b.x=
e;0>=b.nflags&&(b.beam_st=b.beam_end=!0);f=b.next;if(!f){b.beam_end=!0;break}0>=f.nflags&&(b.beam_end=!0);b.beam_end&&(f.beam_st=!0,e+=d/4);0>=b.nflags&&(e+=d/4);b.y>f.y+8&&(e-=1.5);e+=d}(f=a.next)&&f.type==m.NOTE&&(b.y>=3*(f.notes[f.nhd].pit-18)?--c:b.beam_st&&b.y<3*(f.notes[f.nhd].pit-18)-4&&(c+=2));a.wl=e+c;a.wr=0;a.a_ly&&ld(a);return;case m.STBRK:a.wl=a.xmx;a.wr=8;return;case m.CUSTOS:a.wl=a.wr=4;return;case m.TEMPO:e=0;f=[];if(!a.tempo_str){p.musicfont.used||Ma("music");T("tempo");b=A.curfont.size;
a.tempo_str1&&(f.push(a.tempo_str1),e+=ua(a.tempo_str1)[0]);if(a.tempo_notes){c=' dy="-1"';b*=1.3;for(d=0;d<a.tempo_notes.length;d++)c=He(f,a,a.tempo_notes[d],c),e+=c*A.curfont.swfac,c="";f.push('<tspan dy="1">=</tspan>');e+=yb("=")*A.curfont.swfac;a.tempo_ca&&(f.push(a.tempo_ca),e+=ua(a.tempo_ca)[0]);a.tempo?(f.push(a.tempo),e+=ua(a.tempo.toString())[0]):(c=He(f,a,a.new_beat,' dy="-1"'),e+=c*A.curfont.swfac,c="y")}a.tempo_str2&&(c?f.push('<tspan\n\tdy="1">'+a.tempo_str2+"</tspan>"):f.push(a.tempo_str2),
e+=ua(a.tempo_str2)[0]);a.tempo_str=f.join(" ");e+=yb(" ")*A.curfont.swfac*(f.length-1);a.tempo_wh=[e,b]}break;case m.BLOCK:case m.REMARK:case m.STAVES:break;default:w(2,a,"set_width - Cannot set width for symbol $1",a.type)}a.wl=a.wr=0;a.seqst&&a.ts_next&&(a.ts_next.seqst=0)}};var Ad={t:-4,c:0,b:4,p:-6},$e=[[18,18],[12,18],[12,12],[10,12],[10,10],[10,10],[8,4],[9,0],[9,4],[6,8]];Abc.prototype.set_pitch=function(a){var b,c,d=m.BLEN,e=V+1,f=new Int16Array(2*e);for(b=0;b<=V;b++){var g=x[b].clef;f[b]=
Ad[g.clef_type]+2*g.clef_line;g.clefpit&&(f[b]+=g.clefpit);p.sound?g.clef_octave&&!g.clef_oct_transp&&(f[b]+=g.clef_octave):g.clef_oct_transp&&(f[b]-=g.clef_octave)}for(g=M;g!=a;g=g.ts_next)switch(b=g.st,g.type){case m.CLEF:f[b]=Ad[g.clef_type]+2*g.clef_line;g.clefpit&&(f[b]+=g.clefpit);p.sound?g.clef_octave&&!g.clef_oct_transp&&(f[b]+=g.clef_octave):g.clef_oct_transp&&(f[b]-=g.clef_octave);Jc(g);break;case m.GRACE:for(b=g.extra;b;b=b.next){if((c=f[b.st])&&!g.p_v.ckey.k_drum)for(e=0;e<=b.nhd;e++){var h=
b.notes[e];h.opit=h.pit;h.pit+=c}b.ymn=3*(b.notes[0].pit-18)-2;b.ymx=3*(b.notes[b.nhd].pit-18)+2}Jc(g);break;case m.KEY:g.k_y_clef=f[b];default:Jc(g);break;case m.MREST:if(g.invis)break;g.y=12;g.ymx=39;g.ymn=-2;break;case m.REST:g.y=12;if(1<g.rep_nb||g.bar_mrep){g.ymx=38;g.ymn=0;break}c=g;c.ymx=c.y+$e[5-c.nflags][0];c.ymn=c.y-$e[5-c.nflags][1];case m.NOTE:if((c=f[b])&&!g.p_v.ckey.k_drum)for(e=g.nhd;0<=e;e--)h=g.notes[e],h.opit=h.pit,h.pit+=c;g.dur<d&&(d=g.dur)}a||(md=d)};Abc.prototype.set_stem_dir=
function(){for(var a,b,c,d,e,f,g,h=[],k=M,l=K,n=l.nstaff;k;){for(a=0;a<=n;a++)h[a]=[];g=[];for(b=k;b&&b.type!=m.BAR;b=b.ts_next)if(b.type==m.STAVES){if(b!=k)break;l=k.sy;for(a=n;a<=l.nstaff;a++)h[a]=[];n=l.nstaff}else if(!(b.type!=m.NOTE&&b.type!=m.REST||b.invis)){a=b.st;if(a>n)throw b="*** fatal set_stem_dir(): bad staff number "+a+" max "+n,w(2,null,b),Error(b);c=b.v;d=g[c];d||(d={st1:-1,st2:-1},g[c]=d);0>d.st1?d.st1=a:d.st1!=a&&(a>d.st1?a>d.st2&&(d.st2=a):(d.st1>d.st2&&(d.st2=d.st1),d.st1=a));
e=h[a];d=l.voices[c].range;for(c=e.length;0<=--c&&(f=e[c],f.v!=d););if(0>c){f={v:d,ymx:0,ymn:24};for(c=0;c<e.length;c++)if(d<e[c].v){e.splice(c,0,f);break}c==e.length&&e.push(f)}b.type==m.NOTE&&(b.ymx>f.ymx&&(f.ymx=b.ymx),b.ymn<f.ymn&&(f.ymn=b.ymn),b.xstem&&(b.ts_prev.st!=a-1||b.ts_prev.type!=m.NOTE?(w(1,k,"Bad !xstem!"),b.xstem=!1):(b.ts_prev.multi=1,b.multi=1,b.stemless=!0)))}for(;k!=b;k=k.ts_next)if(!k.multi){switch(k.type){default:continue;case m.REST:if(void 0!=k.combine&&0>k.combine||!k.ts_next||
k.ts_next.type!=m.REST||k.ts_next.st!=k.st||k.time!=k.ts_next.time||k.dur!=k.ts_next.dur||k.a_dd&&k.ts_next.a_dd||k.a_gch&&k.ts_next.a_gch||k.invis)break;k.ts_next.a_dd&&(k.a_dd=k.ts_next.a_dd);k.ts_next.a_gch&&(k.a_gch=k.ts_next.a_gch);1!=k.p_v.scale&&k.ts_next.p_v.scale>k.p_v.scale?Na(k):Na(k.ts_next);if(!(k.ts_prev.dur&&k.ts_prev.time==k.time&&k.ts_prev.st==k.st||k.ts_next.time==k.time&&k.ts_next.st==k.st))continue;case m.NOTE:case m.GRACE:}a=k.st;c=k.v;d=g[c];e=h[a];if(d&&0<=d.st2)a==d.st1?k.multi=
-1:a==d.st2&&(k.multi=1);else if(1>=e.length)k.floating&&(k.multi=a==C[c].st?-1:1);else{d=l.voices[c].range;for(c=e.length;0<=--c&&e[c].v!=d;);0>c||(c==e.length-1?k.multi=-1:(k.multi=1,c&&c+2==e.length&&(e[c].ymn-k.fmt.stemheight>=e[c+1].ymx&&(k.multi=-1),a=k.ts_next,k.ts_prev&&k.ts_prev.time==k.time&&k.ts_prev.st==k.st&&k.notes[k.nhd].pit==k.ts_prev.notes[0].pit&&k.beam_st&&k.beam_end&&(!a||a.st!=k.st||a.time!=k.time)&&(k.multi=-1))))}}for(;k&&k.type==m.BAR;)k=k.ts_next}};Abc.prototype.set_stems=
function(){var a,b,c,d;for(a=M;a;a=a.ts_next)if(a.type!=m.NOTE){if(a.type==m.GRACE){var e=d=a.mid;for(b=a.extra;b;b=b.next){var f=15;1<b.nflags&&(f+=1.2*(b.nflags-1));var g=3*(b.notes[0].pit-18);var h=3*(b.notes[b.nhd].pit-18);0<=a.stem?(b.y=g,b.ys=h+f,h=Math.round(b.ys)):(b.y=h,b.ys=g-f,g=Math.round(b.ys));h+=4;g-=4;g<e?e=g:h>d&&(d=h);b.ymx=h;b.ymn=g}a.ymx=d;a.ymn=e}}else{ae(a);b=a.nflags;if(a.beam_st&&!a.beam_end){a.feathered_beam&&(b=++a.nflags);for(f=a.next;f.type!=m.NOTE||(a.feathered_beam&&
f.nflags++,!f.beam_end);f=f.next);f.nflags>b&&(b=f.nflags)}else if(!a.beam_st&&a.beam_end){for(f=a.prev;!f.beam_st;f=f.prev);f.nflags>b&&(b=f.nflags)}f=a.fmt.stemheight;switch(b){case 3:f+=4;break;case 4:f+=8;break;case 5:f+=12}1!=(c=a.p_v.scale)&&(f*=.5*(c+1));g=3*(a.notes[0].pit-18);0<a.nhd?(f-=2,h=3*(a.notes[a.nhd].pit-18)):h=g;a.ntrem&&(f+=2*a.ntrem);null!=a.decstm&&(0>=b?f<a.decstm+6&&(f=a.decstm+6):(e=4*b,a.beam_st&a.beam_end&&(e+=2),f<a.decstm+4+e&&(f=a.decstm+4+e)));a.stemless?(0<=a.stem?
(a.y=g,a.ys=h):(a.ys=g,a.y=h),a.ymx=h+4,a.ymn=g-4):0<=a.stem?(26<a.notes[a.nhd].pit&&(0>=b||!a.beam_st||!a.beam_end)&&(f-=2,28<a.notes[a.nhd].pit&&(f-=2)),a.y=g,a.notes[0].tie&&(g-=3),a.ymn=g-4,a.ys=h+f,a.ys<a.mid&&(a.ys=a.mid),a.ymx=a.ys+2.5|0):(18>a.notes[0].pit&&(0>=b||!a.beam_st||!a.beam_end)&&(f-=2,16>a.notes[0].pit&&(f-=2)),a.ys=g-f,a.ys>a.mid&&(a.ys=a.mid),a.ymn=a.ys-2.5|0,a.y=h,a.notes[a.nhd].tie&&(h+=3),a.ymx=h+4)}};var Yc=[];Abc.prototype.block_gen=function(a){switch(a.subtype){case "leftmargin":case "rightmargin":case "pagescale":case "pagewidth":case "scale":case "staffwidth":U.set_format(a.subtype,
a.param);break;case "mc_start":if(da){w(1,a,"No end of the previous %%multicol");break}da={state:r.state,posy:wa,maxy:wa,lm:p.leftmargin,rm:p.rightmargin,w:p.pagewidth,sc:p.scale};break;case "mc_new":if(!da||da.state!=r.state){w(1,a,"%%multicol new without start");break}wa>da.maxy&&(da.maxy=wa);p.leftmargin=da.lm;p.rightmargin=da.rm;p.pagewidth=da.w;p.scale=da.sc;wa=da.posy;ba.chg=1;break;case "mc_end":if(!da||da.state!=r.state){w(1,a,"%%multicol end without start");break}wa<da.maxy&&(wa=da.maxy);
p.leftmargin=da.lm;p.rightmargin=da.rm;p.pagewidth=da.w;p.scale=da.sc;da=void 0;nb();ba.chg=1;break;case "ml":nb();u.img_out(a.text);break;case "newpage":if(!u.page_format)break;nb();0>Ta&&u.img_out("</div>");Ta=2;break;case "sep":lb();ra(a.sk1);D+='<path class="stroke"\n\td="M';$a((ba.width-a.l)/2-ba.lm," ",0);D+="h"+a.l.toFixed(1)+'"/>\n';ra(a.sk2);break;case "text":T(a.font);bb(a.font);td(a.text,a.opt);break;case "title":sd(a.text,!0);break;case "vskip":ra(a.sk)}};Abc.prototype.set_sym_glue=function(a){for(var b,
c,d,e=4,f=0,g=0,h=0,k=0,l=!va||va.type==m.BLOCK&&!va.play||Yc.length,n=M,q=0;n;n=n.ts_next)n.type!=m.GRACE||c||(c=n),n.seqst&&(f+=n.shrink,f>a&&(p.singleline?a=f:w(1,n,"Line too much shrunk $1 $2 $3",f.toFixed(1),g.toFixed(1),a.toFixed(1))),n.space?n.space<n.shrink?(k+=n.shrink,g+=n.shrink):(g+=n.space,q+=n.shrink):h+=n.shrink);if(g){n=M;l?(g-q+h)/a>1-n.fmt.stretchlast&&(d=1):n.fmt.stretchstaff&&(d=1);if(f>=a){for(b=0;n;n=n.ts_next)n.seqst&&(b+=n.shrink),n.x=b;Zc=.65}else{d?(g==k&&(g+=10),f=(a-h-
k)/(g-k)):(f=Zc,l&&f<n.fmt.stretchlast?f=n.fmt.stretchlast:l||(f=1-.75*p.maxshrink),f>(a-h)/g&&(f=(a-h)/g));for(;0<=--e;){b=k=g=0;for(n=M;n;n=n.ts_next)n.seqst&&(n.space?n.space*f<=n.shrink?(k+=n.shrink,g+=n.shrink,b+=n.shrink):(g+=n.space,b+=n.space*f):b+=n.shrink),n.x=b;if(!d&&b<a)break;if(.1>Math.abs(b-a))break;g==k&&(g+=10);f=(a-h-k)/(g-k)}Zc=f}la=b;for(n=c;n;n=n.ts_next)if(n.type==m.GRACE)for(b=n.gr_shift?n.prev.x+n.prev.wr:n.x-n.wl,a=n.extra;a;a=a.next)a.x+=b}else la=0};Abc.prototype.output_music=
function(){var a,b,c=C.length,d,e=C.length,f=K,g=f.nstaff;for(Wc=0<=p.writefields.indexOf("M");;){f=f.next;if(!f)break;f.nstaff>g&&(g=f.nstaff)}V=g;for(var h,k=M;k.ts_next;)k=k.ts_next;k.type!=m.BAR&&(h=bd(k),h.ts_prev=k,k.next=k.ts_next=h);for(d=0;d<e;d++){var l=C[d];Kf(l);l.ckey=l.key;for(var n=void 0,q=void 0,r=l.sym;r;)if(r.type!=m.BAR||!r.rbstart||r.norepbra)r=r.next;else for(n=0,q=null,r=r.next;r;r=r.next)if(r.type==m.BAR){if(r.rbstop)break;if(!r.next){r.rbstop=2;break}n++;n==r.fmt.rbmin&&(q=
r);if(n==r.fmt.rbmax){q&&(r=q);r.rbstop=1;break}}}if(1<e){var u,t,v;for(u=0;u<C.length;u++){var F=C[u];var B=!1;var E=F.st;for(t=F.sym;t;t=t.next){if(!t.floating){for(;t&&!t.floating;)t=t.next;if(!t)break;B=!1}if(t.dur)if(19<=t.notes[0].pit)B=!1;else if(12>=t.notes[t.nhd].pit)B=!0,t.st++;else{var G=127;for(v=t.ts_prev;v&&v.st==E&&v.v!=t.v;v=v.ts_prev)v.type==m.NOTE&&v.notes[0].pit<G&&(G=v.notes[0].pit);if(127==G)B&&t.st++;else if(t.notes[t.nhd].pit>G-3)B=!1;else{var H=-127;for(v=t.ts_next;v&&v.st==
E+1&&v.v!=t.v;v=v.ts_next)v.type==m.NOTE&&v.notes[v.nhd].pit>H&&(H=v.notes[v.nhd].pit);if(-127==H)B&&t.st++;else{if(t.notes[0].pit<H+3)B=!0;else if(G-=t.notes[t.nhd].pit,H=t.notes[0].pit-H,!B){if(G<H+3)continue;B=!0}else if(G<H-3){B=!1;continue}t.st++}}}else B&&t.st++}}if(oa.mrest_p){var L;for(L=M;L;L=L.ts_next)if(L.type==m.MREST){if(!L.seqst&&Sa[L.ts_prev.type])var R=L;else for(R=L.ts_next;!R.seqst&&R.type==m.MREST&&R.nmes==L.nmes;)R=R.ts_next;if(R.seqst)L=R.ts_prev;else for(;L.type==m.MREST;){for(var ea,
Y,Q,X,ha,T=L,ma=T.nmes,na=T.dur/ma,ka=T.next;ka&&!ka.bar_type;)ka=ka.next;if(ka){for(ha=ka;!ka.bar_num;)ka=ka.ts_prev;ea=ka.bar_num-T.nmes;T.type=m.REST;T.notes[0].dur=T.dur=T.dur_orig=na;T.nflags=-2;T.head=m.FULL;T.fmr=1;Y=T.time+na;for(X=T;0<--ma;){ka=y(ha);delete ka.soln;delete ka.a_gch;delete ka.a_dd;delete ka.text;delete ka.rbstart;delete ka.rbstop;Uc(ka,T.next);for(ka.time=Y;X.time<Y;)X=X.ts_next;if(X.time==Y)for(;!X.bar_type&&X.ts_next&&X.ts_next.time==Y;)X=X.ts_next;for(;X&&X.v<T.v&&X.type==
m.BAR;)X=X.ts_next;if(X)X.bar_type&&(X.seqst=0),ic(ka,X),X.type==m.BAR&&delete X.bar_num;else{for(X=T;X.ts_next;)X=X.ts_next;X.ts_next=ka;ka.ts_prev=X;ka.ts_next=null}ea++;ka.seqst?(ka.bar_num=ea,Q=ka.ts_next):(delete ka.bar_num,Q=ka.ts_prev);ka.bar_type=Q.bar_type||"|";Q.bar_num&&!Q.seqst&&delete Q.bar_num;Q=y(T);delete Q.a_dd;delete Q.soln;delete Q.a_gch;delete Q.part;ka.next?(Q.next=ka.next,Q.next.prev=Q):Q.next=null;ka.next=Q;Q.prev=ka;for(Q.time=Y;X&&!X.dur&&X.time==Y;)X=X.ts_next;for(;X&&X.v<
T.v&&(!(X=X.ts_next)||!X.seqst););if(X)X.dur&&(X.seqst=0),ic(Q,X);else{for(X=T;X.ts_next;)X=X.ts_next;X.ts_next=Q;Q.ts_prev=X;Q.ts_next=null}Y+=na;T=X=Q}}else w(1,T,"Lack of bar after multi-measure rest");L=L.ts_next}}}}oa.ottava&&"play"!=p.sound&&Hf();var ia,ca,ta,Z,fa=Array(V+1),da=K,Ka=[];x=Array(V+1);for(ca=0;ca<=V;ca++)fa[ca]={autoclef:!0},x[ca]={output:"",sc_out:""};for(ca=0;ca<=da.nstaff;ca++)Ka[ca]=3*(da.staves[ca].stafflines.length-1);for(ia=M;ia;ia=ia.ts_next){ia.repeat_n&&Gf(ia);switch(ia.type){case m.STAVES:da=
ia.sy;for(ca=0;ca<=V;ca++)fa[ca].autoclef=!0;for(ta=0;ta<C.length;ta++)if(da.voices[ta]){var ja=C[ta];ca=da.voices[ta].st;da.voices[ta].second||(da.staves[ca].staffnonote=ja.staffnonote,ja.staffscale&&(da.staves[ca].staffscale=ja.staffscale),da.voices[ta].sep&&(da.staves[ca].sep=da.voices[ta].sep),da.voices[ta].maxsep&&(da.staves[ca].maxsep=da.voices[ta].maxsep));var pa=ja.clef;pa.clef_auto||(fa[ca].autoclef=!1)}for(ca=0;ca<=da.nstaff;ca++)Ka[ca]=3*(da.staves[ca].stafflines.length-1);for(ta=0;ta<
C.length;ta++)if(da.voices[ta]&&!da.voices[ta].second){ja=C[ta];ca=da.voices[ta].st;pa=ja.clef;if(pa.clef_auto){var Ca=ke(ca,ia,fa[ca].clef?fa[ca].clef.clef_type:"a");var Ia="t"==Ca?2:4;Jc(ja.clef)}else Ca=pa.clef_type,Ia=pa.clef_line;if(!fa[ca].clef)pa.clef_auto&&("a"!=pa.clef_type&&(ja.clef=y(ja.clef)),ja.clef.clef_type=Ca,ja.clef.clef_line=Ia,Jc(ja.clef)),x[ca].clef=fa[ca].clef=ja.clef;else if(Ca!=fa[ca].clef.clef_type||Ia!=fa[ca].clef.clef_line){for(Z=ia.ts_prev;Z&&Z.time==ia.time&&(Z.v!=ta||
Z.st!=ca);)Z=Z.ts_prev;if(!Z||Z.time!=ia.time){for(Z=ia.ts_next;Z&&(Z.v!=ta||Z.st!=ca);)Z=Z.ts_next;Z&&Z.time==ia.time||(Z=ia)}Z.type!=m.CLEF&&(Z=ce(Z,Ca,Ia),pa.clef_auto&&(Z.clef_auto=!0));fa[ca].clef=ja.clef=Z}}continue;default:ia.mid=Ka[ia.st];continue;case m.CLEF:}"a"==ia.clef_type&&(ia.clef_type=ke(ia.st,ia.ts_next,fa[ia.st].clef.clef_type),ia.clef_line="t"==ia.clef_type?2:4,Jc(ia));ja=ia.p_v;ja.clef=ia;ca=ia.st;if(fa[ca].clef){if(ia.clef_type==fa[ca].clef.clef_type&&ia.clef_line==fa[ca].clef.clef_line)continue}else x[ca].clef=
ia;fa[ca].clef=ia}da=K;for(ta=0;ta<C.length;ta++)if(da.voices[ta]&&(pa=C[ta].sym)&&127==pa.notes[0].pit){ca=da.voices[ta].st;switch(x[ca].clef.clef_type){default:var Qa=22;break;case "c":Qa=16;break;case "b":Qa=10}for(ia=pa;ia;ia=ia.next)ia.notes[0].pit=Qa}U.set_pitch(null);1<c&&U.set_stem_dir();for(a=0;a<c;a++){var La,Ma=void 0,Ta=void 0,aa,Na=-1;for(aa=C[a].sym;aa;aa=aa.next)if(aa.type!=m.NOTE){if(aa.type==m.GRACE){var qa=aa.extra;if(2==qa.stem)Ma=aa;else for(aa.stem||(aa.stem=aa.multi||1);qa;qa=
qa.next)qa.stem=aa.stem,qa.multi=aa.multi}}else{!aa.stem&&aa.multi&&(aa.stem=aa.multi);if(aa.stem)aa.beam_st&&!aa.beam_end&&(Ta=!0);else{var Da=aa.mid/3+18;if(Ta)aa.stem=Na;else if(aa.beam_st&&!aa.beam_end){Ta=!0;var Ya=aa.notes[aa.nhd].pit;var $a=aa.notes[0].pit;for(qa=aa.next;qa;qa=qa.next)if(qa.type==m.NOTE){if(qa.stem||qa.multi)aa.stem=qa.stem||qa.multi;qa.notes[qa.nhd].pit>Ya&&(Ya=qa.notes[qa.nhd].pit);qa.notes[0].pit<$a&&($a=qa.notes[0].pit);if(qa.beam_end)break}!aa.stem&&qa.beam_end&&(Ya+$a<
2*Da?aa.stem=1:Ya+$a>2*Da?aa.stem=-1:aa.fmt.bstemdown&&(aa.stem=-1));aa.stem||(aa.stem=Na)}else{var ab=(aa.notes[aa.nhd].pit+aa.notes[0].pit)/2;if(ab==Da&&1<aa.nhd){for(La=0;La<aa.nhd&&!(aa.notes[La].pit>=Da);La++);ab=2*La<aa.nhd?Da-1:Da+1}aa.stem=ab<Da?1:ab>Da||aa.fmt.bstemdown?-1:Na}}aa.beam_end&&(Ta=!1);Na=aa.stem;if(Ma){for(qa=Ma.extra;qa;qa=qa.next)qa.stem=-Na;Ma.stem=-Na;Ma=null}}}U.set_stems();var cb,ob,Xa,gb;for(cb=M;cb;)if(cb.type!=m.NOTE||cb.invis)cb=cb.ts_next;else{var Bb=cb.st;var Ib=
cb.time;var zb=!1;for(ob=cb;ob&&ob.time==Ib&&ob.type==m.NOTE&&ob.st==Bb;ob=ob.ts_next)for(Xa=0;Xa<=ob.nhd;Xa++)ob.notes[Xa].acc&&(ob.notes[Xa].s=ob,zb=!0);if(zb){for(gb=[];cb!=ob;cb=cb.ts_next)cb.invis||Array.prototype.push.apply(gb,cb.notes);gb.sort(abc2svg.pitcmp);be(gb)}else cb=ob}if(1<c){If();var Ea,P,Mb,N,ac,Fa,bb,Va;for(Ea=M;Ea;Ea=Ea.ts_next)if(Ea.type==m.NOTE&&!Ea.invis){Ea.second&&(Ea.dot_low=1);if(Ea.xstem&&0>Ea.ts_prev.stem)for(Fa=0;Fa<=Ea.nhd;Fa++)Ea.notes[Fa].shhd-=7,Ea.notes[Fa].shac+=
16;for(P=Ea;;){P=P.ts_next;if(!P)break;if(P.time!=Ea.time){P=null;break}if(P.type==m.NOTE&&!P.invis&&P.st==Ea.st)break}if(P){var S=Ea;if(!(S.ymn>P.ymx||S.ymx<P.ymn||Mf(S,P)))if(S.dots||P.dots||!(0<S.stem&&0>P.stem&&S.notes[0].pit==P.notes[P.nhd].pit+1||0>S.stem&&0<P.stem&&S.notes[S.nhd].pit+1==P.notes[0].pit)){var Wa=od(S);var wb=nd(P);if((Mb=S.ts_prev)&&Mb.time==S.time&&Mb.st==S.st&&Mb.type==m.NOTE&&!Mb.invis){var ib=od(Mb);for(N=0;96>N;N++)ib[N]>Wa[N]&&(Wa[N]=ib[N])}else Mb=null;var Ja=-10;for(N=
0;96>N;N++)wb[N]+Wa[N]>Ja&&(Ja=wb[N]+Wa[N]);if(!(-3>Ja&&(P.notes[0].pit&1||!S.dots&&!P.dots||!(S.notes[S.nhd].pit==P.notes[0].pit+2&&S.dot_low||S.notes[S.nhd].pit+2==P.notes[0].pit&&P.dot_low)))){var jb=od(P);var kb=nd(S);if(Mb)for(ib=nd(Mb),N=0;96>N;N++)ib[N]>kb[N]&&(kb[N]=ib[N]);var xa=bb=Va=-100;for(N=0;96>N;N++)kb[N]+jb[N]>xa&&(xa=kb[N]+jb[N]),jb[N]>Va&&(Va=jb[N]),Wa[N]>bb&&(bb=Wa[N]);var mb=0;var Oa=S.nhd;for(ac=P.nhd;;){var Db=S.notes[Oa].pit-P.notes[ac].pit;switch(Db){case 2:S.notes[Oa].pit&
1||(S.dot_low=!1);break;case 1:S.notes[Oa].pit&1?P.dot_low=!0:S.dot_low=!1;break;case 0:if(S.notes[Oa].acc!=P.notes[ac].acc){mb=-1;break}P.notes[ac].acc&&(S.notes[Oa].acc||(S.notes[Oa].acc=P.notes[ac].acc),P.notes[ac].acc=0);S.dots&&P.dots&&S.notes[Oa].pit&1&&(mb=1);break;case -1:S.notes[Oa].pit&1?P.dot_low=!1:S.dot_low=!0;break;case -2:S.notes[Oa].pit&1||(P.dot_low=!1)}if(0>mb)break;if(0<=Db&&0>--Oa)break;if(0>=Db&&0>--ac)break}if(0>mb){var qb=void 0,rb=void 0,hb=void 0,db=S,sb=P,pb=Oa;if(qb=sb.notes[ac].acc){rb=
2*Xc[db.head]+db.xmx+sb.notes[ac].shac+2;"object"==typeof qb&&(rb+=2);db.dots&&(rb+=6);for(hb=0;hb<=sb.nhd;hb++)sb.notes[hb].shhd+=rb,sb.notes[hb].shac-=rb;sb.xmx+=rb;db.notes[pb].acc&&(db.notes[pb].shac-=7)}else{rb=2*Xc[sb.head]+sb.xmx+db.notes[pb].shac+2;qb=db.notes[pb].acc;"object"==typeof qb&&(rb+=2);sb.dots&&(rb+=6);for(hb=0;hb<=db.nhd;hb++)db.notes[hb].shhd+=rb,db.notes[hb].shac-=rb;db.xmx+=rb}}else{var Ab=0;S.dots?P.dots&&mb||(Ab=1):P.dots&&xa+bb<Ja+Va&&(Ab=1);var zc=wb;var Ac=jb;!Mb&&xa+bb<
Ja+Va&&(S=P,P=Ea,Ja=xa,zc=kb,Ac=Wa,Va=bb);Ja+=3;0>Ja&&(Ja=0);Fa=0<=S.stem?0:S.nhd;Ja+=S.notes[Fa].shhd;Fa=0<=P.stem?0:P.nhd;Ja-=P.notes[Fa].shhd;if(S.dots){var Kb=7.7+S.xmx+3.5*S.dots-3.5+3;if(!Ab){xa=-100;for(Oa=0;Oa<=S.nhd;Oa++)N=S.notes[Oa].pit,N&1||(S.dot_low?N--:N++),N*=2,1>N?N=1:95<=N&&(N=94),zc[N]>xa&&(xa=zc[N]),zc[N-1]+1>xa&&(xa=zc[N-1]+1),zc[N+1]+1>xa&&(xa=zc[N+1]+1);Kb+xa+2>Ja&&(Ja=Kb+xa+2)}else if(Kb<Ja+Va+P.xmx){for(Oa=xa=0;Oa<=S.nhd;Oa++)N=S.notes[Oa].pit,N&1||(S.dot_low?N--:N++),N*=
2,1>N?N=1:95<=N&&(N=94),Ac[N]>xa&&(xa=Ac[N]),Ac[N-1]+1>xa&&(xa=Ac[N-1]=1),Ac[N+1]+1>xa&&(xa=Ac[N+1]+1);4.5<xa&&7.7+S.xmx+2<Ja+xa+P.xmx&&(P.xmx=xa+3-7.7)}}for(Fa=P.nhd;0<=Fa;Fa--)P.notes[Fa].shhd+=Ja;P.xmx+=Ja;Ab&&(S.xmx=P.xmx)}}}else{0>S.stem&&(S=P,P=Ea);Ja=S.notes[0].shhd+7;for(Fa=0;Fa<=P.nhd;Fa++)P.notes[Fa].shhd+=Ja;P.xmx+=Ja;S.xmx=P.xmx}}}}he(1);le();if(M){var Bc=Lf();if(p.singleline){a=ie();var Cc=Bc[0]+a[0]+a[1]+je(M,null)[0];a=2==p.singleline?Jb():Cc;a>Cc?Cc=a:ba.width=Cc*p.scale+ba.lm+ba.rm+
2}else{var Cb=Cc=Jb(),Ga,Lb,gc=p.leftmargin,jc=p.rightmargin,nc=p.pagewidth,pc=p.scale,Eb=Bc[1]-Bc[2],Nb=ie(),za=M;Cb-=Bc[2];p.indent&&p.indent>Bc[1]&&(Eb+=p.indent);Cb-=Nb[0];Eb+=Nb[1];if(Lb=za.fmt.barsperstaff)for(Ga=za;Ga;Ga=Ga.ts_next)if(Ga.type==m.BAR&&Ga.bar_num&&!(0<--Lb)){for(;Ga.ts_next&&Ga.ts_next.type==m.BAR;)Ga=Ga.ts_next;Ga.ts_next&&(Ga.ts_next.soln=!0);Lb=za.fmt.barsperstaff}for(Ga=za;za;za=za.ts_next){if(za.type==m.BLOCK)switch(za.subtype){case "leftmargin":case "rightmargin":case "pagescale":case "pagewidth":case "scale":case "staffwidth":za.soln||
U.set_format(za.subtype,za.param);break;case "mc_start":var Ob={lm:p.leftmargin,rm:p.rightmargin};break;case "mc_new":case "mc_end":Ob&&(p.leftmargin=Ob.lm,p.rightmargin=Ob.rm,ba.chg=1)}if(za.ts_next)if(za.soln){za.soln=!1;if(za.time==Ga.time)continue;for(;!za.seqst;)za=za.ts_prev}else continue;else za=null;lb();Cb=Jb()-Bc[1]-Nb[0];a:{var Mc=void 0,xb=void 0,Dc=void 0,bc=void 0,yb=void 0,Fb=void 0,Rb=void 0,Sb=void 0,Aa=void 0,Tb=void 0,kc=void 0,J=Ga,Ba=za,Xb=Cb,qc=Eb,dc=Ba?Ba.ts_prev:null,Nc=je(J,
Ba);J.fmt.keywarn&&Ba&&Ba.type==m.KEY&&!dc.dur&&(Nc[0]+=Ba.wr,Nc[1]+=Ba.wr);if(Nc[1]+qc<Xb)Ba&&(Ba=Vc(Ba)),Ga=Ba||dc;else{for(xb=Nc[0]+qc;;){Mc=Math.ceil(xb/Xb);if(1>=Mc){Ba&&(Ba=Vc(Ba));Ga=Ba||dc;break a}Tb=kc=J;yb=J.x;Dc=yb+Xb;bc=yb+xb/Mc;yb+=xb/Mc*J.fmt.breaklimit;for(J=J.ts_next;J!=Ba&&!(J.x&&(J.type==m.BAR&&(Tb=J),J.x>=yb));J=J.ts_next);Sb=J;if(J==Ba){J&&(J=Vc(J));break}if(J.x>Dc&&J.prev.a_ly){for(Aa=J=J.prev;!Aa.seqst;)Aa=Aa.ts_prev;var ya=J,xc=Dc-Aa.x,Pa=y(ya),Qb=ya.a_ly[0].t,tc=0,Pc=0;for(A.deffont=
ya.a_ly[0].font;;){var ec=Qb.indexOf(" ",Pc)+1;if(0>=ec)break;var Gc=ua(Qb.slice(Pc,ec));tc+=Gc[0];if(tc>xc)break;Pc=ec}ya.a_ly[0].t=new String(Qb.slice(0,Pc-1));Pa.a_ly=y(ya.a_ly);Pa.a_ly[0]=y(ya.a_ly[0]);Pa.a_ly[0].t=new String(Qb.slice(Pc));abc2svg.el?(ua(ya.a_ly[0].t),ua(Pa.a_ly[0].t)):(ya.a_ly[0].t.wh=ua(ya.a_ly[0].t),Pa.a_ly[0].t.wh=ua(Pa.a_ly[0].t));tc=ya.a_ly[0].t.wh[0];ya.wr=xc;Pa.wr-=tc;Uc(Pa,Pa.next);Pa.time+=.1;for(Pa.nl=0;!ya.seqst;)ya=ya.ts_prev;Pa.x=ya.x+tc;Pa.shrink=tc-Pa.wl;for(ya=
Pa.ts_next;ya;){if(ya.seqst){ya.wl-=tc;ya.shrink-=tc;break}ya=ya.ts_next}ic(Pa,Pa.ts_next)}else{for(Aa=null;J!=Ba;J=J.ts_next)if(Fb=J.x){if(Fb>Dc)break;if(J.type==m.BAR)if(Fb<bc)Aa=J;else{if(!Aa||Fb-bc<bc-Aa.x)Aa=J;break}}if(!Aa){J=Sb;var fc=0,Hc=Tb.time;Dc-=8;for(Rb=J;J!=Ba;J=J.ts_next){if(J.seqst){Fb=J.x;if(Fb+J.wr>=Dc)break;fc||J.in_tuplet||!(bc-Rb.x>Fb-bc||0==(J.time-Hc)%(m.BLEN/4))||(Aa=J)}J.beam_st&&(fc|=1<<J.v);J.beam_end&&(fc&=~(1<<J.v));Rb=J}if(Aa){do Aa=Aa.ts_prev;while(!Aa.seqst)}}if(!Aa)for(Aa=
J=Sb;J!=Ba;J=J.ts_next)if(Fb=J.x){if(Fb+J.wr>=Dc)break;if(Aa&&Fb>=bc){bc-Aa.x>Fb-bc&&(Aa=J);break}Aa=J}J=Aa}for(;J.ts_next&&(J=J.ts_next,!J.seqst););if(J.nl)for(w(0,J,"Line split problem - adjust maxshrink and/or breaklimit"),Mc=2,J=J.ts_next;J!=Ba&&!(J.x&&0>=--Mc);J=J.ts_next);J=Vc(J);if(!J||Ba&&J.time>=Ba.time)break;xb-=J.x-kc.x}Ga=J}}if(!Ga)break;za=Ga.type==m.BLOCK?Ga.ts_prev:za;Eb=0}p.leftmargin=gc;p.rightmargin=jc;p.pagewidth=nc;p.scale=pc;ba.chg=1;lb()}var hc=M;for(a=c;0<=--a;)C[a].osym=C[a].sym;
var Ic=hc.p_v.meter;for(Zc=.65;;){Nf();var Ub,Kc=Bc,Vb=0,lc=va?va.fmt:p;if(lc.systvoices)for(Ub=C.length;0<=--Ub;){var Wb=C[Ub];if(K.voices[Ub]&&A.st_print[Wb.st]){if(Wb.nm&&(1==lc.systvoices||Wb.new_name&&3==lc.systvoices)){Vb=1;break}Wb.snm&&(Vb=2)}}A.vnt=Vb;var cc=Kc[Vb];!b&&p.indent&&cc<p.indent&&(cc=p.indent);U.set_sym_glue(Cc-cc);if(la){ba.wx<la&&(ba.wx=la);cc&&(ba.wx+=cc,wc+=cc);mf();if(b=qf()){rf(cc);var Ua=void 0,Qc=void 0,Rc=void 0,Za=void 0,W=void 0,mc=void 0,Yb=void 0,Sc=void 0,Lc=C.length;
for(Yb=0;Yb<Lc;Yb++)if(Sc=C[Yb],Sc.sym&&void 0!=Sc.sym.x){U.draw_symbols(Sc);var tb=void 0,eb=void 0,ub=void 0,rc=void 0,Tc=void 0,Ha=void 0,Gb=void 0,sc=0;Ha=Sc.sym;for(fb(Ha.color);Ha;Ha=Ha.next){if(Ha.ti2&&!Ha.invis&&Ha.time!=sc)for(ub=0;ub<=Ha.nhd;ub++)tb=Ha.notes[ub],(eb=tb.tie_s)&&eb.s.v==Ha.v&&yc(eb,tb,1);if(Ha.ti1&&!Ha.invis)if(Ha.type==m.GRACE)for(Gb=Ha.extra;Gb;Gb=Gb.next)for(ub=0;ub<=Ha.nhd;ub++){if(eb=Gb.notes[ub],tb=eb.tie_e)yc(eb,tb),sc=tb.s.time}else for(ub=0;ub<=Ha.nhd;ub++)if(eb=
Ha.notes[ub],tb=eb.tie_e)if(Tc=tb.s,va&&Tc.time>=va.time)yc(eb,tb,2);else{sc=Tc.time;for(Gb=Ha.ts_next;Gb!=Tc;Gb=Gb.ts_next)if(Gb.st==Ha.st&&Gb.type==m.CLEF){rc=!0;break}rc||Ha.st!=Tc.st?(yc(eb,tb,2),yc(eb,tb,3),rc=!1):yc(eb,tb)}else eb.tie_ty&&yc(eb,eb,2)}fb()}U.draw_all_deco();oc();for(var uc=void 0;;){uc=$b.shift();if(!uc)break;switch(uc.type){case m.CLEF:case m.METER:case m.KEY:case m.REST:if(uc.type!=m.REST||uc.rep_nb){Ra(uc.st);break}case m.GRACE:case m.NOTE:case m.MREST:Zb(uc)}Pb(uc)}Ra(-1);
if(A.a_sl)for(;;){Ua=A.a_sl.shift();if(!Ua)break;mc=Ua[3].indexOf('d="M')+4;D+=Ua[3].slice(0,mc);W=new Float32Array(Ua[3].slice(mc).match(/[\d.-]+/g));W[1]-=x[Ua[0].st].y;Qc=Ua[0].fmt.sysstaffsep+24;Rc=x[Ua[1].st].y-x[Ua[0].st].y;switch(Ua[2]){case "//":case "\\\\":Za=-(Ua[1].prev.prev.y+x[Ua[0].st].y+Ua[1].prev.next.y+x[Ua[1].st].y)-2*(W[1]-wa);W[5]=Za-W[5];W[7]=Za-W[7];8<W.length&&(Za="/"==Ua[2][0]?3:-3,W[8]=-W[8],W[10]=-W[3]+Za,W[12]=-W[5]+Za,W[14]=-W[7]);break;case "/\\":case "\\/":Za="/"==Ua[2][0]?
Rc-Qc-10:Rc+Qc+10;W[3]+=Za;W[5]+=Za;8<W.length&&(W[10]+=Za,W[12]+=Za);break;default:Za="/"==Ua[2][0]?Rc-Qc:-Rc-Qc,W[5]+=Za,W[7]+=Za,8<W.length&&(W[12]-=Za,W[14]-=Za)}D+=W[0].toFixed(1)+" "+W[1].toFixed(1)+"c"+W[2].toFixed(1)+" "+W[3].toFixed(1)+" "+W[4].toFixed(1)+" "+W[5].toFixed(1)+" "+W[6].toFixed(1)+" "+W[7].toFixed(1);8<W.length&&(D+="v"+W[8].toFixed(1)+"c"+W[9].toFixed(1)+" "+W[10].toFixed(1)+" "+W[11].toFixed(1)+" "+W[12].toFixed(1)+" "+W[13].toFixed(1)+" "+W[14].toFixed(1));D+='"/>\n'}var Hb;
for(Hb=0;Hb<=V;Hb++)x[Hb].sc_out&&(D+="<g "+x[Hb].scale_str+">\n"+x[Hb].sc_out+"</g>\n",x[Hb].sc_out=""),x[Hb].output&&(D+='<g transform="translate(0,'+(-x[Hb].y).toFixed(1)+')">\n'+x[Hb].output+"</g>\n",x[Hb].output="");ra(b)}cc&&(wc-=cc)}for(nb();Yc.length;)U.block_gen(Yc.shift());vc&&(vc.ts_next.ts_prev=vc);if(!va)break;va.ts_prev.ts_next=M=va;le();if(!M)break;var vc=M.ts_prev;M.ts_prev=null;for(var Ec,vb,Fc=C.length;0<=--Fc;)vb=C[Fc],vb.sym&&vb.s_prev&&(vb.sym.prev=vb.s_prev,vb.s_prev.next=vb.sym),
Ec=vb.s_next,vb.s_next=null,(vb.sym=Ec)?(Ec.prev&&(Ec.prev.next=Ec),vb.s_prev=Ec.prev,Ec.prev=null):vb.s_prev=null;Cc=Jb()}M=hc;for(a=c;0<=--a;){var Oc=C[a];Oc.sym&&Oc.s_prev&&(Oc.sym.prev=Oc.s_prev);Oc.sym=Oc.osym}hc.p_v.meter=Ic}};var Ia,ma=[],da,Lb={},Rf=new Int8Array([0,1,3,2,3,0,2,0,3,0]),qb="CDEFGABcdefgab";Abc.prototype.set_vp=function(a){for(var b,c,d,e,f,g=0;;){c=a.shift();if(!c)break;if("="==c.slice(-1)&&!a.length){v(1,G.bad_val,c);break}switch(c){case "clef=":b=a.shift();break;case "clefpitch=":if(c=
a.shift())if(e=qb.indexOf(c[0]),0<=e){switch(c[1]){case "'":e+=7;break;case ",":e-=7,","==c[2]&&(e-=7)}f=4-e;break}v(1,G.bad_val,c);break;case "octave=":e=+a.shift();isNaN(e)?v(1,G.bad_val,c):l.octave=e;break;case "cue=":"on"==a.shift()&&(l.scale=.7);break;case "instrument=":c=a.shift();e=c.indexOf("/");if(0>e){e=Db("c"+c);if(void 0==e)break;l.sound=e;g|=2;e=0}else{e=Db("c"+c.slice(e+1));if(void 0==e)break;l.sound=e;g|=2;e=Db(c.replace("/",""));if(void 0==e)break}l.score=p.sound?l.sound:e;g|=1;break;
case "map=":l.map=a.shift();break;case "name=":case "nm=":l.nm=a.shift();'"'==l.nm[0]&&(l.nm=Hc(l.nm.slice(1,-1)));l.new_name=!0;break;case "stem=":case "pos=":c="pos="==c?a.shift().slice(1,-1).split(" "):["stm",a.shift()];e=zd[c[1]];if(void 0==e){v(1,G.bad_val,"%%pos");break}switch(c[2]){case "align":e|=m.SL_ALIGN;break;case "center":e|=m.SL_CENTER;break;case "close":e|=m.SL_CLOSE}d||(d={});d[c[0]]=e;break;case "scale=":e=+a.shift();isNaN(e)||.5>e||2<e?v(1,G.bad_val,"%%voicescale"):l.scale=e;break;
case "score=":if(p.nedo){v(1,G.notransp);break}c=a.shift();if(p.sound)break;e=Db(c,!0);void 0!=e&&(l.score=e,g|=1);break;case "shift=":if(p.nedo){v(1,G.notransp);break}e=Db(a.shift());void 0!=e&&(l.shift=e,g=3);break;case "sound=":if(p.nedo){v(1,G.notransp);break}e=Db(a.shift());if(void 0==e)break;l.sound=e;p.sound&&(l.score=e);g|=2;break;case "subname=":case "sname=":case "snm=":l.snm=a.shift();'"'==l.snm[0]&&(l.snm=l.snm.slice(1,-1));break;case "stafflines=":e=Of(a.shift());if(void 0==e){v(1,"Bad %%stafflines value");
break}void 0!=l.st&&(H.staves[l.st].stafflines=e);l.stafflines=e;break;case "staffnonote=":e=+a.shift();isNaN(e)?v(1,"Bad %%staffnonote value"):l.staffnonote=e;break;case "staffscale=":e=+a.shift();isNaN(e)||.3>e||2<e?v(1,"Bad %%staffscale value"):l.staffscale=e;break;case "tacet=":e=a.shift();l.tacet=e||void 0;break;case "transpose=":e=Le(a.shift());void 0==e?v(1,G.bad_transp):(l.sound=e,p.sound&&(l.score=e),g=2);break;default:switch(c.slice(0,4)){case "treb":case "bass":case "alto":case "teno":case "perc":b=
c;break;default:0<="GFC".indexOf(c[0])?b=c:"="==c.slice(-1)&&a.shift()}}}if(d)for(c in l.pos=y(l.pos),d)d.hasOwnProperty(c)&&(l.pos[c]=d[c]);b&&(b=me(b))&&(f&&(b.clefpit=f),Ne(b));g&2&&((g=(l.sound|0)+(l.shift|0))?l.tr_snd=abc2svg.b40m(g+122)-36:l.tr_snd&&(l.tr_snd=0),l.tr_snd40=g)};var Wb=/(\d*)(\/*)(\d*)/g;Abc.prototype.new_note=function(a,b){var c=1,d=0,e=[],f=r.line,g=ma;ma=[];r.stemless=!1;var h={type:m.NOTE,fname:r.fname,stem:0,multi:0,nhd:0,xmx:0};h.istart=r.bol+f.index;l.color&&(h.color=l.color);
if(a)h.grace=!0;else{if(l.tie_s){var k=l.tie_s;l.tie_s=null}Ia&&Vb(h);r.repeat_n&&(h.repeat_n=r.repeat_n,h.repeat_k=r.repeat_k,r.repeat_n=0)}var u=f.char();switch(u){case "X":h.invis=!0;case "Z":h.type=m.MREST;u=f.next_char();h.nmes="0"<u&&"9">=u?f.get_int():1;if(1==l.wmeasure){w(1,h,"multi-measure rest, but no measure!");return}h.dur=l.wmeasure*h.nmes;1==h.nmes?(h.type=m.REST,h.dur_orig=h.dur,h.fmr=1,h.notes=[{pit:18,dur:h.dur}]):(oa.mrest_p=!0,1==H.voices.length&&(h.tacet=l.tacet,delete h.invis));
break;case "y":h.type=m.SPACE;h.invis=!0;h.dur=0;u=f.next_char();h.width="0"<=u&&"9">=u?f.get_int():10;k&&(l.tie_s=k,k=null);break;case "x":h.invis=!0;case "z":h.type=m.REST;f.index++;var n=lc(f);h.dur_orig=(0>l.ulen?m.BLEN:l.ulen)*n[0]/n[1];12>h.dur_orig&&(w(0,h,"Bad note duration $1",h.dur_orig),h.dur_orig=12);h.dur=h.dur_orig*l.dur_fact;h.dur==l.wmeasure&&(h.fmr=1);h.notes=[{pit:18,dur:h.dur_orig}];break;case "[":u=f.next_char();var q=f.buffer.indexOf("]",f.index);if(0>q){v(1,"No end of chord");
return}var y=f.index;f.index=q+1;n=lc(f);c=n[0]/n[1];n=Wb.lastIndex;f.index=y;default:if(l.acc_tie){var z=l.acc_tie;l.acc_tie=null}for(h.notes=[];;){if(n)for(;u;){q=u.charCodeAt(0);if(128<=q){v(1,G.not_ascii);return}var t=Da[q];switch(t[0]){case "(":e.push(mc());u=f.char();continue;case "!":1<t.length?ma.push(t.slice(1,-1)):te();u=f.next_char();continue}break}var x=f;t=h.grace?m.BLEN/4:0>l.ulen?m.BLEN:l.ulen;(q=jc(x))?("0"==x.char()&&(r.stemless=!0,x.index++),x=lc(x),q.dur=t*x[0]/x[1],t=q):t=void 0;
if(!t)return;t.dur*=c;12>t.dur&&(w(0,h,"Bad note duration $1",t.dur),t.dur=12);l.octave&&(t.pit+=7*l.octave);x=t.pit+19;q=t.acc;q||(q="p"==p["propagate-accidentals"][0]?l.acc[x%7]:l.acc[x])||(q=l.ckey.k_map[x%7]||0);q&&!l.ckey.k_drum&&("p"==p["propagate-accidentals"][0]?l.acc[x%7]=q:"n"!=p["propagate-accidentals"][0]&&(l.acc[x]=q));z&&z[x]&&(q=z[x]);t.midi||(t.midi=re(x,q));if(l.tr_sco&&(rd(l,t,q,1),!t.notrp)){d=void 0;y=void 0;u=t;"object"==typeof q&&(d=q[0],y=q[1],q=0<d?1:-1);var A=abc2svg.pab40(u.pit,
q)+l.tr_sco;u.pit=abc2svg.b40p(A);A=abc2svg.b40a(A);if(y){switch(A){case -2:d=0<d?d-2*y:d-y;break;case -1:0<d&&(d-=y);break;case 0:case 3:d=0<d?d-y:d+y;break;case 1:0>d&&(d+=y);break;case 2:d=0>d?d+2*y:d+y}u.acc=[d,y]}else-3!=A&&(q&&!A&&(A=3),q=A,u.acc||l.ckey.k_none||(q=0),u.acc=q);q=A;-3==q&&(w(1,h,"triple sharp/flat"),q=0<t.acc?1:-1,t.pit+=q,t.acc=q);d=t.pit+19-x}l.tr_snd&&(t.midi+=l.tr_snd);l.map&&rd(l,t,q);if(q)switch(p["writeout-accidentals"][1]){case "d":u=l.ckey;if(!u.k_a_acc)break;for(y=
0;y<u.k_a_acc.length;y++)if(0==(u.k_a_acc[y].pit-t.pit)%7){t.acc=q;break}break;case "l":t.acc=q}if(e.length)for(;;){q=e.shift();if(!q)break;l.sls.push({ty:q,ss:h,nts:t})}h.notes.push(t);if(!n)break;for(u=f.char();;){switch(u){case ")":se(h,t);u=f.next_char();continue;case "-":t.tie_ty=mc();t.s=h;l.tie_s=h;h.ti1=!0;if(l.acc[x]||z&&z[x])l.acc_tie||(l.acc_tie=[]),q=l.acc[x],z&&z[x]&&(q=z[x]),l.acc_tie[x]=q;u=f.char();continue;case ".":u=f.next_char();switch(u){case "-":case "(":ma.push("dot");continue}v(1,
"Misplaced dot")}break}ma.length&&(h.time=l.time,Fc(h,t));if("]"==u){f.index=n;h.nhd=h.notes.length-1;break}}if(b.length)for(;;){q=b.shift();if(!q)break;l.sls.push({ty:q,ss:h});a&&(l.sls[l.sls.length-1].grace=a)}h.dur_orig=h.notes[0].dur;h.dur=h.notes[0].dur*l.dur_fact}if(h.grace&&h.type!=m.NOTE)v(1,G.bad_grace);else{if(h.notes){if(!h.fmr){y=h.dur_orig/12;for(q=0;!(y&1);)y>>=1,q++;y+1&y&&w(0,h,"Non standard note duration $1",y+"/"+(1<<6-q))}if(a){b=l.ckey.k_bagpipe?8:4;for(q=0;q<=h.nhd;q++)h.notes[q].dur/=
b;h.dur/=b;h.dur_orig/=b;a.stem&&(h.stem=a.stem)}else{switch(l.pos.stm&7){case m.SL_ABOVE:h.stem=1;break;case m.SL_BELOW:h.stem=-1;break;case m.SL_HIDDEN:h.stemless=!0}if(b=l.brk_rhythm){l.brk_rhythm=0;u=l.last_note;if(0<b){y=2*b-1;h.dur=h.dur*y/b;h.dur_orig=h.dur_orig*y/b;for(q=0;q<=h.nhd;q++)h.notes[q].dur=h.notes[q].dur*y/b;u.dur/=b;u.dur_orig/=b;for(q=0;q<=u.nhd;q++)u.notes[q].dur/=b}else{b=-b;y=2*b-1;h.dur/=b;h.dur_orig/=b;for(q=0;q<=h.nhd;q++)h.notes[q].dur/=b;u.dur=u.dur*y/b;u.dur_orig=u.dur_orig*
y/b;for(q=0;q<=u.nhd;q++)u.notes[q].dur=u.notes[q].dur*y/b}l.time=u.time+u.dur;for(u=u.next;u;u=u.next)u.time=l.time}}l.last_note=h;for(u=f.char();;){switch(u){case ".":if("-"!=f.buffer[f.index+1])break;ma.push("dot");f.index++;case "-":t=mc();for(q=0;q<=h.nhd;q++)h.notes[q].tie_ty=t,h.notes[q].s=h;l.tie_s=a||h;l.tie_s.ti1=!0;for(q=0;q<=h.nhd;q++)if(t=h.notes[q],x=t.pit+19-d,l.acc[x]||z&&z[x])l.acc_tie||(l.acc_tie=[]),y=l.acc[x],z&&z[x]&&(y=z[x]),l.acc_tie[x]=y;u=f.char();continue}break}if(k){c=0;
d=k.time+k.dur==l.time;for(z=0;z<=h.nhd;z++)if(e=h.notes[z],n=e.midi,k.type!=m.GRACE)for(t=0;t<=k.nhd;t++){if(b=k.notes[t],b.tie_ty&&!(b.midi!=n||d&&b.tie_e)){e.tie_s=b;e.s=h;d&&(b.tie_e=e,b.s=k);c++;break}}else for(t=k.extra;t;t=t.next)if(b=t.notes[0],b.tie_ty&&b.midi==n){t.ti1=!0;e.tie_s=b;e.s=h;b.tie_e=e;b.s=t;c++;break}c?h.ti2=!0:w(1,k,"Bad tie")}}ja(h);a||(l.lyric_restart||(l.lyric_restart=h),l.sym_restart||(l.sym_restart=h));g.length&&(ma=g,dc(h,h.prev));a&&h.ottava&&(a.ottava=h.ottava);r.stemless&&
(h.stemless=!0);h.iend=r.bol+f.index;return h}};var Da='0;0;0;0;0;0;0;0;0; ;\n;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0; ;!;";i;\n;0;&;0;(;);i;0;0;-;!dot!;0;0;0;0;0;0;0;0;0;0;0;|;i;<;n;<;i;i;n;n;n;n;n;n;n;!fermata!;d;d;d;!emphasis!;!lowermordent!;d;!coda!;!uppermordent!;d;d;!segno!;!trill!;d;d;d;n;d;n;[;\\;|;n;n;i;n;n;n;n;n;n;n;d;d;d;d;d;d;d;d;d;d;d;d;d;!upbow!;!downbow!;d;n;n;n;{;|;};!gmark!;0'.split(";"),Bd,hd=abc2svg.el?function(a){mb+="\n"+a;if(!abc2svg.styles){var b=document.createElement("style");
document.head.appendChild(b);abc2svg.styles=b}Bd=abc2svg.styles.sheet;for(a=a.match(/[^{]+{[^}]+}/g);;){b=a.shift();if(!b)break;Bd.insertRule(b,Bd.cssRules.length)}}:function(a){mb+="\n"+a},vf=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.25,.333,.408,.5,.5,.833,.778,.333,.333,.333,.5,.564,.25,.564,.25,.278,.5,.5,.5,.5,.5,.5,.5,.5,.5,.5,.278,.278,.564,.564,.564,.444,.921,.722,.667,.667,.722,.611,.556,.722,.722,.333,.389,.722,.611,.889,.722,.722,.556,.722,.667,
.556,.611,.722,.722,.944,.722,.722,.611,.333,.278,.333,.469,.5,.333,.444,.5,.444,.5,.444,.333,.5,.5,.278,.278,.5,.278,.778,.5,.5,.5,.5,.333,.389,.278,.5,.5,.722,.5,.5,.444,.48,.2,.48,.541,.5]),Vd=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.278,.278,.355,.556,.556,.889,.667,.191,.333,.333,.389,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.278,.278,.584,.584,.584,.556,1.015,.667,.667,.722,.722,.667,.611,.778,.722,.278,.5,.667,.556,
.833,.722,.778,.667,.778,.722,.667,.611,.722,.667,.944,.667,.667,.611,.278,.278,.278,.469,.556,.333,.556,.556,.5,.556,.556,.278,.556,.556,.222,.222,.5,.222,.833,.556,.556,.556,.556,.333,.5,.278,.556,.5,.722,.5,.5,.5,.334,.26,.334,.584,.512]),uf=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,
.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52,.52]),ua;(function(){ua="undefined"!=typeof document&&abc2svg.el?function(a){if(a.wh)return a.wh;var b=abc2svg.el;var c=A.curfont;var d=c.size,e=0,f=0,g=0;b.parentElement||document.body.appendChild(b);b.className=Ib(c);if("object"==typeof a)return b.innerHTML=a,a.wh=[b.clientWidth,b.clientHeight],
a.wh;for(a=Wd(a);;){g=a.indexOf("$",g);if(0<=g){c=a[g+1];if("0"==c)c=A.deffont;else if("1"<=c&&"9">=c)c=Ma("u"+c);else{g++;continue}b.className=Ib(c)}b.innerHTML=a.slice(f,0<=g?g:void 0);e+=b.clientWidth;b.clientHeight>d&&(d=b.clientHeight);if(0>g)break;f=g+=2}return[e,d]}:function(a){var b=A.curfont,c=b.swfac,d=b.size,e=0,f,g=a.length;for(f=0;f<g;f++){var h=a[f];switch(h){case "$":h=a[f+1];if("0"==h)b=A.deffont;else if("1"<=h&&"9">=h)b=Ma("u"+h);else{h="$";break}f++;c=b.swfac;b.size>d&&(d=b.size);
continue;case "&":if(" "!=a[f+1]){var k=a.indexOf(";",f);0<k&&10>k-f&&(f=k,h="a")}}e+=yb(h,b)*c}return[e,d]}})();Abc.prototype.tunhd=function(){var a,b,c=Jb();ra(p.topspace);if(L.T&&0<=p.writefields.indexOf("T"))for(a=0;;){var d=L.T.indexOf("\n",a);if(0>d){sd(L.T.substring(a),0!=a);break}sd(L.T.slice(a,d),0!=a);a=d+1}var e=b=0;if(r.ckey.k_bagpipe&&!p.infoline&&0<=p.writefields.indexOf("R"))var f=L.R;f&&(T("composer"),e=p.composerspace+A.curfont.size+2,na(0,-e+.22*A.curfont.size,f));var g=L.A;if(0<=
p.writefields.indexOf("C"))var h=L.C;if(0<=p.writefields.indexOf("O"))var k=L.O;if(h||k||p.infoline){T("composer");if(0>p.aligncomposer){var m=0;var l=" "}else 0==p.aligncomposer?(m=.5*c,l="c"):(m=c,l="r");if(h||k)for(b=p.composerspace+2,a=0;;){b+=A.curfont.size;d=h?h.indexOf("\n",a):-1;if(0>d){we(m,-b+.22*A.curfont.size,h?h.substring(a):null,k,l);break}na(m,-b+.22*A.curfont.size,h.slice(a,d),l);a=d+1}((f=f?null:L.R)||g)&&p.infoline&&(T("info"),b+=p.infospace+A.curfont.size,we(c,-b+.22*A.curfont.size,
f,g,"r"))}L.P&&0<=p.writefields.indexOf("P")?(T("parts"),a=p.partsspace+A.curfont.size+A.curfont.pad,b=e+a>b?e+a:b+a,a=L.P,p.partname&&(a=xe()),na(0,-b+.22*A.curfont.size,a),b+=A.curfont.pad):e>b&&(b=e);ra(b+p.musicspace)};var D="",Eb="\n.stroke{stroke:currentColor;fill:none}\n.bW{stroke:currentColor;fill:none;stroke-width:1}\n.bthW{stroke:currentColor;fill:none;stroke-width:3}\n.slW{stroke:currentColor;fill:none;stroke-width:.7}\n.slthW{stroke:currentColor;fill:none;stroke-width:1.5}\n.sltnW{stroke:currentColor;fill:none;stroke-width:.25}\n.sldW{stroke:currentColor;fill:none;stroke-width:.7;stroke-dasharray:5,10}\n.sW{stroke:currentColor;fill:none;stroke-width:.7}\n.box{outline:1px solid black;outline-offset:1px}",
mb="",wc=p.leftmargin/p.scale,wa=0,ba={width:p.pagewidth,lm:p.leftmargin,rm:p.rightmargin,wx:0,chg:1},ud={},Yb="",vd="",B={scale:1,stsc:1,vsc:1,dy:0,st:-1,v:-1,g:0},Ta=0,xc={"mtr ":{x:0,y:0,c:" "},brace:{x:0,y:0,c:"\ue000"},lphr:{x:0,y:23,c:"\ue030"},mphr:{x:0,y:23,c:"\ue038"},sphr:{x:0,y:25,c:"\ue039"},short:{x:0,y:32,c:"\ue038"},tick:{x:0,y:25,c:"\ue039"},rdots:{x:0,y:0,c:"\ue043"},rdot:{x:0,y:0,c:"\ue044"},dsgn:{x:-12,y:0,c:"\ue045"},dcap:{x:-12,y:0,c:"\ue046"},sgno:{x:-5,y:0,c:"\ue047"},coda:{x:-10,
y:0,c:"\ue048"},tclef:{x:-8,y:0,c:"\ue050"},cclef:{x:-8,y:0,c:"\ue05c"},bclef:{x:-8,y:0,c:"\ue062"},pclef:{x:-6,y:0,c:"\ue069"},spclef:{x:-6,y:0,c:"\ue069"},stclef:{x:-8,y:0,c:"\ue07a"},scclef:{x:-8,y:0,c:"\ue07b"},sbclef:{x:-7,y:0,c:"\ue07c"},oct:{x:0,y:2,c:"\ue07d"},oct2:{x:0,y:2,c:"\ue07e"},mtr0:{x:0,y:0,c:"\ue080"},mtr1:{x:0,y:0,c:"\ue081"},mtr2:{x:0,y:0,c:"\ue082"},mtr3:{x:0,y:0,c:"\ue083"},mtr4:{x:0,y:0,c:"\ue084"},mtr5:{x:0,y:0,c:"\ue085"},mtr6:{x:0,y:0,c:"\ue086"},mtr7:{x:0,y:0,c:"\ue087"},
mtr8:{x:0,y:0,c:"\ue088"},mtr9:{x:0,y:0,c:"\ue089"},mtrC:{x:0,y:0,c:"\ue08a"},"mtrC|":{x:0,y:0,c:"\ue08b"},"mtr+":{x:0,y:0,c:"\ue08c"},"mtr(":{x:0,y:0,c:"\ue094"},"mtr)":{x:0,y:0,c:"\ue095"},HDD:{x:-7,y:0,c:"\ue0a0"},breve:{x:-7,y:0,c:"\ue0a1"},HD:{x:-5.2,y:0,c:"\ue0a2"},Hd:{x:-3.8,y:0,c:"\ue0a3"},hd:{x:-3.7,y:0,c:"\ue0a4"},ghd:{x:2,y:0,c:"\ue0a4",sc:.66},pshhd:{x:-3.7,y:0,c:"\ue0a9"},pfthd:{x:-3.7,y:0,c:"\ue0b3"},x:{x:-3.7,y:0,c:"\ue0a9"},"circle-x":{x:-3.7,y:0,c:"\ue0b3"},srep:{x:-5,y:0,c:"\ue101"},
"dot+":{x:-5,y:0,sc:.7,c:"\ue101"},diamond:{x:-4,y:0,c:"\ue1b9"},triangle:{x:-4,y:0,c:"\ue1bb"},dot:{x:-1,y:0,c:"\ue1e7"},flu1:{x:-.3,y:0,c:"\ue240"},fld1:{x:-.3,y:0,c:"\ue241"},flu2:{x:-.3,y:0,c:"\ue242"},fld2:{x:-.3,y:0,c:"\ue243"},flu3:{x:-.3,y:3.5,c:"\ue244"},fld3:{x:-.3,y:-4,c:"\ue245"},flu4:{x:-.3,y:8,c:"\ue246"},fld4:{x:-.3,y:-9,c:"\ue247"},flu5:{x:-.3,y:12.5,c:"\ue248"},fld5:{x:-.3,y:-14,c:"\ue249"},"acc-1":{x:-1,y:0,c:"\ue260"},"cacc-1":{x:-18,y:0,c:"\ue26a\ue260\ue26b"},"sacc-1":{x:-1,y:0,
sc:.7,c:"\ue260"},acc3:{x:-1,y:0,c:"\ue261"},cacc3:{x:-18,y:0,c:"\ue26a\ue261\ue26b"},sacc3:{x:-1,y:0,sc:.7,c:"\ue261"},acc1:{x:-2,y:0,c:"\ue262"},cacc1:{x:-18,y:0,c:"\ue26a\ue262\ue26b"},sacc1:{x:-2,y:0,sc:.7,c:"\ue262"},acc2:{x:-3,y:0,c:"\ue263"},"acc-2":{x:-3,y:0,c:"\ue264"},"acc-1_2":{x:-2,y:0,c:"\ue280"},"acc-3_2":{x:-3,y:0,c:"\ue281"},acc1_2:{x:-1,y:0,c:"\ue282"},acc3_2:{x:-3,y:0,c:"\ue283"},accent:{x:-3,y:2,c:"\ue4a0"},stc:{x:0,y:-2,c:"\ue4a2"},emb:{x:0,y:-2,c:"\ue4a4"},wedge:{x:0,y:0,c:"\ue4a8"},
marcato:{x:-3,y:-2,c:"\ue4ac"},hld:{x:-7,y:-2,c:"\ue4c0"},brth:{x:0,y:0,c:"\ue4ce"},caes:{x:0,y:8,c:"\ue4d1"},r00:{x:-1.5,y:0,c:"\ue4e1"},r0:{x:-1.5,y:0,c:"\ue4e2"},r1:{x:-3.5,y:-6,c:"\ue4e3"},r2:{x:-3.2,y:0,c:"\ue4e4"},r4:{x:-3,y:0,c:"\ue4e5"},r8:{x:-3,y:0,c:"\ue4e6"},r16:{x:-4,y:0,c:"\ue4e7"},r32:{x:-4,y:0,c:"\ue4e8"},r64:{x:-4,y:0,c:"\ue4e9"},r128:{x:-4,y:0,c:"\ue4ea"},mrep:{x:-6,y:0,c:"\ue500"},mrep2:{x:-9,y:0,c:"\ue501"},p:{x:-3,y:0,c:"\ue520"},f:{x:-3,y:0,c:"\ue522"},pppp:{x:-15,y:0,c:"\ue529"},
ppp:{x:-14,y:0,c:"\ue52a"},pp:{x:-8,y:0,c:"\ue52b"},mp:{x:-8,y:0,c:"\ue52c"},mf:{x:-8,y:0,c:"\ue52d"},ff:{x:-7,y:0,c:"\ue52f"},fff:{x:-10,y:0,c:"\ue530"},ffff:{x:-14,y:0,c:"\ue531"},sfz:{x:-10,y:0,c:"\ue539"},trl:{x:-3,y:-3,c:"\ue566"},turn:{x:-5,y:0,c:"\ue567"},turnx:{x:-5,y:0,c:"\ue569"},umrd:{x:-6,y:2,c:"\ue56c"},lmrd:{x:-6,y:2,c:"\ue56d"},dplus:{x:-3,y:0,c:"\ue582"},sld:{x:-3,y:2,c:"\ue5d0"},grm:{x:-3,y:-2,c:"\ue5e2"},dnb:{x:-3,y:0,c:"\ue610"},upb:{x:-2,y:0,c:"\ue612"},opend:{x:-2,y:-2,c:"\ue614"},
roll:{x:0,y:0,c:"\ue618"},thumb:{x:-2,y:-2,c:"\ue624"},snap:{x:-2,y:-2,c:"\ue630"},ped:{x:-10,y:0,c:"\ue650"},pedoff:{x:-5,y:0,c:"\ue655"},"mtro.":{x:0,y:0,c:"\ue910"},mtro:{x:0,y:0,c:"\ue911"},"mtro|":{x:0,y:0,c:"\ue912"},"mtrc.":{x:0,y:0,c:"\ue914"},mtrc:{x:0,y:0,c:"\ue915"},"mtrc|":{x:0,y:0,c:"\ue918"},longa:{x:-4.7,y:0,c:"\ue95d"},custos:{x:-4,y:3,c:"\uea02"},ltr:{x:2,y:6,c:"\ueaa4"}},kb={},pa=Lc,Pb=Lc;Abc.prototype.out_svg=function(a){D+=a};Abc.prototype.sx=gb;Abc.prototype.sy=pc;Abc.prototype.sh=
function(a){return 0>B.st?a/B.scale:a};Abc.prototype.ax=function(a){return a+wc};Abc.prototype.ay=function(a){return 0>B.st?wa-a:wa+(B.dy-a)*B.scale-B.dy};Abc.prototype.ah=function(a){return 0>B.st?a:a*B.scale};Abc.prototype.out_sxsy=$a;Abc.prototype.xypath=ib;var Ca=[[],[],"",[],[],[]],rc={crdc:{dx:0,dy:5,style:"font:italic 14px text,serif",anchor:' text-anchor="middle"'},dacs:{dx:0,dy:3,style:"font:bold 15px text,serif",anchor:' text-anchor="middle"'},pf:{dx:0,dy:5,style:"font:italic bold 16px text,serif",
anchor:' text-anchor="middle"'}};rc.at=rc.crdc;Abc.prototype.out_lped=function(a,b,c,d){d.nost||R(a,b,"ped");d.noen||R(a+c+6,b,"pedoff")};var Ge={arp:Ee,cresc:function(a,b,c,d){a+=c*B.scale;c=-c;ea('<path class="stroke"\n\td="mX YlF ',a,b,c);D=d.nost?D+("-2.2m0 -3.6l"+(-c).toFixed(1)+' -2.2"/>\n'):D+("-4l"+(-c).toFixed(1)+' -4"/>\n')},dim:function(a,b,c,d){ea('<path class="stroke"\n\td="mX YlF ',a,b,c);D=d.noen?D+("-2.2m0 -3.6l"+(-c).toFixed(1)+' -2.2"/>\n'):D+("-4l"+(-c).toFixed(1)+' -4"/>\n')},
ltr:Fe,lped:function(a,b,c,d){U.out_lped(a,b,c,d)},"8va":function(a,b,c,d){18>c&&(c=18,a-=4);d.nost||(ea('<text x="X" y="Y" style="font:italic bold 12px text,serif">8<tspan dy="-4" style="font-size:10px">va</tspan></text>\n',a-8,b),a+=12,c-=12);b+=6;ea('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',a,b,c);d.noen||ea('<path class="stroke" d="mX Yv6"/>\n',a+c,b)},"8vb":function(a,b,c,d){18>c&&(c=18,a-=4);d.nost||(ea('<text x="X" y="Y" style="font:italic bold 12px text,serif">8<tspan dy=".5" style="font-size:10px">vb</tspan></text>\n',
a-8,b),a+=10,c-=10);ea('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',a,b,c);d.noen||ea('<path class="stroke" d="mX Yv-6"/>\n',a+c,b)},"15ma":function(a,b,c,d){25>c&&(c=25,a-=6);d.nost||(ea('<text x="X" y="Y" style="font:italic bold 12px text,serif">15<tspan dy="-4" style="font-size:10px">ma</tspan></text>\n',a-10,b),a+=20,c-=20);b+=6;ea('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',a,b,c);d.noen||ea('<path class="stroke" d="mX Yv6"/>\n',a+c,b)},"15mb":function(a,b,c,
d){24>c&&(c=24,a-=5);d.nost||(ea('<text x="X" y="Y" style="font:italic bold 12px text,serif">15<tspan dy=".5" style="font-size:10px">mb</tspan></text>\n',a-10,b),a+=18,c-=18);ea('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',a,b,c);d.noen||ea('<path class="stroke" d="mX Yv-6"/>\n',a+c,b)}},Qe={glisq:function(a,b,c){var d=c.start,e=d.x,f=d.y+x[d.st].y;a-=e;b=U.sh(f-b);B.g||(a/=B.scale);var g=Math.atan2(b,a);b=g/Math.PI*180;c=(a-(d.s.dots?13+d.s.xmx:8)-8-(c.s.notes[0].shac||0))/Math.cos(g);
zb(e,f,b);e=d.s.dots?13+d.s.xmx:8;c=c/6|0;for(1>c&&(c=1);0<=--c;)R(e,0,"ltr"),e+=6;Ab()},gliss:function(a,b,c){var d=c.start,e=d.x,f=d.y+x[d.st].y;a-=e;b=U.sh(f-b);B.g||(a/=B.scale);var g=Math.atan2(b,a);b=g/Math.PI*180;c=(a-(d.s.dots?13+d.s.xmx:8)-8-(c.s.notes[0].shac||0))/Math.cos(g);zb(e,f,b);ib(d.s.dots?13+d.s.xmx:8,0);D+="h"+c.toFixed(1)+'" stroke-width="1"/>\n';Ab()}};Abc.prototype.blk_flush=nb;var H,K,C,l,Xa,fa,M,Sa=new Uint8Array([6,2,8,6,7,3,4,9,9,0,9,5,0,1,0,0,0,0]);Abc.prototype.voice_adj=
function(a){function b(){for(var a,b,c=C[H.top_voice];;){a=r.pq_d.shift();if(!a)break;for(b=c.sym;;b=b.next)if(b.time>=a.time&&b.dur){a.next=b;a.prev=b.prev;a.prev.next=b.prev=a;a.v=b.v;a.p_v=c;a.st=b.st;break}}}function c(a){var b;var c=a.dur;var d=1;for(b=a;b&&!b.beam_end&&b.next;b=b.next)d++;if(1>=d)delete a.feathered_beam;else{var e=b;var f=c/2;var g=c/(d-1);var h=a.time;if(0<a.feathered_beam)for(b=a,a=d-1;b!=e;b=b.next,a--)c=(g*a|0)+f,b.dur=c,b.time=h,h+=c;else for(b=a,a=0;b!=e;b=b.next,a++)c=
(g*a|0)+f,b.dur=c,b.time=h,h+=c;b.dur=b.time+b.dur-h;b.time=h}}var d;l&&l.clone&&(r.istart=r.eol,Ya());H.one_v&&Tf(C[H.top_voice]);r.pq_d&&b();for(d=0;d<C.length;d++){var e=C[d];if(!a)for(delete e.eoln;;){var f=e.sls.shift();if(!f)break;var g=f.ss;g.sls||(g.sls=[]);f.loc="o";g.sls.push(f)}for(g=e.sym;g&&!(g.time>=Xa);g=g.next);for(;g;g=g.next)switch(5>Sa[g.type]&&g.type!=m.STAVES&&g.type!=m.CLEF&&g.time&&(!g.prev||g.time>g.prev.time+g.prev.dur)&&(e={type:m.BAR,bar_type:"[]",v:g.v,p_v:g.p_v,st:g.st,
time:g.time,dur:0,next:g,prev:g.prev,fmt:g.fmt,invis:1},g.prev?g.prev.next=e:C[g.v].sym=e,g.prev=e),g.type){case m.GRACE:if(!p.graceword)continue;for(e=g.next;e;e=e.next){switch(e.type){case m.SPACE:continue;case m.NOTE:e.a_ly&&(g.a_ly=e.a_ly,e.a_ly=null)}break}continue;case m.NOTE:g.feathered_beam&&c(g)}}};Abc.prototype.set_bar_num=function(){var a,b,c,d=0,e=A.nbar,f=0,g=0,h=C[K.top_voice].meter.wmeasure;for(a=M;;a=a.ts_next){if(!a)return;switch(a.type){case m.METER:h=a.wmeasure;case m.CLEF:case m.KEY:case m.STBRK:continue;
case m.BAR:a.bar_num&&(e=a.bar_num)}break}for(b=a.ts_next;b;b=b.ts_next)if(b.type==m.BAR&&b.time&&!b.invis&&!b.bar_dotted){b.time<h&&(a=b,f=a.time);break}for(;a;a=a.ts_next)switch(a.type){case m.METER:1!=h&&(e+=(a.time-f)/h);f=a.time;for(h=a.wmeasure;a.ts_next&&a.ts_next.wmeasure;)a=a.ts_next;break;case m.BAR:if(!(a.time<=d)){d=a.time;var k=1;var l="";for(b=a;b&&!(b.time>d);b=b.next)b.bar_type&&("["!=b.bar_type&&(k=0),b.text&&(l=b.text));if(a.bar_num)e=a.bar_num,g=f=d;else if(1==h)a.bar_dotted||(l&&
(p.contbarnb||("1"==l[0]?c=e:e=c)),k||(a.bar_num=++e));else{var n=e+(d-f)/h;b=n-(n|0);var q;if(q=p.checkbars&&b)if(d>g+h&&a.prev.type!=m.MREST)q=1;else{for(q=a.next;q&&q.time==a.time;q=q.next);for(;q&&!q.bar_type;q=q.next);q=q&&(q.time-f)%h}q&&w(0,a,"Bad measure duration");d>g+h&&(n|=0,b=0,f=d,e=n);l?"1"==l[0]?(p.contbarnb||(c=d-f),k||(a.bar_num=n)):(p.contbarnb||(f=d-c),n=e+(d-f)/h,n==(n|0)&&(a.bar_num=n)):n==(n|0)&&(a.bar_num=n);b||(g=d)}}}};Abc.prototype.do_pscom=function(a){var b;if(b=a.match(/[^\s]+/)){b=
b[0];if(l&&l.ignore)switch(b){case "staves":case "score":break;default:return}a=a.replace(b,"").trim();if(" lock"==a.slice(-5))Ye[b]=!0,a=a.slice(0,-5).trim();else if(Ye[b])return;switch(b){case "clef":2<=r.state&&(b=me(a))&&Ne(b);return;case "deco":b=a.match(/(\S*)\s+(.*)/);Ob[b[1]]=b[2];return;case "linebreak":for(b=0;128>b;b++)"\n"==Da[b]&&(Da[b]="0");a=a.split(/\s+/);for(b=0;b<a.length;b++){var c=a[b];switch(c){case "!":case "$":case "*":case ";":case "?":case "@":break;case "<none>":continue;
case "<EOL>":c="\n";break;default:v(1,"Bad value '$1' in %%linebreak - ignored",c);continue}Da[c.charCodeAt(0)]="\n"}return;case "map":a:if(a){var d="";b=a.split(/\s+/);if(3>b.length)v(1,G.not_enough_p);else{var e=b[1];if("*"!=e){0!=e.indexOf("octave,")&&0!=e.indexOf("key,")&&e.indexOf("tonic,")||(d=e[0],e=e.split(",")[1].toUpperCase());c=new F;c.buffer=e;c=jc(c);if(!c){v(1,"Bad note in %%map");break a}e=d+qe(c.pit,c.acc)}(c=Lb[b[0]])||(Lb[b[0]]=c={});(a=c[e])||(c[e]=a=[]);b.shift();b.shift();if(b.length){b=
kc(b.join(" "));e=0;if(0>b[0].indexOf("=")){"*"!=b[0][0]&&(c=new F,c.buffer=b[0],a[1]=jc(c));if(!b[1])break a;e++;0>b[1].indexOf("=")&&(a[0]=b[1].split(","),e++)}for(;e<b.length;e++)switch(b[e]){case "heads=":if(!b[++e]){v(1,G.not_enough_p);break}a[0]=b[e].split(",");break;case "print=":case "play=":case "print_notrp=":if(!b[++e]){v(1,G.not_enough_p);break}c=new F;c.buffer=b[e];c=jc(c);"_"==b[e-1][5]&&(c.notrp=1);"r"==b[e-1][1]?a[1]=c:a[3]=c;break;case "color=":b[++e]?a[2]=b[e]:v(1,G.not_enough_p)}}}}return;
case "maxsysstaffsep":case "sysstaffsep":if(3==r.state){c=ab(a);if(isNaN(c)){v(1,G.bad_val,"%%"+b);return}H.voices[l.v]["m"==b[0]?"maxsep":"sep"]=c;return}break;case "multicol":switch(a){case "start":case "new":case "end":break;default:v(1,"Unknown keyword '$1' in %%multicol",a);return}b={type:m.BLOCK,subtype:"mc_"+a,dur:0};if(2<=r.state){l.clone&&Ya();l=C[0];l.eoln=1;ja(b);return}Wa(b);U.block_gen(b);return;case "ottava":if(3!=r.state)return;b=parseInt(a);if(isNaN(b)||-2>b||2<b||!b&&!l.ottava){v(1,
G.bad_val,"%%ottava");return}(c=b)?l.ottava=b:(b=l.ottava,l.ottava=0);ma.push(["15mb","8vb","","8va","15ma"][b+2]+(c?"(":")"));return;case "repbra":l&&(l.norepbra=!Bb(a));return;case "repeat":if(3!=r.state)return;if(!l.last_sym){v(1,"%%repeat cannot start a tune");return}if(a.length){a=a.split(/\s+/);b=parseInt(a[0]);c=parseInt(a[1]);if(isNaN(b)||1>b||l.last_sym.type==m.BAR&&2<b){v(1,"Incorrect 1st value in %%repeat");return}if(isNaN(c))c=1;else if(1>c){v(1,"Incorrect 2nd value in %%repeat");return}}else c=
b=1;r.repeat_n=l.last_sym.type==m.BAR?b:-b;r.repeat_k=c;return;case "sep":lb();var f=ba.width-ba.lm-ba.rm;c=e=d=0;if(a&&(a=a.split(/\s+/),c=ab(a[0]),a[1]&&(e=ab(a[1]),a[2]&&(d=ab(a[2]))),isNaN(c)||isNaN(e)||isNaN(d))){v(1,G.bad_val,"%%sep");return}1>c&&(c=14);1>e&&(e=c);1>d&&(d=90);if(2<=r.state){l.clone&&Ya();b=Va(b);b.x=(f-d)/2/p.scale;b.l=d/p.scale;b.sk1=c;b.sk2=e;return}ra(c);D+='<path class="stroke"\n\td="M';$a((f-d)/2/p.scale," ",0);D+="h"+(d/p.scale).toFixed(1)+'"/>\n';ra(e);nb();return;case "setbarnb":c=
parseInt(a);if(isNaN(c)||1>c){v(1,"Bad %%setbarnb value");break}oa.new_nbar=c;return;case "staff":if(3!=r.state)return;l.clone&&Ya();c=parseInt(a);if(isNaN(c)){v(1,"Bad %%staff value '$1'",a);return}b="+"==a[0]||"-"==a[0]?l.cst+c:c-1;if(0>b||b>V){v(1,"Bad %%staff number $1 (cur $2, max $3)",b,l.cst,V);return}delete l.floating;l.cst=b;return;case "staffbreak":if(3!=r.state)return;l.clone&&Ya();b={type:m.STBRK,dur:0};"f"==a.slice(-1)&&(b.stbrk_forced=!0,a=a.replace(/\sf$/,""));if(a){c=ab(a);if(isNaN(c)){v(1,
G.bad_val,"%%staffbreak");return}b.xmx=c}else b.xmx=14;ja(b);return;case "tacet":'"'==a[0]&&(a=a.slice(1,-1));case "stafflines":case "staffscale":case "staffnonote":Sb(b,a);return;case "staves":case "score":if(!r.state)return;r.scores&&0<r.scores.length&&(a=r.scores.shift(),b=a.match(/([^\s]+)\s*(.*)/),a=b[2],b=b[1]);a:{d=a;c=C.length;a=0;l&&l.clone&&Ya();if(d){b:{var g={};var h=[];var k=!1;var w=0,n=0,q=0,x=0,z=0,t=d.match(/[^[\]|{}()*+\s]+|[^\s]/g);if(t){for(;;){var A=t.shift();if(!A)break;switch(A){case "[":if(x||
2<=n+q){v(1,G.misplaced,"[");k=!0;break}w|=0==n+q?4:1024;q++;z<<=8;z|=4;break;case "{":if(x||n||2<=q){v(1,G.misplaced,"{");k=!0;break}w|=q?256:1;n++;z<<=8;z|=1;break;case "(":if(x){v(1,G.misplaced,"(");k=!0;break}w|=16;x++;z<<=8;z|=16;break;case "*":!n||x||w&257||(w|=128);break;case "+":w|=4096;break;case "]":case "}":case ")":v(1,"Bad voice ID in %%score");k=!0;break;default:for(f=A;;){A=t.shift();if(!A)break;switch(A){case "]":if(!(z&4)){v(1,G.misplaced,"]");k=!0;break}q--;w|=0==n+q?8:2048;z>>=
8;continue;case "}":if(!(z&1)){v(1,G.misplaced,"}");k=!0;break}n--;w|=q?512:2;w&=-129;z>>=8;continue;case ")":if(!(z&16)){v(1,G.misplaced,")");k=!0;break}x--;w|=32;z>>=8;continue;case "|":w|=64;continue}break}g[f]?(v(1,"Double voice in %%score"),k=!0):(g[f]=!0,h.push([f,w]));w=0;A&&t.unshift(A)}}0!=z&&(v(1,"'}', ')' or ']' missing in %%score"),k=!0);if(!k&&h.length){f=h;break b}}else v(1,G.bad_val,"%%score");f=void 0}if(!f)break a}else if(0>Xa){v(1,G.bad_val,"%%"+b);break a}for(h=0;h<c;h++)g=C[h],
g.eoln&&(e=1,delete g.eoln),g.time>a&&(a=g.time);if(a){U.voice_adj(1);for(h=0;h<c;h++)g=C[h],a-g.time>=g.meter.wmeasure&&(g.acc=[]),g.time=a,g.lyric_restart=g.last_sym,g.sym_restart=g.last_sym;if(!H.voices[l.v])for(h=0;h<H.voices.length;h++)if(H.voices[h]){l=C[h];break}l.eoln=e;e={type:m.STAVES,dur:0};ja(e);H.nstaff=V;if(!d){e.sy=y(H,2);H=H.next=e.sy;Xa=a;l=C[H.top_voice];break a}Ke();e.sy=H}else H.staves=[],H.voices=[];Xa=a;for(h=0;h<c;h++)if(g=C[h],delete g.second,delete g.floating,g.ignore){g.ignore=
0;if(e=g.sym)for(;e.next;)e=e.next;g.last_sym=e}for(e=c=0;e<f.length;e++)for(d=f[e][0],g=sc(d),h=g.v,f[e][0]=g;;){H.voices[h]={range:c++};g=g.voice_down;if(!g)break;h=g.v}H.top_voice=f[0][0].v;1==f.length&&(H.one_v=1);if("t"==b[1])for(e=0;e<f.length;e++)c=f[e][1],c&257&&3!=(c&3)&&768!=(c&768)&&0==f[e+1][1]&&!(c&16||f[e+2][1]&16)&&(f[e+2][1]&514?f[e+1][1]|=128:0==f[e+2][1]&&f[e+3][1]&514&&(f[e][1]|=16,f[e+1][1]|=32,f[e+2][1]|=16,f[e+3][1]|=32));d=-1;for(e=0;e<f.length;e++)if(c=f[e][1],48==(c&48)&&
(c&=-49,f[e][1]=c),g=f[e][0],c&128?(g.floating=!0,g.second=!0):(d++,H.staves[d]||(H.staves[d]={staffscale:1}),H.staves[d].stafflines=g.stafflines||"|||||",H.staves[d].flags=0),h=g.v,g.st=g.cst=H.voices[h].st=d,H.staves[d].flags|=c,c&16){for(k=g;e<f.length-1&&!(g=f[++e][0],h=g.v,f[e][1]&4096?(k.second=!0,k=g):g.second=!0,g.st=g.cst=H.voices[h].st=d,f[e][1]&32););H.staves[d].flags|=f[e][1]}0>d&&(d=0);H.nstaff=V=d;if("c"==b[1])for(d=0;d<V;d++)H.staves[d].flags^=64;c=C.length;for(h=d=0;h<c;h++){g=C[h];
H.voices[h]?d=g.st:g.st=d;if(!a)for(e=g.sym;e;e=e.next)e.st=d;if(H.voices[h]){for(k=g.voice_down;k;)k.second=1,e=k.v,k.st=k.cst=H.voices[e].st=d,k=k.voice_down;H.voices[h].second=g.second;d=g.st;0<d&&void 0==g.norepbra&&!(H.staves[d-1].flags&64)&&(g.norepbra=!0)}}l=2<=r.state?C[H.top_voice]:null}return;case "center":case "text":c="c"==b[0]?"c":p.textoption;T("text");if(2<=r.state){l.clone&&Ya();b=Va("text");b.text=a;b.opt=c;b.font=p.textfont;return}td(a,c);return;case "transpose":if(p.sound)return;
c=Le(a);if(void 0==c&&(c=Db(a),void 0==c))return;switch(r.state){case 0:p.transp=0;case 1:p.transp=(p.transp||0)+c;return}l.shift=c;Me();return;case "tune":return;case "user":ne(a);return;case "voicecolor":l&&(l.color=a);return;case "vskip":c=ab(a);if(isNaN(c)){v(1,G.bad_val,"%%vskip");return}if(0>c){v(1,"%%vskip cannot be negative");return}if(2<=r.state){l.clone&&Ya();b=Va(b);b.sk=c;return}ra(c);return;case "newpage":case "leftmargin":case "rightmargin":case "pagescale":case "pagewidth":case "printmargin":case "scale":case "staffwidth":if(2<=
r.state){l.clone&&Ya();b=Va(b);b.param=a;return}if("newpage"==b){nb();u.page_format&&(Ta=2);return}}U.set_format(b,a)}};Abc.prototype.do_begin_end=function(a,b,c){var d;l&&l.clone&&Ya();switch(a){case "js":Ka(c);break;case "ml":if(p.pageheight){v(1,"Cannot have %%beginml with %%pageheight");break}2<=r.state?(a=Va(a),a.text=c):(nb(),u.img_out&&u.img_out(c));break;case "svg":for(d=0;;){b=c.indexOf("<style",d);if(0>b)break;b=c.indexOf(">",b);d=c.indexOf("</style>",b);if(0>d){v(1,"No </style> in %%beginsvg sequence");
break}a=c.slice(b+1,d).replace(/\s+$/gm,"");p.fullsvg&&(b=a.match(/@font-face[^}]*}/))&&0<b[0].indexOf("text")&&(Kb.text="\n"+b[0],a=a.replace(b[0],""));a&&"\n"!=a&&(Eb+=a)}for(d=0;;){b=c.indexOf("<defs>\n",d);if(0>b)break;d=c.indexOf("</defs>",b);if(0>d){v(1,"No </defs> in %%beginsvg sequence");break}Ae(c.slice(b+6,d))}break;case "text":b=Qd(b),b||(b=p.textoption),T("text"),0<=c.indexOf("\\")&&(c=Hc(c)),1<r.state?(a=Va(a),a.text=c,a.opt=b,a.font=p.textfont):td(c,b)}};Abc.prototype.gch_build=function(a){var b,
c=0,d=0;for(b=0;b<a.a_gch.length;b++){var e=a.a_gch[b];if("g"==e.type)e.text=e.text.replace(/##|#|=|bb|b/g,function(a){switch(a){case "##":return"&#x1d12a;";case "#":return"\u266f";case "=":return"\u266e";case "b":return"\u266d"}return"&#x1d12b;"});else if("@"==e.type&&!u.anno_start&&!u.anno_stop){T(e.font);e.text=nc(e.text);continue}T(e.font);e.text=nc(e.text);var f=e.text.wh;switch(e.type){case "@":break;default:f=.4*f[0];8<f&&(f=8);e.x=-f;break;case "<":e.x=-(f[0]+6);c-=f[1];e.y=c+f[1]/2;break;
case ">":e.x=6,d-=f[1],e.y=d+f[1]/2}}c/=2;d/=2;for(b=0;b<a.a_gch.length;b++)switch(e=a.a_gch[b],e.type){case "<":e.y-=c;break;case ">":e.y-=d}};Abc.prototype.draw_gchord=function(a,b,c,d){if(!b.invis||!b.play){var e=b.a_gch[a],f=e.text.wh[1],g=e.font.pad,h=e.text.wh[0]+2*g,k=.22*f;e.font.figb&&(f*=2.4,k+=1.3*e.font.size);switch(e.type){case "_":d-=f+g;break;case "^":d+=g;break;case "<":case ">":"<"==e.type?(b.notes[0].acc&&(c-=b.notes[0].shac),c-=g):(b.xmx&&(c+=b.xmx),b.dots&&(c+=1.5+3.5*b.dots),
c+=g);d+=(b.type==m.NOTE?3*((b.notes[b.nhd].pit+b.notes[0].pit>>1)-18):12)-f/2;break;default:d=0<=d?d+g:d-(f+g);break;case "@":d+=(b.type==m.NOTE?3*((b.notes[b.nhd].pit+b.notes[0].pit>>1)-18):12)-f/2,0<d?(a=d+f+g+2,a>x[b.st].ann_top&&(x[b.st].ann_top=a)):(a=d-2,a<x[b.st].ann_bot&&(x[b.st].ann_bot=a))}"@"!=e.type&&(0<=d?Y(b.st,1,c,h,d+f+g+2):Y(b.st,0,c,h,d-g));bb(e.font);T(e.font);La(b.st);u.anno_start&&u.anno_start("annot",e.istart,e.iend,c-2,d+f+2,h+4,f+4,b);na(c,d+k,e.text);u.anno_stop&&u.anno_stop("annot",
e.istart,e.iend,c-2,d+f+2,h+4,f+4,b)}};Xd();Abc.prototype.a_de=function(){return ha};Abc.prototype.add_style=function(a){Eb+=a};Abc.prototype.anno_a=$b;Abc.prototype.cfmt=function(){return p};Abc.prototype.clone=y;Abc.prototype.clr_sty=Ie;Abc.prototype.deco_put=function(a,b){ma.push(a);dc(b)};Abc.prototype.defs_add=Ae;Abc.prototype.dh_put=function(a,b,c){ma.push(a);Fc(b,c)};Abc.prototype.draw_meter=Ld;Abc.prototype.draw_note=Qb;Abc.prototype.errs=G;Abc.prototype.font_class=Ib;Abc.prototype.gch_tr1=
yd;Abc.prototype.get_bool=Bb;Abc.prototype.get_cur_sy=function(){return K};Abc.prototype.get_curvoice=function(){return l};Abc.prototype.get_delta_tb=function(){return Ad};Abc.prototype.get_decos=function(){return Ob};Abc.prototype.get_font=Ma;Abc.prototype.get_font_style=function(){return mb};Abc.prototype.get_glyphs=function(){return kb};Abc.prototype.get_img=function(){return ba};Abc.prototype.get_lwidth=Jb;Abc.prototype.get_maps=function(){return Lb};Abc.prototype.get_multi=function(){return da};
Abc.prototype.get_newpage=function(){if(block.newpage)return block.newpage=!1,!0};Abc.prototype.get_parse=function(){return r};Abc.prototype.get_posy=function(){return wa};Abc.prototype.get_staff_tb=function(){return x};Abc.prototype.get_top_v=function(){return H.top_voice};Abc.prototype.get_tsfirst=function(){return M};Abc.prototype.get_unit=ab;Abc.prototype.get_user=function(){return u};Abc.prototype.get_voice_tb=function(){return C};Abc.prototype.glout=oc;Abc.prototype.glovar=function(){return oa};
Abc.prototype.info=function(){return L};Abc.prototype.new_block=Va;Abc.prototype.out_arp=Ee;Abc.prototype.out_deco_str=De;Abc.prototype.out_deco_val=xd;Abc.prototype.out_ltr=Fe;Abc.prototype.param_set_font=xb;Abc.prototype.part_seq=xe;Abc.prototype.psdeco=Lc;Abc.prototype.psxygl=Lc;Abc.prototype.set_cur_sy=function(a){K=a};Abc.prototype.set_curvoice=function(a){l=a};Abc.prototype.set_dscale=La;Abc.prototype.set_font=T;Abc.prototype.set_a_gch=function(a,b){Ia=b;Vb(a)};Abc.prototype.set_hl=jb;Abc.prototype.set_map=
rd;Abc.prototype.set_page=lb;Abc.prototype.set_pagef=function(){Ta=1};Abc.prototype.set_realwidth=function(a){la=a};Abc.prototype.set_scale=Zb;Abc.prototype.set_sscale=Ra;Abc.prototype.set_tsfirst=function(a){M=a};Abc.prototype.set_v_param=Sb;Abc.prototype.str2svg=nc;Abc.prototype.strwh=ua;Abc.prototype.stv_g=function(){return B};Abc.prototype.svg_flush=Xb;Abc.prototype.syntax=v;Abc.prototype.tunes=jd;Abc.prototype.unlksym=Na;Abc.prototype.use_font=bb;Abc.prototype.vskip=ra;Abc.prototype.xy_str=na;
Abc.prototype.xygl=R;Abc.prototype.y_get=Q;Abc.prototype.y_set=Y};var Abc=abc2svg.Abc;"object"==typeof module&&"object"==typeof exports&&(exports.abc2svg=abc2svg,exports.Abc=Abc);abc2svg.loadjs||(abc2svg.loadjs=function(u,y,E){E&&E(u)});
abc2svg.modules={ambitus:{},begingrid:{fn:"grid3"},beginps:{fn:"psvg"},break:{},capo:{},chordnames:{},clip:{},clairnote:{fn:"clair"},voicecombine:{fn:"combine"},diagram:{fn:"diag"},equalbars:{},fit2box:{},gamelan:{},grid:{},grid2:{},jazzchord:{},jianpu:{},mdnn:{},MIDI:{},nns:{},pageheight:{fn:"page"},pedline:{},percmap:{fn:"perc"},playswing:{fn:"swing"},roman:{},soloffs:{},sth:{},strtab:{},temperament:{fn:"temper"},temponame:{fn:"tempo"},tropt:{},titleformat:{fn:"tunhd"},nreq:0,load:function(u,y,
E){function w(){return"object"==typeof user&&user.errmsg?user.errmsg:"function"==typeof abc2svg.printErr?abc2svg.printErr:"function"==typeof alert?function(u){alert(u)}:"object"==typeof console?console.log:function(){}}function F(){0==--abc2svg.modules.nreq&&abc2svg.modules.cbf()}var v=this.nreq;u=u.match(/(%%|I:).+?\b/g);if(!u)return!0;this.cbf=y||function(){};this.errmsg=E||w();for(E=0;E<u.length;E++){var Ka=u[E].replace(/\n?(%%|I:)/,"");(y=abc2svg.modules[Ka])&&!y.loaded&&(y.loaded=!0,y.fn&&(Ka=
y.fn),this.nreq++,abc2svg.loadjs(Ka+"-1.js",F,function(){abc2svg.modules.errmsg("Error loading the module "+Ka);F()}))}return this.nreq==v}};abc2svg.version="v1.22.33";abc2svg.vdate="2025-11-19";"undefined"==typeof abc2svg&&(abc2svg={});
abc2svg.MIDI={do_midi:function(u){var y=u.split(/\s+/);u=this.cfmt();var E=this.get_curvoice();var w=this.get_parse();if(E){if(E.ignore)return;void 0==E.chn&&(E.chn=9>E.v?E.v:E.v+1)}switch(y[1]){case "chordname":u.chord||(u.chord={});u.chord.names||(u.chord.names={});u.chord.names[y[2]]=y.slice(3);break;case "chordprog":u.chord||(u.chord={});u.chord.prog=y[2];y[3]&&"octave="==y[3].slice(0,7)&&(u.chord.trans=Number(y[3].slice(7)));break;case "chordvol":var F=Number(y[2]);if(isNaN(F)||0>F||127<F){this.syntax(1,
this.errs.bad_val,"%%MIDI chordvol");break}u.chord||(u.chord={});u.chord.vol=F;break;case "gchord":case "gchordbars":case "gchordon":case "gchordoff":u.chord||(u.chord={});2<=w.state&&E?(w=this.new_block("midigch"),w.play=w.invis=1,"o"==y[1][6]?w.on="n"==y[1][7]:"b"==y[1][6]?w.gchnb=+y[2]:w.rhy=y[2]):"o"==y[1][6]?u.chord.gchon="n"==y[1][7]:"b"==y[1][6]?u.chord.gchnb=+y[2]:u.chord.rhy=y[2];break;case "channel":F=parseInt(y[2]);if(isNaN(F)||0>=F||16<F){this.syntax(1,this.errs.bad_val,"%%MIDI channel");
break}F--;2<=w.state?(w=this.new_block("midiprog"),w.play=w.invis=1,w.chn=F):this.set_v_param("channel",F);break;case "drummap":F=Number(y[3]);if(isNaN(F)){this.syntax(1,this.errs.bad_val,"%%MIDI drummap");break}for(E="C ^C D _E E F ^F G ^G A _B B".split(" ")[F%12];60>F;)E+=",",F+=12;for(;72<F;)E+="'",F-=12;this.do_pscom("map MIDIdrum "+y[2]+" play="+E);this.set_v_param("mididrum","MIDIdrum");break;case "program":y.shift();F=[];y[2]?(F[0]=+y[2],F[1]=+y[1]):(F[0]=+y[1],F[1]=0);if(isNaN(F[0])||0>F[0]||
127<F[0]||F[1]&&(isNaN(F[1])||0>=F[1]||16<F[1])){this.syntax(1,this.errs.bad_val,"%%MIDI program");break}2<=w.state?(w=this.new_block("midiprog"),w.play=w.invis=1,w.instr=F[0],w.chn=0<F[1]?F[1]-1:9>E.v?E.v:E.v+1):this.set_v_param("instr",y.slice(1).join(" "));break;case "control":E=parseInt(y[2]);if(isNaN(E)||0>E||127<E){this.syntax(1,"Bad controller number in %%MIDI");break}F=parseInt(y[3]);if(isNaN(F)||0>F||127<F){this.syntax(1,"Bad controller value in %%MIDI");break}2<=w.state?(w=this.new_block("midictl"),
w.play=w.invis=1,w.ctrl=E,w.val=F):this.set_v_param("midictl",y[2]+" "+y[3]);break;case "temperamentequal":if(E=parseInt(y[2]),isNaN(E)||5>E||255<E)this.syntax(1,this.errs.bad_val,"%%MIDI "+y[1]);else{w=this.get_glyphs();53!=E||w.acc12_53||(w.acc12_53='<text id="acc12_53" x="-1">&#xe282;</text>',w.acc24_53='<text id="acc24_53" x="-1">&#xe282;\t<tspan x="0" y="-9" style="font-size:9px">2</tspan></text>',w.acc36_53='<text id="acc36_53" x="-1">&#xe262;\t<tspan x="0" y="-9" style="font-size:9px">3</tspan></text>',
w.acc48_53='<text id="acc48_53" x="-1">&#xe262;</text>',w.acc60_53='<g id="acc60_53">\n\t<text style="font-size:1.1em" x="-1">&#xe282;</text>\n\t<path class="stroke" stroke-width="1.6" d="M-2 1l7 -2.2"/>\n</g>',w.acc96_53='<g id="acc96_53">\n\t<text style="font-size:1.1em" x="-2">&#xe262;</text>\n\t<path class="stroke" stroke-width="1.6" d="M-2.8 1.4l8.5 -2.8"/>\n</g>',w.acc108_53='<text id="acc108_53" x="-3">&#xe263;</text>',w["acc-108_53"]='<text id="acc-108_53" x="-3">&#xe264;</text>',w["acc-96_53"]=
'<g id="acc-96_53">\n\t<text x="-1">&#xe260;</text>\n\t<path class="stroke" stroke-width="1.3" d="M-3 -7l5 -2m0 3l-5 2"/>\n</g>',w["acc-60_53"]='<text id="acc-60_53" x="-1">&#xe260;</text>',w["acc-48_53"]='<g id="acc-48_53">\n\t<text x="-1">&#xe260;</text>\n\t<path class="stroke" stroke-width="1.3" d="M-3 -5.5l5 -2"/>\n</g>',w["acc-36_53"]='<g id="acc-36_53">\n\t<text x="-1">&#xe260;\t\t<tspan x="0" y="-12" style="font-size:9px">3</tspan></text>\n\t<path class="stroke" stroke-width="1.3" d="M-3 -5.5l5 -2"/>\n</g>',
w["acc-24_53"]='<text id="acc-24_53" x="-2">&#xe280;\t<tspan x="0" y="-12" style="font-size:9px">2</tspan></text>',w["acc-12_53"]='<text id="acc-12_53" x="-2">&#xe280;</text>');u.nedo=E;F=12*(7.019550008653874*E/12+.5|0)/E;(6.85>F||7.2<F)&&this.syntax(0,this.errs.bad_val,"%%MIDI "+y[1]);E=[2,25,8,31,14,37,20,3,26,9,32,15,38,21,4,27,10,33,16,39];w=[0,19,36,13,30,7,24,1,18,35,12,29,6,23,0,17];var v=21-3*F,Ka=new Float32Array(40);for(y=0;y<E.length;y++)Ka[E[y]]=(F*y+v)%12;for(y=1;y<=w.length;y++)Ka[w[y]]=
12-(F*y-v)%12;u.temper=Ka}}},set_vp:function(u,y){var E=this.get_curvoice();u(y.slice(0));for(u=0;u<y.length;u++)switch(y[u]){case "channel=":var w=this.new_block("midiprog");w.play=w.invis=1;w.chn=+y[++u];break;case "instr=":w=this.new_block("midiprog");w.play=w.invis=1;w.instr=y[++u].split(" ");w.chn=w.instr[1]?w.instr.shift()-1:9>E.v?E.v:E.v+1;w.instr=+w.instr[0];break;case "midictl=":E.midictl||(E.midictl=[]);w=y[++u].split(" ");E.midictl[w[0]]=Number(w[1]);break;case "mididrum=":E.map||(E.map=
{}),E.map=y[++u]}},do_pscom:function(u,y){"MIDI "==y.slice(0,5)?abc2svg.MIDI.do_midi.call(this,y):u(y)},set_hooks:function(u){u.do_pscom=abc2svg.MIDI.do_pscom.bind(u,u.do_pscom);u.set_vp=abc2svg.MIDI.set_vp.bind(u,u.set_vp)}};abc2svg.mhooks||(abc2svg.mhooks={});abc2svg.mhooks.MIDI=abc2svg.MIDI.set_hooks;"undefined"==typeof abc2svg&&(abc2svg={});
abc2svg.perc={do_perc:function(u){new Int8Array([0,0,1,2,2,3,3,4,5,5,6,6]);new Int8Array([3,1,3,-1,3,3,1,3,-1,3,-1,3]);var y={"a-b-d":35,"a-s":38,"b-d-1":36,ca:69,cl:75,co:56,"c-c":52,"c-c-1":49,"c-c-2":57,"c-h-h":42,"e-s":40,"h-a":67,"h-b":60,"h-c":39,"h-f-t":43,"h-m-t":48,"h-ti":65,"h-to":50,"h-w-b":76,"l-a":68,"l-b":61,"l-c":64,"l-f-t":41,"l-g":74,"l-m-t":47,"l-ti":66,"l-to":45,"l-w":72,"l-w-b":77,m:70,"m-c":78,"m-h-c":62,"m-t":80,"o-c":79,"o-h-c":63,"o-h-h":46,"o-t":81,"p-h-h":44,"r-b":53,"r-c-1":51,
"r-c-2":59,"s-c":55,"s-g":73,"s-s":37,"s-w":71,t:54,v:58};u=u.split(/\s+/);var E=u[1].replace(/[=_^]/,"");this.do_pscom("map MIDIdrum "+u[1]+" play="+function(u){var w;if(/^[_^]*[A-Ga-g][,']*$/.test(u))return u;var v=Number(u);if(isNaN(v)){u=u.toLowerCase(u);var E=u[0];for(w=0;;){w=u.indexOf("-",w);if(0>w)break;w+=1;E+="-"+u[w]}v=y[E];if(!v){switch(u[0]){case "c":switch(u[1]){case "a":v=y.ca;break;case "l":v=y.cl;break;case "o":v=y.co}break;case "h":case "l":if(w=u.indexOf("-"),"t"==u[w+1])switch(u[w+
2]){case "i":case "o":v=y[E+u[w+2]]}}if(!v)return}}for(u="C ^C D _E E F ^F G ^G A _B B".split(" ")[v%12];60>v;)u+=",",v+=12;for(;72<=v;)u+="'",v-=12;return u}(u[2])+" print="+E+(u[3]?" heads="+u[3]:""));this.set_v_param("perc","MIDIdrum")},set_perc:function(u){var y,E=this.get_curvoice();for(y=0;y<u.length;y++)switch(u[y]){case "perc=":E.map||(E.map={});E.map=u[y+1];var w=this.new_block("midiprog");w.play=w.invis=1;E.chn=w.chn=9}},do_pscom:function(u,y){"percmap "==y.slice(0,8)?abc2svg.perc.do_perc.call(this,
y):u(y)},set_vp:function(u,y){abc2svg.perc.set_perc.call(this,y);u(y)},set_hooks:function(u){u.do_pscom=abc2svg.perc.do_pscom.bind(u,u.do_pscom);u.set_vp=abc2svg.perc.set_vp.bind(u,u.set_vp)}};abc2svg.mhooks||(abc2svg.mhooks={});abc2svg.mhooks.perc=abc2svg.perc.set_hooks;"undefined"==typeof abc2svg&&(abc2svg={});
abc2svg.pedline={draw_all_deco:function(u){var y,E,w=this.a_de();if(w.length){if(this.cfmt().pedline)for(y=0;y<w.length;y++){var F=w[y];if("ped)"==F.dd.name){var v=F.start;(E=F.prev)&&"ped)"==E.dd.name&&E.s.v==v.s.v?(F.defl.nost=E.defl.noen=2,F.x=v.s.x-10,F.val=F.s.x-v.s.x-3,E.val=F.x-E.x,F.y>E.y&&(F.y=E.y),E.y=F.y):(F.x=v.s.x-8,F.defl.noen||(F.val=F.s.x-v.s.x-F.s.wl))}}u()}},out_lped:function(u,y,E,w,F){this.cfmt().pedline?(this.xypath(y,E+8),F.nost?2==F.nost?(this.out_svg("l2.5 6"),w-=2.5):this.out_svg("m0 6"):
this.out_svg("v6"),F.noen?2==F.noen?this.out_svg("h"+(w-2.5).toFixed(1)+"l2.5 -6"):this.out_svg("h"+w.toFixed(1)):this.out_svg("h"+w.toFixed(1)+"v-6"),this.out_svg('"/>\n')):u(y,E,w,F)},set_fmt:function(u,y,E){"pedline"==y?this.cfmt().pedline=this.get_bool(E):u(y,E)},set_hooks:function(u){u.draw_all_deco=abc2svg.pedline.draw_all_deco.bind(u,u.draw_all_deco);u.out_lped=abc2svg.pedline.out_lped.bind(u,u.out_lped);u.set_format=abc2svg.pedline.set_fmt.bind(u,u.set_format)}};
abc2svg.mhooks||(abc2svg.mhooks={});abc2svg.mhooks.pedline=abc2svg.pedline.set_hooks;
// abc2svg - strtab.js - tablature for string instruments
//
// Copyright (C) 2020-2025 Jean-Francois Moine
//
// This file is part of abc2svg.
//
// abc2svg is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// abc2svg is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with abc2svg.  If not, see <http://www.gnu.org/licenses/>.
//
// This module is loaded by %%strtab.
//
// The command %%strtab changes the display of the voice to a tablature.
// Syntax:
//	%%strtab <string list> [diafret] [nodot]
// <string list> is the list of the strings as ABC notes
// diafret indicates the instrument has diatonic frets
// nodot removes the dots of dotted notes
// The fret may be forced by a decoration format
//	"!" digit "s!"
// where 'digit' is the string range in the string list (last string is '1')
//
// The command %%minfret indicates the smallest usable fret numbers.
// Syntax:
//	%%minfret [ <string number> : <fret number> ]*
// Each command replaces the previous value.
//
//	%%tabfont font_name size (default: sans-serifBold 7)
//	%%cstabfont font_name size (default %%gchordfont with size / 1.6)
//
// This module accepts Willem Vree's tablature syntax:
//	https://wim.vree.org/svgParse/abc2xml.html#tab

if (typeof abc2svg == "undefined")
    var	abc2svg = {}

abc2svg.strtab = {

    // draw the tablature
    draw_symbols: function(of, p_v) {
    var	s, m, not, stb, x, y, g,
	C = abc2svg.C,
	abc = this

	// draw the note heads
	function draw_heads(stb, s) {
	    var	m, not, x, y

		for (m = 0; m <= s.nhd; m++) {
			not = s.notes[m]
			if (!not.nb)
				continue
			x = s.x - 3
			if (not.nb.length > 1)
				x -= 3
			y = 3 * (not.pit - 18)
			if (s.grace) {
				abc.out_svg('<text class="bg' + abc.bgn
					+ '" transform="translate(')
				abc.out_sxsy(x, ',', stb + y - 1.9)
				abc.out_svg(') scale(.75)')
			} else {
				abc.out_svg('<text class="bg' + abc.bgn + '" x="')
				abc.out_sxsy(x, '" y="', stb + y - 2.5)
			}
			abc.out_svg('">' + not.nb + '</text>\n')
		}
	} // draw_heads()

	// draw the stems, flags and beams
	function draw_stems(stb, s) {
		if (!s.tabst)
			return			// don't draw any stem
	    var	s1, s2, nfl, l, i, x,
		y = stb + 3 * (s.notes[0].pit - 19) // -18) - 3
				* s.p_v.staffscale,
		h = (11 + 3 * (s.notes[0].pit - 18)) * s.p_v.staffscale

		abc.out_svg('<path class="sW" d="M')
		abc.out_sxsy(s.x, ' ', y)
		abc.out_svg('v' + h.toFixed(1) +'"/>\n')

		// draw the dots
		if (s.dots) {
			x = s.x + 4
			i = (s.dur / 12) >> ((5 - s.nflags) - s.dots)
			while (s.dots-- > 0) {
				abc.xygl(x, stb - 8, (i & (1 << s.dots)) ? "dot" : "dot+")
				x += 3.5
			}
		}

		// draw the flag(s)
		if (s.nflags <= 0
		 || !s.beam_end)		// inside beam
			return
		y -= h
		if (s.beam_st) {		// no beam
			abc.out_svg('<text class="f'
				+ abc.get_font('music').fid
				+ '" transform="translate(')
			abc.out_sxsy(s.x, ',', y)
			abc.out_svg(') scale('
				+ (s.grace ? '.5,.5' : '.7,.7') + ')">'
				+ String.fromCharCode(0xe23f + 2 * s.nflags)
				+ '</text>\n')
			return
		}

		// draw the beam(s)
		s2 = s
		nfl = s.nflags
		while (1) {
			if (s.nflags > nfl)
				nfl = s.nflags
			if (s.beam_st)
				break
			s = s.prev
		}
		s1 = s
		l = (s2.x - s1.x).toFixed(1)
		abc.out_svg('<path d="M')
		abc.out_sxsy(s1.x, ' ', y)
		abc.out_svg('h' + l
				+ 'v-3h-' + l
				+ 'v3"/>\n')
		if (nfl == 1)
			return
//fixme: do more levels
		y += 5
		while (1) {
			while (s.nflags < 2) {
				s = s.next
				if (s == s2)
					break
			}
			if (s == s2)
				break
			s1 = s
			while (s.next.nflags >= 2) {
				s = s.next
				if (s == s2)
					break
			}
			l = (s.x - s1.x).toFixed(1)
			abc.out_svg('<path d="M')
			abc.out_sxsy(s1.x, ' ', y)
			abc.out_svg('h' + l
					+ 'v-3h-' + l
					+ 'v3"/>\n')
			if (s == s2)
				break
			s = s.next
			if (s == s2)
				break
		}
	} // draw_stems()

	if (!p_v.tab) {
		of(p_v)
		return
	}

	// define the 'bgx' filter if not done yet
	m = abc.cfmt().bgcolor || "white"
	if (abc.bgt != m) {
		if (!abc.bgn)
			abc.bgn = 1
		else
			abc.bgn++
		abc.bgt = m
		abc.defs_add('\
<filter x="-0.1" y="0.1" width="1.2" height=".8" id="bg' + abc.bgn + '">\n\
<feFlood flood-color="' + m + '"/>\n\
<feComposite in="SourceGraphic" operator="over"/>\n\
</filter>')
		abc.add_style('\n.bg' + abc.bgn + '{filter:url(#bg' + abc.bgn + ')}')
	}

	// adjust the symbol before generation
	for (s = p_v.sym; s; s = s.next) {
		switch (s.type) {
		case C.KEY:
		case C.METER:
		case C.REST:
			s.invis = true
			break
		}
	}

	stb = abc.get_staff_tb()[p_v.st].y

	// draw the stems and beams
	abc.set_sscale(-1)		// no scale
	for (s = p_v.sym; s; s = s.next) {
		switch (s.type) {
		case C.GRACE:
			for (g = s.extra; g; g = g.next)
				draw_stems(stb, g)
			break
		case C.NOTE:
			draw_stems(stb, s)
			break
		}
	}

	// draw the note heads
	abc.set_scale(p_v.sym)		// (for draw_all_ties)
	abc.out_svg('<g class="'
		+ abc.font_class(abc.get_font('tab'))
		+ '">\n')
	for (s = p_v.sym; s; s = s.next) {
		switch (s.type) {
		case C.GRACE:
			for (g = s.extra; g; g = g.next)
				draw_heads(stb, g)
			break
		case C.NOTE:
			draw_heads(stb, s)
			break
		}
	}
	abc.out_svg('</g>\n')

	of(p_v)
    }, // draw_symbols()

    // change the font size of the chord symbols
    csan_bld: function(of, s) {
	if (s.p_v.tab) {
	    var	i, gch,
		fmt = this.cfmt()

		for (i = 0; i < s.a_gch.length; i++) {
			gch = s.a_gch[i]
			if (gch.type != 'g')
				continue

			// create the smaller font if not done yet
			if (!fmt.cstabfont) {
			    var	f = gch.font

				this.param_set_font("cstabfont",
						f.name + ' ' + (f.size / 1.6).toFixed(1))
			}
			gch.font = this.get_font("cstab")
		}
	}
	of(s)
    }, // set_csan()

    // set a format parameter
    set_fmt: function(of, cmd, parm) {
	switch (cmd) {
	case "cstabfont":
		this.param_set_font("cstabfont", parm)
		return
	case "strtab":
		if (!parm)
			return
	    var	p_v = this.get_curvoice()
		if (!p_v) {
			this.get_parse().tab = parm
			return
		}
		this.set_v_param("clef", "tab")
		if (parm.indexOf("diafret") >= 0) {
			this.set_v_param("diafret", true)
			parm = parm.replace(/\s*diafret\s*/, "")
		}
		this.set_v_param("strings", parm)
		return
	case "minfret":
		this.set_v_param("minfret", parm)
		return
	}
	of(cmd, parm)
    }, // set_fmt()

    // change the notes when the global generation settings are done
    set_stems: function(of) {
    var	p_v, i, m, nt, n, bi, bn, strss, g,
	C = abc2svg.C,
	abc = this,
	s = abc.get_tsfirst(),		// first symbol
	strs = [],			// notes per staff - index = staff
	lstr = []			// lowest string per staff - index staff

	// set a string (pitch) and a fret number
	function set_pit(p_v, s, nt, i) {
	    var	m,
		st = s.st

		if (i >= 0) {
			nt.nb = ((p_v.diafret ? nt.pit : nt.midi) - p_v.tab[i])
						.toString()
			if (p_v.diafret && nt.acc)
				nt.nb += '+'
			nt.pit = i * 2 + 18
		} else {
			nt.nb = ""
			nt.pit = 18
		}
		nt.acc = 0
		nt.invis = true
		if (!s.grace)
			strss[i] = s.time + s.dur
	    if (p_v.pos.stm != C.SL_HIDDEN) {
		if (!lstr[st])
			lstr[st] = [ 10, null, C.BLEN, null ]
		if (lstr[st][0] > i) {
			lstr[st][0] = i		// lowest string
			lstr[st][1] = s
		}
		if (s.dur < lstr[st][2])
			lstr[st][2] = s.dur
		if (s.dots) {
			lstr[st][3] = s.dots
			delete s.dots
		}
	    }
		s.stemless = 1 //true
		if (s.dots) {			// have nicer dots
			if (p_v.nodot)
				delete s.dots
			s.xmx = 0
			for (m = 0; m <= s.nhd; m++)
				s.notes[m].shhd = 0
			s.dot_low = 0
		}
	} // set_pit()

	function set_notes(p_v, s) {
	    var	i, bi, bn, nt, m, n, ns

		s.stem = -1			// down stems

		// handle the fret numbers as chord decoration
		if (!s.nhd && s.a_dd) {
			i = s.a_dd.length
			while (--i >= 0) {
				bi = strnum(s.a_dd[i].name)
				if (bi >= 0) {
					nt = s.notes[0]
					set_pit(p_v, s, nt, bi)
					break
				}
			}
		}
		delete s.a_dd

		if (s.sls) {			// set the slurs above the staff
			for (i = 0; i < s.sls.length; i++) {
				s.sls[i].ty &= ~0x07
				s.sls[i].ty |= C.SL_ABOVE
			}
		}

	ls:	for (m = 0; m <= s.nhd; m++) {
			nt = s.notes[m]
			if (nt.sls) {			// if start of slur
				for (i = 0; i < nt.sls.length; i++) {
					nt.sls[i].ty &= ~0x07
					nt.sls[i].ty |= C.SL_ABOVE
				}
			}
			if (nt.nb) {
				delete nt.a_dd
				continue
			}
			if (nt.a_dd) {
				i = nt.a_dd.length
				while (--i >= 0) {
					bi = strnum(nt.a_dd[i].name)
					if (bi >= 0) {
						set_pit(p_v, s, nt, bi)
						delete nt.a_dd
						continue ls
					}
				}
				delete nt.a_dd
			}

			// search the best string
			bn = 100
			bi = -1
			ns = i = p_v.tab.length
			while (--i >= 0) {
				if (strss[i] && strss[i] > s.time)
					continue
				n = (p_v.diafret ?
					nt.pit : nt.midi) -
						p_v.tab[i]
				if (n >= 0 && n < bn
				 && (!p_v.minfret
				  || !p_v.minfret[ns - i]
				  || n >= p_v.minfret[ns - i])) {
					bi = i
					bn = n
				}
			}
			set_pit(p_v, s, nt, bi)
		}

		s.y = 3 * (nt.pit - 18)
		s.ymx = s.y + 2
		s.ymn = 3 * (s.notes[0].pit - 18)
	} // set_notes()

	// get the string number from the decoration
	// format is either !<n>s! or !<n>!
	function strnum(n) {
		n = n.match(/^([1-9])s?$/)
		return n ? p_v.tab.length - n[1] : -1
	} // strnum()

	// set_stems entry
	of()

	// change the notes of the strings when a capo
	p_v = abc.get_voice_tb()
	for (n = 0; n < p_v.length; n++) {
		if (!p_v[n].tab)
			continue
		m = p_v[n].capo
		if (m) {
			for (i = 0; i < p_v[n].tab.length; i++)
				p_v[n].tab[i] += m
		}
	}

	// loop on the notes of the voices with a tablature
	for ( ; s; s = s.ts_next) {

		// let a stem on the lowest string
		if (s.seqst || (s.ts_prev && s.ts_prev.type == C.GRACE)) {
			for (i = 0; i < lstr.length; i++) {
				if (lstr[i] && lstr[i][2] < C.BLEN) {
					lstr[i][1].tabst = 1
					lstr[i][1].dots = lstr[i][3]
				}
				lstr[i] = null
			}
		}

		p_v = s.p_v
		if (!p_v.tab)
			continue
		strss = strs[s.st]
		if (!strss)
			strss = strs[s.st] = []
		switch (s.type) {
		case C.KEY:
		case C.REST:
		case C.TIME:
			s.invis = true
		default:
			delete s.a_dd
			break
		case C.GRACE:
			if (p_v.pos.gst == C.SL_HIDDEN)
				s.sappo = 0
			for (g = s.extra; g; g = g.next) {
				set_notes(p_v, g)
				for (i = 0; i < lstr.length; i++) {
					if (lstr[i] && lstr[i][2] < C.BLEN) {
						lstr[i][1].tabst = 1
						lstr[i][1].dots = lstr[i][3]
					}
					lstr[i] = null
				}
			}
			break
		case C.NOTE:
			set_notes(p_v, s)
			break
		}
	}
	for (i = 0; i < lstr.length; i++) {
		if (lstr[i] && lstr[i][2] < C.BLEN) {
			lstr[i][1].tabst = 1		// top of stem
			lstr[i][1].dots = lstr[i][3]
		}
	}
    }, // set_stems()

    // set the bottom of the stems at end of line generation
    set_glue: function(of, w) {
    var	v, p_v,
	vtb = this.get_voice_tb()

	of(w)
	for (v = 0; v < vtb.length; v++) {
		p_v = vtb[v]
		if (!p_v.tab || !p_v.sym
		 || p_v.pos.stm == abc2svg.C.SL_HIDDEN)
			continue
		p_v.sym.ymn = -16
	}
    }, // set_glue()

    // get the parameters of the current voice
    set_vp: function(of, a) {
    var	i, e, g, tab, strs, ok,
	parse = this.get_parse(),
	p_v = this.get_curvoice()

	// convert a list of ABC notes into a list of MIDI pitches
	function abc2tab(p) {
	    var	i, c, a,
		t = []

		if (p_v.diafret) {
		    for (i = 0; i < p.length; i++) {
			c = p[i]
			c = "CDEFGABcdefgab".indexOf(c)
			if (c < 0)
				return // null
			c += 16
			while (1) {
				if (p[i + 1] == "'") {
					c += 7
					i++
				} else if (p[i + 1] == ",") {
					c -= 7
					i++
				} else {
					break
				}
			}
			t.push(c)
		    }
		} else {
		    for (i = 0; i < p.length; i++) {
			c = p[i]
			switch (c) {
			case '^':
			case '_':
				a = c == '^' ? 1 : -1
				c = p[++i]
				break
			default:
				a = 0
				break
			}
			c = "CCDDEFFGGAABccddeffggaab".indexOf(c)
			if (c < 0)
				return // null
			c += 60 + a
			while (1) {
				if (p[i + 1] == "'") {
					c += 12
					i++
				} else if (p[i + 1] == ",") {
					c -= 12
					i++
				} else {
					break
				}
			}
			t.push(c)
		    }
		}
		return t
	} // abc2tab

	// convert an array of <note name><octave> into a list of MIDI pitches
	function str2tab(a) {
	    var	str, p, o,
		t = []

		if (p_v.diafret) {
		    while (1) {
			str = a.shift()
			if (!str)
				break
			p = "CDEFGAB".indexOf(str[0])
			o = Number(str[1])
			if (p < 0 || isNaN(o))
				return // null
			t.push(o * 7 + p - 12)	// C4 = 16 (12 = 4 * 7 - 16)
		    }
		} else {
		    while (1) {
			str = a.shift()
			if (!str)
				break
			p = "CCDDEFFGGAAB".indexOf(str[0])
			if (p < 0)
				return // undefined
			o = str[1]
			switch (o) {
			case '#':
			case 'b':
				p += o == '#' ? 1 : -1
				o = Number(str[2])
				break
			default:
				o = Number(str[1])
				break
			}
			if (isNaN(o))
				return // undefined
			t.push((o + 1) * 12 + p)	// C4 = 60
		    }
		}
		return t
	} // str2tab()

	// convert the list of <string number> ':' <fret number>
	function minfret(a) {
	    var	sf,
		sfa = a.split(' ')

		p_v.minfret = {}
		while (1) {
			sf = sfa.shift()
			if (!sf)
				break
			sf = sf.split(':')
			if (sf.length != 2)
				break		//fixme: error
			p_v.minfret[sf[0]] = sf[1]
		}
	} //minfret()

	for (i = 0; i < a.length; i++) {
		switch (a[i]) {
		case "clef=":
			e = a[i + 1]
			if (e != "tab")
				break
			a.splice(i, 1)
			// fall thru
		case "tab":
			a.splice(i, 1)
			i--
			ok = true
			break
		case "strings=":
			strs = a[++i]
			ok = true
			break
		case "nostems":
			p_v.pos.stm = abc2svg.C.SL_HIDDEN
			p_v.pos.gst = abc2svg.C.SL_HIDDEN
			break
		case "capo=":
			p_v.capo = Number(a[++i])
			break
		case "diafret=":
			i++
		case "diafret":
			p_v.diafret = true
			break
		case "minfret=":
			minfret(a[++i])
			break
		case "nodot":
			p_v.nodot = 1 //true
			break
		}
	}

	// define the elements of the tablature
	if (ok) {
		if (!strs && parse.tab) {		// if a global definition
			strs = parse.tab
			if (strs.indexOf("diafret") >= 0) {
				p_v.diafret = true
				strs = strs.replace(/\s*diafret\s*/, "")
			}
			if (strs.indexOf("nodot") >= 0) {
				p_v.nodot = 1 //true
				strs = strs.replace(/\s*nodot\s*/, "")
			}
		}
		if (strs) {
			e = strs.slice(-1)
			if (e >= '1' && e <= '9')
				tab = str2tab(strs.split(','))	// W.V.'s syntax
			else
				tab = abc2tab(strs)		// ABC syntax
			if (!tab) {
				this.syntax(1, "Bad strings in tablature")
				ok = false
			}
		} else if (!p_v.tab) {
			tab = p_v.diafret ?
				[17, 14, 10] :		// dulcimer
				[40, 45, 50, 55, 59, 64] // guitar strings
		} else {
			tab = p_v.tab
		}
	}
	if (ok) {
		if (p_v.capo) {
			p_v.tab = []
			for (i = 0; i < tab.length; i++)
				p_v.tab.push(tab[i] + p_v.capo)
		} else {
			p_v.tab = tab
		}

		a.push("clef=")				// set the clef
		g = this.get_glyphs()
		if (tab.length == 3) {
			a.push('"tab3"')
			if (!g.tab3)
// SMuFL: -none-
				g.tab3 = '<text id="tab3"\
 x="-2,-2,-2" y="-4,3,10"\
 style="font:bold 8px sans-serif">TAB</text>'
		} else if (tab.length == 4) {
			a.push('"tab4"')
			if (!g.tab4)
// SMuFL: \ue06e
				g.tab4 = '<text id="tab4"\
 x="-3,-3,-3" y="-8,1,10"\
 style="font:bold 12px sans-serif">TAB</text>'
		} else if (tab.length == 5) {
			a.push('"tab5"')
			if (!g.tab5)
// SMuFL: -none-
				g.tab5 = '<text id="tab5"\
 x="-4,-4,-4" y="-11,-2,7"\
 style="font:bold 12px sans-serif">TAB</text>'
		} else {
			a.push('"tab6"')
			if (!g.tab6)
// SMuFL: \ue06d
				g.tab6 = '<text id="tab6"\
 x="-4,-4,-4" y="-14.5,-4,5.5"\
 style="font:bold 13px sans-serif">TAB</text>'
		}
		a.push("stafflines=")
		a.push("|||||||||".slice(0, tab.length))
		p_v.staffscale = 1.6
//		p_v.scale = .6
//		p_v.straightflags = true
	}
	of(a)
    }, // set_vp()

    set_hooks: function(abc) {
	abc.draw_symbols = abc2svg.strtab.draw_symbols.bind(abc, abc.draw_symbols)
	abc.gch_build = abc2svg.strtab.csan_bld.bind(abc, abc.gch_build)
	abc.set_format = abc2svg.strtab.set_fmt.bind(abc, abc.set_format);
	abc.set_stems = abc2svg.strtab.set_stems.bind(abc, abc.set_stems)
	abc.set_sym_glue = abc2svg.strtab.set_glue.bind(abc, abc.set_sym_glue)
	abc.set_vp = abc2svg.strtab.set_vp.bind(abc, abc.set_vp)

	// define specific decorations used to force the string number
    var	decos = abc.get_decos()
	decos["1s"] = "3 nil 0 0 0"
	decos["2s"] = "3 nil 0 0 0"
	decos["3s"] = "3 nil 0 0 0"
	decos["4s"] = "3 nil 0 0 0"
	decos["5s"] = "3 nil 0 0 0"
	decos["6s"] = "3 nil 0 0 0"

	abc.param_set_font("tabfont", "sans-serifBold 7")
    } // set_hooks()
} // strtab

if (!abc2svg.mhooks)
	abc2svg.mhooks = {}
abc2svg.mhooks.strtab = abc2svg.strtab.set_hooks
